Merge pull request #4420 from larsbrubaker/master

master
This commit is contained in:
Lars Brubaker 2019-04-12 15:40:21 -07:00 committed by GitHub
commit bb2a11b32d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 118 additions and 23 deletions

View file

@ -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,18 +2753,90 @@ 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)
{
// 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)
{
// 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 = @"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)";
var time = Stopwatch.StartNew();
ShowNotification("Print Canceled".Localize(), markdownText, () =>
{
// 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 title, string markdownText, Func<bool> keepShowing)
{
if (!string.IsNullOrEmpty(markdownText))
{
bool stopped = false;
_ = Tasks.Execute(title,
null,
(reporter, cancellationToken) =>
{
var progressStatus = new ProgressStatus();
while (keepShowing() && !stopped)
{
Thread.Sleep(200);
}
return Task.CompletedTask;
},
taskActions: new RunningTaskOptions()
{
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),
},
});
}
}
public void ConnectToPrinter(PrinterConfig printer)
@ -2817,6 +2899,7 @@ namespace MatterHackers.MatterControl
public class StartupTask
{
public string Title { get; set; }
public int Priority { get; set; }
public Func<IProgress<ProgressStatus>, CancellationToken, Task> Action { get; set; }
}

View file

@ -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);
}
}
}

View file

@ -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),
};

@ -1 +1 @@
Subproject commit 86fbe3c7fc1ea12611cd66409806abf8f5bc10da
Subproject commit 62e0c361791b279ddaca49fec2d45accab03f5ab