From cbd2ef77db06dfb25cde1d4b463133cc299e2a7e Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Fri, 12 Apr 2019 07:54:27 -0700 Subject: [PATCH 1/3] Starting work on post print notifications --- .../ApplicationView/ApplicationController.cs | 47 +++++++++++++++++-- Submodules/MatterSlice | 2 +- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/MatterControlLib/ApplicationView/ApplicationController.cs b/MatterControlLib/ApplicationView/ApplicationController.cs index 0d91736ea..6d387d332 100644 --- a/MatterControlLib/ApplicationView/ApplicationController.cs +++ b/MatterControlLib/ApplicationView/ApplicationController.cs @@ -2750,11 +2750,48 @@ namespace MatterHackers.MatterControl public void Connection_PrintCanceled(object sender, EventArgs e) { - // TODO: show a long running task showing support options - // add links to forum, articles and documentation - // support: "https://www.matterhackers.com/support#mattercontrol" - // documentation: "https://www.matterhackers.com/mattercontrol/support" - // forum: "https://forums.matterhackers.com/recent" + if (sender is PrinterConnection printerConnection) + { + // TODO: show a long running task showing support options + // add links to forum, articles and documentation + // support: "https://www.matterhackers.com/support#mattercontrol" + // documentation: "https://www.matterhackers.com/mattercontrol/support" + // forum: "https://forums.matterhackers.com/recent" + + string markdownText = "A sample notification message"; + + ShowNotification(markdownText, () => + { + return true; + }); + } + } + + private void ShowNotification(string markdownText, Func keepShowing) + { + if (!string.IsNullOrEmpty(markdownText)) + { + bool stopped = false; + Tasks.Execute("Notification", null, (reporter, cancellationToken) => + { + var progressStatus = new ProgressStatus(); + + while (keepShowing() && !stopped) + { + Thread.Sleep(200); + } + + return Task.CompletedTask; + }, + taskActions: new RunningTaskOptions() + { + StopAction = (abortCancel) => UiThread.RunOnIdle(() => + { + stopped = true; + }), + StopToolTip = "Dismiss".Localize() + }); + } } public void ConnectToPrinter(PrinterConfig printer) diff --git a/Submodules/MatterSlice b/Submodules/MatterSlice index 86fbe3c7f..62e0c3617 160000 --- a/Submodules/MatterSlice +++ b/Submodules/MatterSlice @@ -1 +1 @@ -Subproject commit 86fbe3c7fc1ea12611cd66409806abf8f5bc10da +Subproject commit 62e0c361791b279ddaca49fec2d45accab03f5ab From d45afb51276f6d93aa2c91a31f44fbfab2f38e32 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Fri, 12 Apr 2019 15:02:34 -0700 Subject: [PATCH 2/3] Adding print canceled print complete messaging issue: MatterHackers/MCCentral#5239 Print conclusion should gather user feedback --- .../ApplicationView/ApplicationController.cs | 96 ++++++++++++++----- 1 file changed, 71 insertions(+), 25 deletions(-) diff --git a/MatterControlLib/ApplicationView/ApplicationController.cs b/MatterControlLib/ApplicationView/ApplicationController.cs index 6d387d332..3afffe55b 100644 --- a/MatterControlLib/ApplicationView/ApplicationController.cs +++ b/MatterControlLib/ApplicationView/ApplicationController.cs @@ -61,6 +61,7 @@ namespace MatterHackers.MatterControl using Agg.Image; using CustomWidgets; using global::MatterControl.Printing; + using Markdig.Agg; using MatterHackers.Agg.Platform; using MatterHackers.Agg.VertexSource; using MatterHackers.DataConverters3D; @@ -495,6 +496,14 @@ namespace MatterHackers.MatterControl if (!string.IsNullOrEmpty(OemSettings.Instance.AffiliateCode) && targetUri.Contains("matterhackers.com")) { + string internalLink = ""; + // if we have a trailing internal link + if (targetUri.Contains("#")) + { + internalLink = targetUri.Substring(targetUri.IndexOf("#")); + targetUri = targetUri.Substring(0, targetUri.Length - internalLink.Length); + } + if (targetUri.Contains("?")) { targetUri += $"&aff={OemSettings.Instance.AffiliateCode}"; @@ -503,8 +512,9 @@ namespace MatterHackers.MatterControl { targetUri += $"?aff={OemSettings.Instance.AffiliateCode}"; } - + targetUri += internalLink; } + Process.Start(targetUri); }); } @@ -2743,54 +2753,89 @@ namespace MatterHackers.MatterControl public void Connection_PrintFinished(object sender, string e) { - // TODO: show a long running task asking about print feedback and up-selling more materials - // Ask about the print, offer help if needed. - // Let us know how your print came out. + if (sender is PrinterConnection printerConnection) + { + // show a long running task asking about print feedback and up-selling more materials + // Ask about the print, offer help if needed. + // Let us know how your print came out. + string markdownText = @"Shop supplies and accessories: +- [Filament](https://www.matterhackers.com/store/c/3d-printer-filament) +- [Bed Adhesives](https://www.matterhackers.com/store/c/3d-printer-adhesive) +- [Digital Designs](https://www.matterhackers.com/store/c/digital-designs) + +Support and tutorials: +- [MatterControl Docs](https://www.matterhackers.com/mattercontrol/support) +- [Tutorials](https://www.matterhackers.com/store/l/mattercontrol/sk/MKZGTDW6#tutorials) +- [Trick, Tips & Support Articles](https://www.matterhackers.com/support#mattercontrol) +- [User Forum](https://forums.matterhackers.com/recent)"; + + var time = Stopwatch.StartNew(); + ShowNotification("Print Completed".Localize(), markdownText, () => + { + // leave the message on screen for 3 minutes or until another print starts + return !printerConnection.Printing + && time.ElapsedMilliseconds < 3 * 60 * 1000; + }); + } } public void Connection_PrintCanceled(object sender, EventArgs e) { if (sender is PrinterConnection printerConnection) { - // TODO: show a long running task showing support options + // show a long running task showing support options // add links to forum, articles and documentation // support: "https://www.matterhackers.com/support#mattercontrol" // documentation: "https://www.matterhackers.com/mattercontrol/support" // forum: "https://forums.matterhackers.com/recent" - string markdownText = "A sample notification message"; + string markdownText = @"Looks like you canceled this print. If you need help, here are some links that might be useful. +- [MatterControl Docs](https://www.matterhackers.com/mattercontrol/support) +- [Tutorials](https://www.matterhackers.com/store/l/mattercontrol/sk/MKZGTDW6#tutorials) +- [Trick, Tips & Support Articles](https://www.matterhackers.com/support#mattercontrol) +- [User Forum](https://forums.matterhackers.com/recent)"; - ShowNotification(markdownText, () => + var time = Stopwatch.StartNew(); + ShowNotification("Print Canceled".Localize(), markdownText, () => { - return true; + // leave the message on screen for 3 minutes or until another print starts + return !printerConnection.Printing + && time.ElapsedMilliseconds < 3 * 60 * 1000; }); } } - private void ShowNotification(string markdownText, Func keepShowing) + private void ShowNotification(string title, string markdownText, Func keepShowing) { if (!string.IsNullOrEmpty(markdownText)) { bool stopped = false; - Tasks.Execute("Notification", null, (reporter, cancellationToken) => - { - var progressStatus = new ProgressStatus(); - - while (keepShowing() && !stopped) + _ = Tasks.Execute(title, + null, + (reporter, cancellationToken) => { - Thread.Sleep(200); - } + var progressStatus = new ProgressStatus(); - return Task.CompletedTask; - }, - taskActions: new RunningTaskOptions() - { - StopAction = (abortCancel) => UiThread.RunOnIdle(() => + while (keepShowing() && !stopped) + { + Thread.Sleep(200); + } + + return Task.CompletedTask; + }, + taskActions: new RunningTaskOptions() { - stopped = true; - }), - StopToolTip = "Dismiss".Localize() - }); + ExpansionSerializationKey = $"{title}_expanded", + StopAction = (abortCancel) => UiThread.RunOnIdle(() => stopped = true), + StopToolTip = "Dismiss".Localize(), + RichProgressWidget = () => new MarkdownWidget(Theme) + { + Markdown = markdownText, + HAnchor = HAnchor.Stretch, + VAnchor = VAnchor.Fit, + Margin = new BorderDouble(5), + }, + }); } } @@ -2854,6 +2899,7 @@ namespace MatterHackers.MatterControl public class StartupTask { public string Title { get; set; } + public int Priority { get; set; } public Func, CancellationToken, Task> Action { get; set; } } From 440b49cfc95aa9ab37ff9484367f839ff861aeb8 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Fri, 12 Apr 2019 15:03:03 -0700 Subject: [PATCH 3/3] fixing formatting warnings --- .../PrintingWindow/ProgressDial.cs | 36 ++++++++++++------- .../PartPreviewWindow/PrinterTabPage.cs | 2 +- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/MatterControlLib/CustomWidgets/PrintingWindow/ProgressDial.cs b/MatterControlLib/CustomWidgets/PrintingWindow/ProgressDial.cs index 98a54bf95..47344325e 100644 --- a/MatterControlLib/CustomWidgets/PrintingWindow/ProgressDial.cs +++ b/MatterControlLib/CustomWidgets/PrintingWindow/ProgressDial.cs @@ -95,10 +95,14 @@ namespace MatterHackers.MatterControl.CustomWidgets public double CompletedRatio { - get { return completedRatio; } - set - { - if (completedRatio != value) + get + { + return completedRatio; + } + + set + { + if (completedRatio != value) { completedRatio = Math.Min(value, 1); @@ -115,25 +119,33 @@ namespace MatterHackers.MatterControl.CustomWidgets percentCompleteWidget.Text = $"{Math.Min(99.9, percentComplete):0.0}%"; } } - } + } } public double LayerCompletedRatio { - get { return layerCompletedRatio; } - set - { - if (layerCompletedRatio != value) + get + { + return layerCompletedRatio; + } + + set + { + if (layerCompletedRatio != value) { layerCompletedRatio = value; this.Invalidate(); } - } + } } public int LayerIndex { - get { return layerCount; } + get + { + return layerCount; + } + set { if (layerCount != value) @@ -145,7 +157,7 @@ namespace MatterHackers.MatterControl.CustomWidgets } else { - layerCountWidget.Text = "Layer".Localize() + " " + (layerCount+1); + layerCountWidget.Text = "Layer".Localize() + " " + (layerCount + 1); } } } diff --git a/MatterControlLib/PartPreviewWindow/PrinterTabPage.cs b/MatterControlLib/PartPreviewWindow/PrinterTabPage.cs index d76b871eb..6639a93d7 100644 --- a/MatterControlLib/PartPreviewWindow/PrinterTabPage.cs +++ b/MatterControlLib/PartPreviewWindow/PrinterTabPage.cs @@ -620,7 +620,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Top | VAnchor.Fit, - //BackgroundColor = new Color(theme.Colors.PrimaryBackgroundColor, 128), + // BackgroundColor = new Color(theme.Colors.PrimaryBackgroundColor, 128), MinimumSize = new Vector2(275, 140), };