Json Profiles
This commit is contained in:
parent
bfa2ddafd8
commit
4496720772
93 changed files with 3069 additions and 4120 deletions
|
|
@ -1,437 +0,0 @@
|
||||||
using MatterHackers.Agg;
|
|
||||||
using MatterHackers.Agg.UI;
|
|
||||||
using MatterHackers.Agg.VertexSource;
|
|
||||||
using MatterHackers.Localizations;
|
|
||||||
using MatterHackers.MatterControl.DataStorage;
|
|
||||||
using MatterHackers.MatterControl.PrinterCommunication;
|
|
||||||
using MatterHackers.VectorMath;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl.ActionBar
|
|
||||||
{
|
|
||||||
//Base widget for ActionBarRows
|
|
||||||
public abstract class ActionRowBase : FlowLayoutWidget
|
|
||||||
{
|
|
||||||
public ActionRowBase()
|
|
||||||
: base(FlowDirection.LeftToRight)
|
|
||||||
{
|
|
||||||
Initialize();
|
|
||||||
SetDisplayAttributes();
|
|
||||||
AddChildElements();
|
|
||||||
AddHandlers();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void Initialize()
|
|
||||||
{
|
|
||||||
//Placeholder for row-specific initialization
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void SetDisplayAttributes()
|
|
||||||
{
|
|
||||||
this.HAnchor = HAnchor.ParentLeftRight;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void AddChildElements();
|
|
||||||
|
|
||||||
protected virtual void AddHandlers()
|
|
||||||
{
|
|
||||||
//Placeholder for row-specific handlers
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Base widget for use in ButtonViewStates
|
|
||||||
public class ControlButtonViewBase : GuiWidget
|
|
||||||
{
|
|
||||||
protected RGBA_Bytes fillColor;
|
|
||||||
protected RGBA_Bytes borderColor;
|
|
||||||
protected double borderWidth;
|
|
||||||
protected double borderRadius;
|
|
||||||
protected double padding;
|
|
||||||
|
|
||||||
public ControlButtonViewBase(string label,
|
|
||||||
double width,
|
|
||||||
double height,
|
|
||||||
double textHeight,
|
|
||||||
double borderWidth,
|
|
||||||
double borderRadius,
|
|
||||||
double padding,
|
|
||||||
RGBA_Bytes textColor,
|
|
||||||
RGBA_Bytes fillColor,
|
|
||||||
RGBA_Bytes borderColor)
|
|
||||||
: base(width, height)
|
|
||||||
{
|
|
||||||
this.borderRadius = borderRadius;
|
|
||||||
this.borderWidth = borderWidth;
|
|
||||||
this.fillColor = fillColor;
|
|
||||||
this.borderColor = borderColor;
|
|
||||||
this.padding = padding;
|
|
||||||
|
|
||||||
TextWidget buttonText = new TextWidget(label, textHeight);
|
|
||||||
buttonText.VAnchor = VAnchor.ParentCenter;
|
|
||||||
buttonText.HAnchor = HAnchor.ParentCenter;
|
|
||||||
buttonText.TextColor = textColor;
|
|
||||||
|
|
||||||
//this.AnchorAll();
|
|
||||||
this.AddChild(buttonText);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnDraw(Graphics2D graphics2D)
|
|
||||||
{
|
|
||||||
RectangleDouble Bounds = LocalBounds;
|
|
||||||
RoundedRect rectBorder = new RoundedRect(Bounds, this.borderRadius);
|
|
||||||
|
|
||||||
graphics2D.Render(rectBorder, borderColor);
|
|
||||||
|
|
||||||
RectangleDouble insideBounds = Bounds;
|
|
||||||
insideBounds.Inflate(-this.borderWidth);
|
|
||||||
RoundedRect rectInside = new RoundedRect(insideBounds, Math.Max(this.borderRadius - this.borderWidth, 0));
|
|
||||||
|
|
||||||
graphics2D.Render(rectInside, this.fillColor);
|
|
||||||
|
|
||||||
base.OnDraw(graphics2D);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Base widget for use in ButtonViewStates
|
|
||||||
public class PrinterSelectViewBase : GuiWidget
|
|
||||||
{
|
|
||||||
protected RGBA_Bytes fillColor;
|
|
||||||
protected RGBA_Bytes borderColor;
|
|
||||||
protected double borderWidth;
|
|
||||||
protected double borderRadius;
|
|
||||||
protected double padding;
|
|
||||||
protected double statusTextHeight = 8;
|
|
||||||
private TextWidget printerStatusText;
|
|
||||||
private TextWidget printerNameText;
|
|
||||||
|
|
||||||
private event EventHandler unregisterEvents;
|
|
||||||
|
|
||||||
public PrinterSelectViewBase(
|
|
||||||
double width,
|
|
||||||
double height,
|
|
||||||
double textHeight,
|
|
||||||
double borderWidth,
|
|
||||||
double borderRadius,
|
|
||||||
double padding,
|
|
||||||
RGBA_Bytes textColor,
|
|
||||||
RGBA_Bytes fillColor,
|
|
||||||
RGBA_Bytes borderColor)
|
|
||||||
: base(width, height)
|
|
||||||
{
|
|
||||||
this.borderRadius = borderRadius;
|
|
||||||
this.borderWidth = borderWidth;
|
|
||||||
this.fillColor = fillColor;
|
|
||||||
this.borderColor = borderColor;
|
|
||||||
this.padding = padding;
|
|
||||||
this.Padding = new BorderDouble(10, 5);
|
|
||||||
this.HAnchor = HAnchor.ParentLeftRight;
|
|
||||||
|
|
||||||
FlowLayoutWidget textContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
|
||||||
textContainer.VAnchor = VAnchor.ParentBottomTop;
|
|
||||||
textContainer.HAnchor = HAnchor.ParentLeftRight;
|
|
||||||
|
|
||||||
printerNameText = new TextWidget("", pointSize: textHeight);
|
|
||||||
printerNameText.AutoExpandBoundsToText = true;
|
|
||||||
printerNameText.HAnchor = HAnchor.ParentCenter;
|
|
||||||
printerNameText.TextColor = textColor;
|
|
||||||
|
|
||||||
string printerStatusTextBeg = LocalizedString.Get("Status");
|
|
||||||
string printerStatusTextEnd = LocalizedString.Get("Connected");
|
|
||||||
string printerStatusTextFull = string.Format("{0}: {1}", printerStatusTextBeg, printerStatusTextEnd);
|
|
||||||
printerStatusText = new TextWidget(printerStatusTextFull, pointSize: statusTextHeight);
|
|
||||||
printerStatusText.AutoExpandBoundsToText = true;
|
|
||||||
printerStatusText.HAnchor = HAnchor.ParentCenter;
|
|
||||||
printerStatusText.TextColor = textColor;
|
|
||||||
|
|
||||||
textContainer.AddChild(printerNameText);
|
|
||||||
textContainer.AddChild(printerStatusText);
|
|
||||||
|
|
||||||
SetButtonText();
|
|
||||||
|
|
||||||
//this.AnchorAll();
|
|
||||||
this.AddChild(textContainer);
|
|
||||||
|
|
||||||
ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(onActivePrinterChanged, ref unregisterEvents);
|
|
||||||
PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onActivePrinterChanged, ref unregisterEvents);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnClosed(EventArgs e)
|
|
||||||
{
|
|
||||||
if (unregisterEvents != null)
|
|
||||||
{
|
|
||||||
unregisterEvents(this, null);
|
|
||||||
}
|
|
||||||
base.OnClosed(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onActivePrinterChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(SetButtonText);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int GetPrinterRecordCount()
|
|
||||||
{
|
|
||||||
return Datastore.Instance.RecordCount("Printer");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetButtonText()
|
|
||||||
{
|
|
||||||
if (PrinterConnectionAndCommunication.Instance.CommunicationState == PrinterConnectionAndCommunication.CommunicationStates.FailedToConnect && PrinterConnectionAndCommunication.Instance.ConnectionFailureMessage != "")
|
|
||||||
{
|
|
||||||
printerStatusText.Text = "Status: " + PrinterConnectionAndCommunication.Instance.ConnectionFailureMessage;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string statusStringBeg = LocalizedString.Get("Status").ToUpper();
|
|
||||||
string statusString = string.Format("{1}: {0}", PrinterConnectionAndCommunication.Instance.PrinterConnectionStatusVerbose, statusStringBeg);
|
|
||||||
printerStatusText.Text = string.Format(statusString, PrinterConnectionAndCommunication.Instance.PrinterConnectionStatusVerbose);
|
|
||||||
}
|
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter != null)
|
|
||||||
{
|
|
||||||
printerNameText.Text = ActivePrinterProfile.Instance.ActivePrinter.Name;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (GetPrinterRecordCount() > 0)
|
|
||||||
{
|
|
||||||
string printerNameLabel = LocalizedString.Get("Select Printer");
|
|
||||||
string printerNameLabelFull = string.Format("- {0} -", printerNameLabel);
|
|
||||||
printerNameText.Text = (printerNameLabelFull);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string addPrinterLabel = LocalizedString.Get("Add Printer");
|
|
||||||
string addPrinterLabelFull = string.Format("- {0} -", addPrinterLabel);
|
|
||||||
printerNameText.Text = (addPrinterLabelFull);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnDraw(Graphics2D graphics2D)
|
|
||||||
{
|
|
||||||
RectangleDouble Bounds = LocalBounds;
|
|
||||||
RoundedRect rectBorder = new RoundedRect(Bounds, this.borderRadius);
|
|
||||||
|
|
||||||
graphics2D.Render(rectBorder, borderColor);
|
|
||||||
|
|
||||||
RectangleDouble insideBounds = Bounds;
|
|
||||||
insideBounds.Inflate(-this.borderWidth);
|
|
||||||
RoundedRect rectInside = new RoundedRect(insideBounds, Math.Max(this.borderRadius - this.borderWidth, 0));
|
|
||||||
|
|
||||||
graphics2D.Render(rectInside, this.fillColor);
|
|
||||||
base.OnDraw(graphics2D);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class PrinterSelectButton : Button
|
|
||||||
{
|
|
||||||
private double width = 180;
|
|
||||||
private double height = 40;
|
|
||||||
private double borderRadius = 0;
|
|
||||||
private double borderWidth = 1;
|
|
||||||
private double fontSize = 14;
|
|
||||||
private double padding = 3;
|
|
||||||
private BorderDouble margin = new BorderDouble(0, 0);
|
|
||||||
|
|
||||||
public PrinterSelectButton()
|
|
||||||
{
|
|
||||||
this.HAnchor = HAnchor.ParentLeftRight;
|
|
||||||
|
|
||||||
//Widgets to show during the four button states
|
|
||||||
PrinterSelectViewBase buttonWidgetPressed = getButtonWidgetNormal();
|
|
||||||
PrinterSelectViewBase buttonWidgetHover = getButtonWidgetHover();
|
|
||||||
PrinterSelectViewBase buttonWidgetNormal = getButtonWidgetNormal();
|
|
||||||
PrinterSelectViewBase buttonWidgetDisabled = getButtonWidgetNormal();
|
|
||||||
|
|
||||||
//Create container for the three state widgets for the button
|
|
||||||
ButtonViewStates buttonView = new ButtonViewStates(buttonWidgetNormal, buttonWidgetHover, buttonWidgetPressed, buttonWidgetDisabled);
|
|
||||||
buttonView.HAnchor = HAnchor.ParentLeftRight;
|
|
||||||
|
|
||||||
this.ToolTipText = "Select a printer".Localize();
|
|
||||||
this.Name = "Select a Printer Button";
|
|
||||||
|
|
||||||
Margin = DefaultMargin;
|
|
||||||
|
|
||||||
OriginRelativeParent = new Vector2(0, 0);
|
|
||||||
|
|
||||||
if (buttonView != null)
|
|
||||||
{
|
|
||||||
buttonView.Selectable = false;
|
|
||||||
|
|
||||||
AddChild(buttonView);
|
|
||||||
|
|
||||||
HAnchor = HAnchor.FitToChildren;
|
|
||||||
VAnchor = VAnchor.FitToChildren;
|
|
||||||
|
|
||||||
if (LocalBounds.Left != 0 || LocalBounds.Bottom != 0)
|
|
||||||
{
|
|
||||||
// let's make sure that a button has 0, 0 at the lower left
|
|
||||||
// move the children so they will fit with 0, 0 at the lower left
|
|
||||||
foreach (GuiWidget child in Children)
|
|
||||||
{
|
|
||||||
child.OriginRelativeParent = child.OriginRelativeParent + new Vector2(-LocalBounds.Left, -LocalBounds.Bottom);
|
|
||||||
}
|
|
||||||
|
|
||||||
HAnchor = HAnchor.FitToChildren;
|
|
||||||
VAnchor = VAnchor.FitToChildren;
|
|
||||||
}
|
|
||||||
|
|
||||||
MinimumSize = new Vector2(Width, Height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private PrinterSelectViewBase getButtonWidgetHover()
|
|
||||||
{
|
|
||||||
RGBA_Bytes borderColor;
|
|
||||||
RGBA_Bytes fillColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
|
||||||
if (ActiveTheme.Instance.IsDarkTheme)
|
|
||||||
{
|
|
||||||
borderColor = new RGBA_Bytes(128, 128, 128);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
borderColor = new RGBA_Bytes(128, 128, 128);
|
|
||||||
}
|
|
||||||
RGBA_Bytes textColor = ActiveTheme.Instance.PrimaryTextColor;
|
|
||||||
PrinterSelectViewBase widget = new PrinterSelectViewBase(
|
|
||||||
this.width,
|
|
||||||
this.height,
|
|
||||||
this.fontSize,
|
|
||||||
this.borderWidth,
|
|
||||||
this.borderRadius,
|
|
||||||
this.padding,
|
|
||||||
textColor,
|
|
||||||
fillColor,
|
|
||||||
borderColor);
|
|
||||||
return widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PrinterSelectViewBase getButtonWidgetNormal()
|
|
||||||
{
|
|
||||||
RGBA_Bytes fillColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
|
||||||
RGBA_Bytes borderColor;
|
|
||||||
if (ActiveTheme.Instance.IsDarkTheme)
|
|
||||||
{
|
|
||||||
borderColor = new RGBA_Bytes(77, 77, 77);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
borderColor = new RGBA_Bytes(190, 190, 190);
|
|
||||||
}
|
|
||||||
|
|
||||||
RGBA_Bytes textColor = ActiveTheme.Instance.PrimaryTextColor;
|
|
||||||
PrinterSelectViewBase widget = new PrinterSelectViewBase(
|
|
||||||
this.width,
|
|
||||||
this.height,
|
|
||||||
this.fontSize,
|
|
||||||
this.borderWidth,
|
|
||||||
this.borderRadius,
|
|
||||||
this.padding,
|
|
||||||
textColor,
|
|
||||||
fillColor,
|
|
||||||
borderColor);
|
|
||||||
return widget;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ActionBarControlButtonFactory
|
|
||||||
{
|
|
||||||
private double width = 75;
|
|
||||||
private double height = 30;
|
|
||||||
private double borderRadius = 3;
|
|
||||||
private double borderWidth = 1;
|
|
||||||
private double fontSize = 14;
|
|
||||||
private double padding = 3;
|
|
||||||
private BorderDouble margin = new BorderDouble(5, 0);
|
|
||||||
|
|
||||||
public Button Generate(string buttonText)
|
|
||||||
{
|
|
||||||
//Widgets to show during the four button states
|
|
||||||
ControlButtonViewBase buttonWidgetPressed = getButtonWidgetPressed(buttonText);
|
|
||||||
ControlButtonViewBase buttonWidgetHover = getButtonWidgetHover(buttonText);
|
|
||||||
ControlButtonViewBase buttonWidgetNormal = getButtonWidgetNormal(buttonText);
|
|
||||||
ControlButtonViewBase buttonWidgetDisabled = getButtonWidgetDisabled(buttonText);
|
|
||||||
|
|
||||||
//Create container for the three state widgets for the button
|
|
||||||
ButtonViewStates buttonViewWidget = new ButtonViewStates(buttonWidgetNormal, buttonWidgetHover, buttonWidgetPressed, buttonWidgetDisabled);
|
|
||||||
|
|
||||||
//Create button based on view container widget
|
|
||||||
Button controlButton = new Button(0, 0, buttonViewWidget);
|
|
||||||
controlButton.Margin = margin;
|
|
||||||
|
|
||||||
return controlButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ControlButtonViewBase getButtonWidgetPressed(string buttonText)
|
|
||||||
{
|
|
||||||
RGBA_Bytes fillColor = new RGBA_Bytes(63, 63, 70);
|
|
||||||
RGBA_Bytes borderColor = new RGBA_Bytes(37, 37, 38);
|
|
||||||
RGBA_Bytes textColor = new RGBA_Bytes(230, 230, 230);
|
|
||||||
ControlButtonViewBase widget = new ControlButtonViewBase(buttonText,
|
|
||||||
this.width,
|
|
||||||
this.height,
|
|
||||||
this.fontSize,
|
|
||||||
this.borderWidth,
|
|
||||||
this.borderRadius,
|
|
||||||
this.padding,
|
|
||||||
textColor,
|
|
||||||
fillColor,
|
|
||||||
borderColor);
|
|
||||||
return widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ControlButtonViewBase getButtonWidgetHover(string buttonText)
|
|
||||||
{
|
|
||||||
RGBA_Bytes fillColor = new RGBA_Bytes(63, 63, 70);
|
|
||||||
RGBA_Bytes borderColor = RGBA_Bytes.LightGray;
|
|
||||||
RGBA_Bytes textColor = new RGBA_Bytes(230, 230, 230);
|
|
||||||
ControlButtonViewBase widget = new ControlButtonViewBase(buttonText,
|
|
||||||
this.width,
|
|
||||||
this.height,
|
|
||||||
this.fontSize,
|
|
||||||
this.borderWidth,
|
|
||||||
this.borderRadius,
|
|
||||||
this.padding,
|
|
||||||
textColor,
|
|
||||||
fillColor,
|
|
||||||
borderColor);
|
|
||||||
return widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ControlButtonViewBase getButtonWidgetNormal(string buttonText)
|
|
||||||
{
|
|
||||||
RGBA_Bytes fillColor = new RGBA_Bytes(245, 245, 245);
|
|
||||||
RGBA_Bytes borderColor = new RGBA_Bytes(204, 204, 204);
|
|
||||||
RGBA_Bytes textColor = new RGBA_Bytes(69, 69, 69);
|
|
||||||
ControlButtonViewBase widget = new ControlButtonViewBase(buttonText,
|
|
||||||
this.width,
|
|
||||||
this.height,
|
|
||||||
this.fontSize,
|
|
||||||
this.borderWidth,
|
|
||||||
this.borderRadius,
|
|
||||||
this.padding,
|
|
||||||
textColor,
|
|
||||||
fillColor,
|
|
||||||
borderColor);
|
|
||||||
return widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ControlButtonViewBase getButtonWidgetDisabled(string buttonText)
|
|
||||||
{
|
|
||||||
RGBA_Bytes fillColor = new RGBA_Bytes(245, 245, 245);
|
|
||||||
RGBA_Bytes borderColor = new RGBA_Bytes(204, 204, 204);
|
|
||||||
RGBA_Bytes textColor = new RGBA_Bytes(153, 153, 153);
|
|
||||||
ControlButtonViewBase widget = new ControlButtonViewBase(buttonText,
|
|
||||||
this.width,
|
|
||||||
this.height,
|
|
||||||
this.fontSize,
|
|
||||||
this.borderWidth,
|
|
||||||
this.borderRadius,
|
|
||||||
this.padding,
|
|
||||||
textColor,
|
|
||||||
fillColor,
|
|
||||||
borderColor);
|
|
||||||
return widget;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +1,33 @@
|
||||||
using MatterHackers.Agg;
|
/*
|
||||||
|
Copyright (c) 2016, Lars Brubaker
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
The views and conclusions contained in the software and documentation are those
|
||||||
|
of the authors and should not be interpreted as representing official policies,
|
||||||
|
either expressed or implied, of the FreeBSD Project.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using MatterHackers.Agg;
|
||||||
using MatterHackers.Agg.UI;
|
using MatterHackers.Agg.UI;
|
||||||
using MatterHackers.MatterControl.ActionBar;
|
using MatterHackers.MatterControl.ActionBar;
|
||||||
using MatterHackers.MatterControl.PrintQueue;
|
using MatterHackers.MatterControl.PrintQueue;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2014, Kevin Pope
|
Copyright (c) 2016, Lars Brubaker
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
@ -30,22 +30,37 @@ either expressed or implied, of the FreeBSD Project.
|
||||||
using MatterHackers.Agg;
|
using MatterHackers.Agg;
|
||||||
using MatterHackers.Agg.UI;
|
using MatterHackers.Agg.UI;
|
||||||
using MatterHackers.Agg.VertexSource;
|
using MatterHackers.Agg.VertexSource;
|
||||||
using MatterHackers.MatterControl.PrintLibrary;
|
|
||||||
using MatterHackers.MatterControl.PrintLibrary.Provider;
|
|
||||||
using MatterHackers.VectorMath;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl.CustomWidgets.LibrarySelector
|
namespace MatterHackers.MatterControl.ActionBar
|
||||||
{
|
{
|
||||||
public class LibraryDataViewEventArgs : EventArgs
|
//Base widget for ActionBarRows
|
||||||
|
public abstract class ActionRowBase : FlowLayoutWidget
|
||||||
{
|
{
|
||||||
public LibraryProvider LibraryProvider { get; set; }
|
public ActionRowBase()
|
||||||
|
: base(FlowDirection.LeftToRight)
|
||||||
public LibraryDataViewEventArgs(LibraryProvider libraryProvider)
|
|
||||||
{
|
{
|
||||||
this.LibraryProvider = libraryProvider;
|
Initialize();
|
||||||
|
SetDisplayAttributes();
|
||||||
|
AddChildElements();
|
||||||
|
AddHandlers();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Initialize()
|
||||||
|
{
|
||||||
|
//Placeholder for row-specific initialization
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void SetDisplayAttributes()
|
||||||
|
{
|
||||||
|
this.HAnchor = HAnchor.ParentLeftRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void AddChildElements();
|
||||||
|
|
||||||
|
protected virtual void AddHandlers()
|
||||||
|
{
|
||||||
|
//Placeholder for row-specific handlers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,33 @@
|
||||||
using MatterHackers.Agg;
|
/*
|
||||||
|
Copyright (c) 2016, Lars Brubaker
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
The views and conclusions contained in the software and documentation are those
|
||||||
|
of the authors and should not be interpreted as representing official policies,
|
||||||
|
either expressed or implied, of the FreeBSD Project.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using MatterHackers.Agg;
|
||||||
using MatterHackers.Agg.UI;
|
using MatterHackers.Agg.UI;
|
||||||
using MatterHackers.Localizations;
|
using MatterHackers.Localizations;
|
||||||
using MatterHackers.MatterControl.ConfigurationPage.PrintLeveling;
|
using MatterHackers.MatterControl.ConfigurationPage.PrintLeveling;
|
||||||
|
|
@ -256,7 +285,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PrinterConnectionAndCommunication.CommunicationStates.Connected:
|
case PrinterConnectionAndCommunication.CommunicationStates.Connected:
|
||||||
PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(ActivePrinterProfile.Instance.ActivePrinter);
|
PrintLevelingData levelingData = ActiveSliceSettings.Instance.PrintLevelingData;
|
||||||
if (levelingData != null && ActiveSliceSettings.Instance.LevelingRequiredToPrint
|
if (levelingData != null && ActiveSliceSettings.Instance.LevelingRequiredToPrint
|
||||||
&& !levelingData.HasBeenRun())
|
&& !levelingData.HasBeenRun())
|
||||||
{
|
{
|
||||||
|
|
@ -393,7 +422,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
||||||
|
|
||||||
private void onConnectButton_Click(object sender, EventArgs mouseEvent)
|
private void onConnectButton_Click(object sender, EventArgs mouseEvent)
|
||||||
{
|
{
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter == null)
|
if (ActiveSliceSettings.Instance == null)
|
||||||
{
|
{
|
||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
SetupWizardWindow.Show();
|
SetupWizardWindow.Show();
|
||||||
|
|
|
||||||
|
|
@ -238,16 +238,16 @@ namespace MatterHackers.MatterControl.ActionBar
|
||||||
autoLevelButton.Cursor = Cursors.Hand;
|
autoLevelButton.Cursor = Cursors.Hand;
|
||||||
autoLevelButton.Margin = new Agg.BorderDouble(top: 3);
|
autoLevelButton.Margin = new Agg.BorderDouble(top: 3);
|
||||||
autoLevelButton.ToolTipText = "Print leveling is enabled.".Localize();
|
autoLevelButton.ToolTipText = "Print leveling is enabled.".Localize();
|
||||||
autoLevelButton.Visible = ActivePrinterProfile.Instance.DoPrintLeveling;
|
autoLevelButton.Visible = ActiveSliceSettings.Instance.DoPrintLeveling;
|
||||||
|
|
||||||
ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent((sender, e) =>
|
ActiveSliceSettings.ActivePrinterChanged.RegisterEvent((sender, e) =>
|
||||||
{
|
{
|
||||||
autoLevelButton.Visible = ActivePrinterProfile.Instance.DoPrintLeveling;
|
autoLevelButton.Visible = ActiveSliceSettings.Instance.DoPrintLeveling;
|
||||||
}, ref unregisterEvents);
|
}, ref unregisterEvents);
|
||||||
|
|
||||||
ActivePrinterProfile.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) =>
|
ActiveSliceSettings.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) =>
|
||||||
{
|
{
|
||||||
autoLevelButton.Visible = ActivePrinterProfile.Instance.DoPrintLeveling;
|
autoLevelButton.Visible = ActiveSliceSettings.Instance.DoPrintLeveling;
|
||||||
}, ref unregisterEvents);
|
}, ref unregisterEvents);
|
||||||
|
|
||||||
return autoLevelButton;
|
return autoLevelButton;
|
||||||
|
|
@ -255,7 +255,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
||||||
|
|
||||||
private string getConnectionMessage()
|
private string getConnectionMessage()
|
||||||
{
|
{
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter == null)
|
if (ActiveSliceSettings.Instance == null)
|
||||||
{
|
{
|
||||||
return LocalizedString.Get("Press 'Connect' to select a printer.");
|
return LocalizedString.Get("Press 'Connect' to select a printer.");
|
||||||
}
|
}
|
||||||
|
|
@ -339,7 +339,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
||||||
}
|
}
|
||||||
private void SetVisibleStatus()
|
private void SetVisibleStatus()
|
||||||
{
|
{
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter != null)
|
if (ActiveSliceSettings.Instance != null)
|
||||||
{
|
{
|
||||||
if (ActiveSliceSettings.Instance.HasHeatedBed())
|
if (ActiveSliceSettings.Instance.HasHeatedBed())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,33 @@
|
||||||
using MatterHackers.Agg;
|
/*
|
||||||
|
Copyright (c) 2016, Lars Brubaker
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
The views and conclusions contained in the software and documentation are those
|
||||||
|
of the authors and should not be interpreted as representing official policies,
|
||||||
|
either expressed or implied, of the FreeBSD Project.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using MatterHackers.Agg;
|
||||||
using MatterHackers.Agg.UI;
|
using MatterHackers.Agg.UI;
|
||||||
using MatterHackers.Localizations;
|
using MatterHackers.Localizations;
|
||||||
using MatterHackers.MatterControl.PrinterCommunication;
|
using MatterHackers.MatterControl.PrinterCommunication;
|
||||||
|
|
@ -10,7 +39,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
||||||
{
|
{
|
||||||
public class PrinterActionRow : ActionRowBase
|
public class PrinterActionRow : ActionRowBase
|
||||||
{
|
{
|
||||||
static private ConnectionWindow connectionWindow;
|
static private ConnectionWizard connectionWindow;
|
||||||
private TextImageButtonFactory actionBarButtonFactory = new TextImageButtonFactory();
|
private TextImageButtonFactory actionBarButtonFactory = new TextImageButtonFactory();
|
||||||
private Button connectPrinterButton;
|
private Button connectPrinterButton;
|
||||||
private string disconnectAndCancelMessage = "Disconnect and cancel the current print?".Localize();
|
private string disconnectAndCancelMessage = "Disconnect and cancel the current print?".Localize();
|
||||||
|
|
@ -26,12 +55,12 @@ namespace MatterHackers.MatterControl.ActionBar
|
||||||
{
|
{
|
||||||
if (connectAfterSelection)
|
if (connectAfterSelection)
|
||||||
{
|
{
|
||||||
ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(ConnectToActivePrinter, ref staticUnregisterEvents);
|
ActiveSliceSettings.ActivePrinterChanged.RegisterEvent(ConnectToActivePrinter, ref staticUnregisterEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connectionWindow == null)
|
if (connectionWindow == null)
|
||||||
{
|
{
|
||||||
connectionWindow = new ConnectionWindow();
|
connectionWindow = new ConnectionWizard();
|
||||||
|
|
||||||
connectionWindow.Closed += new EventHandler(ConnectionWindow_Closed);
|
connectionWindow.Closed += new EventHandler(ConnectionWindow_Closed);
|
||||||
}
|
}
|
||||||
|
|
@ -46,10 +75,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
||||||
|
|
||||||
public override void OnClosed(EventArgs e)
|
public override void OnClosed(EventArgs e)
|
||||||
{
|
{
|
||||||
if (unregisterEvents != null)
|
unregisterEvents?.Invoke(this, null);
|
||||||
{
|
|
||||||
unregisterEvents(this, null);
|
|
||||||
}
|
|
||||||
base.OnClosed(e);
|
base.OnClosed(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,7 +121,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
||||||
disconnectPrinterButton.VAnchor = VAnchor.ParentTop;
|
disconnectPrinterButton.VAnchor = VAnchor.ParentTop;
|
||||||
disconnectPrinterButton.Cursor = Cursors.Hand;
|
disconnectPrinterButton.Cursor = Cursors.Hand;
|
||||||
|
|
||||||
selectActivePrinterButton = new PrinterSelectButton();
|
selectActivePrinterButton = new PrinterSelector();
|
||||||
selectActivePrinterButton.HAnchor = HAnchor.ParentLeftRight;
|
selectActivePrinterButton.HAnchor = HAnchor.ParentLeftRight;
|
||||||
selectActivePrinterButton.Cursor = Cursors.Hand;
|
selectActivePrinterButton.Cursor = Cursors.Hand;
|
||||||
if (ApplicationController.Instance.WidescreenMode)
|
if (ApplicationController.Instance.WidescreenMode)
|
||||||
|
|
@ -132,11 +158,10 @@ namespace MatterHackers.MatterControl.ActionBar
|
||||||
|
|
||||||
protected override void AddHandlers()
|
protected override void AddHandlers()
|
||||||
{
|
{
|
||||||
ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(onActivePrinterChanged, ref unregisterEvents);
|
ActiveSliceSettings.ActivePrinterChanged.RegisterEvent(onActivePrinterChanged, ref unregisterEvents);
|
||||||
PrinterConnectionAndCommunication.Instance.EnableChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
PrinterConnectionAndCommunication.Instance.EnableChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||||
PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||||
|
|
||||||
selectActivePrinterButton.Click += new EventHandler(onSelectActivePrinterButton_Click);
|
|
||||||
connectPrinterButton.Click += new EventHandler(onConnectButton_Click);
|
connectPrinterButton.Click += new EventHandler(onConnectButton_Click);
|
||||||
disconnectPrinterButton.Click += new EventHandler(onDisconnectButtonClick);
|
disconnectPrinterButton.Click += new EventHandler(onDisconnectButtonClick);
|
||||||
resetConnectionButton.Click += new EventHandler(resetConnectionButton_Click);
|
resetConnectionButton.Click += new EventHandler(resetConnectionButton_Click);
|
||||||
|
|
@ -196,7 +221,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
||||||
Button buttonClicked = ((Button)sender);
|
Button buttonClicked = ((Button)sender);
|
||||||
if (buttonClicked.Enabled)
|
if (buttonClicked.Enabled)
|
||||||
{
|
{
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter == null)
|
if (ActiveSliceSettings.Instance == null)
|
||||||
{
|
{
|
||||||
OpenConnectionWindow(true);
|
OpenConnectionWindow(true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
60
ActionBar/PrinterSelector.cs
Normal file
60
ActionBar/PrinterSelector.cs
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
Copyright (c) 2016, John Lewin
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
The views and conclusions contained in the software and documentation are those
|
||||||
|
of the authors and should not be interpreted as representing official policies,
|
||||||
|
either expressed or implied, of the FreeBSD Project.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using MatterHackers.Localizations;
|
||||||
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||||
|
|
||||||
|
namespace MatterHackers.MatterControl
|
||||||
|
{
|
||||||
|
public class PrinterSelector : StyledDropDownList
|
||||||
|
{
|
||||||
|
public PrinterSelector() : base("Printers".Localize() + "... ")
|
||||||
|
{
|
||||||
|
//Add the menu items to the menu itself
|
||||||
|
foreach (var printer in ActiveSliceSettings.ProfileData.Profiles)
|
||||||
|
{
|
||||||
|
this.AddItem(printer.Name, printer.Id.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(ActiveSliceSettings.ProfileData.ActiveProfileID))
|
||||||
|
{
|
||||||
|
this.SelectedValue = ActiveSliceSettings.ProfileData.ActiveProfileID;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.SelectionChanged += (s, e) =>
|
||||||
|
{
|
||||||
|
int printerID;
|
||||||
|
if (int.TryParse(this.SelectedValue, out printerID))
|
||||||
|
{
|
||||||
|
ActiveSliceSettings.SwitchToProfile(printerID);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2014, Kevin Pope
|
Copyright (c) 2016, Kevin Pope, John Lewin
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
@ -37,46 +37,52 @@ using System;
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl
|
namespace MatterHackers.MatterControl
|
||||||
{
|
{
|
||||||
public class ThirdPanelTabView : GuiWidget
|
public class AdvancedControlsPanel : GuiWidget
|
||||||
{
|
{
|
||||||
|
private static readonly string ThirdPanelTabView_AdvancedControls_CurrentTab = "ThirdPanelTabView_AdvancedControls_CurrentTab";
|
||||||
|
|
||||||
private event EventHandler unregisterEvents;
|
private event EventHandler unregisterEvents;
|
||||||
|
|
||||||
private Button advancedControlsBackButton;
|
private Button backButton;
|
||||||
private SliceSettingsWidget sliceSettingsWidget;
|
private GuiWidget sliceSettingsWidget;
|
||||||
private EventHandler AdvancedControlsButton_Click;
|
|
||||||
|
|
||||||
private TabControl advancedControls2;
|
public event EventHandler BackClicked;
|
||||||
|
|
||||||
public ThirdPanelTabView(EventHandler AdvancedControlsButton_Click = null)
|
private TabControl advancedTab;
|
||||||
|
|
||||||
|
public AdvancedControlsPanel()
|
||||||
{
|
{
|
||||||
this.AdvancedControlsButton_Click = AdvancedControlsButton_Click;
|
advancedTab = CreateAdvancedControlsTab();
|
||||||
|
AddChild(advancedTab);
|
||||||
advancedControls2 = CreateNewAdvancedControls(AdvancedControlsButton_Click);
|
|
||||||
|
|
||||||
AddChild(advancedControls2);
|
|
||||||
|
|
||||||
ApplicationController.Instance.ReloadAdvancedControlsPanelTrigger.RegisterEvent(ReloadAdvancedControlsPanelTrigger, ref unregisterEvents);
|
|
||||||
|
|
||||||
AnchorAll();
|
AnchorAll();
|
||||||
|
|
||||||
|
ApplicationController.Instance.ReloadAdvancedControlsPanelTrigger.RegisterEvent((s, e) => UiThread.RunOnIdle(ReloadSliceSettings), ref unregisterEvents);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string SliceSettingsTabName { get; } = "Slice Settings Tab";
|
||||||
|
|
||||||
|
public static string ControlsTabName { get; } = "Controls Tab";
|
||||||
|
|
||||||
|
public void ReloadSliceSettings()
|
||||||
|
{
|
||||||
|
WidescreenPanel.PreChangePanels.CallEvents(null, null);
|
||||||
|
|
||||||
|
// remove the advance control and replace it with new ones built for the selected printer
|
||||||
|
int advancedControlsIndex = GetChildIndex(advancedTab);
|
||||||
|
RemoveChild(advancedControlsIndex);
|
||||||
|
advancedTab.Close();
|
||||||
|
|
||||||
|
advancedTab = CreateAdvancedControlsTab();
|
||||||
|
AddChild(advancedTab, advancedControlsIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnClosed(EventArgs e)
|
public override void OnClosed(EventArgs e)
|
||||||
{
|
{
|
||||||
if (unregisterEvents != null)
|
unregisterEvents?.Invoke(this, null);
|
||||||
{
|
|
||||||
unregisterEvents(this, null);
|
|
||||||
}
|
|
||||||
base.OnClosed(e);
|
base.OnClosed(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReloadAdvancedControlsPanelTrigger(object sender, EventArgs e)
|
private TabControl CreateAdvancedControlsTab()
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(ReloadSliceSettings);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static readonly string ThirdPanelTabView_AdvancedControls_CurrentTab = "ThirdPanelTabView_AdvancedControls_CurrentTab";
|
|
||||||
|
|
||||||
private TabControl CreateNewAdvancedControls(EventHandler AdvancedControlsButton_Click)
|
|
||||||
{
|
{
|
||||||
TabControl advancedControls = new TabControl();
|
TabControl advancedControls = new TabControl();
|
||||||
|
|
||||||
|
|
@ -87,44 +93,46 @@ namespace MatterHackers.MatterControl
|
||||||
|
|
||||||
int textSize = 16;
|
int textSize = 16;
|
||||||
|
|
||||||
if (AdvancedControlsButton_Click != null)
|
// this means we are in compact view and so we will make the tabs text a bit smaller
|
||||||
{
|
textSize = 14;
|
||||||
// this means we are in compact view and so we will make the tabs text a bit smaller
|
TextImageButtonFactory advancedControlsButtonFactory = new TextImageButtonFactory();
|
||||||
textSize = 14;
|
advancedControlsButtonFactory.fontSize = 14;
|
||||||
TextImageButtonFactory advancedControlsButtonFactory = new TextImageButtonFactory();
|
advancedControlsButtonFactory.invertImageLocation = false;
|
||||||
advancedControlsButtonFactory.fontSize = 14;
|
backButton = advancedControlsButtonFactory.Generate(LocalizedString.Get("Back"), "icon_arrow_left_32x32.png");
|
||||||
advancedControlsButtonFactory.invertImageLocation = false;
|
backButton.ToolTipText = "Switch to Queue, Library and History".Localize();
|
||||||
advancedControlsBackButton = advancedControlsButtonFactory.Generate(LocalizedString.Get("Back"), "icon_arrow_left_32x32.png");
|
backButton.Margin = new BorderDouble(right: 3);
|
||||||
advancedControlsBackButton.ToolTipText = "Switch to Queue, Library and History".Localize();
|
backButton.VAnchor = VAnchor.ParentBottom;
|
||||||
advancedControlsBackButton.Margin = new BorderDouble(right: 3);
|
backButton.Cursor = Cursors.Hand;
|
||||||
advancedControlsBackButton.VAnchor = VAnchor.ParentBottom;
|
backButton.Click += (s, e) => BackClicked?.Invoke(this, null);
|
||||||
advancedControlsBackButton.Cursor = Cursors.Hand;
|
|
||||||
advancedControlsBackButton.Click += new EventHandler(AdvancedControlsButton_Click);
|
|
||||||
|
|
||||||
advancedControls.TabBar.AddChild(advancedControlsBackButton);
|
advancedControls.TabBar.AddChild(backButton);
|
||||||
}
|
|
||||||
|
|
||||||
advancedControls.TabBar.AddChild(new HorizontalSpacer());
|
advancedControls.TabBar.AddChild(new HorizontalSpacer());
|
||||||
|
|
||||||
GuiWidget manualPrinterControls = new ManualPrinterControls();
|
GuiWidget manualPrinterControls = new ManualPrinterControls();
|
||||||
|
|
||||||
ScrollableWidget manualPrinterControlsScrollArea = new ScrollableWidget(true);
|
ScrollableWidget manualPrinterControlsScrollArea = new ScrollableWidget(true);
|
||||||
manualPrinterControlsScrollArea.ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
|
manualPrinterControlsScrollArea.ScrollArea.HAnchor |= HAnchor.ParentLeftRight;
|
||||||
manualPrinterControlsScrollArea.AnchorAll();
|
manualPrinterControlsScrollArea.AnchorAll();
|
||||||
manualPrinterControlsScrollArea.AddChild(manualPrinterControls);
|
manualPrinterControlsScrollArea.AddChild(manualPrinterControls);
|
||||||
|
|
||||||
RGBA_Bytes unselectedTextColor = ActiveTheme.Instance.TabLabelUnselected;
|
RGBA_Bytes unselectedTextColor = ActiveTheme.Instance.TabLabelUnselected;
|
||||||
|
|
||||||
//Add the tab contents for 'Advanced Controls'
|
if (ActiveSliceSettings.Instance.PrinterSelected)
|
||||||
string sliceSettingsLabel = LocalizedString.Get("Settings").ToUpper();
|
{
|
||||||
string printerControlsLabel = LocalizedString.Get("Controls").ToUpper();
|
sliceSettingsWidget = new SliceSettingsWidget();
|
||||||
sliceSettingsWidget = new SliceSettingsWidget();
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sliceSettingsWidget = new NoSettingsWidget();
|
||||||
|
}
|
||||||
|
|
||||||
TabPage sliceSettingsTabPage = new TabPage(sliceSettingsWidget, sliceSettingsLabel);
|
var sliceSettingsTabPage = new TabPage(sliceSettingsWidget, "Settings".Localize().ToUpper());
|
||||||
PopOutTextTabWidget sliceSettingPopOut = new PopOutTextTabWidget(sliceSettingsTabPage, SliceSettingsTabName, new Vector2(590, 400), textSize);
|
var sliceSettingPopOut = new PopOutTextTabWidget(sliceSettingsTabPage, SliceSettingsTabName, new Vector2(590, 400), textSize);
|
||||||
advancedControls.AddTab(sliceSettingPopOut);
|
advancedControls.AddTab(sliceSettingPopOut);
|
||||||
|
|
||||||
TabPage controlsTabPage = new TabPage(manualPrinterControlsScrollArea, printerControlsLabel);
|
var controlsTabPage = new TabPage(manualPrinterControlsScrollArea, "Controls".Localize().ToUpper());
|
||||||
PopOutTextTabWidget controlsPopOut = new PopOutTextTabWidget(controlsTabPage, ControlsTabName, new Vector2(400, 300), textSize);
|
var controlsPopOut = new PopOutTextTabWidget(controlsTabPage, ControlsTabName, new Vector2(400, 300), textSize);
|
||||||
advancedControls.AddTab(controlsPopOut);
|
advancedControls.AddTab(controlsPopOut);
|
||||||
|
|
||||||
#if !__ANDROID__
|
#if !__ANDROID__
|
||||||
|
|
@ -132,9 +140,8 @@ namespace MatterHackers.MatterControl
|
||||||
MenuOptionSettings.controlsPopOut = controlsPopOut;
|
MenuOptionSettings.controlsPopOut = controlsPopOut;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
string optionsLabel = LocalizedString.Get("Options").ToUpper();
|
var optionsControls = new PrinterConfigurationScrollWidget();
|
||||||
ScrollableWidget optionsControls = new PrinterConfigurationScrollWidget();
|
advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(optionsControls, "Options".Localize().ToUpper()), "Options Tab", textSize,
|
||||||
advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(optionsControls, optionsLabel), "Options Tab", textSize,
|
|
||||||
ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));
|
ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));
|
||||||
|
|
||||||
// Make sure we are on the right tab when we create this view
|
// Make sure we are on the right tab when we create this view
|
||||||
|
|
@ -142,7 +149,7 @@ namespace MatterHackers.MatterControl
|
||||||
string selectedTab = UserSettings.Instance.get(ThirdPanelTabView_AdvancedControls_CurrentTab);
|
string selectedTab = UserSettings.Instance.get(ThirdPanelTabView_AdvancedControls_CurrentTab);
|
||||||
advancedControls.SelectTab(selectedTab);
|
advancedControls.SelectTab(selectedTab);
|
||||||
|
|
||||||
advancedControls.TabBar.TabIndexChanged += (object sender, EventArgs e) =>
|
advancedControls.TabBar.TabIndexChanged += (sender, e) =>
|
||||||
{
|
{
|
||||||
UserSettings.Instance.set(ThirdPanelTabView_AdvancedControls_CurrentTab, advancedControls.TabBar.SelectedTabName);
|
UserSettings.Instance.set(ThirdPanelTabView_AdvancedControls_CurrentTab, advancedControls.TabBar.SelectedTabName);
|
||||||
};
|
};
|
||||||
|
|
@ -150,37 +157,5 @@ namespace MatterHackers.MatterControl
|
||||||
|
|
||||||
return advancedControls;
|
return advancedControls;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string SliceSettingsTabName
|
|
||||||
{
|
|
||||||
get { return "Slice Settings Tab"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string ControlsTabName
|
|
||||||
{
|
|
||||||
get { return "Controls Tab"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ReloadSliceSettings()
|
|
||||||
{
|
|
||||||
WidescreenPanel.PreChangePanels.CallEvents(null, null);
|
|
||||||
|
|
||||||
// remove the advance control and replace it with new ones built for the selected printer
|
|
||||||
int advancedControlsIndex = GetChildIndex(advancedControls2);
|
|
||||||
RemoveChild(advancedControlsIndex);
|
|
||||||
advancedControls2.Close();
|
|
||||||
|
|
||||||
if (advancedControlsBackButton != null)
|
|
||||||
{
|
|
||||||
advancedControlsBackButton.Click -= new EventHandler(AdvancedControlsButton_Click);
|
|
||||||
}
|
|
||||||
|
|
||||||
advancedControls2 = CreateNewAdvancedControls(AdvancedControlsButton_Click);
|
|
||||||
AddChild(advancedControls2, advancedControlsIndex);
|
|
||||||
|
|
||||||
// This is a hack to make the panel remain on the screen. It would be great to debug it and understand
|
|
||||||
// why it does not work without this code in here.
|
|
||||||
//currentParent.Parent.Width = currentParent.Parent.Width + 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -46,22 +46,18 @@ namespace MatterHackers.MatterControl
|
||||||
|
|
||||||
private QueueDataView queueDataView;
|
private QueueDataView queueDataView;
|
||||||
|
|
||||||
private GuiWidget LeftPanel
|
const int StandardControlsPanelIndex = 0;
|
||||||
{
|
const int AdvancedControlsPanelIndex = 1;
|
||||||
get { return GetPanel(0); }
|
|
||||||
}
|
|
||||||
|
|
||||||
private GuiWidget RightPanel
|
private GuiWidget LeftPanel => GetPanel(0);
|
||||||
{
|
|
||||||
get { return GetPanel(1); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public double TabBarWidth { get { return mainControlsTabControl.Width; } }
|
private GuiWidget RightPanel => GetPanel(1);
|
||||||
|
|
||||||
|
public double TabBarWidth => mainControlsTabControl.Width;
|
||||||
|
|
||||||
private static int lastPanelIndexBeforeReload = 0;
|
private static int lastPanelIndexBeforeReload = 0;
|
||||||
|
|
||||||
public CompactSlidePanel(QueueDataView queueDataView)
|
public CompactSlidePanel(QueueDataView queueDataView) : base(2)
|
||||||
: base(2)
|
|
||||||
{
|
{
|
||||||
this.queueDataView = queueDataView;
|
this.queueDataView = queueDataView;
|
||||||
|
|
||||||
|
|
@ -73,24 +69,27 @@ namespace MatterHackers.MatterControl
|
||||||
// construct the main controls tab control
|
// construct the main controls tab control
|
||||||
mainControlsTabControl = new FirstPanelTabView(queueDataView);
|
mainControlsTabControl = new FirstPanelTabView(queueDataView);
|
||||||
|
|
||||||
TextImageButtonFactory advancedControlsButtonFactory = new TextImageButtonFactory();
|
var advancedControlsButtonFactory = new TextImageButtonFactory()
|
||||||
advancedControlsButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
{
|
||||||
advancedControlsButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
normalTextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||||
advancedControlsButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
hoverTextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||||
advancedControlsButtonFactory.fontSize = 10;
|
pressedTextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||||
|
fontSize = 10,
|
||||||
|
|
||||||
advancedControlsButtonFactory.disabledTextColor = RGBA_Bytes.LightGray;
|
disabledTextColor = RGBA_Bytes.LightGray,
|
||||||
advancedControlsButtonFactory.disabledFillColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
disabledFillColor = ActiveTheme.Instance.PrimaryBackgroundColor,
|
||||||
advancedControlsButtonFactory.disabledBorderColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
disabledBorderColor = ActiveTheme.Instance.PrimaryBackgroundColor,
|
||||||
|
|
||||||
|
invertImageLocation = true
|
||||||
|
};
|
||||||
|
|
||||||
advancedControlsButtonFactory.invertImageLocation = true;
|
|
||||||
Button advancedControlsLinkButton = advancedControlsButtonFactory.Generate(LocalizedString.Get("Settings\n& Controls"), "icon_arrow_right_32x32.png");
|
Button advancedControlsLinkButton = advancedControlsButtonFactory.Generate(LocalizedString.Get("Settings\n& Controls"), "icon_arrow_right_32x32.png");
|
||||||
advancedControlsLinkButton.Name = "SettingsAndControls";
|
advancedControlsLinkButton.Name = "SettingsAndControls";
|
||||||
advancedControlsLinkButton.ToolTipText = "Switch to Settings, Controls and Options".Localize();
|
advancedControlsLinkButton.ToolTipText = "Switch to Settings, Controls and Options".Localize();
|
||||||
advancedControlsLinkButton.Margin = new BorderDouble(right: 3);
|
advancedControlsLinkButton.Margin = new BorderDouble(right: 3);
|
||||||
advancedControlsLinkButton.VAnchor = VAnchor.ParentBottom;
|
advancedControlsLinkButton.VAnchor = VAnchor.ParentBottom;
|
||||||
advancedControlsLinkButton.Cursor = Cursors.Hand;
|
advancedControlsLinkButton.Cursor = Cursors.Hand;
|
||||||
advancedControlsLinkButton.Click += new EventHandler(AdvancedControlsButton_Click);
|
advancedControlsLinkButton.Click += ToggleActivePanel_Click;
|
||||||
|
|
||||||
mainControlsTabControl.TabBar.AddChild(new HorizontalSpacer());
|
mainControlsTabControl.TabBar.AddChild(new HorizontalSpacer());
|
||||||
mainControlsTabControl.TabBar.AddChild(advancedControlsLinkButton);
|
mainControlsTabControl.TabBar.AddChild(advancedControlsLinkButton);
|
||||||
|
|
@ -100,17 +99,20 @@ namespace MatterHackers.MatterControl
|
||||||
this.LeftPanel.AddChild(mainControlsTabControl);
|
this.LeftPanel.AddChild(mainControlsTabControl);
|
||||||
}
|
}
|
||||||
|
|
||||||
// do the right panel
|
// Right panel
|
||||||
|
this.RightPanel.AddChild(new PrintProgressBar());
|
||||||
|
|
||||||
|
var advancedControlsPanel = new AdvancedControlsPanel()
|
||||||
{
|
{
|
||||||
this.RightPanel.AddChild(new PrintProgressBar());
|
Name = "For - CompactSlidePanel"
|
||||||
ThirdPanelTabView thirdPanelTabView = new ThirdPanelTabView(AdvancedControlsButton_Click);
|
};
|
||||||
thirdPanelTabView.Name = "For - CompactSlidePanel";
|
advancedControlsPanel.BackClicked += ToggleActivePanel_Click;
|
||||||
this.RightPanel.AddChild(thirdPanelTabView);
|
|
||||||
}
|
this.RightPanel.AddChild(advancedControlsPanel);
|
||||||
|
|
||||||
WidescreenPanel.PreChangePanels.RegisterEvent(SaveCurrentPanelIndex, ref unregisterEvents);
|
WidescreenPanel.PreChangePanels.RegisterEvent(SaveCurrentPanelIndex, ref unregisterEvents);
|
||||||
|
|
||||||
SetPanelIndexImediate(lastPanelIndexBeforeReload);
|
SetPanelIndexImmediate(lastPanelIndexBeforeReload);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveCurrentPanelIndex(object sender, EventArgs e)
|
private void SaveCurrentPanelIndex(object sender, EventArgs e)
|
||||||
|
|
@ -118,30 +120,22 @@ namespace MatterHackers.MatterControl
|
||||||
lastPanelIndexBeforeReload = PanelIndex;
|
lastPanelIndexBeforeReload = PanelIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AdvancedControlsButton_Click(object sender, EventArgs mouseEvent)
|
private void ToggleActivePanel_Click(object sender, EventArgs mouseEvent)
|
||||||
{
|
{
|
||||||
if (this.PanelIndex == 0)
|
if (this.PanelIndex == StandardControlsPanelIndex)
|
||||||
{
|
{
|
||||||
this.PanelIndex = 1;
|
this.PanelIndex = AdvancedControlsPanelIndex;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.PanelIndex = 0;
|
this.PanelIndex = StandardControlsPanelIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnClosed(EventArgs e)
|
public override void OnClosed(EventArgs e)
|
||||||
{
|
{
|
||||||
if (unregisterEvents != null)
|
unregisterEvents?.Invoke(this, null);
|
||||||
{
|
|
||||||
unregisterEvents(this, null);
|
|
||||||
}
|
|
||||||
base.OnClosed(e);
|
base.OnClosed(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DoNotChangePanel()
|
|
||||||
{
|
|
||||||
//Empty function used as placeholder
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -207,9 +207,9 @@ namespace MatterHackers.MatterControl
|
||||||
QueueData.Instance.ItemAdded.RegisterEvent(NumQueueItemsChanged, ref unregisterEvents);
|
QueueData.Instance.ItemAdded.RegisterEvent(NumQueueItemsChanged, ref unregisterEvents);
|
||||||
QueueData.Instance.ItemRemoved.RegisterEvent(NumQueueItemsChanged, ref unregisterEvents);
|
QueueData.Instance.ItemRemoved.RegisterEvent(NumQueueItemsChanged, ref unregisterEvents);
|
||||||
|
|
||||||
ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(LoadSettingsOnPrinterChanged, ref unregisterEvents);
|
ActiveSliceSettings.ActivePrinterChanged.RegisterEvent((s, e) => ApplicationController.Instance.ReloadAdvancedControlsPanel(), ref unregisterEvents);
|
||||||
PrinterConnectionAndCommunication.Instance.ActivePrintItemChanged.RegisterEvent(OnActivePrintItemChanged, ref unregisterEvents);
|
PrinterConnectionAndCommunication.Instance.ActivePrintItemChanged.RegisterEvent((s, e) => UiThread.RunOnIdle(ReloadPartPreview, null, 1), ref unregisterEvents);
|
||||||
ApplicationController.Instance.ReloadAdvancedControlsPanelTrigger.RegisterEvent(ReloadAdvancedControlsPanelTrigger, ref unregisterEvents);
|
ApplicationController.Instance.ReloadAdvancedControlsPanelTrigger.RegisterEvent((s, e) => UiThread.RunOnIdle(LoadAdvancedControls), ref unregisterEvents);
|
||||||
UpdateControlData.Instance.UpdateStatusChanged.RegisterEvent(SetUpdateNotification, ref unregisterEvents);
|
UpdateControlData.Instance.UpdateStatusChanged.RegisterEvent(SetUpdateNotification, ref unregisterEvents);
|
||||||
|
|
||||||
// Make sure we are on the right tab when we create this view
|
// Make sure we are on the right tab when we create this view
|
||||||
|
|
@ -225,28 +225,9 @@ namespace MatterHackers.MatterControl
|
||||||
}
|
}
|
||||||
private event EventHandler unregisterEvents;
|
private event EventHandler unregisterEvents;
|
||||||
|
|
||||||
public void LoadSettingsOnPrinterChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
ActiveSliceSettings.Instance.LoadAllSettings();
|
|
||||||
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnClosed(EventArgs e)
|
public override void OnClosed(EventArgs e)
|
||||||
{
|
{
|
||||||
if (unregisterEvents != null)
|
unregisterEvents?.Invoke(this, null);
|
||||||
{
|
|
||||||
unregisterEvents(this, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ReloadAdvancedControlsPanel()
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(LoadAdvancedControls);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ReloadAdvancedControlsPanelTrigger(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(ReloadAdvancedControlsPanel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetUpdateNotification(object sender, EventArgs widgetEvent)
|
public void SetUpdateNotification(object sender, EventArgs widgetEvent)
|
||||||
|
|
@ -294,11 +275,6 @@ namespace MatterHackers.MatterControl
|
||||||
QueueTabPage.Text = string.Format(queueString, QueueData.Instance.Count);
|
QueueTabPage.Text = string.Format(queueString, QueueData.Instance.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnActivePrintItemChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(ReloadPartPreview, null, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ReloadConfigurationWidget()
|
private void ReloadConfigurationWidget()
|
||||||
{
|
{
|
||||||
optionsPage.RemoveAllChildren();
|
optionsPage.RemoveAllChildren();
|
||||||
|
|
|
||||||
|
|
@ -36,13 +36,14 @@ using MatterHackers.MatterControl.SlicerConfiguration;
|
||||||
using MatterHackers.VectorMath;
|
using MatterHackers.VectorMath;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl
|
namespace MatterHackers.MatterControl
|
||||||
{
|
{
|
||||||
public abstract class ApplicationView : GuiWidget
|
public abstract class ApplicationView : GuiWidget
|
||||||
{
|
{
|
||||||
public TopContainerWidget TopContainer;
|
public FlowLayoutWidget TopContainer;
|
||||||
|
|
||||||
public abstract void AddElements();
|
public abstract void AddElements();
|
||||||
|
|
||||||
|
|
@ -57,14 +58,14 @@ namespace MatterHackers.MatterControl
|
||||||
private QueueDataView queueDataView;
|
private QueueDataView queueDataView;
|
||||||
private GuiWidget menuSeparator;
|
private GuiWidget menuSeparator;
|
||||||
private PrintProgressBar progressBar;
|
private PrintProgressBar progressBar;
|
||||||
|
private bool topIsHidden = false;
|
||||||
|
|
||||||
public CompactApplicationView()
|
public CompactApplicationView()
|
||||||
{
|
{
|
||||||
AddElements();
|
AddElements();
|
||||||
Initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool topIsHidden = false;
|
this.AnchorAll();
|
||||||
|
}
|
||||||
|
|
||||||
public override void HideTopContainer()
|
public override void HideTopContainer()
|
||||||
{
|
{
|
||||||
|
|
@ -98,7 +99,7 @@ namespace MatterHackers.MatterControl
|
||||||
FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||||
container.AnchorAll();
|
container.AnchorAll();
|
||||||
|
|
||||||
TopContainer = new TopContainerWidget();
|
TopContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||||
TopContainer.HAnchor = HAnchor.ParentLeftRight;
|
TopContainer.HAnchor = HAnchor.ParentLeftRight;
|
||||||
|
|
||||||
ApplicationMenuRow menuRow = new ApplicationMenuRow();
|
ApplicationMenuRow menuRow = new ApplicationMenuRow();
|
||||||
|
|
@ -114,7 +115,6 @@ namespace MatterHackers.MatterControl
|
||||||
|
|
||||||
queueDataView = new QueueDataView();
|
queueDataView = new QueueDataView();
|
||||||
TopContainer.AddChild(new ActionBarPlus(queueDataView));
|
TopContainer.AddChild(new ActionBarPlus(queueDataView));
|
||||||
TopContainer.SetOriginalHeight();
|
|
||||||
|
|
||||||
container.AddChild(TopContainer);
|
container.AddChild(TopContainer);
|
||||||
|
|
||||||
|
|
@ -124,47 +124,7 @@ namespace MatterHackers.MatterControl
|
||||||
container.AddChild(menuSeparator);
|
container.AddChild(menuSeparator);
|
||||||
compactTabView = new CompactTabView(queueDataView);
|
compactTabView = new CompactTabView(queueDataView);
|
||||||
|
|
||||||
BottomOverlay bottomOverlay = new BottomOverlay();
|
this.AddChild(compactTabView);
|
||||||
bottomOverlay.AddChild(compactTabView);
|
|
||||||
|
|
||||||
container.AddChild(bottomOverlay);
|
|
||||||
|
|
||||||
this.AddChild(container);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Initialize()
|
|
||||||
{
|
|
||||||
this.AnchorAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class TopContainerWidget : FlowLayoutWidget
|
|
||||||
{
|
|
||||||
private double originalHeight;
|
|
||||||
|
|
||||||
public TopContainerWidget()
|
|
||||||
: base(FlowDirection.TopToBottom)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetOriginalHeight()
|
|
||||||
{
|
|
||||||
originalHeight = this.Height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class BottomOverlay : GuiWidget
|
|
||||||
{
|
|
||||||
public BottomOverlay()
|
|
||||||
: base()
|
|
||||||
{
|
|
||||||
this.AnchorAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnMouseDown(MouseEventArgs mouseEvent)
|
|
||||||
{
|
|
||||||
base.OnMouseDown(mouseEvent);
|
|
||||||
//ApplicationController.Instance.MainView.HideTopContainer();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -188,36 +148,31 @@ namespace MatterHackers.MatterControl
|
||||||
|
|
||||||
public override void AddElements()
|
public override void AddElements()
|
||||||
{
|
{
|
||||||
Stopwatch timer = Stopwatch.StartNew();
|
|
||||||
timer.Start();
|
|
||||||
this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
||||||
|
|
||||||
FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
var container = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||||
|
|
||||||
container.AnchorAll();
|
container.AnchorAll();
|
||||||
|
|
||||||
ApplicationMenuRow menuRow = new ApplicationMenuRow();
|
var menuRow = new ApplicationMenuRow();
|
||||||
container.AddChild(menuRow);
|
container.AddChild(menuRow);
|
||||||
|
|
||||||
GuiWidget menuSeparator = new GuiWidget();
|
var menuSeparator = new GuiWidget()
|
||||||
menuSeparator.BackgroundColor = new RGBA_Bytes(200, 200, 200);
|
{
|
||||||
menuSeparator.Height = 2;
|
BackgroundColor = new RGBA_Bytes(200, 200, 200),
|
||||||
menuSeparator.HAnchor = HAnchor.ParentLeftRight;
|
Height = 2,
|
||||||
menuSeparator.Margin = new BorderDouble(3, 6, 3, 3);
|
HAnchor = HAnchor.ParentLeftRight,
|
||||||
|
Margin = new BorderDouble(3, 6, 3, 3)
|
||||||
|
};
|
||||||
container.AddChild(menuSeparator);
|
container.AddChild(menuSeparator);
|
||||||
Console.WriteLine("{0} ms 1".FormatWith(timer.ElapsedMilliseconds)); timer.Restart();
|
|
||||||
widescreenPanel = new WidescreenPanel();
|
widescreenPanel = new WidescreenPanel();
|
||||||
container.AddChild(widescreenPanel);
|
container.AddChild(widescreenPanel);
|
||||||
|
|
||||||
Console.WriteLine("{0} ms 2".FormatWith(timer.ElapsedMilliseconds)); timer.Restart();
|
|
||||||
|
|
||||||
Console.WriteLine("{0} ms 3".FormatWith(timer.ElapsedMilliseconds)); timer.Restart();
|
|
||||||
using (new PerformanceTimer("ReloadAll", "AddChild"))
|
using (new PerformanceTimer("ReloadAll", "AddChild"))
|
||||||
{
|
{
|
||||||
this.AddChild(container);
|
this.AddChild(container);
|
||||||
}
|
}
|
||||||
Console.WriteLine("{0} ms 4".FormatWith(timer.ElapsedMilliseconds)); timer.Restart();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Initialize()
|
private void Initialize()
|
||||||
|
|
@ -267,18 +222,12 @@ namespace MatterHackers.MatterControl
|
||||||
|
|
||||||
public void StartLogin()
|
public void StartLogin()
|
||||||
{
|
{
|
||||||
if (privateStartLogin != null)
|
privateStartLogin?.Invoke(null, null);
|
||||||
{
|
|
||||||
privateStartLogin(null, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartLogout()
|
public void StartLogout()
|
||||||
{
|
{
|
||||||
if (privateStartLogout != null)
|
privateStartLogout?.Invoke(null, null);
|
||||||
{
|
|
||||||
privateStartLogout(null, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetSessionUsername()
|
public string GetSessionUsername()
|
||||||
|
|
@ -301,13 +250,12 @@ namespace MatterHackers.MatterControl
|
||||||
{
|
{
|
||||||
// give the widget a chance to hear about the close before they are actually closed.
|
// give the widget a chance to hear about the close before they are actually closed.
|
||||||
PopOutManager.SaveIfClosed = false;
|
PopOutManager.SaveIfClosed = false;
|
||||||
WidescreenPanel.PreChangePanels.CallEvents(this, null);
|
WidescreenPanel.PreChangePanels.CallEvents(this, null);
|
||||||
MainView.CloseAllChildren();
|
MainView.CloseAllChildren();
|
||||||
using (new PerformanceTimer("ReloadAll", "AddElements"))
|
using (new PerformanceTimer("ReloadAll", "AddElements"))
|
||||||
{
|
{
|
||||||
MainView.AddElements();
|
MainView.AddElements();
|
||||||
}
|
}
|
||||||
DoneReloadingAll.CallEvents(null, null);
|
|
||||||
PopOutManager.SaveIfClosed = true;
|
PopOutManager.SaveIfClosed = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -315,10 +263,7 @@ namespace MatterHackers.MatterControl
|
||||||
|
|
||||||
public void OnApplicationClosed()
|
public void OnApplicationClosed()
|
||||||
{
|
{
|
||||||
if (ApplicationClosed != null)
|
ApplicationClosed?.Invoke(null, null);
|
||||||
{
|
|
||||||
ApplicationClosed(null, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ApplicationController Instance
|
public static ApplicationController Instance
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ namespace MatterHackers.MatterControl
|
||||||
this.Margin = new BorderDouble(0);
|
this.Margin = new BorderDouble(0);
|
||||||
this.Padding = new BorderDouble(0);
|
this.Padding = new BorderDouble(0);
|
||||||
this.VAnchor = Agg.UI.VAnchor.ParentCenter;
|
this.VAnchor = Agg.UI.VAnchor.ParentCenter;
|
||||||
this.MenuDropList.SelectionChanged += new EventHandler(MenuDropList_SelectionChanged);
|
this.MenuDropList.SelectionChanged += MenuDropList_SelectionChanged;
|
||||||
this.MenuDropList.OpenOffset = new Vector2(0, 0);
|
this.MenuDropList.OpenOffset = new Vector2(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -64,9 +64,9 @@ namespace MatterHackers.MatterControl
|
||||||
string menuSelection = ((DropDownMenu)sender).SelectedValue;
|
string menuSelection = ((DropDownMenu)sender).SelectedValue;
|
||||||
foreach (MenuItemAction item in menuItems)
|
foreach (MenuItemAction item in menuItems)
|
||||||
{
|
{
|
||||||
if (item.Title == menuSelection)
|
if (item.Title == menuSelection && item.Action != null)
|
||||||
{
|
{
|
||||||
item.Action?.Invoke();
|
UiThread.RunOnIdle(item.Action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ using System.Collections.Generic;
|
||||||
using MatterHackers.VectorMath;
|
using MatterHackers.VectorMath;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl
|
namespace MatterHackers.MatterControl
|
||||||
{
|
{
|
||||||
|
|
@ -18,127 +19,69 @@ namespace MatterHackers.MatterControl
|
||||||
|
|
||||||
public static MenuOptionFile CurrentMenuOptionFile = null;
|
public static MenuOptionFile CurrentMenuOptionFile = null;
|
||||||
|
|
||||||
public event EventHandler<StringEventArgs> AddLocalFolderToLibrary;
|
|
||||||
public EventHandler RedeemDesignCode;
|
public EventHandler RedeemDesignCode;
|
||||||
public EventHandler EnterShareCode;
|
public EventHandler EnterShareCode;
|
||||||
|
|
||||||
public MenuOptionFile()
|
public MenuOptionFile()
|
||||||
: base("File".Localize())
|
: base("File".Localize())
|
||||||
{
|
{
|
||||||
Name = "File Menu";
|
Name = "File Menu";
|
||||||
CurrentMenuOptionFile = this;
|
CurrentMenuOptionFile = this;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override protected IEnumerable<MenuItemAction> GetMenuItems()
|
protected override IEnumerable<MenuItemAction> GetMenuItems()
|
||||||
{
|
{
|
||||||
return new List<MenuItemAction>
|
return new List<MenuItemAction>
|
||||||
{
|
{
|
||||||
new MenuItemAction("Add Printer".Localize(), addPrinter_Click),
|
new MenuItemAction("Add Printer".Localize(), () => ConnectionWizard.Show()),
|
||||||
new MenuItemAction("Add File To Queue".Localize(), importFile_Click),
|
new MenuItemAction("Add File To Queue".Localize(), importFile_Click),
|
||||||
//new MenuItemAction("Add Folder To Library".Localize(), addFolderToLibrar_Click),
|
new MenuItemAction("Redeem Design Code".Localize(), () => RedeemDesignCode?.Invoke(this, null)),
|
||||||
new MenuItemAction("Redeem Design Code".Localize(), redeemDesignCode_Click),
|
new MenuItemAction("Enter Share Code".Localize(), () => EnterShareCode?.Invoke(this, null)),
|
||||||
new MenuItemAction("Enter Share Code".Localize(), enterShareCode_Click),
|
|
||||||
new MenuItemAction("------------------------", null),
|
new MenuItemAction("------------------------", null),
|
||||||
new MenuItemAction("Exit".Localize(), exit_Click),
|
new MenuItemAction("Exit".Localize(), () =>
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private void redeemDesignCode_Click()
|
|
||||||
{
|
|
||||||
if (RedeemDesignCode != null)
|
|
||||||
{
|
|
||||||
RedeemDesignCode(this, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void enterShareCode_Click()
|
|
||||||
{
|
|
||||||
if (EnterShareCode != null)
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(() => EnterShareCode(this, null));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addFolderToLibrar_Click()
|
|
||||||
{
|
|
||||||
if (AddLocalFolderToLibrary != null)
|
|
||||||
{
|
|
||||||
if (createFolderWindow == null)
|
|
||||||
{
|
{
|
||||||
UiThread.RunOnIdle(() =>
|
MatterControlApplication app = this.Parents<MatterControlApplication>().FirstOrDefault();
|
||||||
{
|
app.RestartOnClose = false;
|
||||||
createFolderWindow = new CreateFolderWindow((returnInfo) =>
|
app.Close();
|
||||||
{
|
})
|
||||||
AddLocalFolderToLibrary(this, new StringEventArgs(returnInfo.newName));
|
};
|
||||||
});
|
|
||||||
createFolderWindow.Closed += (sender2, e2) => { createFolderWindow = null; };
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
createFolderWindow.BringToFront();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addPrinter_Click()
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(ConnectionWindow.Show);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void importFile_Click()
|
private void importFile_Click()
|
||||||
{
|
{
|
||||||
UiThread.RunOnIdle(() =>
|
FileDialog.OpenFileDialog(
|
||||||
{
|
new OpenFileDialogParams(ApplicationSettings.OpenPrintableFileParams)
|
||||||
FileDialog.OpenFileDialog(
|
{
|
||||||
new OpenFileDialogParams(ApplicationSettings.OpenPrintableFileParams)
|
MultiSelect = true,
|
||||||
|
ActionButtonLabel = "Add to Queue",
|
||||||
|
Title = "MatterControl: Select A File"
|
||||||
|
},
|
||||||
|
(openParams) =>
|
||||||
|
{
|
||||||
|
if (openParams.FileNames != null)
|
||||||
{
|
{
|
||||||
MultiSelect = true,
|
foreach (string loadedFileName in openParams.FileNames)
|
||||||
ActionButtonLabel = "Add to Queue",
|
|
||||||
Title = "MatterControl: Select A File"
|
|
||||||
},
|
|
||||||
(openParams) =>
|
|
||||||
{
|
|
||||||
if (openParams.FileNames != null)
|
|
||||||
{
|
{
|
||||||
foreach (string loadedFileName in openParams.FileNames)
|
if (Path.GetExtension(loadedFileName).ToUpper() == ".ZIP")
|
||||||
{
|
{
|
||||||
if (Path.GetExtension(loadedFileName).ToUpper() == ".ZIP")
|
ProjectFileHandler project = new ProjectFileHandler(null);
|
||||||
{
|
List<PrintItem> partFiles = project.ImportFromProjectArchive(loadedFileName);
|
||||||
ProjectFileHandler project = new ProjectFileHandler(null);
|
if (partFiles != null)
|
||||||
List<PrintItem> partFiles = project.ImportFromProjectArchive(loadedFileName);
|
{
|
||||||
if (partFiles != null)
|
foreach (PrintItem part in partFiles)
|
||||||
{
|
{
|
||||||
foreach (PrintItem part in partFiles)
|
QueueData.Instance.AddItem(new PrintItemWrapper(new PrintItem(part.Name, part.FileLocation)));
|
||||||
{
|
}
|
||||||
QueueData.Instance.AddItem(new PrintItemWrapper(new PrintItem(part.Name, part.FileLocation)));
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
}
|
{
|
||||||
else
|
QueueData.Instance.AddItem(new PrintItemWrapper(new PrintItem(Path.GetFileNameWithoutExtension(loadedFileName), Path.GetFullPath(loadedFileName))));
|
||||||
{
|
|
||||||
QueueData.Instance.AddItem(new PrintItemWrapper(new PrintItem(Path.GetFileNameWithoutExtension(loadedFileName), Path.GetFullPath(loadedFileName))));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
private void exit_Click()
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(() =>
|
|
||||||
{
|
|
||||||
GuiWidget parent = this;
|
|
||||||
while (parent as MatterControlApplication == null)
|
|
||||||
{
|
|
||||||
parent = parent.Parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
MatterControlApplication app = parent as MatterControlApplication;
|
|
||||||
app.RestartOnClose = false;
|
|
||||||
app.Close();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -11,81 +11,30 @@ namespace MatterHackers.MatterControl
|
||||||
{
|
{
|
||||||
public class MenuOptionHelp : MenuBase
|
public class MenuOptionHelp : MenuBase
|
||||||
{
|
{
|
||||||
public MenuOptionHelp()
|
public MenuOptionHelp() : base("Help".Localize())
|
||||||
: base("Help".Localize())
|
|
||||||
{
|
{
|
||||||
Name = "Help Menu";
|
Name = "Help Menu";
|
||||||
}
|
}
|
||||||
|
|
||||||
override protected IEnumerable<MenuItemAction> GetMenuItems()
|
protected override IEnumerable<MenuItemAction> GetMenuItems()
|
||||||
{
|
{
|
||||||
return new List<MenuItemAction>
|
return new List<MenuItemAction>
|
||||||
{
|
{
|
||||||
new MenuItemAction("Getting Started".Localize(), gettingStarted_Click),
|
new MenuItemAction("Getting Started".Localize(), () => MatterControlApplication.Instance.LaunchBrowser("http://www.mattercontrol.com/articles/mattercontrol-getting-started")),
|
||||||
new MenuItemAction("View Help".Localize(), help_Click),
|
new MenuItemAction("View Help".Localize(), () => MatterControlApplication.Instance.LaunchBrowser("http://www.mattercontrol.com/articles")),
|
||||||
new MenuItemAction("Release Notes".Localize(), notes_Click),
|
new MenuItemAction("Release Notes".Localize(), () => MatterControlApplication.Instance.LaunchBrowser("http://wiki.mattercontrol.com/Release_Notes")),
|
||||||
new MenuItemAction("User Manual".Localize(), manual_Click),
|
new MenuItemAction("User Manual".Localize(), () => MatterControlApplication.Instance.LaunchBrowser("http://wiki.mattercontrol.com")),
|
||||||
new MenuItemAction("------------------------", null),
|
|
||||||
new MenuItemAction("Report a Bug".Localize(), bug_Click),
|
|
||||||
new MenuItemAction("Check For Update".Localize(), checkForUpdate_Click),
|
|
||||||
new MenuItemAction("------------------------", null),
|
new MenuItemAction("------------------------", null),
|
||||||
new MenuItemAction("About MatterControl".Localize(), about_Click),
|
new MenuItemAction("Report a Bug".Localize(), () => ContactFormWindow.Open()),
|
||||||
};
|
new MenuItemAction("Check For Update".Localize(), () =>
|
||||||
}
|
|
||||||
|
|
||||||
private void bug_Click()
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(() =>
|
|
||||||
{
|
|
||||||
ContactFormWindow.Open();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void help_Click()
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(() =>
|
|
||||||
{
|
|
||||||
MatterControlApplication.Instance.LaunchBrowser("http://www.mattercontrol.com/articles");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkForUpdate_Click()
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(() =>
|
|
||||||
{
|
|
||||||
ApplicationMenuRow.AlwaysShowUpdateStatus = true;
|
|
||||||
UpdateControlData.Instance.CheckForUpdateUserRequested();
|
|
||||||
CheckForUpdateWindow.Show();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void about_Click()
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(AboutWindow.Show);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void notes_Click()
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(() =>
|
|
||||||
{
|
{
|
||||||
MatterControlApplication.Instance.LaunchBrowser("http://wiki.mattercontrol.com/Release_Notes");
|
ApplicationMenuRow.AlwaysShowUpdateStatus = true;
|
||||||
});
|
UpdateControlData.Instance.CheckForUpdateUserRequested();
|
||||||
|
CheckForUpdateWindow.Show();
|
||||||
|
}),
|
||||||
|
new MenuItemAction("------------------------", null),
|
||||||
|
new MenuItemAction("About MatterControl".Localize(), () => AboutWindow.Show()),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private void gettingStarted_Click()
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(() =>
|
|
||||||
{
|
|
||||||
MatterControlApplication.Instance.LaunchBrowser("http://www.mattercontrol.com/articles/mattercontrol-getting-started");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void manual_Click()
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(() =>
|
|
||||||
{
|
|
||||||
MatterControlApplication.Instance.LaunchBrowser("http://wiki.mattercontrol.com");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -17,47 +17,18 @@ namespace MatterHackers.MatterControl
|
||||||
static public PopOutTextTabWidget sliceSettingsPopOut = null;
|
static public PopOutTextTabWidget sliceSettingsPopOut = null;
|
||||||
static public PopOutTextTabWidget controlsPopOut = null;
|
static public PopOutTextTabWidget controlsPopOut = null;
|
||||||
|
|
||||||
public MenuOptionSettings()
|
public MenuOptionSettings() : base("View".Localize())
|
||||||
: base("View".Localize())
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override protected IEnumerable<MenuItemAction> GetMenuItems()
|
protected override IEnumerable<MenuItemAction> GetMenuItems()
|
||||||
{
|
{
|
||||||
return new List<MenuItemAction>
|
return new List<MenuItemAction>
|
||||||
{
|
|
||||||
new MenuItemAction("Settings".Localize(), openPrintingPanel_Click),
|
|
||||||
new MenuItemAction("Controls".Localize(), openControlsPanel_Click),
|
|
||||||
new MenuItemAction("Terminal".Localize(), openTermanialPanel_Click),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openPrintingPanel_Click()
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(() =>
|
|
||||||
{
|
{
|
||||||
if (sliceSettingsPopOut != null)
|
new MenuItemAction("Settings".Localize(), () => sliceSettingsPopOut?.ShowInWindow()),
|
||||||
{
|
new MenuItemAction("Controls".Localize(), () => controlsPopOut?.ShowInWindow()),
|
||||||
sliceSettingsPopOut.ShowInWindow();
|
new MenuItemAction("Terminal".Localize(), () => UiThread.RunOnIdle(TerminalWindow.Show)),
|
||||||
}
|
};
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openControlsPanel_Click()
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(() =>
|
|
||||||
{
|
|
||||||
if (controlsPopOut != null)
|
|
||||||
{
|
|
||||||
controlsPopOut.ShowInWindow();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openTermanialPanel_Click()
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(TerminalWindow.Show);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,12 +1,4 @@
|
||||||
using MatterHackers.Agg;
|
/*
|
||||||
using MatterHackers.Agg.UI;
|
|
||||||
using MatterHackers.MatterControl.PartPreviewWindow;
|
|
||||||
using MatterHackers.MatterControl.PrinterCommunication;
|
|
||||||
using MatterHackers.MatterControl.PrintQueue;
|
|
||||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
|
||||||
using MatterHackers.VectorMath;
|
|
||||||
|
|
||||||
/*
|
|
||||||
Copyright (c) 2014, Kevin Pope
|
Copyright (c) 2014, Kevin Pope
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
@ -37,6 +29,14 @@ either expressed or implied, of the FreeBSD Project.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
using MatterHackers.Agg;
|
||||||
|
using MatterHackers.Agg.UI;
|
||||||
|
using MatterHackers.MatterControl.PartPreviewWindow;
|
||||||
|
using MatterHackers.MatterControl.PrinterCommunication;
|
||||||
|
using MatterHackers.MatterControl.PrintQueue;
|
||||||
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||||
|
using MatterHackers.VectorMath;
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl
|
namespace MatterHackers.MatterControl
|
||||||
{
|
{
|
||||||
public class WidescreenPanel : FlowLayoutWidget
|
public class WidescreenPanel : FlowLayoutWidget
|
||||||
|
|
@ -68,15 +68,12 @@ namespace MatterHackers.MatterControl
|
||||||
BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
||||||
Padding = new BorderDouble(4);
|
Padding = new BorderDouble(4);
|
||||||
|
|
||||||
ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(LoadSettingsOnPrinterChanged, ref unregisterEvents);
|
// TODO: This hooks seems to invalidate most of the other ActivePrinterChanged subscribers as this destroys and recreates everything
|
||||||
PrinterConnectionAndCommunication.Instance.ActivePrintItemChanged.RegisterEvent(onActivePrintItemChanged, ref unregisterEvents);
|
ActiveSliceSettings.ActivePrinterChanged.RegisterEvent((s, e) => ApplicationController.Instance.ReloadAll(null, null), ref unregisterEvents);
|
||||||
ApplicationController.Instance.ReloadAdvancedControlsPanelTrigger.RegisterEvent(ReloadAdvancedControlsPanelTrigger, ref unregisterEvents);
|
|
||||||
this.BoundsChanged += new EventHandler(onBoundsChanges);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ReloadAdvancedControlsPanelTrigger(object sender, EventArgs e)
|
PrinterConnectionAndCommunication.Instance.ActivePrintItemChanged.RegisterEvent(onActivePrintItemChanged, ref unregisterEvents);
|
||||||
{
|
ApplicationController.Instance.ReloadAdvancedControlsPanelTrigger.RegisterEvent((s, e) => UiThread.RunOnIdle(ReloadAdvancedControlsPanel), ref unregisterEvents);
|
||||||
UiThread.RunOnIdle(ReloadAdvancedControlsPanel);
|
this.BoundsChanged += onBoundsChanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnParentChanged(EventArgs e)
|
public override void OnParentChanged(EventArgs e)
|
||||||
|
|
@ -96,10 +93,7 @@ namespace MatterHackers.MatterControl
|
||||||
|
|
||||||
public override void OnClosed(EventArgs e)
|
public override void OnClosed(EventArgs e)
|
||||||
{
|
{
|
||||||
if (unregisterEvents != null)
|
unregisterEvents?.Invoke(this, null);
|
||||||
{
|
|
||||||
unregisterEvents(this, null);
|
|
||||||
}
|
|
||||||
base.OnClosed(e);
|
base.OnClosed(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -207,11 +201,6 @@ namespace MatterHackers.MatterControl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnDraw(Graphics2D graphics2D)
|
|
||||||
{
|
|
||||||
base.OnDraw(graphics2D);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RemovePanelsAndCreateEmpties()
|
private void RemovePanelsAndCreateEmpties()
|
||||||
{
|
{
|
||||||
CloseAllChildren();
|
CloseAllChildren();
|
||||||
|
|
@ -237,12 +226,6 @@ namespace MatterHackers.MatterControl
|
||||||
{
|
{
|
||||||
PreChangePanels.CallEvents(this, null);
|
PreChangePanels.CallEvents(this, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadSettingsOnPrinterChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
ActiveSliceSettings.Instance.LoadAllSettings();
|
|
||||||
ApplicationController.Instance.ReloadAll(null, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UpdateNotificationMark : GuiWidget
|
public class UpdateNotificationMark : GuiWidget
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage
|
||||||
mainContainer.AddChild(GetLanguageControl());
|
mainContainer.AddChild(GetLanguageControl());
|
||||||
mainContainer.AddChild(new HorizontalLine(separatorLineColor));
|
mainContainer.AddChild(new HorizontalLine(separatorLineColor));
|
||||||
GuiWidget sliceEngineControl = GetSliceEngineControl();
|
GuiWidget sliceEngineControl = GetSliceEngineControl();
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter != null)
|
if (ActiveSliceSettings.Instance != null)
|
||||||
{
|
{
|
||||||
mainContainer.AddChild(sliceEngineControl);
|
mainContainer.AddChild(sliceEngineControl);
|
||||||
mainContainer.AddChild(new HorizontalLine(separatorLineColor));
|
mainContainer.AddChild(new HorizontalLine(separatorLineColor));
|
||||||
|
|
@ -399,15 +399,14 @@ namespace MatterHackers.MatterControl.ConfigurationPage
|
||||||
FlowLayoutWidget optionsContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
FlowLayoutWidget optionsContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||||
optionsContainer.Margin = new BorderDouble(bottom: 6);
|
optionsContainer.Margin = new BorderDouble(bottom: 6);
|
||||||
|
|
||||||
if (ActiveSliceSettings.Instance.ExtruderCount > 1)
|
var settings = ActiveSliceSettings.Instance;
|
||||||
|
|
||||||
|
// Reset active slicer to MatterSlice when multi-extruder is detected and MatterSlice is not already set
|
||||||
|
if (settings?.ExtruderCount > 1 && settings.ActiveSliceEngineType != SlicingEngineTypes.MatterSlice)
|
||||||
{
|
{
|
||||||
// Reset active slicer to MatterSlice when multi-extruder is detected and MatterSlice is not already set
|
settings.ActiveSliceEngineType = SlicingEngineTypes.MatterSlice;
|
||||||
if (ActivePrinterProfile.Instance.ActiveSliceEngineType != ActivePrinterProfile.SlicingEngineTypes.MatterSlice)
|
ApplicationController.Instance.ReloadAll(null, null);
|
||||||
{
|
}
|
||||||
ActivePrinterProfile.Instance.ActiveSliceEngineType = ActivePrinterProfile.SlicingEngineTypes.MatterSlice;
|
|
||||||
ApplicationController.Instance.ReloadAll(null, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
optionsContainer.AddChild(new SliceEngineSelector("Slice Engine".Localize()));
|
optionsContainer.AddChild(new SliceEngineSelector("Slice Engine".Localize()));
|
||||||
optionsContainer.Width = 200;
|
optionsContainer.Width = 200;
|
||||||
|
|
|
||||||
|
|
@ -92,12 +92,12 @@ namespace MatterHackers.MatterControl.ConfigurationPage
|
||||||
ImageWidget levelingIcon = new ImageWidget(levelingImage);
|
ImageWidget levelingIcon = new ImageWidget(levelingImage);
|
||||||
levelingIcon.Margin = new BorderDouble(right: 6);
|
levelingIcon.Margin = new BorderDouble(right: 6);
|
||||||
|
|
||||||
CheckBox printLevelingSwitch = ImageButtonFactory.CreateToggleSwitch(ActivePrinterProfile.Instance.DoPrintLeveling);
|
CheckBox printLevelingSwitch = ImageButtonFactory.CreateToggleSwitch(ActiveSliceSettings.Instance.DoPrintLeveling);
|
||||||
printLevelingSwitch.VAnchor = VAnchor.ParentCenter;
|
printLevelingSwitch.VAnchor = VAnchor.ParentCenter;
|
||||||
printLevelingSwitch.Margin = new BorderDouble(left: 16);
|
printLevelingSwitch.Margin = new BorderDouble(left: 16);
|
||||||
printLevelingSwitch.CheckedStateChanged += (sender, e) =>
|
printLevelingSwitch.CheckedStateChanged += (sender, e) =>
|
||||||
{
|
{
|
||||||
ActivePrinterProfile.Instance.DoPrintLeveling = printLevelingSwitch.Checked;
|
ActiveSliceSettings.Instance.DoPrintLeveling = printLevelingSwitch.Checked;
|
||||||
};
|
};
|
||||||
|
|
||||||
printLevelingStatusLabel = new TextWidget("");
|
printLevelingStatusLabel = new TextWidget("");
|
||||||
|
|
@ -105,10 +105,10 @@ namespace MatterHackers.MatterControl.ConfigurationPage
|
||||||
printLevelingStatusLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
printLevelingStatusLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||||
printLevelingStatusLabel.VAnchor = VAnchor.ParentCenter;
|
printLevelingStatusLabel.VAnchor = VAnchor.ParentCenter;
|
||||||
|
|
||||||
ActivePrinterProfile.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) =>
|
ActiveSliceSettings.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) =>
|
||||||
{
|
{
|
||||||
SetPrintLevelButtonVisiblity();
|
SetPrintLevelButtonVisiblity();
|
||||||
printLevelingSwitch.Checked = ActivePrinterProfile.Instance.DoPrintLeveling;
|
printLevelingSwitch.Checked = ActiveSliceSettings.Instance.DoPrintLeveling;
|
||||||
}, ref unregisterEvents);
|
}, ref unregisterEvents);
|
||||||
|
|
||||||
buttonRow.AddChild(levelingIcon);
|
buttonRow.AddChild(levelingIcon);
|
||||||
|
|
@ -284,7 +284,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage
|
||||||
|
|
||||||
private void SetPrintLevelButtonVisiblity()
|
private void SetPrintLevelButtonVisiblity()
|
||||||
{
|
{
|
||||||
if (ActivePrinterProfile.Instance.DoPrintLeveling)
|
if (ActiveSliceSettings.Instance.DoPrintLeveling)
|
||||||
{
|
{
|
||||||
printLevelingStatusLabel.Text = "Software Print Leveling (enabled)".Localize();
|
printLevelingStatusLabel.Text = "Software Print Leveling (enabled)".Localize();
|
||||||
}
|
}
|
||||||
|
|
@ -302,7 +302,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage
|
||||||
currentStatus == PrinterConnectionAndCommunication.CommunicationStates.Connected ||
|
currentStatus == PrinterConnectionAndCommunication.CommunicationStates.Connected ||
|
||||||
currentStatus == PrinterConnectionAndCommunication.CommunicationStates.FinishedPrint;
|
currentStatus == PrinterConnectionAndCommunication.CommunicationStates.FinishedPrint;
|
||||||
|
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter == null || !connected)
|
if (ActiveSliceSettings.Instance == null || !connected)
|
||||||
{
|
{
|
||||||
printLevelingContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
printLevelingContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ either expressed or implied, of the FreeBSD Project.
|
||||||
using MatterHackers.Agg;
|
using MatterHackers.Agg;
|
||||||
using MatterHackers.Agg.Font;
|
using MatterHackers.Agg.Font;
|
||||||
using MatterHackers.Agg.UI;
|
using MatterHackers.Agg.UI;
|
||||||
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||||
using MatterHackers.VectorMath;
|
using MatterHackers.VectorMath;
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl
|
namespace MatterHackers.MatterControl
|
||||||
|
|
@ -62,7 +63,8 @@ namespace MatterHackers.MatterControl
|
||||||
public static Vector3 ManualControlsFeedRate()
|
public static Vector3 ManualControlsFeedRate()
|
||||||
{
|
{
|
||||||
Vector3 feedRate = new Vector3(3000, 3000, 315);
|
Vector3 feedRate = new Vector3(3000, 3000, 315);
|
||||||
string savedSettings = ActivePrinterProfile.Instance.ActivePrinter.ManualMovementSpeeds;
|
|
||||||
|
string savedSettings = ActiveSliceSettings.Instance.ManualMovementSpeeds;
|
||||||
if (savedSettings != null && savedSettings != "")
|
if (savedSettings != null && savedSettings != "")
|
||||||
{
|
{
|
||||||
feedRate.x = double.Parse(savedSettings.Split(',')[1]);
|
feedRate.x = double.Parse(savedSettings.Split(',')[1]);
|
||||||
|
|
|
||||||
|
|
@ -51,15 +51,14 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
|
|
||||||
public static string ApplyLeveling(string lineBeingSent, Vector3 currentDestination, PrinterMachineInstruction.MovementTypes movementMode)
|
public static string ApplyLeveling(string lineBeingSent, Vector3 currentDestination, PrinterMachineInstruction.MovementTypes movementMode)
|
||||||
{
|
{
|
||||||
Printer activePrinter = PrinterConnectionAndCommunication.Instance.ActivePrinter;
|
|
||||||
if (activePrinter != null
|
var settings = ActiveSliceSettings.Instance;
|
||||||
&& activePrinter.DoPrintLeveling
|
if (settings?.DoPrintLeveling == true
|
||||||
&& (lineBeingSent.StartsWith("G0 ") || lineBeingSent.StartsWith("G1 "))
|
&& (lineBeingSent.StartsWith("G0 ") || lineBeingSent.StartsWith("G1 "))
|
||||||
&& lineBeingSent.Length > 2
|
&& lineBeingSent.Length > 2
|
||||||
&& lineBeingSent[2] == ' ')
|
&& lineBeingSent[2] == ' ')
|
||||||
{
|
{
|
||||||
PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(activePrinter);
|
return GetLevelingFunctions(numberOfRadialSamples, settings.PrintLevelingData, ActiveSliceSettings.Instance.BedCenter)
|
||||||
return GetLevelingFunctions(numberOfRadialSamples, levelingData, ActiveSliceSettings.Instance.BedCenter)
|
|
||||||
.DoApplyLeveling(lineBeingSent, currentDestination, movementMode);
|
.DoApplyLeveling(lineBeingSent, currentDestination, movementMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,8 +67,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
|
|
||||||
public override Vector2 GetPrintLevelPositionToSample(int index, double radius)
|
public override Vector2 GetPrintLevelPositionToSample(int index, double radius)
|
||||||
{
|
{
|
||||||
Printer activePrinter = PrinterConnectionAndCommunication.Instance.ActivePrinter;
|
PrintLevelingData levelingData = ActiveSliceSettings.Instance.PrintLevelingData;
|
||||||
PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(activePrinter);
|
|
||||||
return GetLevelingFunctions(numberOfRadialSamples, levelingData, ActiveSliceSettings.Instance.BedCenter)
|
return GetLevelingFunctions(numberOfRadialSamples, levelingData, ActiveSliceSettings.Instance.BedCenter)
|
||||||
.GetPrintLevelPositionToSample(index, radius);
|
.GetPrintLevelPositionToSample(index, radius);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ using MatterHackers.Agg.UI;
|
||||||
using MatterHackers.GCodeVisualizer;
|
using MatterHackers.GCodeVisualizer;
|
||||||
using MatterHackers.Localizations;
|
using MatterHackers.Localizations;
|
||||||
using MatterHackers.MatterControl.PrinterCommunication;
|
using MatterHackers.MatterControl.PrinterCommunication;
|
||||||
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||||
using MatterHackers.VectorMath;
|
using MatterHackers.VectorMath;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
@ -115,8 +116,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
|
|
||||||
public static string ApplyLeveling(string lineBeingSent, Vector3 currentDestination, PrinterMachineInstruction.MovementTypes movementMode)
|
public static string ApplyLeveling(string lineBeingSent, Vector3 currentDestination, PrinterMachineInstruction.MovementTypes movementMode)
|
||||||
{
|
{
|
||||||
if (PrinterConnectionAndCommunication.Instance.ActivePrinter != null
|
var settings = ActiveSliceSettings.Instance;
|
||||||
&& PrinterConnectionAndCommunication.Instance.ActivePrinter.DoPrintLeveling
|
if (settings?.DoPrintLeveling == true
|
||||||
&& (lineBeingSent.StartsWith("G0 ") || lineBeingSent.StartsWith("G1 ")))
|
&& (lineBeingSent.StartsWith("G0 ") || lineBeingSent.StartsWith("G1 ")))
|
||||||
{
|
{
|
||||||
lineBeingSent = PrintLevelingPlane.Instance.ApplyLeveling(currentDestination, movementMode, lineBeingSent);
|
lineBeingSent = PrintLevelingPlane.Instance.ApplyLeveling(currentDestination, movementMode, lineBeingSent);
|
||||||
|
|
@ -153,7 +154,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
}
|
}
|
||||||
if (PrinterConnectionAndCommunication.Instance.CommunicationState == PrinterConnectionAndCommunication.CommunicationStates.Printing)
|
if (PrinterConnectionAndCommunication.Instance.CommunicationState == PrinterConnectionAndCommunication.CommunicationStates.Printing)
|
||||||
{
|
{
|
||||||
ActivePrinterProfile.Instance.DoPrintLeveling = false;
|
ActiveSliceSettings.Instance.DoPrintLeveling = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
probeIndex = 0;
|
probeIndex = 0;
|
||||||
|
|
@ -248,14 +249,15 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
|
|
||||||
private static void SetEquations()
|
private static void SetEquations()
|
||||||
{
|
{
|
||||||
PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(ActivePrinterProfile.Instance.ActivePrinter);
|
PrintLevelingData levelingData = ActiveSliceSettings.Instance.PrintLevelingData;
|
||||||
|
|
||||||
// position 0 does not change as it is the distance from the switch trigger to the extruder tip.
|
// position 0 does not change as it is the distance from the switch trigger to the extruder tip.
|
||||||
//levelingData.sampledPosition0 = levelingData.sampledPosition0;
|
//levelingData.sampledPosition0 = levelingData.sampledPosition0;
|
||||||
levelingData.SampledPosition1 = levelingData.SampledPosition0 + probeRead1;
|
levelingData.SampledPosition1 = levelingData.SampledPosition0 + probeRead1;
|
||||||
levelingData.SampledPosition2 = levelingData.SampledPosition0 + probeRead2;
|
levelingData.SampledPosition2 = levelingData.SampledPosition0 + probeRead2;
|
||||||
|
|
||||||
ActivePrinterProfile.Instance.DoPrintLeveling = true;
|
ActiveSliceSettings.Instance.PrintLevelingData = levelingData;
|
||||||
|
ActiveSliceSettings.Instance.DoPrintLeveling = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -101,8 +101,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
|
|
||||||
public static string ApplyLeveling(string lineBeingSent, Vector3 currentDestination, PrinterMachineInstruction.MovementTypes movementMode)
|
public static string ApplyLeveling(string lineBeingSent, Vector3 currentDestination, PrinterMachineInstruction.MovementTypes movementMode)
|
||||||
{
|
{
|
||||||
if (PrinterConnectionAndCommunication.Instance.ActivePrinter != null
|
var settings = ActiveSliceSettings.Instance;
|
||||||
&& PrinterConnectionAndCommunication.Instance.ActivePrinter.DoPrintLeveling
|
if (settings?.DoPrintLeveling == true
|
||||||
&& (lineBeingSent.StartsWith("G0 ") || lineBeingSent.StartsWith("G1 ")))
|
&& (lineBeingSent.StartsWith("G0 ") || lineBeingSent.StartsWith("G1 ")))
|
||||||
{
|
{
|
||||||
lineBeingSent = PrintLevelingPlane.Instance.ApplyLeveling(currentDestination, movementMode, lineBeingSent);
|
lineBeingSent = PrintLevelingPlane.Instance.ApplyLeveling(currentDestination, movementMode, lineBeingSent);
|
||||||
|
|
|
||||||
|
|
@ -260,14 +260,13 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
|
|
||||||
public static string ApplyLeveling(string lineBeingSent, Vector3 currentDestination, PrinterMachineInstruction.MovementTypes movementMode)
|
public static string ApplyLeveling(string lineBeingSent, Vector3 currentDestination, PrinterMachineInstruction.MovementTypes movementMode)
|
||||||
{
|
{
|
||||||
Printer activePrinter = PrinterConnectionAndCommunication.Instance.ActivePrinter;
|
var settings = ActiveSliceSettings.Instance;
|
||||||
if (activePrinter != null
|
if (settings?.DoPrintLeveling == true
|
||||||
&& activePrinter.DoPrintLeveling
|
|
||||||
&& (lineBeingSent.StartsWith("G0 ") || lineBeingSent.StartsWith("G1 "))
|
&& (lineBeingSent.StartsWith("G0 ") || lineBeingSent.StartsWith("G1 "))
|
||||||
&& lineBeingSent.Length > 2
|
&& lineBeingSent.Length > 2
|
||||||
&& lineBeingSent[2] == ' ')
|
&& lineBeingSent[2] == ' ')
|
||||||
{
|
{
|
||||||
PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(activePrinter);
|
PrintLevelingData levelingData = ActiveSliceSettings.Instance.PrintLevelingData;
|
||||||
return GetLevelingFunctions(numberOfRadialSamples, levelingData, ActiveSliceSettings.Instance.BedCenter)
|
return GetLevelingFunctions(numberOfRadialSamples, levelingData, ActiveSliceSettings.Instance.BedCenter)
|
||||||
.DoApplyLeveling(lineBeingSent, currentDestination, movementMode);
|
.DoApplyLeveling(lineBeingSent, currentDestination, movementMode);
|
||||||
}
|
}
|
||||||
|
|
@ -277,8 +276,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
|
|
||||||
public override Vector2 GetPrintLevelPositionToSample(int index, double radius)
|
public override Vector2 GetPrintLevelPositionToSample(int index, double radius)
|
||||||
{
|
{
|
||||||
Printer activePrinter = PrinterConnectionAndCommunication.Instance.ActivePrinter;
|
PrintLevelingData levelingData = ActiveSliceSettings.Instance.PrintLevelingData;
|
||||||
PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(activePrinter);
|
|
||||||
return GetLevelingFunctions(numberOfRadialSamples, levelingData, ActiveSliceSettings.Instance.BedCenter)
|
return GetLevelingFunctions(numberOfRadialSamples, levelingData, ActiveSliceSettings.Instance.BedCenter)
|
||||||
.GetPrintLevelPositionToSample(index, radius);
|
.GetPrintLevelPositionToSample(index, radius);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,19 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
|
|
||||||
private static SystemWindow printLevelWizardWindow;
|
private static SystemWindow printLevelWizardWindow;
|
||||||
|
|
||||||
|
public static void ShowPrintLevelWizard()
|
||||||
|
{
|
||||||
|
LevelWizardBase.RuningState runningState = LevelWizardBase.RuningState.UserRequestedCalibration;
|
||||||
|
|
||||||
|
if (ActiveSliceSettings.Instance.LevelingRequiredToPrint)
|
||||||
|
{
|
||||||
|
// run in the first run state
|
||||||
|
runningState = LevelWizardBase.RuningState.InitialStartupCalibration;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowPrintLevelWizard(runningState);
|
||||||
|
}
|
||||||
|
|
||||||
public static void ShowPrintLevelWizard(LevelWizardBase.RuningState runningState)
|
public static void ShowPrintLevelWizard(LevelWizardBase.RuningState runningState)
|
||||||
{
|
{
|
||||||
if (printLevelWizardWindow == null)
|
if (printLevelWizardWindow == null)
|
||||||
|
|
@ -140,7 +153,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
|
|
||||||
private static LevelWizardBase CreateAndShowWizard(LevelWizardBase.RuningState runningState)
|
private static LevelWizardBase CreateAndShowWizard(LevelWizardBase.RuningState runningState)
|
||||||
{
|
{
|
||||||
PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(ActivePrinterProfile.Instance.ActivePrinter);
|
PrintLevelingData levelingData = ActiveSliceSettings.Instance.PrintLevelingData;
|
||||||
|
|
||||||
LevelWizardBase printLevelWizardWindow;
|
LevelWizardBase printLevelWizardWindow;
|
||||||
switch (levelingData.CurrentPrinterLevelingSystem)
|
switch (levelingData.CurrentPrinterLevelingSystem)
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
|
|
||||||
public override void PageIsBecomingActive()
|
public override void PageIsBecomingActive()
|
||||||
{
|
{
|
||||||
ActivePrinterProfile.Instance.DoPrintLeveling = false;
|
ActiveSliceSettings.Instance.DoPrintLeveling = false;
|
||||||
base.PageIsBecomingActive();
|
base.PageIsBecomingActive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -63,13 +63,18 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
|
|
||||||
public override void PageIsBecomingActive()
|
public override void PageIsBecomingActive()
|
||||||
{
|
{
|
||||||
PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(ActivePrinterProfile.Instance.ActivePrinter);
|
|
||||||
Vector3 paperWidth = new Vector3(0, 0, ActiveSliceSettings.Instance.ProbePaperWidth);
|
Vector3 paperWidth = new Vector3(0, 0, ActiveSliceSettings.Instance.ProbePaperWidth);
|
||||||
|
|
||||||
|
PrintLevelingData levelingData = ActiveSliceSettings.Instance.PrintLevelingData;
|
||||||
levelingData.SampledPosition0 = probePositions[0].position - paperWidth;
|
levelingData.SampledPosition0 = probePositions[0].position - paperWidth;
|
||||||
levelingData.SampledPosition1 = probePositions[1].position - paperWidth;
|
levelingData.SampledPosition1 = probePositions[1].position - paperWidth;
|
||||||
levelingData.SampledPosition2 = probePositions[2].position - paperWidth;
|
levelingData.SampledPosition2 = probePositions[2].position - paperWidth;
|
||||||
|
|
||||||
ActivePrinterProfile.Instance.DoPrintLeveling = true;
|
// Invoke setter forcing persistence of leveling data
|
||||||
|
ActiveSliceSettings.Instance.PrintLevelingData = levelingData;
|
||||||
|
|
||||||
|
ActiveSliceSettings.Instance.DoPrintLeveling = true;
|
||||||
|
|
||||||
base.PageIsBecomingActive();
|
base.PageIsBecomingActive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -86,7 +91,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
|
|
||||||
public override void PageIsBecomingActive()
|
public override void PageIsBecomingActive()
|
||||||
{
|
{
|
||||||
PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(ActivePrinterProfile.Instance.ActivePrinter);
|
PrintLevelingData levelingData = ActiveSliceSettings.Instance.PrintLevelingData;
|
||||||
levelingData.SampledPositions.Clear();
|
levelingData.SampledPositions.Clear();
|
||||||
Vector3 paperWidth = new Vector3(0, 0, ActiveSliceSettings.Instance.ProbePaperWidth);
|
Vector3 paperWidth = new Vector3(0, 0, ActiveSliceSettings.Instance.ProbePaperWidth);
|
||||||
for (int i = 0; i < probePositions.Length; i++)
|
for (int i = 0; i < probePositions.Length; i++)
|
||||||
|
|
@ -94,10 +99,10 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
levelingData.SampledPositions.Add(probePositions[i].position - paperWidth);
|
levelingData.SampledPositions.Add(probePositions[i].position - paperWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
levelingData.Commit();
|
// Invoke setter forcing persistence of leveling data
|
||||||
|
ActiveSliceSettings.Instance.PrintLevelingData = levelingData;
|
||||||
|
|
||||||
|
ActiveSliceSettings.Instance.DoPrintLeveling = true;
|
||||||
ActivePrinterProfile.Instance.DoPrintLeveling = true;
|
|
||||||
base.PageIsBecomingActive();
|
base.PageIsBecomingActive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -120,10 +125,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
|
|
||||||
public override void OnClosed(EventArgs e)
|
public override void OnClosed(EventArgs e)
|
||||||
{
|
{
|
||||||
if (unregisterEvents != null)
|
unregisterEvents?.Invoke(this, null);
|
||||||
{
|
|
||||||
unregisterEvents(this, null);
|
|
||||||
}
|
|
||||||
base.OnClosed(e);
|
base.OnClosed(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -178,7 +181,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
// This data is currently the offset from the probe to the extruder tip. We need to translate them
|
// This data is currently the offset from the probe to the extruder tip. We need to translate them
|
||||||
// into bed offsets and store them.
|
// into bed offsets and store them.
|
||||||
|
|
||||||
PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(ActivePrinterProfile.Instance.ActivePrinter);
|
|
||||||
// The first point is the user assisted offset to the bed
|
// The first point is the user assisted offset to the bed
|
||||||
Vector3 userBedSample0 = probePositions[0].position;
|
Vector3 userBedSample0 = probePositions[0].position;
|
||||||
// The first point sample offset at the limit switch
|
// The first point sample offset at the limit switch
|
||||||
|
|
@ -193,6 +195,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
|
|
||||||
Vector3 paperWidth = new Vector3(0, 0, ActiveSliceSettings.Instance.ProbePaperWidth);
|
Vector3 paperWidth = new Vector3(0, 0, ActiveSliceSettings.Instance.ProbePaperWidth);
|
||||||
|
|
||||||
|
PrintLevelingData levelingData = ActiveSliceSettings.Instance.PrintLevelingData;
|
||||||
levelingData.SampledPosition0 = userBedSample0 - paperWidth;
|
levelingData.SampledPosition0 = userBedSample0 - paperWidth;
|
||||||
levelingData.SampledPosition1 = userBedSample1 - paperWidth;
|
levelingData.SampledPosition1 = userBedSample1 - paperWidth;
|
||||||
levelingData.SampledPosition2 = probeOffset2 - probeOffset0 + userBedSample0 - paperWidth;
|
levelingData.SampledPosition2 = probeOffset2 - probeOffset0 + userBedSample0 - paperWidth;
|
||||||
|
|
@ -200,7 +203,10 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
levelingData.ProbeOffset0 = probeOffset0 - paperWidth;
|
levelingData.ProbeOffset0 = probeOffset0 - paperWidth;
|
||||||
levelingData.ProbeOffset1 = probeOffset1 - paperWidth;
|
levelingData.ProbeOffset1 = probeOffset1 - paperWidth;
|
||||||
|
|
||||||
ActivePrinterProfile.Instance.DoPrintLeveling = true;
|
// Invoke setter forcing persistence of leveling data
|
||||||
|
ActiveSliceSettings.Instance.PrintLevelingData = levelingData;
|
||||||
|
|
||||||
|
ActiveSliceSettings.Instance.DoPrintLeveling = true;
|
||||||
base.PageIsBecomingActive();
|
base.PageIsBecomingActive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -270,7 +276,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
public override void PageIsBecomingActive()
|
public override void PageIsBecomingActive()
|
||||||
{
|
{
|
||||||
// always make sure we don't have print leveling turned on
|
// always make sure we don't have print leveling turned on
|
||||||
ActivePrinterProfile.Instance.DoPrintLeveling = false;
|
ActiveSliceSettings.Instance.DoPrintLeveling = false;
|
||||||
|
|
||||||
base.PageIsBecomingActive();
|
base.PageIsBecomingActive();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
public class PrintLevelingData
|
public class PrintLevelingData
|
||||||
{
|
{
|
||||||
public List<Vector3> SampledPositions = new List<Vector3>();
|
public List<Vector3> SampledPositions = new List<Vector3>();
|
||||||
private static bool activelyLoading = false;
|
|
||||||
|
|
||||||
private static Printer activePrinter = null;
|
|
||||||
|
|
||||||
private static PrintLevelingData instance = null;
|
|
||||||
|
|
||||||
private Vector3 probeOffset0Private;
|
private Vector3 probeOffset0Private;
|
||||||
|
|
||||||
|
|
@ -60,7 +55,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
if (probeOffset0Private != value)
|
if (probeOffset0Private != value)
|
||||||
{
|
{
|
||||||
probeOffset0Private = value;
|
probeOffset0Private = value;
|
||||||
Commit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -73,7 +67,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
if (probeOffset1Private != value)
|
if (probeOffset1Private != value)
|
||||||
{
|
{
|
||||||
probeOffset1Private = value;
|
probeOffset1Private = value;
|
||||||
Commit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -86,9 +79,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
if (sampledPosition0Private != value)
|
if (sampledPosition0Private != value)
|
||||||
{
|
{
|
||||||
sampledPosition0Private = value;
|
sampledPosition0Private = value;
|
||||||
Commit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3 SampledPosition1
|
public Vector3 SampledPosition1
|
||||||
|
|
@ -99,7 +91,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
if (sampledPosition1Private != value)
|
if (sampledPosition1Private != value)
|
||||||
{
|
{
|
||||||
sampledPosition1Private = value;
|
sampledPosition1Private = value;
|
||||||
Commit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -112,54 +103,25 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
if (sampledPosition2Private != value)
|
if (sampledPosition2Private != value)
|
||||||
{
|
{
|
||||||
sampledPosition2Private = value;
|
sampledPosition2Private = value;
|
||||||
Commit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PrintLevelingData GetForPrinter(Printer printer)
|
internal static PrintLevelingData Create(string jsonData, string depricatedPositionsCsv3ByXYZ)
|
||||||
{
|
{
|
||||||
if (printer != null)
|
if (!string.IsNullOrEmpty(jsonData))
|
||||||
{
|
{
|
||||||
if (activePrinter != printer)
|
return JsonConvert.DeserializeObject<PrintLevelingData>(jsonData);
|
||||||
{
|
|
||||||
CreateFromJsonOrLegacy(printer.PrintLevelingJsonData, printer.PrintLevelingProbePositions);
|
|
||||||
activePrinter = printer;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return instance;
|
else if (!string.IsNullOrEmpty(depricatedPositionsCsv3ByXYZ))
|
||||||
}
|
|
||||||
|
|
||||||
public void Commit()
|
|
||||||
{
|
|
||||||
if (!activelyLoading)
|
|
||||||
{
|
{
|
||||||
string newLevelingInfo = Newtonsoft.Json.JsonConvert.SerializeObject(this);
|
var item = new PrintLevelingData();
|
||||||
|
item.ParseDepricatedPrintLevelingMeasuredPositions(depricatedPositionsCsv3ByXYZ);
|
||||||
// clear the legacy value
|
return item;
|
||||||
activePrinter.PrintLevelingProbePositions = "";
|
|
||||||
// set the new value
|
|
||||||
activePrinter.PrintLevelingJsonData = newLevelingInfo;
|
|
||||||
activePrinter.Commit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void CreateFromJsonOrLegacy(string jsonData, string depricatedPositionsCsv3ByXYZ)
|
|
||||||
{
|
|
||||||
if (jsonData != null)
|
|
||||||
{
|
|
||||||
activelyLoading = true;
|
|
||||||
instance = Newtonsoft.Json.JsonConvert.DeserializeObject<PrintLevelingData>(jsonData);
|
|
||||||
activelyLoading = false;
|
|
||||||
}
|
|
||||||
else if (depricatedPositionsCsv3ByXYZ != null)
|
|
||||||
{
|
|
||||||
instance = new PrintLevelingData();
|
|
||||||
instance.ParseDepricatedPrintLevelingMeasuredPositions(depricatedPositionsCsv3ByXYZ);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
instance = new PrintLevelingData();
|
return new PrintLevelingData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -176,9 +138,9 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
sampledPosition0Private[i % 3] = double.Parse(lines[0 * 3 + i]);
|
sampledPosition0Private[i] = double.Parse(lines[0 * 3 + i]);
|
||||||
sampledPosition1Private[i % 3] = double.Parse(lines[1 * 3 + i]);
|
sampledPosition1Private[i] = double.Parse(lines[1 * 3 + i]);
|
||||||
sampledPosition2Private[i % 3] = double.Parse(lines[2 * 3 + i]);
|
sampledPosition2Private[i] = double.Parse(lines[2 * 3 + i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -218,17 +180,5 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RunLevelingWizard()
|
|
||||||
{
|
|
||||||
LevelWizardBase.RuningState runningState = LevelWizardBase.RuningState.UserRequestedCalibration;
|
|
||||||
if (ActiveSliceSettings.Instance.LevelingRequiredToPrint)
|
|
||||||
{
|
|
||||||
// run in the first run state
|
|
||||||
runningState = LevelWizardBase.RuningState.InitialStartupCalibration;
|
|
||||||
}
|
|
||||||
|
|
||||||
LevelWizardBase.ShowPrintLevelWizard(runningState);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -70,7 +70,7 @@ namespace MatterHackers.MatterControl
|
||||||
mainLayoutContainer.VAnchor = Agg.UI.VAnchor.FitToChildren;
|
mainLayoutContainer.VAnchor = Agg.UI.VAnchor.FitToChildren;
|
||||||
mainLayoutContainer.Padding = new BorderDouble(top: 10);
|
mainLayoutContainer.Padding = new BorderDouble(top: 10);
|
||||||
|
|
||||||
if (!ActiveSliceSettings.Instance.HasHardwareLeveling())
|
if (!ActiveSliceSettings.Instance.HasHardwareLeveling() == true)
|
||||||
{
|
{
|
||||||
mainLayoutContainer.AddChild(new CalibrationSettingsWidget());
|
mainLayoutContainer.AddChild(new CalibrationSettingsWidget());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -251,7 +251,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage
|
||||||
|
|
||||||
private void SetPrintLevelButtonVisiblity()
|
private void SetPrintLevelButtonVisiblity()
|
||||||
{
|
{
|
||||||
if (ActivePrinterProfile.Instance.DoPrintLeveling)
|
if (ActiveSliceSettings.Instance.DoPrintLeveling)
|
||||||
{
|
{
|
||||||
printLevelingStatusLabel.Text = "Software Print Leveling (enabled)".Localize();
|
printLevelingStatusLabel.Text = "Software Print Leveling (enabled)".Localize();
|
||||||
}
|
}
|
||||||
|
|
@ -263,7 +263,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage
|
||||||
|
|
||||||
private void SetVisibleControls()
|
private void SetVisibleControls()
|
||||||
{
|
{
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter == null)
|
if (ActiveSliceSettings.Instance == null)
|
||||||
{
|
{
|
||||||
// no printer selected
|
// no printer selected
|
||||||
eePromControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
eePromControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,6 @@ namespace MatterHackers.Agg.UI
|
||||||
|
|
||||||
private TextWidget mainControlText;
|
private TextWidget mainControlText;
|
||||||
|
|
||||||
public DropDownMenu(GuiWidget topMenuWidget, Direction direction = Direction.Down)
|
|
||||||
: base(direction)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public DropDownMenu(string topMenuText, Direction direction = Direction.Down, double pointSize = 12)
|
public DropDownMenu(string topMenuText, Direction direction = Direction.Down, double pointSize = 12)
|
||||||
: base(direction)
|
: base(direction)
|
||||||
{
|
{
|
||||||
|
|
@ -29,41 +24,11 @@ namespace MatterHackers.Agg.UI
|
||||||
SetStates(topMenuText, pointSize);
|
SetStates(topMenuText, pointSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool menuAsWideAsItems = true;
|
public bool MenuAsWideAsItems { get; set; } = true;
|
||||||
public bool MenuAsWideAsItems
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return menuAsWideAsItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
public bool DrawDirectionalArrow { get; set; } = true;
|
||||||
{
|
|
||||||
menuAsWideAsItems = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int borderWidth = 1;
|
public int BorderWidth { get; set; } = 1;
|
||||||
|
|
||||||
bool drawDirectionalArrow = true;
|
|
||||||
public bool DrawDirectionalArrow
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return drawDirectionalArrow;
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
drawDirectionalArrow = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int BorderWidth
|
|
||||||
{
|
|
||||||
get { return borderWidth; }
|
|
||||||
set { borderWidth = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public RGBA_Bytes BorderColor { get; set; }
|
public RGBA_Bytes BorderColor { get; set; }
|
||||||
|
|
||||||
|
|
@ -75,17 +40,7 @@ namespace MatterHackers.Agg.UI
|
||||||
|
|
||||||
public RGBA_Bytes HoverColor { get; set; }
|
public RGBA_Bytes HoverColor { get; set; }
|
||||||
|
|
||||||
private RGBA_Bytes textColor = RGBA_Bytes.Black;
|
public RGBA_Bytes TextColor { get; set; } = RGBA_Bytes.Black;
|
||||||
|
|
||||||
public RGBA_Bytes TextColor
|
|
||||||
{
|
|
||||||
get { return textColor; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
textColor = value;
|
|
||||||
//mainControlText.TextColor = TextColor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int selectedIndex = -1;
|
private int selectedIndex = -1;
|
||||||
|
|
||||||
|
|
@ -261,16 +216,16 @@ namespace MatterHackers.Agg.UI
|
||||||
private void DrawBorder(Graphics2D graphics2D)
|
private void DrawBorder(Graphics2D graphics2D)
|
||||||
{
|
{
|
||||||
RectangleDouble Bounds = LocalBounds;
|
RectangleDouble Bounds = LocalBounds;
|
||||||
if (borderWidth > 0)
|
if (BorderWidth > 0)
|
||||||
{
|
{
|
||||||
if (borderWidth == 1)
|
if (BorderWidth == 1)
|
||||||
{
|
{
|
||||||
graphics2D.Rectangle(Bounds, BorderColor);
|
graphics2D.Rectangle(Bounds, BorderColor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RoundedRect borderRect = new RoundedRect(this.LocalBounds, 0);
|
RoundedRect borderRect = new RoundedRect(this.LocalBounds, 0);
|
||||||
Stroke strokeRect = new Stroke(borderRect, borderWidth);
|
Stroke strokeRect = new Stroke(borderRect, BorderWidth);
|
||||||
graphics2D.Render(strokeRect, BorderColor);
|
graphics2D.Render(strokeRect, BorderColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,8 @@ namespace MatterHackers.MatterControl
|
||||||
this.Name = "Export Item Window";
|
this.Name = "Export Item Window";
|
||||||
|
|
||||||
CreateWindowContent();
|
CreateWindowContent();
|
||||||
ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(ReloadAfterPrinterProfileChanged, ref unregisterEvents);
|
ActiveSliceSettings.ActivePrinterChanged.RegisterEvent(ReloadAfterPrinterProfileChanged, ref unregisterEvents);
|
||||||
ActivePrinterProfile.Instance.DoPrintLevelingChanged.RegisterEvent(ReloadAfterPrinterProfileChanged, ref unregisterEvents);
|
ActiveSliceSettings.Instance.DoPrintLevelingChanged.RegisterEvent(ReloadAfterPrinterProfileChanged, ref unregisterEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string applyLevelingDuringExportString = "Apply leveling to G-Code during export".Localize();
|
private string applyLevelingDuringExportString = "Apply leveling to G-Code during export".Localize();
|
||||||
|
|
@ -114,7 +114,7 @@ namespace MatterHackers.MatterControl
|
||||||
middleRowContainer.AddChild(exportAsAmfButton);
|
middleRowContainer.AddChild(exportAsAmfButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool showExportGCodeButton = ActivePrinterProfile.Instance.ActivePrinter != null || partIsGCode;
|
bool showExportGCodeButton = ActiveSliceSettings.Instance != null || partIsGCode;
|
||||||
if (showExportGCodeButton)
|
if (showExportGCodeButton)
|
||||||
{
|
{
|
||||||
string exportGCodeTextFull = string.Format("{0} G-Code", "Export as".Localize());
|
string exportGCodeTextFull = string.Format("{0} G-Code", "Export as".Localize());
|
||||||
|
|
@ -191,7 +191,7 @@ namespace MatterHackers.MatterControl
|
||||||
middleRowContainer.AddChild(new VerticalSpacer());
|
middleRowContainer.AddChild(new VerticalSpacer());
|
||||||
|
|
||||||
// If print leveling is enabled then add in a check box 'Apply Leveling During Export' and default checked.
|
// If print leveling is enabled then add in a check box 'Apply Leveling During Export' and default checked.
|
||||||
if (showExportGCodeButton && ActivePrinterProfile.Instance.DoPrintLeveling)
|
if (showExportGCodeButton && ActiveSliceSettings.Instance.DoPrintLeveling)
|
||||||
{
|
{
|
||||||
applyLeveling = new CheckBox(LocalizedString.Get(applyLevelingDuringExportString), ActiveTheme.Instance.PrimaryTextColor, 10);
|
applyLeveling = new CheckBox(LocalizedString.Get(applyLevelingDuringExportString), ActiveTheme.Instance.PrimaryTextColor, 10);
|
||||||
applyLeveling.Checked = true;
|
applyLeveling.Checked = true;
|
||||||
|
|
@ -308,12 +308,12 @@ namespace MatterHackers.MatterControl
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (ActivePrinterProfile.Instance.DoPrintLeveling)
|
if (ActiveSliceSettings.Instance.DoPrintLeveling)
|
||||||
{
|
{
|
||||||
GCodeFileLoaded unleveledGCode = new GCodeFileLoaded(source);
|
GCodeFileLoaded unleveledGCode = new GCodeFileLoaded(source);
|
||||||
if (applyLeveling.Checked)
|
if (applyLeveling.Checked)
|
||||||
{
|
{
|
||||||
PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(ActivePrinterProfile.Instance.ActivePrinter);
|
PrintLevelingData levelingData = ActiveSliceSettings.Instance.PrintLevelingData;
|
||||||
if (levelingData != null)
|
if (levelingData != null)
|
||||||
{
|
{
|
||||||
for (int lineIndex = 0; lineIndex < unleveledGCode.LineCount; lineIndex++)
|
for (int lineIndex = 0; lineIndex < unleveledGCode.LineCount; lineIndex++)
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ namespace MatterHackers.MatterControl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPanelIndexImediate(int index)
|
public void SetPanelIndexImmediate(int index)
|
||||||
{
|
{
|
||||||
desiredPanelIndex = index;
|
desiredPanelIndex = index;
|
||||||
SetSlidePosition();
|
SetSlidePosition();
|
||||||
|
|
|
||||||
218
DataStorage/Classic/ClassicSqlitePrinterProfiles.cs
Normal file
218
DataStorage/Classic/ClassicSqlitePrinterProfiles.cs
Normal file
|
|
@ -0,0 +1,218 @@
|
||||||
|
/*
|
||||||
|
Copyright (c) 2016, Lars Brubaker, John Lewin
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
The views and conclusions contained in the software and documentation are those
|
||||||
|
of the authors and should not be interpreted as representing official policies,
|
||||||
|
either expressed or implied, of the FreeBSD Project.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using MatterHackers.Agg;
|
||||||
|
using MatterHackers.Agg.PlatformAbstract;
|
||||||
|
using MatterHackers.Agg.UI;
|
||||||
|
using MatterHackers.Localizations;
|
||||||
|
using MatterHackers.MatterControl.ConfigurationPage.PrintLeveling;
|
||||||
|
using MatterHackers.MatterControl.ContactForm;
|
||||||
|
using MatterHackers.MatterControl.DataStorage;
|
||||||
|
using MatterHackers.MatterControl.PrinterCommunication;
|
||||||
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||||
|
using MatterHackers.VectorMath;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace MatterHackers.MatterControl.DataStorage.ClassicDB
|
||||||
|
{
|
||||||
|
public class ClassicSqlitePrinterProfiles
|
||||||
|
{
|
||||||
|
|
||||||
|
public class ClassicSettingsLayer
|
||||||
|
{
|
||||||
|
//Container class representing a collection of setting along with the meta info for that collection
|
||||||
|
public Dictionary<string, SliceSetting> settingsDictionary;
|
||||||
|
|
||||||
|
public SliceSettingsCollection settingsCollectionData;
|
||||||
|
|
||||||
|
public ClassicSettingsLayer(SliceSettingsCollection settingsCollection, Dictionary<string, SliceSetting> settingsDictionary)
|
||||||
|
{
|
||||||
|
this.settingsCollectionData = settingsCollection;
|
||||||
|
this.settingsDictionary = settingsDictionary;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ImportPrinters(ProfileData profileData, string profilePath)
|
||||||
|
{
|
||||||
|
foreach (Printer printer in Datastore.Instance.dbSQLite.Query<Printer>("SELECT * FROM Printer;"))
|
||||||
|
{
|
||||||
|
ImportPrinter(printer, profileData, profilePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ImportPrinter(Printer printer, ProfileData profileData, string profilePath)
|
||||||
|
{
|
||||||
|
var printerInfo = new PrinterInfo()
|
||||||
|
{
|
||||||
|
Name = printer.Name,
|
||||||
|
Id = printer.Id.ToString()
|
||||||
|
};
|
||||||
|
profileData.Profiles.Add(printerInfo);
|
||||||
|
|
||||||
|
var layeredProfile = ActiveSliceSettings.LoadEmptyProfile();
|
||||||
|
|
||||||
|
//Load printer settings from database as second layer
|
||||||
|
|
||||||
|
layeredProfile.OemProfile = new OemProfile(LoadOemLayer(printer));
|
||||||
|
|
||||||
|
//Ordering matters - Material presets trump Quality
|
||||||
|
LoadQualitySettings(layeredProfile, printer);
|
||||||
|
LoadMaterialSettings(layeredProfile, printer);
|
||||||
|
|
||||||
|
string fullProfilePath = Path.Combine(profilePath, printer.Id + ".json");
|
||||||
|
|
||||||
|
File.WriteAllText(fullProfilePath, JsonConvert.SerializeObject(layeredProfile, Formatting.Indented));
|
||||||
|
|
||||||
|
//GET LEVELING DATA from DB
|
||||||
|
|
||||||
|
//PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(printer);
|
||||||
|
|
||||||
|
/*
|
||||||
|
PrintLevelingPlane.Instance.SetPrintLevelingEquation(
|
||||||
|
levelingData.SampledPosition0,
|
||||||
|
levelingData.SampledPosition1,
|
||||||
|
levelingData.SampledPosition2,
|
||||||
|
ActiveSliceSettings.Instance.PrintCenter); */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void LoadMaterialSettings(LayeredProfile layeredProfile, Printer printer)
|
||||||
|
{
|
||||||
|
var materialAssignments = printer.MaterialCollectionIds.Split(',');
|
||||||
|
|
||||||
|
var collections = Datastore.Instance.dbSQLite.Table<SliceSettingsCollection>().Where(v => v.PrinterId == printer.Id && v.Tag == "material");
|
||||||
|
foreach (var collection in collections)
|
||||||
|
{
|
||||||
|
var settingsDictionary = LoadSettings(collection);
|
||||||
|
layeredProfile.MaterialLayers[collection.Name] = new SettingsLayer(settingsDictionary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LoadQualitySettings(LayeredProfile layeredProfile, Printer printer)
|
||||||
|
{
|
||||||
|
var collections = Datastore.Instance.dbSQLite.Table<SliceSettingsCollection>().Where(v => v.PrinterId == printer.Id && v.Tag == "quality");
|
||||||
|
foreach (var collection in collections)
|
||||||
|
{
|
||||||
|
var settingsDictionary = LoadSettings(collection);
|
||||||
|
layeredProfile.QualityLayers[collection.Name] = new SettingsLayer(settingsDictionary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Dictionary<string, string> LoadOemLayer(Printer printer)
|
||||||
|
{
|
||||||
|
SliceSettingsCollection collection;
|
||||||
|
if (printer.DefaultSettingsCollectionId != 0)
|
||||||
|
{
|
||||||
|
int activePrinterSettingsID = printer.DefaultSettingsCollectionId;
|
||||||
|
collection = Datastore.Instance.dbSQLite.Table<SliceSettingsCollection>().Where(v => v.Id == activePrinterSettingsID).Take(1).FirstOrDefault();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
collection = new SliceSettingsCollection();
|
||||||
|
collection.Name = printer.Name;
|
||||||
|
collection.Commit();
|
||||||
|
|
||||||
|
printer.DefaultSettingsCollectionId = collection.Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return LoadSettings(collection);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Dictionary<string, string> LoadSettings(SliceSettingsCollection collection)
|
||||||
|
{
|
||||||
|
var settings = Datastore.Instance.dbSQLite.Query<SliceSetting>(
|
||||||
|
string.Format("SELECT * FROM SliceSetting WHERE SettingsCollectionID = " + collection.Id));
|
||||||
|
|
||||||
|
//return settings.ToDictionary(s => s.Name, s => s.Value);
|
||||||
|
|
||||||
|
var dictionary = new Dictionary<string, string>();
|
||||||
|
foreach(var setting in settings)
|
||||||
|
{
|
||||||
|
// Not distinct on .Name; last value wins
|
||||||
|
dictionary[setting.Name] = setting.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dictionary;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void LoadDefaultConfigrationSettings(List<ClassicSettingsLayer> settings)
|
||||||
|
{
|
||||||
|
SliceSettingsCollection defaultCollection = new SliceSettingsCollection();
|
||||||
|
defaultCollection.Name = "__default__";
|
||||||
|
ClassicSettingsLayer defaultSettingsLayer = LoadConfigurationSettingsFromFile(Path.Combine("PrinterSettings", "config.ini"), defaultCollection);
|
||||||
|
|
||||||
|
settings.Add(defaultSettingsLayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static ClassicSettingsLayer LoadConfigurationSettingsFromFile(string pathAndFileName, SliceSettingsCollection collection)
|
||||||
|
{
|
||||||
|
Dictionary<string, SliceSetting> settingsDictionary = new Dictionary<string, SliceSetting>();
|
||||||
|
ClassicSettingsLayer activeCollection;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (StaticData.Instance.FileExists(pathAndFileName))
|
||||||
|
{
|
||||||
|
foreach (string line in StaticData.Instance.ReadAllLines(pathAndFileName))
|
||||||
|
{
|
||||||
|
//Ignore commented lines
|
||||||
|
if (!line.StartsWith("#"))
|
||||||
|
{
|
||||||
|
string[] settingLine = line.Split('=');
|
||||||
|
string keyName = settingLine[0].Trim();
|
||||||
|
string settingDefaultValue = settingLine[1].Trim();
|
||||||
|
|
||||||
|
SliceSetting sliceSetting = new SliceSetting();
|
||||||
|
sliceSetting.Name = keyName;
|
||||||
|
sliceSetting.Value = settingDefaultValue;
|
||||||
|
|
||||||
|
settingsDictionary.Add(keyName, sliceSetting);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
activeCollection = new ClassicSettingsLayer(collection, settingsDictionary);
|
||||||
|
return activeCollection;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.Print(e.Message);
|
||||||
|
GuiWidget.BreakInDebugger();
|
||||||
|
Debug.WriteLine(string.Format("Error loading configuration: {0}", e));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -328,7 +328,7 @@ namespace MatterHackers.MatterControl.DataStorage
|
||||||
if (TEST_FLAG)
|
if (TEST_FLAG)
|
||||||
{
|
{
|
||||||
ValidateSchema();
|
ValidateSchema();
|
||||||
GenerateSampleData sampleData = new GenerateSampleData();
|
GenerateSampleData();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -352,6 +352,18 @@ namespace MatterHackers.MatterControl.DataStorage
|
||||||
dbSQLite.Insert(activeSession);
|
dbSQLite.Insert(activeSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void GenerateSampleData()
|
||||||
|
{
|
||||||
|
for (int index = 1; index <= 5; index++)
|
||||||
|
{
|
||||||
|
Printer printer = new Printer();
|
||||||
|
printer.ComPort = string.Format("COM{0}", index);
|
||||||
|
printer.BaudRate = "250000";
|
||||||
|
printer.Name = string.Format("Printer {0}", index);
|
||||||
|
Datastore.Instance.dbSQLite.Insert(printer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Checks if the datastore contains the appropriate tables - adds them if necessary
|
// Checks if the datastore contains the appropriate tables - adds them if necessary
|
||||||
private void ValidateSchema()
|
private void ValidateSchema()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
namespace MatterHackers.MatterControl.DataStorage
|
|
||||||
{
|
|
||||||
internal class GenerateSampleData
|
|
||||||
{
|
|
||||||
public GenerateSampleData()
|
|
||||||
{
|
|
||||||
AddPrinters();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AddPrinters()
|
|
||||||
{
|
|
||||||
for (int index = 1; index <= 5; index++)
|
|
||||||
{
|
|
||||||
Printer printer = new Printer();
|
|
||||||
printer.ComPort = string.Format("COM{0}", index);
|
|
||||||
printer.BaudRate = "250000";
|
|
||||||
printer.Name = string.Format("Printer {0}", index);
|
|
||||||
Datastore.Instance.dbSQLite.Insert(printer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -127,8 +127,9 @@
|
||||||
<Compile Include="AboutPage\UpdateControlData.cs" />
|
<Compile Include="AboutPage\UpdateControlData.cs" />
|
||||||
<Compile Include="AboutPage\UpdateControlView.cs" />
|
<Compile Include="AboutPage\UpdateControlView.cs" />
|
||||||
<Compile Include="AboutPage\HTMLParser\HtmlParser.cs" />
|
<Compile Include="AboutPage\HTMLParser\HtmlParser.cs" />
|
||||||
<Compile Include="ActionBar\ActionBarBaseControls.cs" />
|
<Compile Include="ActionBar\ActionRowBase.cs" />
|
||||||
<Compile Include="ActionBar\ActionBarPlus.cs" />
|
<Compile Include="ActionBar\ActionBarPlus.cs" />
|
||||||
|
<Compile Include="ActionBar\PrinterSelector.cs" />
|
||||||
<Compile Include="ActionBar\TemperatureWidgetBed.cs" />
|
<Compile Include="ActionBar\TemperatureWidgetBed.cs" />
|
||||||
<Compile Include="ActionBar\PrintActionRow.cs" />
|
<Compile Include="ActionBar\PrintActionRow.cs" />
|
||||||
<Compile Include="ActionBar\PrinterActionRow.cs" />
|
<Compile Include="ActionBar\PrinterActionRow.cs" />
|
||||||
|
|
@ -142,7 +143,7 @@
|
||||||
<Compile Include="ApplicationView\MenuRow\ApplicationMenuRow.cs" />
|
<Compile Include="ApplicationView\MenuRow\ApplicationMenuRow.cs" />
|
||||||
<Compile Include="ApplicationView\CompactSlidePanel.cs" />
|
<Compile Include="ApplicationView\CompactSlidePanel.cs" />
|
||||||
<Compile Include="ApplicationView\CompactTabView.cs" />
|
<Compile Include="ApplicationView\CompactTabView.cs" />
|
||||||
<Compile Include="ApplicationView\ThirdPanelTabView.cs" />
|
<Compile Include="ApplicationView\AdvancedControlsPanel.cs" />
|
||||||
<Compile Include="ApplicationView\FirstPanelTabView.cs" />
|
<Compile Include="ApplicationView\FirstPanelTabView.cs" />
|
||||||
<Compile Include="ConfigurationPage\ApplicationSettings\ApplicationSettingsView.cs" />
|
<Compile Include="ConfigurationPage\ApplicationSettings\ApplicationSettingsView.cs" />
|
||||||
<Compile Include="ConfigurationPage\CloudSettings\CloudSettingsView.cs" />
|
<Compile Include="ConfigurationPage\CloudSettings\CloudSettingsView.cs" />
|
||||||
|
|
@ -163,7 +164,6 @@
|
||||||
<Compile Include="CustomWidgets\DoubleSolidSlider.cs" />
|
<Compile Include="CustomWidgets\DoubleSolidSlider.cs" />
|
||||||
<Compile Include="CustomWidgets\FatFlatClickWidget.cs" />
|
<Compile Include="CustomWidgets\FatFlatClickWidget.cs" />
|
||||||
<Compile Include="CustomWidgets\FlowSpacers.cs" />
|
<Compile Include="CustomWidgets\FlowSpacers.cs" />
|
||||||
<Compile Include="CustomWidgets\LibrarySelector\LibraryProviderEventArgs.cs" />
|
|
||||||
<Compile Include="CustomWidgets\LibrarySelector\LibrarySelectorRowItem.cs" />
|
<Compile Include="CustomWidgets\LibrarySelector\LibrarySelectorRowItem.cs" />
|
||||||
<Compile Include="CustomWidgets\LibrarySelector\FolderBreadCrumbWidget.cs" />
|
<Compile Include="CustomWidgets\LibrarySelector\FolderBreadCrumbWidget.cs" />
|
||||||
<Compile Include="CustomWidgets\LibrarySelector\LibrarySelectorRowItemCollection.cs" />
|
<Compile Include="CustomWidgets\LibrarySelector\LibrarySelectorRowItemCollection.cs" />
|
||||||
|
|
@ -202,7 +202,6 @@
|
||||||
<Compile Include="PartPreviewWindow\ViewControls2D.cs" />
|
<Compile Include="PartPreviewWindow\ViewControls2D.cs" />
|
||||||
<Compile Include="PartPreviewWindow\BaseClasses\PartPreview3DWidget.cs" />
|
<Compile Include="PartPreviewWindow\BaseClasses\PartPreview3DWidget.cs" />
|
||||||
<Compile Include="PartPreviewWindow\ViewGcodeWidget.cs" />
|
<Compile Include="PartPreviewWindow\ViewGcodeWidget.cs" />
|
||||||
<Compile Include="PrinterCommunication\ActivePrinterProfile.cs" />
|
|
||||||
<Compile Include="ConfigurationPage\PrinterConfigurationPage.cs" />
|
<Compile Include="ConfigurationPage\PrinterConfigurationPage.cs" />
|
||||||
<Compile Include="CustomWidgets\DisableableWidget.cs" />
|
<Compile Include="CustomWidgets\DisableableWidget.cs" />
|
||||||
<Compile Include="CustomWidgets\ExportPrintItemWindow.cs" />
|
<Compile Include="CustomWidgets\ExportPrintItemWindow.cs" />
|
||||||
|
|
@ -246,6 +245,10 @@
|
||||||
<Compile Include="Queue\OptionsMenu\ExportGcodePlugin.cs" />
|
<Compile Include="Queue\OptionsMenu\ExportGcodePlugin.cs" />
|
||||||
<Compile Include="Queue\OptionsMenu\MergeQueueItems.cs" />
|
<Compile Include="Queue\OptionsMenu\MergeQueueItems.cs" />
|
||||||
<Compile Include="SlicerConfiguration\SliceSettingsDetailControl.cs" />
|
<Compile Include="SlicerConfiguration\SliceSettingsDetailControl.cs" />
|
||||||
|
<Compile Include="SlicerConfiguration\Settings\SettingsProfile.cs" />
|
||||||
|
<Compile Include="SlicerConfiguration\Settings\ActiveSliceSettings.cs" />
|
||||||
|
<Compile Include="SlicerConfiguration\Settings\LayeredProfile.cs" />
|
||||||
|
<Compile Include="DataStorage\Classic\ClassicSqlitePrinterProfiles.cs" />
|
||||||
<Compile Include="Utilities\LimitCallFrequency.cs" />
|
<Compile Include="Utilities\LimitCallFrequency.cs" />
|
||||||
<Compile Include="Utilities\SelectedListItems.cs" />
|
<Compile Include="Utilities\SelectedListItems.cs" />
|
||||||
<Compile Include="Queue\OptionsMenu\ExportToFolderFeedbackWindow.cs" />
|
<Compile Include="Queue\OptionsMenu\ExportToFolderFeedbackWindow.cs" />
|
||||||
|
|
@ -303,7 +306,6 @@
|
||||||
<Compile Include="ControlElements\StyledMessageBoxWindow.cs" />
|
<Compile Include="ControlElements\StyledMessageBoxWindow.cs" />
|
||||||
<Compile Include="ControlElements\ThemeFactory.cs" />
|
<Compile Include="ControlElements\ThemeFactory.cs" />
|
||||||
<Compile Include="CustomWidgets\WizardControl.cs" />
|
<Compile Include="CustomWidgets\WizardControl.cs" />
|
||||||
<Compile Include="DataStorage\GenerateSampleData.cs" />
|
|
||||||
<Compile Include="DataStorage\SQLiteCommon.cs" />
|
<Compile Include="DataStorage\SQLiteCommon.cs" />
|
||||||
<Compile Include="DataStorage\SQLiteWin32.cs" />
|
<Compile Include="DataStorage\SQLiteWin32.cs" />
|
||||||
<Compile Include="DataStorage\Datastore.cs" />
|
<Compile Include="DataStorage\Datastore.cs" />
|
||||||
|
|
@ -322,7 +324,6 @@
|
||||||
<Compile Include="PrinterCommunication\PrinterConnectionAndCommunication.cs" />
|
<Compile Include="PrinterCommunication\PrinterConnectionAndCommunication.cs" />
|
||||||
<Compile Include="PrinterControls\PrintLevelingPlane.cs" />
|
<Compile Include="PrinterControls\PrintLevelingPlane.cs" />
|
||||||
<Compile Include="PrinterControls\TerminalWindow\TerminalWindow.cs" />
|
<Compile Include="PrinterControls\TerminalWindow\TerminalWindow.cs" />
|
||||||
<Compile Include="PrinterControls\PrinterConnections\ChooseConnectionWidget.cs" />
|
|
||||||
<Compile Include="PrinterControls\PrinterConnections\SetupStepComPortManual.cs" />
|
<Compile Include="PrinterControls\PrinterConnections\SetupStepComPortManual.cs" />
|
||||||
<Compile Include="PrinterControls\PrinterConnections\SetupStepConfigureConnection.cs" />
|
<Compile Include="PrinterControls\PrinterConnections\SetupStepConfigureConnection.cs" />
|
||||||
<Compile Include="PrinterControls\PrinterConnections\SetupStepComPortTwo.cs" />
|
<Compile Include="PrinterControls\PrinterConnections\SetupStepComPortTwo.cs" />
|
||||||
|
|
@ -332,10 +333,8 @@
|
||||||
<Compile Include="PrinterControls\PrinterConnections\SetupStepInstallDriver.cs" />
|
<Compile Include="PrinterControls\PrinterConnections\SetupStepInstallDriver.cs" />
|
||||||
<Compile Include="PrinterControls\PrinterConnections\ConnectionWindow.cs" />
|
<Compile Include="PrinterControls\PrinterConnections\ConnectionWindow.cs" />
|
||||||
<Compile Include="PrinterControls\ManualPrinterControls.cs" />
|
<Compile Include="PrinterControls\ManualPrinterControls.cs" />
|
||||||
<Compile Include="PrinterControls\PrinterConnections\EditConnectionWidget.cs" />
|
|
||||||
<Compile Include="PrinterControls\PrinterConnections\BaseConnectionWidget.cs" />
|
<Compile Include="PrinterControls\PrinterConnections\BaseConnectionWidget.cs" />
|
||||||
<Compile Include="PrinterControls\PrinterConnections\PrinterChooser.cs" />
|
<Compile Include="PrinterControls\PrinterConnections\PrinterChooser.cs" />
|
||||||
<Compile Include="PrinterControls\PrinterConnections\PrinterListItems.cs" />
|
|
||||||
<Compile Include="PrinterControls\PrinterConnections\SetupConnectionWidgetBase.cs" />
|
<Compile Include="PrinterControls\PrinterConnections\SetupConnectionWidgetBase.cs" />
|
||||||
<Compile Include="PrinterControls\TemperatureIndicator.cs" />
|
<Compile Include="PrinterControls\TemperatureIndicator.cs" />
|
||||||
<Compile Include="PrinterControls\XYZJogControls.cs" />
|
<Compile Include="PrinterControls\XYZJogControls.cs" />
|
||||||
|
|
@ -355,7 +354,6 @@
|
||||||
<Compile Include="Queue\QueueDataWidget.cs" />
|
<Compile Include="Queue\QueueDataWidget.cs" />
|
||||||
<Compile Include="SettingsManagement\ApplicationSettings.cs" />
|
<Compile Include="SettingsManagement\ApplicationSettings.cs" />
|
||||||
<Compile Include="SettingsManagement\UserSettings.cs" />
|
<Compile Include="SettingsManagement\UserSettings.cs" />
|
||||||
<Compile Include="SlicerConfiguration\ActiveSliceSettings.cs" />
|
|
||||||
<Compile Include="SlicerConfiguration\SettingsControlBar.cs" />
|
<Compile Include="SlicerConfiguration\SettingsControlBar.cs" />
|
||||||
<Compile Include="SlicerConfiguration\SliceSettingsWidget.cs" />
|
<Compile Include="SlicerConfiguration\SliceSettingsWidget.cs" />
|
||||||
<Compile Include="SlicerConfiguration\SliceSettingsOrganizer.cs" />
|
<Compile Include="SlicerConfiguration\SliceSettingsOrganizer.cs" />
|
||||||
|
|
@ -444,6 +442,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
|
<None Include="SlicerConfiguration\Settings\SettingsDiagram.cd" />
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
<None Include="StaticData\PrinterSettings\config.ini" />
|
<None Include="StaticData\PrinterSettings\config.ini" />
|
||||||
<None Include="StaticData\SliceSettings\Properties.json" />
|
<None Include="StaticData\SliceSettings\Properties.json" />
|
||||||
|
|
|
||||||
|
|
@ -146,32 +146,32 @@ namespace MatterHackers.MatterControl
|
||||||
DoCGCollectEveryDraw = true;
|
DoCGCollectEveryDraw = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "CREATE_AND_SELECT_PRINTER":
|
//case "CREATE_AND_SELECT_PRINTER":
|
||||||
if (currentCommandIndex + 1 <= commandLineArgs.Length)
|
// if (currentCommandIndex + 1 <= commandLineArgs.Length)
|
||||||
{
|
// {
|
||||||
currentCommandIndex++;
|
// currentCommandIndex++;
|
||||||
string argument = commandLineArgs[currentCommandIndex];
|
// string argument = commandLineArgs[currentCommandIndex];
|
||||||
string[] printerData = argument.Split(',');
|
// string[] printerData = argument.Split(',');
|
||||||
if (printerData.Length >= 2)
|
// if (printerData.Length >= 2)
|
||||||
{
|
// {
|
||||||
Printer ActivePrinter = new Printer();
|
// Printer ActivePrinter = new Printer();
|
||||||
|
|
||||||
ActivePrinter.Name = "Auto: {0} {1}".FormatWith(printerData[0], printerData[1]);
|
// ActivePrinter.Name = "Auto: {0} {1}".FormatWith(printerData[0], printerData[1]);
|
||||||
ActivePrinter.Make = printerData[0];
|
// ActivePrinter.Make = printerData[0];
|
||||||
ActivePrinter.Model = printerData[1];
|
// ActivePrinter.Model = printerData[1];
|
||||||
|
|
||||||
if (printerData.Length == 3)
|
// if (printerData.Length == 3)
|
||||||
{
|
// {
|
||||||
ActivePrinter.ComPort = printerData[2];
|
// ActivePrinter.ComPort = printerData[2];
|
||||||
}
|
// }
|
||||||
|
|
||||||
PrinterSetupStatus test = new PrinterSetupStatus(ActivePrinter);
|
// PrinterSetupStatus test = new PrinterSetupStatus(ActivePrinter);
|
||||||
test.LoadSettingsFromConfigFile(ActivePrinter.Make, ActivePrinter.Model);
|
// test.LoadSettingsFromConfigFile(ActivePrinter.Make, ActivePrinter.Model);
|
||||||
ActivePrinterProfile.Instance.ActivePrinter = ActivePrinter;
|
// ActiveSliceSettings.Instance = ActivePrinter;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case "CONNECT_TO_PRINTER":
|
case "CONNECT_TO_PRINTER":
|
||||||
if (currentCommandIndex + 1 <= commandLineArgs.Length)
|
if (currentCommandIndex + 1 <= commandLineArgs.Length)
|
||||||
|
|
@ -484,11 +484,6 @@ namespace MatterHackers.MatterControl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DoAutoConnectIfRequired()
|
|
||||||
{
|
|
||||||
ActivePrinterProfile.CheckForAndDoAutoConnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LaunchBrowser(string targetUri)
|
public void LaunchBrowser(string targetUri)
|
||||||
{
|
{
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
|
|
@ -590,7 +585,7 @@ namespace MatterHackers.MatterControl
|
||||||
|
|
||||||
if (firstDraw)
|
if (firstDraw)
|
||||||
{
|
{
|
||||||
UiThread.RunOnIdle(DoAutoConnectIfRequired);
|
UiThread.RunOnIdle(ActiveSliceSettings.CheckForAndDoAutoConnect);
|
||||||
|
|
||||||
firstDraw = false;
|
firstDraw = false;
|
||||||
foreach (string arg in commandLineArgs)
|
foreach (string arg in commandLineArgs)
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
"extruder_offset",
|
"extruder_offset",
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent((s, e) => needToRecretaeBed = true, ref unregisterEvents);
|
ActiveSliceSettings.ActivePrinterChanged.RegisterEvent((s, e) => needToRecretaeBed = true, ref unregisterEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckSettingChanged(object sender, EventArgs e)
|
private void CheckSettingChanged(object sender, EventArgs e)
|
||||||
|
|
|
||||||
|
|
@ -98,8 +98,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
double buildHeight = ActiveSliceSettings.Instance.BuildHeight;
|
double buildHeight = ActiveSliceSettings.Instance.BuildHeight;
|
||||||
|
|
||||||
// put in the 3D view
|
// put in the 3D view
|
||||||
string part3DViewLabelFull = string.Format("{0} {1} ", "3D", "View".Localize()).ToUpper();
|
|
||||||
|
|
||||||
partPreviewView = new View3DWidget(printItem,
|
partPreviewView = new View3DWidget(printItem,
|
||||||
new Vector3(ActiveSliceSettings.Instance.BedSize, buildHeight),
|
new Vector3(ActiveSliceSettings.Instance.BedSize, buildHeight),
|
||||||
ActiveSliceSettings.Instance.BedCenter,
|
ActiveSliceSettings.Instance.BedCenter,
|
||||||
|
|
@ -108,7 +106,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
autoRotate3DView,
|
autoRotate3DView,
|
||||||
openMode);
|
openMode);
|
||||||
|
|
||||||
TabPage partPreview3DView = new TabPage(partPreviewView, part3DViewLabelFull);
|
TabPage partPreview3DView = new TabPage(partPreviewView, string.Format("3D {0} ", "View".Localize()).ToUpper());
|
||||||
|
|
||||||
// put in the gcode view
|
// put in the gcode view
|
||||||
ViewGcodeBasic.WindowMode gcodeWindowMode = ViewGcodeBasic.WindowMode.Embeded;
|
ViewGcodeBasic.WindowMode gcodeWindowMode = ViewGcodeBasic.WindowMode.Embeded;
|
||||||
|
|
@ -124,20 +122,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
|
|
||||||
if (windowMode == View3DWidget.WindowMode.StandAlone)
|
if (windowMode == View3DWidget.WindowMode.StandAlone)
|
||||||
{
|
{
|
||||||
partPreviewView.Closed += (sender, e) =>
|
partPreviewView.Closed += (s, e) => Close();
|
||||||
{
|
viewGcodeBasic.Closed += (s, e) => Close();
|
||||||
Close();
|
|
||||||
};
|
|
||||||
viewGcodeBasic.Closed += (sender, e) =>
|
|
||||||
{
|
|
||||||
Close();
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
layerView = new TabPage(viewGcodeBasic, LocalizedString.Get("Layer View").ToUpper());
|
layerView = new TabPage(viewGcodeBasic, LocalizedString.Get("Layer View").ToUpper());
|
||||||
|
|
||||||
int tabPointSize = 16;
|
int tabPointSize = 16;
|
||||||
// add the correct tabs based on wether we are stand alone or embeded
|
// add the correct tabs based on whether we are stand alone or embedded
|
||||||
Tab threeDViewTab;
|
Tab threeDViewTab;
|
||||||
Tab layerViewTab;
|
Tab layerViewTab;
|
||||||
if (windowMode == View3DWidget.WindowMode.StandAlone || OsInformation.OperatingSystem == OSType.Android)
|
if (windowMode == View3DWidget.WindowMode.StandAlone || OsInformation.OperatingSystem == OSType.Android)
|
||||||
|
|
@ -171,10 +163,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
|
|
||||||
public override void OnClosed(EventArgs e)
|
public override void OnClosed(EventArgs e)
|
||||||
{
|
{
|
||||||
if (unregisterEvents != null)
|
unregisterEvents?.Invoke(this, null);
|
||||||
{
|
|
||||||
unregisterEvents(this, null);
|
|
||||||
}
|
|
||||||
base.OnClosed(e);
|
base.OnClosed(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1065,7 +1065,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
colorSelectionContainer.HAnchor = HAnchor.ParentLeftRight;
|
colorSelectionContainer.HAnchor = HAnchor.ParentLeftRight;
|
||||||
colorSelectionContainer.Padding = new BorderDouble(5);
|
colorSelectionContainer.Padding = new BorderDouble(5);
|
||||||
|
|
||||||
string colorLabelText = "Material {0}".Localize().FormatWith(extruderIndex + 1);
|
string colorLabelText = string.Format("{0} {1}", "Material".Localize(), extruderIndex + 1);
|
||||||
|
|
||||||
RadioButton extruderSelection = new RadioButton(colorLabelText, textColor: ActiveTheme.Instance.PrimaryTextColor);
|
RadioButton extruderSelection = new RadioButton(colorLabelText, textColor: ActiveTheme.Instance.PrimaryTextColor);
|
||||||
extruderButtons.Add(extruderSelection);
|
extruderButtons.Add(extruderSelection);
|
||||||
extruderSelection.SiblingRadioButtonList = extruderButtons;
|
extruderSelection.SiblingRadioButtonList = extruderButtons;
|
||||||
|
|
@ -2101,8 +2102,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
private bool PartsAreInPrintVolume()
|
private bool PartsAreInPrintVolume()
|
||||||
{
|
{
|
||||||
if (ActiveSliceSettings.Instance != null
|
if (ActiveSliceSettings.Instance != null
|
||||||
&& !ActiveSliceSettings.Instance.CenterOnBed()
|
&& !ActiveSliceSettings.Instance.CenterOnBed())
|
||||||
&& ActivePrinterProfile.Instance.ActivePrinter != null)
|
|
||||||
{
|
{
|
||||||
AxisAlignedBoundingBox allBounds = MeshViewerWidget.GetAxisAlignedBoundingBox(MeshGroups);
|
AxisAlignedBoundingBox allBounds = MeshViewerWidget.GetAxisAlignedBoundingBox(MeshGroups);
|
||||||
bool onBed = allBounds.minXYZ.z > -.001 && allBounds.minXYZ.z < .001; // really close to the bed
|
bool onBed = allBounds.minXYZ.z > -.001 && allBounds.minXYZ.z < .001; // really close to the bed
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
SliceSettingsWidget.SettingChanged.RegisterEvent(CheckSettingChanged, ref unregisterEvents);
|
SliceSettingsWidget.SettingChanged.RegisterEvent(CheckSettingChanged, ref unregisterEvents);
|
||||||
ApplicationController.Instance.ReloadAdvancedControlsPanelTrigger.RegisterEvent((s, e) => ClearGCode(), ref unregisterEvents);
|
ApplicationController.Instance.ReloadAdvancedControlsPanelTrigger.RegisterEvent((s, e) => ClearGCode(), ref unregisterEvents);
|
||||||
|
|
||||||
ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(CheckSettingChanged, ref unregisterEvents);
|
ActiveSliceSettings.ActivePrinterChanged.RegisterEvent(CheckSettingChanged, ref unregisterEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckSettingChanged(object sender, EventArgs e)
|
private void CheckSettingChanged(object sender, EventArgs e)
|
||||||
|
|
|
||||||
|
|
@ -1,341 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (c) 2014, Lars Brubaker
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer.
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
The views and conclusions contained in the software and documentation are those
|
|
||||||
of the authors and should not be interpreted as representing official policies,
|
|
||||||
either expressed or implied, of the FreeBSD Project.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using MatterHackers.Agg;
|
|
||||||
using MatterHackers.MatterControl.ConfigurationPage.PrintLeveling;
|
|
||||||
using MatterHackers.MatterControl.DataStorage;
|
|
||||||
using MatterHackers.MatterControl.PrinterCommunication;
|
|
||||||
using MatterHackers.MatterControl.SettingsManagement;
|
|
||||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
|
||||||
using MatterHackers.SerialPortCommunication.FrostedSerial;
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl
|
|
||||||
{
|
|
||||||
public class ActivePrinterProfile
|
|
||||||
{
|
|
||||||
public enum SlicingEngineTypes { Slic3r, CuraEngine, MatterSlice };
|
|
||||||
|
|
||||||
private static readonly SlicingEngineTypes defaultEngineType = SlicingEngineTypes.MatterSlice;
|
|
||||||
private static ActivePrinterProfile globalInstance = null;
|
|
||||||
|
|
||||||
public RootedObjectEventHandler ActivePrinterChanged = new RootedObjectEventHandler();
|
|
||||||
public RootedObjectEventHandler DoPrintLevelingChanged = new RootedObjectEventHandler();
|
|
||||||
|
|
||||||
// private so that it can only be gotten through the Instance
|
|
||||||
private ActivePrinterProfile()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private Printer activePrinter = null;
|
|
||||||
|
|
||||||
public Printer ActivePrinter
|
|
||||||
{
|
|
||||||
get { return activePrinter; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (activePrinter != value)
|
|
||||||
{
|
|
||||||
// If we have an active printer, run Disable otherwise skip to prevent empty ActiveSliceSettings due to null ActivePrinter
|
|
||||||
if (activePrinter != null)
|
|
||||||
{
|
|
||||||
PrinterConnectionAndCommunication.Instance.Disable();
|
|
||||||
}
|
|
||||||
|
|
||||||
activePrinter = value;
|
|
||||||
ValidateMaterialSettings();
|
|
||||||
ValidateQualitySettings();
|
|
||||||
|
|
||||||
if (activePrinter != null)
|
|
||||||
{
|
|
||||||
BedSettings.SetMakeAndModel(activePrinter.Make, activePrinter.Model);
|
|
||||||
}
|
|
||||||
|
|
||||||
globalInstance.OnActivePrinterChanged(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ActivePrinterProfile Instance
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (globalInstance == null)
|
|
||||||
{
|
|
||||||
globalInstance = new ActivePrinterProfile();
|
|
||||||
}
|
|
||||||
|
|
||||||
return globalInstance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ValidateQualitySettings()
|
|
||||||
{
|
|
||||||
if (activePrinter != null)
|
|
||||||
{
|
|
||||||
int index = activePrinter.QualityCollectionId;
|
|
||||||
SliceSettingsCollection collection = Datastore.Instance.dbSQLite.Table<SliceSettingsCollection>().Where(v => v.Id == index).Take(1).FirstOrDefault();
|
|
||||||
if (collection == null)
|
|
||||||
{
|
|
||||||
ActivePrinterProfile.Instance.ActiveQualitySettingsID = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ValidateMaterialSettings()
|
|
||||||
{
|
|
||||||
if (activePrinter != null && activePrinter.MaterialCollectionIds != null)
|
|
||||||
{
|
|
||||||
string[] activeMaterialPresets = activePrinter.MaterialCollectionIds.Split(',');
|
|
||||||
for (int i = 0; i < activeMaterialPresets.Count(); i++)
|
|
||||||
{
|
|
||||||
int index = 0;
|
|
||||||
Int32.TryParse(activeMaterialPresets[i], out index);
|
|
||||||
if (index != 0)
|
|
||||||
{
|
|
||||||
SliceSettingsCollection collection = Datastore.Instance.dbSQLite.Table<SliceSettingsCollection>().Where(v => v.Id == index).Take(1).FirstOrDefault();
|
|
||||||
if (collection == null)
|
|
||||||
{
|
|
||||||
ActivePrinterProfile.Instance.SetMaterialSetting(i + 1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetMaterialSetting(int extruderNumber1Based)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
if (extruderNumber1Based > 0
|
|
||||||
&& ActivePrinter != null)
|
|
||||||
{
|
|
||||||
string materialSettings = ActivePrinter.MaterialCollectionIds;
|
|
||||||
string[] materialSettingsList;
|
|
||||||
if (materialSettings != null)
|
|
||||||
{
|
|
||||||
materialSettingsList = materialSettings.Split(',');
|
|
||||||
if (materialSettingsList.Count() >= extruderNumber1Based)
|
|
||||||
{
|
|
||||||
Int32.TryParse(materialSettingsList[extruderNumber1Based - 1], out i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetMaterialSetting(int extruderPosition, int settingId)
|
|
||||||
{
|
|
||||||
string[] newMaterialSettingsArray;
|
|
||||||
string[] currentMaterialSettingsArray;
|
|
||||||
|
|
||||||
string materialSettings = ActivePrinter.MaterialCollectionIds;
|
|
||||||
|
|
||||||
if (materialSettings != null)
|
|
||||||
{
|
|
||||||
currentMaterialSettingsArray = materialSettings.Split(',');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
currentMaterialSettingsArray = new string[extruderPosition];
|
|
||||||
}
|
|
||||||
|
|
||||||
//Resize the array of material settings if necessary
|
|
||||||
if (currentMaterialSettingsArray.Count() < extruderPosition)
|
|
||||||
{
|
|
||||||
newMaterialSettingsArray = new string[extruderPosition];
|
|
||||||
for (int i = 0; i < currentMaterialSettingsArray.Length; i++)
|
|
||||||
{
|
|
||||||
newMaterialSettingsArray[i] = currentMaterialSettingsArray[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
newMaterialSettingsArray = currentMaterialSettingsArray;
|
|
||||||
}
|
|
||||||
newMaterialSettingsArray[extruderPosition - 1] = settingId.ToString();
|
|
||||||
|
|
||||||
ActivePrinter.MaterialCollectionIds = String.Join(",", newMaterialSettingsArray);
|
|
||||||
ActivePrinter.Commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int ActiveQualitySettingsID
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (ActivePrinter != null)
|
|
||||||
{
|
|
||||||
return ActivePrinter.QualityCollectionId;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (ActiveQualitySettingsID != value)
|
|
||||||
{
|
|
||||||
ActivePrinter.QualityCollectionId = value;
|
|
||||||
ActivePrinter.Commit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public SlicingEngineTypes ActiveSliceEngineType
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (ActivePrinter != null)
|
|
||||||
{
|
|
||||||
foreach (SlicingEngineTypes engine in SlicingEngineTypes.GetValues(typeof(SlicingEngineTypes)))
|
|
||||||
{
|
|
||||||
if (ActivePrinter.CurrentSlicingEngine == engine.ToString())
|
|
||||||
{
|
|
||||||
return engine;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// It is not set in the slice settings, so set it and save it.
|
|
||||||
ActivePrinter.CurrentSlicingEngine = defaultEngineType.ToString();
|
|
||||||
ActivePrinter.Commit();
|
|
||||||
}
|
|
||||||
return defaultEngineType;
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (ActiveSliceEngineType != value)
|
|
||||||
{
|
|
||||||
ActivePrinter.CurrentSlicingEngine = value.ToString();
|
|
||||||
ActivePrinter.Commit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public SliceEngineMapping ActiveSliceEngine
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
switch (ActiveSliceEngineType)
|
|
||||||
{
|
|
||||||
case SlicingEngineTypes.CuraEngine:
|
|
||||||
return EngineMappingCura.Instance;
|
|
||||||
|
|
||||||
case SlicingEngineTypes.MatterSlice:
|
|
||||||
return EngineMappingsMatterSlice.Instance;
|
|
||||||
|
|
||||||
case SlicingEngineTypes.Slic3r:
|
|
||||||
return Slic3rEngineMappings.Instance;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnActivePrinterChanged(EventArgs e)
|
|
||||||
{
|
|
||||||
ActivePrinterChanged.CallEvents(this, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool DoPrintLeveling
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (ActivePrinter != null)
|
|
||||||
{
|
|
||||||
return ActivePrinter.DoPrintLeveling;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (ActivePrinter != null && ActivePrinter.DoPrintLeveling != value)
|
|
||||||
{
|
|
||||||
ActivePrinter.DoPrintLeveling = value;
|
|
||||||
DoPrintLevelingChanged.CallEvents(this, null);
|
|
||||||
ActivePrinter.Commit();
|
|
||||||
|
|
||||||
if (DoPrintLeveling)
|
|
||||||
{
|
|
||||||
PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(ActivePrinterProfile.Instance.ActivePrinter);
|
|
||||||
PrintLevelingPlane.Instance.SetPrintLevelingEquation(
|
|
||||||
levelingData.SampledPosition0,
|
|
||||||
levelingData.SampledPosition1,
|
|
||||||
levelingData.SampledPosition2,
|
|
||||||
ActiveSliceSettings.Instance.PrintCenter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void CheckForAndDoAutoConnect()
|
|
||||||
{
|
|
||||||
bool connectionAvailable;
|
|
||||||
Printer autoConnectProfile = ActivePrinterProfile.GetAutoConnectProfile(out connectionAvailable);
|
|
||||||
if (autoConnectProfile != null)
|
|
||||||
{
|
|
||||||
ActivePrinterProfile.Instance.ActivePrinter = autoConnectProfile;
|
|
||||||
if (connectionAvailable)
|
|
||||||
{
|
|
||||||
PrinterConnectionAndCommunication.Instance.HaltConnectionThread();
|
|
||||||
PrinterConnectionAndCommunication.Instance.ConnectToActivePrinter();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Printer GetAutoConnectProfile(out bool connectionAvailable)
|
|
||||||
{
|
|
||||||
string[] comportNames = FrostedSerialPort.GetPortNames();
|
|
||||||
|
|
||||||
Printer printerToSelect = null;
|
|
||||||
connectionAvailable = false;
|
|
||||||
|
|
||||||
foreach (Printer printer in Datastore.Instance.dbSQLite.Query<Printer>("SELECT * FROM Printer;"))
|
|
||||||
{
|
|
||||||
if (printer.AutoConnectFlag)
|
|
||||||
{
|
|
||||||
printerToSelect = printer;
|
|
||||||
bool portIsAvailable = comportNames.Contains(printer.ComPort);
|
|
||||||
if (portIsAvailable)
|
|
||||||
{
|
|
||||||
// We found a printer that we can select and connect to.
|
|
||||||
connectionAvailable = true;
|
|
||||||
return printer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// return a printer we can connect to even though we can't connect
|
|
||||||
return printerToSelect;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -34,6 +34,7 @@ using MatterHackers.VectorMath;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using MatterHackers.MatterControl.ConfigurationPage.PrintLeveling;
|
using MatterHackers.MatterControl.ConfigurationPage.PrintLeveling;
|
||||||
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl.PrinterCommunication.Io
|
namespace MatterHackers.MatterControl.PrinterCommunication.Io
|
||||||
{
|
{
|
||||||
|
|
@ -90,7 +91,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
|
||||||
|
|
||||||
private string RunPrintLevelingTranslations(string lineBeingSent, PrinterMove currentDestination)
|
private string RunPrintLevelingTranslations(string lineBeingSent, PrinterMove currentDestination)
|
||||||
{
|
{
|
||||||
PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(ActivePrinterProfile.Instance.ActivePrinter);
|
PrintLevelingData levelingData = ActiveSliceSettings.Instance.PrintLevelingData;
|
||||||
if (levelingData != null)
|
if (levelingData != null)
|
||||||
{
|
{
|
||||||
switch (levelingData.CurrentPrinterLevelingSystem)
|
switch (levelingData.CurrentPrinterLevelingSystem)
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,8 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
|
||||||
queuedCommands.Add("G90; use absolute coordinates");
|
queuedCommands.Add("G90; use absolute coordinates");
|
||||||
queuedCommands.Add("G92 E0; reset the expected extruder position");
|
queuedCommands.Add("G92 E0; reset the expected extruder position");
|
||||||
queuedCommands.Add("M82; use absolute distance for extrusion");
|
queuedCommands.Add("M82; use absolute distance for extrusion");
|
||||||
queuedCommands.Add("M109 S{0}".FormatWith(ActiveSliceSettings.Instance.GetMaterialValue("temperature", 1)));
|
queuedCommands.Add("M109 S{0}".FormatWith(ActiveSliceSettings.Instance.GetExtruderTemperature(1)));
|
||||||
|
|
||||||
resumeState = ResumeState.Raising;
|
resumeState = ResumeState.Raising;
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
|
|
@ -194,7 +195,16 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
|
||||||
{
|
{
|
||||||
PrinterMove currentMove = GetPosition(lineToSend, lastDestination);
|
PrinterMove currentMove = GetPosition(lineToSend, lastDestination);
|
||||||
PrinterMove moveToSend = currentMove;
|
PrinterMove moveToSend = currentMove;
|
||||||
double feedRate = ActiveSliceSettings.Instance.GetActiveValueAsDouble("resume_first_layer_speed", 10) * 60;
|
|
||||||
|
double feedRate;
|
||||||
|
|
||||||
|
string firstLayerSpeed = ActiveSliceSettings.Instance.GetActiveValue("resume_first_layer_speed");
|
||||||
|
if (!double.TryParse(firstLayerSpeed, out feedRate))
|
||||||
|
{
|
||||||
|
feedRate = 10;
|
||||||
|
}
|
||||||
|
feedRate *= 60;
|
||||||
|
|
||||||
moveToSend.feedRate = feedRate;
|
moveToSend.feedRate = feedRate;
|
||||||
|
|
||||||
lineToSend = CreateMovementLine(moveToSend, lastDestination);
|
lineToSend = CreateMovementLine(moveToSend, lastDestination);
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
||||||
|
|
||||||
private bool atxPowerIsOn = false;
|
private bool atxPowerIsOn = false;
|
||||||
|
|
||||||
private const int MAX_EXTRUDERS = 16;
|
internal const int MAX_EXTRUDERS = 16;
|
||||||
|
|
||||||
private const int MAX_INVALID_CONNECTION_CHARS = 3;
|
private const int MAX_INVALID_CONNECTION_CHARS = 3;
|
||||||
|
|
||||||
|
|
@ -954,17 +954,8 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Printer ActivePrinter
|
// TODO: Consider having callers use the source rather than this proxy? Maybe better to change after arriving on a final type and location for printer settings
|
||||||
{
|
public SettingsProfile ActivePrinter => ActiveSliceSettings.Instance;
|
||||||
get
|
|
||||||
{
|
|
||||||
return ActivePrinterProfile.Instance.ActivePrinter;
|
|
||||||
}
|
|
||||||
private set
|
|
||||||
{
|
|
||||||
ActivePrinterProfile.Instance.ActivePrinter = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int NumberOfLinesInCurrentPrint
|
private int NumberOfLinesInCurrentPrint
|
||||||
{
|
{
|
||||||
|
|
@ -1056,7 +1047,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectToPrinter(PrinterConnectionAndCommunication.Instance.ActivePrinter);
|
ConnectToPrinter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1173,14 +1164,13 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
||||||
public double GetActualExtruderTemperature(int extruderIndex0Based)
|
public double GetActualExtruderTemperature(int extruderIndex0Based)
|
||||||
{
|
{
|
||||||
extruderIndex0Based = Math.Min(extruderIndex0Based, MAX_EXTRUDERS - 1);
|
extruderIndex0Based = Math.Min(extruderIndex0Based, MAX_EXTRUDERS - 1);
|
||||||
|
|
||||||
return actualExtruderTemperature[extruderIndex0Based];
|
return actualExtruderTemperature[extruderIndex0Based];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public double GetTargetExtruderTemperature(int extruderIndex0Based)
|
public double GetTargetExtruderTemperature(int extruderIndex0Based)
|
||||||
{
|
{
|
||||||
extruderIndex0Based = Math.Min(extruderIndex0Based, MAX_EXTRUDERS - 1);
|
extruderIndex0Based = Math.Min(extruderIndex0Based, MAX_EXTRUDERS - 1);
|
||||||
|
|
||||||
return targetExtruderTemperature[extruderIndex0Based];
|
return targetExtruderTemperature[extruderIndex0Based];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1332,23 +1322,22 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
||||||
{
|
{
|
||||||
PrintFinished.CallEvents(this, new PrintItemWrapperEventArgs(this.ActivePrintItem));
|
PrintFinished.CallEvents(this, new PrintItemWrapperEventArgs(this.ActivePrintItem));
|
||||||
|
|
||||||
bool resetValue = false;
|
// TODO: Shouldn't this logic be in the UI layer where the controls are owned and hooked in via PrintFinished?
|
||||||
foreach (KeyValuePair<String, SliceSetting> currentSetting in ActiveSliceSettings.Instance.DefaultSettings)
|
bool oneOrMoreValuesReset = false;
|
||||||
|
foreach (var kvp in ActiveSliceSettings.Instance.BaseLayer)
|
||||||
{
|
{
|
||||||
string currentValue = ActiveSliceSettings.Instance.GetActiveValue(currentSetting.Key);
|
string currentValue = ActiveSliceSettings.Instance.GetActiveValue(kvp.Key);
|
||||||
|
|
||||||
bool valueIsClear = currentValue == "0" | currentValue == "";
|
bool valueIsClear = currentValue == "0" | currentValue == "";
|
||||||
OrganizerSettingsData data = SliceSettingsOrganizer.Instance.GetSettingsData(currentSetting.Key);
|
OrganizerSettingsData data = SliceSettingsOrganizer.Instance.GetSettingsData(kvp.Key);
|
||||||
if (data != null
|
if (data?.ResetAtEndOfPrint == true && !valueIsClear)
|
||||||
&& data.ResetAtEndOfPrint
|
|
||||||
&& !valueIsClear)
|
|
||||||
{
|
{
|
||||||
resetValue = true;
|
oneOrMoreValuesReset = true;
|
||||||
ActiveSliceSettings.Instance.SaveValue(currentSetting.Key, "", RequestedSettingsLayer.User);
|
ActiveSliceSettings.Instance.ClearValue(kvp.Key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(resetValue)
|
if(oneOrMoreValuesReset)
|
||||||
{
|
{
|
||||||
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
||||||
}
|
}
|
||||||
|
|
@ -1360,12 +1349,12 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
||||||
{
|
{
|
||||||
// If leveling is required or is currently on
|
// If leveling is required or is currently on
|
||||||
if (ActiveSliceSettings.Instance.LevelingRequiredToPrint
|
if (ActiveSliceSettings.Instance.LevelingRequiredToPrint
|
||||||
|| ActivePrinterProfile.Instance.DoPrintLeveling)
|
|| ActiveSliceSettings.Instance.DoPrintLeveling)
|
||||||
{
|
{
|
||||||
PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(ActivePrinterProfile.Instance.ActivePrinter);
|
PrintLevelingData levelingData = ActiveSliceSettings.Instance.PrintLevelingData;
|
||||||
if(!levelingData.HasBeenRun())
|
if(levelingData?.HasBeenRun() != true)
|
||||||
{
|
{
|
||||||
levelingData.RunLevelingWizard();
|
LevelWizardBase.ShowPrintLevelWizard();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1548,7 +1537,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
||||||
// current approach results in unpredictable behavior if the caller fails to close the connection
|
// current approach results in unpredictable behavior if the caller fails to close the connection
|
||||||
if (serialPort == null && this.ActivePrinter != null)
|
if (serialPort == null && this.ActivePrinter != null)
|
||||||
{
|
{
|
||||||
IFrostedSerialPort resetSerialPort = FrostedSerialPortFactory.GetAppropriateFactory(ActivePrinterProfile.Instance.ActivePrinter.DriverType).Create(this.ActivePrinter.ComPort);
|
IFrostedSerialPort resetSerialPort = FrostedSerialPortFactory.GetAppropriateFactory(this.ActivePrinter.DriverType).Create(this.ActivePrinter.ComPort);
|
||||||
resetSerialPort.Open();
|
resetSerialPort.Open();
|
||||||
|
|
||||||
Thread.Sleep(500);
|
Thread.Sleep(500);
|
||||||
|
|
@ -1658,12 +1647,12 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
||||||
|
|
||||||
// run the print leveling wizard if we need to for this printer
|
// run the print leveling wizard if we need to for this printer
|
||||||
if (ActiveSliceSettings.Instance.LevelingRequiredToPrint
|
if (ActiveSliceSettings.Instance.LevelingRequiredToPrint
|
||||||
|| ActivePrinterProfile.Instance.DoPrintLeveling)
|
|| ActiveSliceSettings.Instance.DoPrintLeveling)
|
||||||
{
|
{
|
||||||
PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(ActivePrinterProfile.Instance.ActivePrinter);
|
PrintLevelingData levelingData = ActiveSliceSettings.Instance.PrintLevelingData;
|
||||||
if (!levelingData.HasBeenRun())
|
if (levelingData?.HasBeenRun() != true)
|
||||||
{
|
{
|
||||||
UiThread.RunOnIdle(() => levelingData.RunLevelingWizard() );
|
UiThread.RunOnIdle(LevelWizardBase.ShowPrintLevelWizard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1840,7 +1829,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
||||||
{
|
{
|
||||||
// We reset the board while attempting to connect, so now we don't have a serial port.
|
// We reset the board while attempting to connect, so now we don't have a serial port.
|
||||||
// Create one and do the DTR to reset
|
// Create one and do the DTR to reset
|
||||||
var resetSerialPort = FrostedSerialPortFactory.GetAppropriateFactory(ActivePrinterProfile.Instance.ActivePrinter.DriverType).Create(this.ActivePrinter.ComPort);
|
var resetSerialPort = FrostedSerialPortFactory.GetAppropriateFactory(this.ActivePrinter.DriverType).Create(this.ActivePrinter.ComPort);
|
||||||
resetSerialPort.Open();
|
resetSerialPort.Open();
|
||||||
|
|
||||||
Thread.Sleep(500);
|
Thread.Sleep(500);
|
||||||
|
|
@ -2202,7 +2191,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
||||||
}
|
}
|
||||||
|
|
||||||
bool serialPortIsAvailable = SerialPortIsAvailable(serialPortName);
|
bool serialPortIsAvailable = SerialPortIsAvailable(serialPortName);
|
||||||
bool serialPortIsAlreadyOpen = FrostedSerialPortFactory.GetAppropriateFactory(ActivePrinterProfile.Instance.ActivePrinter.DriverType).SerialPortAlreadyOpen(serialPortName);
|
bool serialPortIsAlreadyOpen = FrostedSerialPortFactory.GetAppropriateFactory(this.ActivePrinter.DriverType).SerialPortAlreadyOpen(serialPortName);
|
||||||
|
|
||||||
if (serialPortIsAvailable && !serialPortIsAlreadyOpen)
|
if (serialPortIsAvailable && !serialPortIsAlreadyOpen)
|
||||||
{
|
{
|
||||||
|
|
@ -2210,7 +2199,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
serialPort = FrostedSerialPortFactory.GetAppropriateFactory(ActivePrinterProfile.Instance.ActivePrinter.DriverType).CreateAndOpen(serialPortName, baudRate, true);
|
serialPort = FrostedSerialPortFactory.GetAppropriateFactory(this.ActivePrinter.DriverType).CreateAndOpen(serialPortName, baudRate, true);
|
||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
ToggleHighLowHeigh(serialPort);
|
ToggleHighLowHeigh(serialPort);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -2299,7 +2288,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ConnectToPrinter(Printer printerRecord)
|
private void ConnectToPrinter()
|
||||||
{
|
{
|
||||||
PrinterOutputCache.Instance.Clear();
|
PrinterOutputCache.Instance.Clear();
|
||||||
LinesToWriteQueue.Clear();
|
LinesToWriteQueue.Clear();
|
||||||
|
|
@ -2504,9 +2493,10 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
||||||
|
|
||||||
if (activePrintTask == null)
|
if (activePrintTask == null)
|
||||||
{
|
{
|
||||||
|
// TODO: Fix printerItemID int requirement
|
||||||
activePrintTask = new PrintTask();
|
activePrintTask = new PrintTask();
|
||||||
activePrintTask.PrintStart = DateTime.Now;
|
activePrintTask.PrintStart = DateTime.Now;
|
||||||
activePrintTask.PrinterId = ActivePrinterProfile.Instance.ActivePrinter.Id;
|
activePrintTask.PrinterId = this.ActivePrinter.Id.GetHashCode();
|
||||||
activePrintTask.PrintName = ActivePrintItem.PrintItem.Name;
|
activePrintTask.PrintName = ActivePrintItem.PrintItem.Name;
|
||||||
activePrintTask.PrintItemId = ActivePrintItem.PrintItem.Id;
|
activePrintTask.PrintItemId = ActivePrintItem.PrintItem.Id;
|
||||||
activePrintTask.PrintingGCodeFileName = ActivePrintItem.GetGCodePathAndFileName();
|
activePrintTask.PrintingGCodeFileName = ActivePrintItem.GetGCodePathAndFileName();
|
||||||
|
|
|
||||||
|
|
@ -166,10 +166,12 @@ namespace MatterHackers.MatterControl.PrinterControls
|
||||||
|
|
||||||
internal static IEnumerable<CustomCommands> GetMacros()
|
internal static IEnumerable<CustomCommands> GetMacros()
|
||||||
{
|
{
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter != null)
|
if (!string.IsNullOrEmpty(ActiveSliceSettings.Instance?.Id))
|
||||||
{
|
{
|
||||||
|
// TODO: Hook macros into new settings system
|
||||||
|
|
||||||
//Retrieve a list of macros from the database
|
//Retrieve a list of macros from the database
|
||||||
string query = string.Format("SELECT * FROM CustomCommands WHERE PrinterId = {0};", ActivePrinterProfile.Instance.ActivePrinter.Id);
|
string query = string.Format("SELECT * FROM CustomCommands WHERE PrinterId = {0};", ActiveSliceSettings.Instance.Id);
|
||||||
|
|
||||||
return Datastore.Instance.dbSQLite.Query<CustomCommands>(query);
|
return Datastore.Instance.dbSQLite.Query<CustomCommands>(query);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ using MatterHackers.Agg.UI;
|
||||||
using MatterHackers.Localizations;
|
using MatterHackers.Localizations;
|
||||||
using MatterHackers.MatterControl.CustomWidgets;
|
using MatterHackers.MatterControl.CustomWidgets;
|
||||||
using MatterHackers.MatterControl.PrinterCommunication;
|
using MatterHackers.MatterControl.PrinterCommunication;
|
||||||
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||||
using MatterHackers.MatterControl.Utilities;
|
using MatterHackers.MatterControl.Utilities;
|
||||||
using MatterHackers.VectorMath;
|
using MatterHackers.VectorMath;
|
||||||
using System;
|
using System;
|
||||||
|
|
@ -88,10 +89,8 @@ namespace MatterHackers.MatterControl.PrinterControls
|
||||||
{
|
{
|
||||||
PrinterConnectionAndCommunication.Instance.OffsetStreamChanged -= OffsetStreamChanged;
|
PrinterConnectionAndCommunication.Instance.OffsetStreamChanged -= OffsetStreamChanged;
|
||||||
|
|
||||||
if (unregisterEvents != null)
|
unregisterEvents?.Invoke(this, null);
|
||||||
{
|
|
||||||
unregisterEvents(this, null);
|
|
||||||
}
|
|
||||||
base.OnClosed(e);
|
base.OnClosed(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -171,9 +170,9 @@ namespace MatterHackers.MatterControl.PrinterControls
|
||||||
private static string GetMovementSpeedsString()
|
private static string GetMovementSpeedsString()
|
||||||
{
|
{
|
||||||
string presets = "x,3000,y,3000,z,315,e0,150"; // stored x,value,y,value,z,value,e1,value,e2,value,e3,value,...
|
string presets = "x,3000,y,3000,z,315,e0,150"; // stored x,value,y,value,z,value,e1,value,e2,value,e3,value,...
|
||||||
if (PrinterConnectionAndCommunication.Instance != null && ActivePrinterProfile.Instance.ActivePrinter != null)
|
if (PrinterConnectionAndCommunication.Instance != null && ActiveSliceSettings.Instance != null)
|
||||||
{
|
{
|
||||||
string savedSettings = ActivePrinterProfile.Instance.ActivePrinter.ManualMovementSpeeds;
|
string savedSettings = ActiveSliceSettings.Instance.ManualMovementSpeeds;
|
||||||
if (savedSettings != null && savedSettings != "")
|
if (savedSettings != null && savedSettings != "")
|
||||||
{
|
{
|
||||||
presets = savedSettings;
|
presets = savedSettings;
|
||||||
|
|
@ -188,8 +187,7 @@ namespace MatterHackers.MatterControl.PrinterControls
|
||||||
StringEventArgs stringEvent = e as StringEventArgs;
|
StringEventArgs stringEvent = e as StringEventArgs;
|
||||||
if (stringEvent != null && stringEvent.Data != null)
|
if (stringEvent != null && stringEvent.Data != null)
|
||||||
{
|
{
|
||||||
ActivePrinterProfile.Instance.ActivePrinter.ManualMovementSpeeds = stringEvent.Data;
|
ActiveSliceSettings.Instance.ManualMovementSpeeds = stringEvent.Data;
|
||||||
ActivePrinterProfile.Instance.ActivePrinter.Commit();
|
|
||||||
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,7 @@ namespace MatterHackers.MatterControl.PrinterControls
|
||||||
temperatureGroupBox.AddChild(mainContainer);
|
temperatureGroupBox.AddChild(mainContainer);
|
||||||
RGBA_Bytes separatorLineColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 100);
|
RGBA_Bytes separatorLineColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 100);
|
||||||
|
|
||||||
int numberOfHeatedExtruders = 1;
|
int numberOfHeatedExtruders = ActiveSliceSettings.Instance.ExtruderCount;
|
||||||
if (!ActiveSliceSettings.Instance.ExtrudersShareTemperature)
|
|
||||||
{
|
|
||||||
numberOfHeatedExtruders = ActiveSliceSettings.Instance.ExtruderCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (numberOfHeatedExtruders > 1)
|
if (numberOfHeatedExtruders > 1)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < numberOfHeatedExtruders; i++)
|
for (int i = 0; i < numberOfHeatedExtruders; i++)
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ namespace MatterHackers.MatterControl
|
||||||
textImageButtonFactory.FixedHeight = 30 * TextWidget.GlobalPointSizeScaleRatio;
|
textImageButtonFactory.FixedHeight = 30 * TextWidget.GlobalPointSizeScaleRatio;
|
||||||
|
|
||||||
// put in the movement edit controls
|
// put in the movement edit controls
|
||||||
PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(ActivePrinterProfile.Instance.ActivePrinter);
|
PrintLevelingData levelingData = ActiveSliceSettings.Instance.PrintLevelingData;
|
||||||
if (EditSamplePositionList(levelingData))
|
if (EditSamplePositionList(levelingData))
|
||||||
{
|
{
|
||||||
for (int i = 0; i < levelingData.SampledPositions.Count; i++)
|
for (int i = 0; i < levelingData.SampledPositions.Count; i++)
|
||||||
|
|
@ -201,7 +201,7 @@ namespace MatterHackers.MatterControl
|
||||||
|
|
||||||
private void DoSave_Click()
|
private void DoSave_Click()
|
||||||
{
|
{
|
||||||
PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(ActivePrinterProfile.Instance.ActivePrinter);
|
PrintLevelingData levelingData = ActiveSliceSettings.Instance.PrintLevelingData;
|
||||||
|
|
||||||
if (EditSamplePositionList(levelingData))
|
if (EditSamplePositionList(levelingData))
|
||||||
{
|
{
|
||||||
|
|
@ -209,22 +209,16 @@ namespace MatterHackers.MatterControl
|
||||||
{
|
{
|
||||||
levelingData.SampledPositions[i] = positions[i];
|
levelingData.SampledPositions[i] = positions[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
levelingData.Commit();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
levelingData.SampledPosition0 = positions[0];
|
levelingData.SampledPosition0 = positions[0];
|
||||||
levelingData.SampledPosition1 = positions[1];
|
levelingData.SampledPosition1 = positions[1];
|
||||||
levelingData.SampledPosition2 = positions[2];
|
levelingData.SampledPosition2 = positions[2];
|
||||||
|
|
||||||
PrintLevelingPlane.Instance.SetPrintLevelingEquation(
|
|
||||||
levelingData.SampledPosition0,
|
|
||||||
levelingData.SampledPosition1,
|
|
||||||
levelingData.SampledPosition2,
|
|
||||||
ActiveSliceSettings.Instance.PrintCenter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ActiveSliceSettings.Instance.PrintLevelingData = levelingData;
|
||||||
|
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ using MatterHackers.MatterControl.CustomWidgets;
|
||||||
using MatterHackers.MatterControl.DataStorage;
|
using MatterHackers.MatterControl.DataStorage;
|
||||||
using MatterHackers.MatterControl.FieldValidation;
|
using MatterHackers.MatterControl.FieldValidation;
|
||||||
using MatterHackers.MatterControl.PrinterControls;
|
using MatterHackers.MatterControl.PrinterControls;
|
||||||
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||||
using MatterHackers.VectorMath;
|
using MatterHackers.VectorMath;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
@ -212,10 +213,14 @@ namespace MatterHackers.MatterControl
|
||||||
|
|
||||||
private void initMacro()
|
private void initMacro()
|
||||||
{
|
{
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter != null)
|
if (ActiveSliceSettings.Instance != null)
|
||||||
{
|
{
|
||||||
|
// TODO: Review bindings to int printerID
|
||||||
|
int printerID;
|
||||||
|
int.TryParse(ActiveSliceSettings.Instance.Id, out printerID);
|
||||||
|
|
||||||
windowController.ActiveMacro = new CustomCommands();
|
windowController.ActiveMacro = new CustomCommands();
|
||||||
windowController.ActiveMacro.PrinterId = ActivePrinterProfile.Instance.ActivePrinter.Id;
|
windowController.ActiveMacro.PrinterId = printerID;
|
||||||
windowController.ActiveMacro.Name = "Home All";
|
windowController.ActiveMacro.Name = "Home All";
|
||||||
windowController.ActiveMacro.Value = "G28 ; Home All Axes";
|
windowController.ActiveMacro.Value = "G28 ; Home All Axes";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,7 @@ namespace MatterHackers.MatterControl
|
||||||
|
|
||||||
private void SetVisibleControls()
|
private void SetVisibleControls()
|
||||||
{
|
{
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter == null)
|
if (ActiveSliceSettings.Instance == null)
|
||||||
{
|
{
|
||||||
// no printer selected
|
// no printer selected
|
||||||
foreach (DisableableWidget extruderTemperatureControlWidget in temperatureControlsContainer.ExtruderWidgetContainers)
|
foreach (DisableableWidget extruderTemperatureControlWidget in temperatureControlsContainer.ExtruderWidgetContainers)
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ using MatterHackers.Agg.UI;
|
||||||
using MatterHackers.Agg.VertexSource;
|
using MatterHackers.Agg.VertexSource;
|
||||||
using MatterHackers.Localizations;
|
using MatterHackers.Localizations;
|
||||||
using MatterHackers.MatterControl.DataStorage;
|
using MatterHackers.MatterControl.DataStorage;
|
||||||
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||||
using MatterHackers.SerialPortCommunication.FrostedSerial;
|
using MatterHackers.SerialPortCommunication.FrostedSerial;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
@ -49,9 +50,9 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
|
|
||||||
public class PrinterSelectRadioButton : RadioButton
|
public class PrinterSelectRadioButton : RadioButton
|
||||||
{
|
{
|
||||||
public Printer printer;
|
public PrinterInfo printer;
|
||||||
|
|
||||||
public PrinterSelectRadioButton(Printer printer)
|
public PrinterSelectRadioButton(PrinterInfo printer)
|
||||||
: base(printer.Name)
|
: base(printer.Name)
|
||||||
{
|
{
|
||||||
this.printer = printer;
|
this.printer = printer;
|
||||||
|
|
@ -131,9 +132,9 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
|
|
||||||
public class PrinterActionLink : ActionLink
|
public class PrinterActionLink : ActionLink
|
||||||
{
|
{
|
||||||
public Printer LinkedPrinter;
|
public PrinterInfo LinkedPrinter;
|
||||||
|
|
||||||
public PrinterActionLink(string text, Printer printer, int fontSize = 10)
|
public PrinterActionLink(string text, PrinterInfo printer, int fontSize = 10)
|
||||||
: base(text, fontSize)
|
: base(text, fontSize)
|
||||||
{
|
{
|
||||||
this.LinkedPrinter = printer;
|
this.LinkedPrinter = printer;
|
||||||
|
|
@ -247,23 +248,37 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
protected List<SerialPortIndexRadioButton> SerialPortButtonsList = new List<SerialPortIndexRadioButton>();
|
protected List<SerialPortIndexRadioButton> SerialPortButtonsList = new List<SerialPortIndexRadioButton>();
|
||||||
private bool printerComPortIsAvailable = false;
|
private bool printerComPortIsAvailable = false;
|
||||||
|
|
||||||
protected GuiWidget containerWindowToClose;
|
|
||||||
protected RGBA_Bytes defaultTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
|
||||||
protected RGBA_Bytes defaultBackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
|
||||||
protected RGBA_Bytes subContainerTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
|
||||||
protected RGBA_Bytes labelBackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
|
||||||
protected RGBA_Bytes linkTextColor = ActiveTheme.Instance.SecondaryAccentColor;
|
|
||||||
protected ConnectionWindow windowController;
|
|
||||||
public ActionLinkFactory actionLinkFactory = new ActionLinkFactory();
|
|
||||||
|
|
||||||
private event EventHandler unregisterEvents;
|
private event EventHandler unregisterEvents;
|
||||||
|
|
||||||
public ConnectionWidgetBase(ConnectionWindow windowController, GuiWidget containerWindowToClose)
|
private PrinterInfo activePrinter = null;
|
||||||
: base()
|
protected PrinterInfo ActivePrinter
|
||||||
{
|
{
|
||||||
this.windowController = windowController;
|
get
|
||||||
this.containerWindowToClose = containerWindowToClose;
|
{
|
||||||
ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
if(activePrinter == null)
|
||||||
|
{
|
||||||
|
var settings = ActiveSliceSettings.Instance;
|
||||||
|
activePrinter = new PrinterInfo
|
||||||
|
{
|
||||||
|
AutoConnectFlag = settings.AutoConnectFlag,
|
||||||
|
BaudRate = settings.BaudRate,
|
||||||
|
ComPort = settings.ComPort,
|
||||||
|
DriverType = settings.DriverType,
|
||||||
|
Id = settings.Id,
|
||||||
|
Name = settings.Name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return activePrinter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ConnectionWizard connectionWizard;
|
||||||
|
|
||||||
|
public ConnectionWidgetBase(ConnectionWizard wizard)
|
||||||
|
{
|
||||||
|
this.connectionWizard = wizard;
|
||||||
|
ActiveTheme.Instance.ThemeChanged.RegisterEvent((s,e) => this.Invalidate(), ref unregisterEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetPrinterRecordCount()
|
public int GetPrinterRecordCount()
|
||||||
|
|
@ -271,18 +286,9 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
return Datastore.Instance.RecordCount("Printer");
|
return Datastore.Instance.RecordCount("Printer");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ThemeChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
this.linkTextColor = ActiveTheme.Instance.PrimaryAccentColor;
|
|
||||||
this.Invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnClosed(EventArgs e)
|
public override void OnClosed(EventArgs e)
|
||||||
{
|
{
|
||||||
if (unregisterEvents != null)
|
unregisterEvents?.Invoke(this, null);
|
||||||
{
|
|
||||||
unregisterEvents(this, null);
|
|
||||||
}
|
|
||||||
base.OnClosed(e);
|
base.OnClosed(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -292,7 +298,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
{
|
{
|
||||||
HAnchor = HAnchor.ParentLeft,
|
HAnchor = HAnchor.ParentLeft,
|
||||||
Margin = new BorderDouble(3, 3, 5, 3),
|
Margin = new BorderDouble(3, 3, 5, 3),
|
||||||
TextColor = this.subContainerTextColor,
|
TextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||||
Checked = isActivePrinterPort
|
Checked = isActivePrinterPort
|
||||||
};
|
};
|
||||||
return comPortOption;
|
return comPortOption;
|
||||||
|
|
@ -361,7 +367,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
{
|
{
|
||||||
TextWidget comPortOption = new TextWidget(LocalizedString.Get("No COM ports available"));
|
TextWidget comPortOption = new TextWidget(LocalizedString.Get("No COM ports available"));
|
||||||
comPortOption.Margin = new BorderDouble(3, 6, 5, 6);
|
comPortOption.Margin = new BorderDouble(3, 6, 5, 6);
|
||||||
comPortOption.TextColor = this.subContainerTextColor;
|
comPortOption.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||||
comPortContainer.AddChild(comPortOption);
|
comPortContainer.AddChild(comPortOption);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,232 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (c) 2014, Kevin Pope
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer.
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
The views and conclusions contained in the software and documentation are those
|
|
||||||
of the authors and should not be interpreted as representing official policies,
|
|
||||||
either expressed or implied, of the FreeBSD Project.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using MatterHackers.Agg;
|
|
||||||
using MatterHackers.Agg.UI;
|
|
||||||
using MatterHackers.Localizations;
|
|
||||||
using MatterHackers.MatterControl.CustomWidgets;
|
|
||||||
using MatterHackers.MatterControl.DataStorage;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|
||||||
{
|
|
||||||
public class ChooseConnectionWidget : ConnectionWidgetBase
|
|
||||||
{
|
|
||||||
private FlowLayoutWidget ConnectionControlContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
|
||||||
|
|
||||||
private List<GuiWidget> radioButtonsOfKnownPrinters = new List<GuiWidget>();
|
|
||||||
private TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
|
|
||||||
private TextImageButtonFactory editButtonFactory = new TextImageButtonFactory();
|
|
||||||
private Button closeButton;
|
|
||||||
|
|
||||||
private bool editMode;
|
|
||||||
|
|
||||||
public ChooseConnectionWidget(ConnectionWindow windowController, SystemWindow container, bool editMode = false)
|
|
||||||
: base(windowController, container)
|
|
||||||
{
|
|
||||||
{
|
|
||||||
this.editMode = editMode;
|
|
||||||
|
|
||||||
textImageButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
|
||||||
textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
|
||||||
textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
|
||||||
textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
|
||||||
textImageButtonFactory.borderWidth = 0;
|
|
||||||
|
|
||||||
editButtonFactory.normalTextColor = ActiveTheme.Instance.SecondaryAccentColor;
|
|
||||||
editButtonFactory.hoverTextColor = RGBA_Bytes.White;
|
|
||||||
editButtonFactory.disabledTextColor = ActiveTheme.Instance.SecondaryAccentColor;
|
|
||||||
editButtonFactory.pressedTextColor = RGBA_Bytes.White;
|
|
||||||
editButtonFactory.borderWidth = 0;
|
|
||||||
editButtonFactory.FixedWidth = 60 * TextWidget.GlobalPointSizeScaleRatio;
|
|
||||||
|
|
||||||
this.AnchorAll();
|
|
||||||
this.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
|
|
||||||
this.Padding = new BorderDouble(0); //To be re-enabled once native borders are turned off
|
|
||||||
|
|
||||||
|
|
||||||
GuiWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
|
||||||
mainContainer.AnchorAll();
|
|
||||||
mainContainer.Padding = new BorderDouble(3, 0, 3, 5);
|
|
||||||
mainContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
|
||||||
|
|
||||||
FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight);
|
|
||||||
headerRow.HAnchor = HAnchor.ParentLeftRight;
|
|
||||||
headerRow.Margin = new BorderDouble(0, 3, 0, 0);
|
|
||||||
headerRow.Padding = new BorderDouble(0, 3, 0, 0);
|
|
||||||
|
|
||||||
{
|
|
||||||
string chooseThreeDPrinterConfigLabel = LocalizedString.Get("Choose a 3D Printer Configuration");
|
|
||||||
string chooseThreeDPrinterConfigFull = string.Format("{0}:", chooseThreeDPrinterConfigLabel);
|
|
||||||
|
|
||||||
TextWidget elementHeader = new TextWidget(string.Format(chooseThreeDPrinterConfigFull), pointSize: 14);
|
|
||||||
elementHeader.TextColor = this.defaultTextColor;
|
|
||||||
elementHeader.HAnchor = HAnchor.ParentLeftRight;
|
|
||||||
elementHeader.VAnchor = Agg.UI.VAnchor.ParentCenter;
|
|
||||||
|
|
||||||
headerRow.AddChild(elementHeader);
|
|
||||||
}
|
|
||||||
|
|
||||||
FlowLayoutWidget editButtonRow = new FlowLayoutWidget(FlowDirection.LeftToRight);
|
|
||||||
editButtonRow.BackgroundColor = ActiveTheme.Instance.TransparentDarkOverlay;
|
|
||||||
editButtonRow.HAnchor = HAnchor.ParentLeftRight;
|
|
||||||
editButtonRow.Margin = new BorderDouble(0, 3, 0, 0);
|
|
||||||
editButtonRow.Padding = new BorderDouble(0, 3, 0, 0);
|
|
||||||
|
|
||||||
Button enterLeaveEditModeButton;
|
|
||||||
if (!this.editMode)
|
|
||||||
{
|
|
||||||
enterLeaveEditModeButton = editButtonFactory.Generate(LocalizedString.Get("Edit"), centerText: true);
|
|
||||||
enterLeaveEditModeButton.Click += EditModeOnLink_Click;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
enterLeaveEditModeButton = editButtonFactory.Generate(LocalizedString.Get("Done"), centerText: true);
|
|
||||||
enterLeaveEditModeButton.Click += EditModeOffLink_Click;
|
|
||||||
}
|
|
||||||
|
|
||||||
editButtonRow.AddChild(enterLeaveEditModeButton);
|
|
||||||
|
|
||||||
//To do - replace with scrollable widget
|
|
||||||
FlowLayoutWidget printerListContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
|
||||||
//ListBox printerListContainer = new ListBox();
|
|
||||||
{
|
|
||||||
printerListContainer.HAnchor = HAnchor.ParentLeftRight;
|
|
||||||
printerListContainer.VAnchor = VAnchor.FitToChildren;
|
|
||||||
printerListContainer.Padding = new BorderDouble(3);
|
|
||||||
printerListContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
|
|
||||||
|
|
||||||
|
|
||||||
//Get a list of printer records and add them to radio button list
|
|
||||||
foreach (Printer printer in GetAllPrinters())
|
|
||||||
{
|
|
||||||
PrinterListItem printerListItem;
|
|
||||||
if (this.editMode)
|
|
||||||
{
|
|
||||||
printerListItem = new PrinterListItemEdit(printer, this.windowController);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printerListItem = new PrinterListItemView(printer, this.windowController);
|
|
||||||
}
|
|
||||||
|
|
||||||
printerListContainer.AddChild(printerListItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FlowLayoutWidget buttonContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
|
|
||||||
buttonContainer.HAnchor = HAnchor.ParentLeft | HAnchor.ParentRight;
|
|
||||||
buttonContainer.Margin = new BorderDouble(0, 3);
|
|
||||||
{
|
|
||||||
closeButton = textImageButtonFactory.Generate(LocalizedString.Get("Close"));
|
|
||||||
|
|
||||||
Button addPrinterButton = textImageButtonFactory.Generate(LocalizedString.Get("Add"), "icon_circle_plus.png");
|
|
||||||
addPrinterButton.Name = "Add new printer button";
|
|
||||||
addPrinterButton.ToolTipText = "Add a new Printer Profile".Localize();
|
|
||||||
addPrinterButton.Click += new EventHandler(AddConnectionLink_Click);
|
|
||||||
|
|
||||||
Button refreshListButton = textImageButtonFactory.Generate(LocalizedString.Get("Refresh"));
|
|
||||||
refreshListButton.Click += new EventHandler(EditModeOffLink_Click);
|
|
||||||
|
|
||||||
//Add buttons to ButtonContainer
|
|
||||||
buttonContainer.AddChild(addPrinterButton);
|
|
||||||
|
|
||||||
if (!this.editMode)
|
|
||||||
{
|
|
||||||
buttonContainer.AddChild(refreshListButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
buttonContainer.AddChild(new HorizontalSpacer());
|
|
||||||
buttonContainer.AddChild(closeButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
ScrollableWidget printerListScrollArea = new ScrollableWidget(true);
|
|
||||||
printerListScrollArea.ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
|
|
||||||
printerListScrollArea.AnchorAll();
|
|
||||||
printerListScrollArea.AddChild(printerListContainer);
|
|
||||||
|
|
||||||
FlowLayoutWidget printerListScrollContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
|
||||||
printerListScrollContainer.HAnchor = HAnchor.ParentLeftRight;
|
|
||||||
printerListScrollContainer.VAnchor = VAnchor.ParentBottomTop;
|
|
||||||
printerListScrollContainer.Padding = new BorderDouble(3);
|
|
||||||
printerListScrollContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
|
|
||||||
|
|
||||||
mainContainer.AddChild(headerRow);
|
|
||||||
mainContainer.AddChild(editButtonRow);
|
|
||||||
mainContainer.AddChild(printerListScrollContainer);
|
|
||||||
printerListScrollContainer.AddChild(printerListScrollArea);
|
|
||||||
mainContainer.AddChild(buttonContainer);
|
|
||||||
|
|
||||||
this.AddChild(mainContainer);
|
|
||||||
|
|
||||||
BindCloseButtonClick();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void BindCloseButtonClick()
|
|
||||||
{
|
|
||||||
closeButton.UnbindClickEvents();
|
|
||||||
closeButton.Click += new EventHandler(CloseWindow);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void EditModeOnLink_Click(object sender, EventArgs mouseEvent)
|
|
||||||
{
|
|
||||||
this.windowController.ChangeToChoosePrinter(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void EditModeOffLink_Click(object sender, EventArgs mouseEvent)
|
|
||||||
{
|
|
||||||
this.windowController.ChangeToChoosePrinter(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AddConnectionLink_Click(object sender, EventArgs mouseEvent)
|
|
||||||
{
|
|
||||||
this.windowController.ChangeToAddPrinter();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void EditConnectionLink_Click(object sender, EventArgs mouseEvent)
|
|
||||||
{
|
|
||||||
PrinterActionLink actionLink = (PrinterActionLink)sender;
|
|
||||||
this.windowController.ChangedToEditPrinter(actionLink.LinkedPrinter);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CloseWindow(object o, EventArgs e)
|
|
||||||
{
|
|
||||||
//Stop listening for connection events (if set) and close window
|
|
||||||
UiThread.RunOnIdle(containerWindowToClose.Close);
|
|
||||||
}
|
|
||||||
|
|
||||||
private IEnumerable<Printer> GetAllPrinters()
|
|
||||||
{
|
|
||||||
//Retrieve a list of saved printers from the Datastore
|
|
||||||
return Datastore.Instance.dbSQLite.Query<Printer>("SELECT * FROM Printer;");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +1,21 @@
|
||||||
using MatterHackers.Agg.UI;
|
using System;
|
||||||
|
using MatterHackers.Agg.UI;
|
||||||
using MatterHackers.Localizations;
|
using MatterHackers.Localizations;
|
||||||
using MatterHackers.MatterControl.DataStorage;
|
using MatterHackers.MatterControl.DataStorage;
|
||||||
using MatterHackers.VectorMath;
|
using MatterHackers.VectorMath;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using MatterHackers.Agg.PlatformAbstract;
|
||||||
|
using System.IO;
|
||||||
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
{
|
{
|
||||||
public class ConnectionWindow : SystemWindow
|
public class ConnectionWizard : SystemWindow
|
||||||
{
|
{
|
||||||
private Printer activePrinter;
|
protected PrinterInfo activePrinter;
|
||||||
private bool editMode = false;
|
private bool editMode = false;
|
||||||
|
|
||||||
public ConnectionWindow()
|
public ConnectionWizard()
|
||||||
: base(350 * TextWidget.GlobalPointSizeScaleRatio, 500 * TextWidget.GlobalPointSizeScaleRatio)
|
: base(350 * TextWidget.GlobalPointSizeScaleRatio, 500 * TextWidget.GlobalPointSizeScaleRatio)
|
||||||
{
|
{
|
||||||
AlwaysOnTopOfMain = true;
|
AlwaysOnTopOfMain = true;
|
||||||
|
|
@ -19,14 +24,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
Title = string.Format("{0} - {1}", connectToPrinterTitle, connectToPrinterTitleEnd);
|
Title = string.Format("{0} - {1}", connectToPrinterTitle, connectToPrinterTitleEnd);
|
||||||
Name = "Printer Connection Window";
|
Name = "Printer Connection Window";
|
||||||
|
|
||||||
if (GetPrinterRecordCount() > 0)
|
ChangeToAddPrinter();
|
||||||
{
|
|
||||||
ChangeToChoosePrinter();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ChangeToAddPrinter();
|
|
||||||
}
|
|
||||||
|
|
||||||
BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
||||||
|
|
||||||
|
|
@ -34,85 +32,89 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
MinimumSize = new Vector2(350 * TextWidget.GlobalPointSizeScaleRatio, 400 * TextWidget.GlobalPointSizeScaleRatio);
|
MinimumSize = new Vector2(350 * TextWidget.GlobalPointSizeScaleRatio, 400 * TextWidget.GlobalPointSizeScaleRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ConnectionWindow connectionWindow = null;
|
private static ConnectionWizard connectionWindow = null;
|
||||||
private static bool connectionWindowIsOpen = false;
|
|
||||||
|
|
||||||
public static void Show()
|
public static void Show()
|
||||||
{
|
{
|
||||||
if (connectionWindowIsOpen == false)
|
if (connectionWindow != null)
|
||||||
{
|
{
|
||||||
connectionWindow = new ConnectionWindow();
|
connectionWindow.BringToFront();
|
||||||
connectionWindowIsOpen = true;
|
|
||||||
connectionWindow.Closed += (parentSender, e) =>
|
|
||||||
{
|
|
||||||
connectionWindowIsOpen = false;
|
|
||||||
connectionWindow = null;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (connectionWindow != null)
|
connectionWindow = new ConnectionWizard();
|
||||||
{
|
connectionWindow.Closed += (s, e) => connectionWindow = null;
|
||||||
connectionWindow.BringToFront();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnMouseUp(MouseEventArgs mouseEvent)
|
internal void ChangeToAddPrinter()
|
||||||
{
|
|
||||||
base.OnMouseUp(mouseEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DoNotChangeWindow()
|
|
||||||
{
|
|
||||||
//Empty function used as default callback for changeToWindowCallback
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ChangeToAddPrinter()
|
|
||||||
{
|
{
|
||||||
this.activePrinter = null;
|
this.activePrinter = null;
|
||||||
UiThread.RunOnIdle(DoChangeToAddPrinter);
|
ChangeToStep(new SetupStepMakeModelName(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DoChangeToAddPrinter()
|
private void ChangeToStep(GuiWidget nextStep)
|
||||||
{
|
{
|
||||||
GuiWidget addConnectionWidget = new SetupStepMakeModelName(this, this);
|
UiThread.RunOnIdle(() =>
|
||||||
this.RemoveAllChildren();
|
{
|
||||||
this.AddChild(addConnectionWidget);
|
this.RemoveAllChildren();
|
||||||
this.Invalidate();
|
this.AddChild(nextStep);
|
||||||
}
|
this.Invalidate();
|
||||||
|
});
|
||||||
public void ChangedToEditPrinter(Printer activePrinter, object state = null)
|
|
||||||
{
|
|
||||||
this.activePrinter = activePrinter;
|
|
||||||
UiThread.RunOnIdle(DoChangeToEditPrinter, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DoChangeToEditPrinter(object state)
|
|
||||||
{
|
|
||||||
GuiWidget addConnectionWidget = new EditConnectionWidget(this, this, activePrinter, state);
|
|
||||||
this.RemoveAllChildren();
|
|
||||||
this.AddChild(addConnectionWidget);
|
|
||||||
this.Invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ChangeToChoosePrinter(bool editMode = false)
|
|
||||||
{
|
|
||||||
this.editMode = editMode;
|
|
||||||
UiThread.RunOnIdle(DoChangeToChoosePrinter);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DoChangeToChoosePrinter()
|
|
||||||
{
|
|
||||||
GuiWidget chooseConnectionWidget = new ChooseConnectionWidget(this, this, this.editMode);
|
|
||||||
this.RemoveAllChildren();
|
|
||||||
this.AddChild(chooseConnectionWidget);
|
|
||||||
this.Invalidate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetPrinterRecordCount()
|
private int GetPrinterRecordCount()
|
||||||
{
|
{
|
||||||
return Datastore.Instance.RecordCount("Printer");
|
return Datastore.Instance.RecordCount("Printer");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void ChangeToSetupBaudRate()
|
||||||
|
{
|
||||||
|
ChangeToStep(new SetupStepBaudRate(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void ChangeToInstallDriver()
|
||||||
|
{
|
||||||
|
ChangeToStep(new SetupStepInstallDriver(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void ChangeToSetupComPortOne()
|
||||||
|
{
|
||||||
|
ChangeToStep(new SetupStepComPortOne(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void ChangeToSetupCompPortTwo()
|
||||||
|
{
|
||||||
|
ChangeToStep(new SetupStepComPortTwo(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void ChangeToSetupComPortManual()
|
||||||
|
{
|
||||||
|
ChangeToStep(new SetupStepComPortManual(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void ChangeToInstallDriverOrComPortOne()
|
||||||
|
{
|
||||||
|
if (ActiveSliceSettings.Instance.PrinterDrivers().Count > 0)
|
||||||
|
{
|
||||||
|
ChangeToInstallDriver();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ChangeToSetupComPortOne();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void ChangeToSetupBaudOrComPortOne()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(activePrinter.BaudRate))
|
||||||
|
{
|
||||||
|
ChangeToSetupBaudRate();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ChangeToSetupComPortOne();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4,6 +4,7 @@ using MatterHackers.Localizations;
|
||||||
using MatterHackers.MatterControl.CustomWidgets;
|
using MatterHackers.MatterControl.CustomWidgets;
|
||||||
using MatterHackers.MatterControl.DataStorage;
|
using MatterHackers.MatterControl.DataStorage;
|
||||||
using MatterHackers.MatterControl.PrinterCommunication;
|
using MatterHackers.MatterControl.PrinterCommunication;
|
||||||
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||||
using MatterHackers.SerialPortCommunication.FrostedSerial;
|
using MatterHackers.SerialPortCommunication.FrostedSerial;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
@ -16,7 +17,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
{
|
{
|
||||||
private List<BaudRateRadioButton> BaudRateButtonsList = new List<BaudRateRadioButton>();
|
private List<BaudRateRadioButton> BaudRateButtonsList = new List<BaudRateRadioButton>();
|
||||||
private FlowLayoutWidget ConnectionControlContainer;
|
private FlowLayoutWidget ConnectionControlContainer;
|
||||||
private Printer ActivePrinter;
|
private SettingsProfile ActivePrinter;
|
||||||
private MHTextEditWidget printerNameInput;
|
private MHTextEditWidget printerNameInput;
|
||||||
private MHTextEditWidget otherBaudRateInput;
|
private MHTextEditWidget otherBaudRateInput;
|
||||||
private MHTextEditWidget printerModelInput;
|
private MHTextEditWidget printerModelInput;
|
||||||
|
|
@ -366,11 +367,15 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
|
|
||||||
private void RefreshComPorts(object sender, EventArgs mouseEvent)
|
private void RefreshComPorts(object sender, EventArgs mouseEvent)
|
||||||
{
|
{
|
||||||
|
// TODO: Why would refresh change the active state and why would it need to destroy and recreate
|
||||||
|
// the control rather than just refreshing the content?
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.ActivePrinter.Name = printerNameInput.Text;
|
var settings = ActiveSliceSettings.Instance;
|
||||||
this.ActivePrinter.BaudRate = GetSelectedBaudRate();
|
|
||||||
this.ActivePrinter.ComPort = GetSelectedSerialPort();
|
settings.Name = printerNameInput.Text;
|
||||||
|
settings.BaudRate = GetSelectedBaudRate();
|
||||||
|
settings.ComPort = GetSelectedSerialPort();
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
@ -378,18 +383,6 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
this.windowController.ChangedToEditPrinter(this.ActivePrinter, new StateBeforeRefresh(enableAutoconnect.Checked));
|
this.windowController.ChangedToEditPrinter(this.ActivePrinter, new StateBeforeRefresh(enableAutoconnect.Checked));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReloadCurrentWidget(object sender, EventArgs mouseEvent)
|
|
||||||
{
|
|
||||||
if (this.addNewPrinterFlag == true)
|
|
||||||
{
|
|
||||||
this.windowController.ChangeToAddPrinter();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.windowController.ChangedToEditPrinter(this.ActivePrinter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void BindSaveButtonHandlers()
|
private void BindSaveButtonHandlers()
|
||||||
{
|
{
|
||||||
saveButton.UnbindClickEvents();
|
saveButton.UnbindClickEvents();
|
||||||
|
|
@ -426,23 +419,16 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
{
|
{
|
||||||
this.ActivePrinter.BaudRate = GetSelectedBaudRate();
|
this.ActivePrinter.BaudRate = GetSelectedBaudRate();
|
||||||
this.ActivePrinter.ComPort = GetSelectedSerialPort();
|
this.ActivePrinter.ComPort = GetSelectedSerialPort();
|
||||||
this.ActivePrinter.Make = printerMakeInput.Text;
|
|
||||||
this.ActivePrinter.Model = printerModelInput.Text;
|
// TODO: These should be read only properties that describe what OEM definition your settings came from
|
||||||
|
//this.ActivePrinter.Make = printerMakeInput.Text;
|
||||||
|
//this.ActivePrinter.Model = printerModelInput.Text;
|
||||||
this.ActivePrinter.AutoConnectFlag = enableAutoconnect.Checked;
|
this.ActivePrinter.AutoConnectFlag = enableAutoconnect.Checked;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
//Unable to retrieve Baud or Port, possibly because they weren't shown as options - needs better handling
|
//Unable to retrieve Baud or Port, possibly because they weren't shown as options - needs better handling
|
||||||
}
|
}
|
||||||
this.ActivePrinter.Commit();
|
|
||||||
|
|
||||||
// If the printer we're updating is also the currently active printer or if the ActivePrinter is unassigned,
|
|
||||||
// then we need to update the instance variable to match the new data - the old instance is bound to sql
|
|
||||||
// data that is no longer valid
|
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter == null || ActivePrinterProfile.Instance.ActivePrinter.Id == this.ActivePrinter.Id)
|
|
||||||
{
|
|
||||||
ActivePrinterProfile.Instance.ActivePrinter = this.ActivePrinter;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.windowController.ChangeToChoosePrinter();
|
this.windowController.ChangeToChoosePrinter();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,232 +0,0 @@
|
||||||
using MatterHackers.Agg;
|
|
||||||
using MatterHackers.Agg.UI;
|
|
||||||
using MatterHackers.Localizations;
|
|
||||||
using MatterHackers.MatterControl.DataStorage;
|
|
||||||
using MatterHackers.MatterControl.PrinterCommunication;
|
|
||||||
using MatterHackers.SerialPortCommunication.FrostedSerial;
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|
||||||
{
|
|
||||||
//Empty base class for selectable printer list
|
|
||||||
public class PrinterListItem : FlowLayoutWidget
|
|
||||||
{
|
|
||||||
protected ConnectionWindow windowController;
|
|
||||||
protected Printer printerRecord;
|
|
||||||
|
|
||||||
public PrinterListItem(Printer printerRecord, ConnectionWindow windowController)
|
|
||||||
{
|
|
||||||
this.printerRecord = printerRecord;
|
|
||||||
this.windowController = windowController;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class PrinterListItemView : PrinterListItem
|
|
||||||
{
|
|
||||||
private TextWidget printerName;
|
|
||||||
|
|
||||||
private RGBA_Bytes defaultBackgroundColor = new RGBA_Bytes(250, 250, 250);
|
|
||||||
private RGBA_Bytes hoverBackgroundColor = new RGBA_Bytes(204, 204, 204);
|
|
||||||
|
|
||||||
private RGBA_Bytes defaultTextColor = new RGBA_Bytes(34, 34, 34);
|
|
||||||
private RGBA_Bytes hoverTextColor = new RGBA_Bytes(34, 34, 34);
|
|
||||||
|
|
||||||
public PrinterListItemView(Printer printerRecord, ConnectionWindow windowController)
|
|
||||||
: base(printerRecord, windowController)
|
|
||||||
{
|
|
||||||
this.Margin = new BorderDouble(1);
|
|
||||||
this.BackgroundColor = this.defaultBackgroundColor;
|
|
||||||
this.Padding = new BorderDouble(0);
|
|
||||||
this.Name = this.printerRecord.Name + " Profile";
|
|
||||||
|
|
||||||
string[] comportNames = FrostedSerialPort.GetPortNames();
|
|
||||||
bool portIsAvailable = comportNames.Contains(printerRecord.ComPort);
|
|
||||||
|
|
||||||
printerName = new TextWidget(this.printerRecord.Name);
|
|
||||||
printerName.TextColor = this.defaultTextColor;
|
|
||||||
printerName.HAnchor = HAnchor.ParentLeftRight;
|
|
||||||
printerName.Margin = new BorderDouble(5, 10, 5, 10);
|
|
||||||
|
|
||||||
string availableText = LocalizedString.Get("Unavailable");
|
|
||||||
RGBA_Bytes availableColor = new RGBA_Bytes(158, 18, 0);
|
|
||||||
if (portIsAvailable)
|
|
||||||
{
|
|
||||||
availableText = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter != null)
|
|
||||||
{
|
|
||||||
int connectedPrinterHash = ActivePrinterProfile.Instance.ActivePrinter.GetHashCode();
|
|
||||||
int printerOptionHash = printerRecord.GetHashCode();
|
|
||||||
if (connectedPrinterHash == printerOptionHash)
|
|
||||||
{
|
|
||||||
availableText = PrinterConnectionAndCommunication.Instance.PrinterConnectionStatusVerbose;
|
|
||||||
availableColor = new RGBA_Bytes(0, 95, 107);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TextWidget availableIndicator = new TextWidget(availableText, pointSize: 10);
|
|
||||||
availableIndicator.TextColor = availableColor;
|
|
||||||
availableIndicator.Padding = new BorderDouble(3, 0, 0, 3);
|
|
||||||
availableIndicator.Margin = new BorderDouble(right: 5);
|
|
||||||
availableIndicator.VAnchor = Agg.UI.VAnchor.ParentCenter;
|
|
||||||
|
|
||||||
this.AddChild(printerName);
|
|
||||||
this.AddChild(availableIndicator);
|
|
||||||
this.HAnchor = HAnchor.ParentLeftRight;
|
|
||||||
|
|
||||||
BindHandlers();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void BindHandlers()
|
|
||||||
{
|
|
||||||
this.MouseEnter += new EventHandler(onMouse_Enter);
|
|
||||||
this.MouseLeave += new EventHandler(onMouse_Leave);
|
|
||||||
this.MouseUp += (sender, e) =>
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(onMouse_Up, e);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onMouse_Up(object state)
|
|
||||||
{
|
|
||||||
MouseEventArgs mouseEvent = state as MouseEventArgs;
|
|
||||||
//Turns this into a standard 'click' event
|
|
||||||
if (this.PositionWithinLocalBounds(mouseEvent.X, mouseEvent.Y))
|
|
||||||
{
|
|
||||||
// Changing ordering around so that CloseOnIdle is called after ActivePrinter is set
|
|
||||||
ActivePrinterProfile.Instance.ActivePrinter = this.printerRecord;
|
|
||||||
|
|
||||||
UiThread.RunOnIdle(this.windowController.Close);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onMouse_Enter(object sender, EventArgs args)
|
|
||||||
{
|
|
||||||
this.BackgroundColor = this.hoverBackgroundColor;
|
|
||||||
this.printerName.TextColor = this.hoverTextColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onMouse_Leave(object sender, EventArgs args)
|
|
||||||
{
|
|
||||||
this.BackgroundColor = this.defaultBackgroundColor;
|
|
||||||
this.printerName.TextColor = this.defaultTextColor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class PrinterListItemEdit : PrinterListItem
|
|
||||||
{
|
|
||||||
private TextWidget printerName;
|
|
||||||
|
|
||||||
private RGBA_Bytes defaultBackgroundColor = new RGBA_Bytes(250, 250, 250);
|
|
||||||
private RGBA_Bytes hoverBackgroundColor = ActiveTheme.Instance.PrimaryAccentColor;
|
|
||||||
|
|
||||||
private RGBA_Bytes defaultTextColor = new RGBA_Bytes(34, 34, 34);
|
|
||||||
private RGBA_Bytes hoverTextColor = new RGBA_Bytes(250, 250, 250);
|
|
||||||
private SlideWidget rightButtonOverlay;
|
|
||||||
|
|
||||||
public PrinterListItemEdit(Printer printerRecord, ConnectionWindow windowController)
|
|
||||||
: base(printerRecord, windowController)
|
|
||||||
{
|
|
||||||
this.printerRecord = printerRecord;
|
|
||||||
this.Margin = new BorderDouble(1);
|
|
||||||
this.BackgroundColor = this.defaultBackgroundColor;
|
|
||||||
this.Padding = new BorderDouble(0);
|
|
||||||
this.HAnchor = HAnchor.ParentLeftRight;
|
|
||||||
|
|
||||||
FlowLayoutWidget printerNameContainer = new FlowLayoutWidget();
|
|
||||||
printerNameContainer.HAnchor = HAnchor.ParentLeftRight;
|
|
||||||
|
|
||||||
printerName = new TextWidget(this.printerRecord.Name);
|
|
||||||
printerName.TextColor = this.defaultTextColor;
|
|
||||||
printerName.Margin = new BorderDouble(5, 10, 0, 10);
|
|
||||||
printerName.HAnchor = HAnchor.ParentLeftRight;
|
|
||||||
|
|
||||||
printerNameContainer.AddChild(printerName);
|
|
||||||
|
|
||||||
FlowLayoutWidget rightButtonOverlayContainer = new FlowLayoutWidget(FlowDirection.RightToLeft);
|
|
||||||
rightButtonOverlayContainer.HAnchor = HAnchor.ParentLeftRight;
|
|
||||||
rightButtonOverlayContainer.VAnchor = VAnchor.ParentBottomTop;
|
|
||||||
|
|
||||||
this.rightButtonOverlay = getItemActionButtons();
|
|
||||||
this.rightButtonOverlay.Padding = new BorderDouble(0);
|
|
||||||
this.rightButtonOverlay.Visible = true;
|
|
||||||
rightButtonOverlayContainer.AddChild(rightButtonOverlay);
|
|
||||||
|
|
||||||
this.AddChild(printerNameContainer);
|
|
||||||
this.AddChild(rightButtonOverlayContainer);
|
|
||||||
}
|
|
||||||
|
|
||||||
private SlideWidget getItemActionButtons()
|
|
||||||
{
|
|
||||||
int buttonWidth;
|
|
||||||
if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen)
|
|
||||||
{
|
|
||||||
buttonWidth = 120;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
buttonWidth = 80;//80
|
|
||||||
}
|
|
||||||
|
|
||||||
SlideWidget buttonContainer = new SlideWidget();
|
|
||||||
buttonContainer.VAnchor = VAnchor.ParentBottomTop;
|
|
||||||
|
|
||||||
FlowLayoutWidget buttonFlowContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
|
|
||||||
buttonFlowContainer.VAnchor = VAnchor.ParentBottomTop;
|
|
||||||
|
|
||||||
TextWidget printLabel = new TextWidget("Remove".Localize());
|
|
||||||
printLabel.TextColor = RGBA_Bytes.White;
|
|
||||||
printLabel.VAnchor = VAnchor.ParentCenter;
|
|
||||||
printLabel.HAnchor = HAnchor.ParentCenter;
|
|
||||||
|
|
||||||
FatFlatClickWidget removeButton = new FatFlatClickWidget(printLabel);
|
|
||||||
removeButton.VAnchor = VAnchor.ParentBottomTop;
|
|
||||||
removeButton.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor;
|
|
||||||
removeButton.Width = buttonWidth;
|
|
||||||
removeButton.Click += RemoveConnectionLink_Click;
|
|
||||||
|
|
||||||
TextWidget editLabel = new TextWidget("Edit".Localize());
|
|
||||||
editLabel.TextColor = RGBA_Bytes.White;
|
|
||||||
editLabel.VAnchor = VAnchor.ParentCenter;
|
|
||||||
editLabel.HAnchor = HAnchor.ParentCenter;
|
|
||||||
|
|
||||||
FatFlatClickWidget editButton = new FatFlatClickWidget(editLabel);
|
|
||||||
editButton.VAnchor = VAnchor.ParentBottomTop;
|
|
||||||
editButton.BackgroundColor = ActiveTheme.Instance.SecondaryAccentColor;
|
|
||||||
editButton.Width = buttonWidth;
|
|
||||||
|
|
||||||
editButton.Click += EditConnectionLink_Click;
|
|
||||||
|
|
||||||
buttonFlowContainer.AddChild(editButton);
|
|
||||||
buttonFlowContainer.AddChild(removeButton);
|
|
||||||
|
|
||||||
buttonContainer.AddChild(buttonFlowContainer);
|
|
||||||
buttonContainer.Width = buttonWidth * 2;
|
|
||||||
|
|
||||||
return buttonContainer;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void EditConnectionLink_Click(object sender, EventArgs mouseEvent)
|
|
||||||
{
|
|
||||||
this.windowController.ChangedToEditPrinter(this.printerRecord);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RemoveConnectionLink_Click(object sender, EventArgs mouseEvent)
|
|
||||||
{
|
|
||||||
//Disconnect printer if the printer being removed is currently connected
|
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter != null && this.printerRecord.Id == ActivePrinterProfile.Instance.ActivePrinter.Id)
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle((state) =>
|
|
||||||
{
|
|
||||||
PrinterConnectionAndCommunication.Instance.Disable();
|
|
||||||
ActivePrinterProfile.Instance.ActivePrinter = null;
|
|
||||||
}, null, 0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.printerRecord.Delete();
|
|
||||||
this.windowController.ChangeToChoosePrinter(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -5,6 +5,7 @@ using MatterHackers.MatterControl.DataStorage;
|
||||||
using MatterHackers.MatterControl.PrintLibrary;
|
using MatterHackers.MatterControl.PrintLibrary;
|
||||||
using MatterHackers.MatterControl.PrintLibrary.Provider;
|
using MatterHackers.MatterControl.PrintLibrary.Provider;
|
||||||
using MatterHackers.MatterControl.PrintQueue;
|
using MatterHackers.MatterControl.PrintQueue;
|
||||||
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
@ -16,20 +17,18 @@ namespace MatterHackers.MatterControl
|
||||||
//Wraps the printer record. Includes temporary information that we don't need in the DB.
|
//Wraps the printer record. Includes temporary information that we don't need in the DB.
|
||||||
public class PrinterSetupStatus
|
public class PrinterSetupStatus
|
||||||
{
|
{
|
||||||
public Printer ActivePrinter;
|
public PrinterInfo ActivePrinter;
|
||||||
public List<string> DriversToInstall = new List<string>();
|
|
||||||
public Type PreviousSetupWidget;
|
public Type PreviousSetupWidget;
|
||||||
public Type NextSetupWidget;
|
public Type NextSetupWidget;
|
||||||
private List<CustomCommands> printerCustomCommands;
|
|
||||||
private string defaultMaterialPreset;
|
|
||||||
private string defaultQualityPreset;
|
|
||||||
private string defaultMovementSpeeds;
|
|
||||||
|
|
||||||
public PrinterSetupStatus(Printer printer = null)
|
private List<CustomCommands> printerCustomCommands;
|
||||||
|
|
||||||
|
public PrinterSetupStatus(PrinterInfo printer = null)
|
||||||
{
|
{
|
||||||
if (printer == null)
|
if (printer == null)
|
||||||
{
|
{
|
||||||
this.ActivePrinter = new Printer();
|
this.ActivePrinter = new PrinterInfo();
|
||||||
this.ActivePrinter.Make = null;
|
this.ActivePrinter.Make = null;
|
||||||
this.ActivePrinter.Model = null;
|
this.ActivePrinter.Model = null;
|
||||||
this.ActivePrinter.Name = "Default Printer ({0})".FormatWith(ExistingPrinterCount() + 1);
|
this.ActivePrinter.Name = "Default Printer ({0})".FormatWith(ExistingPrinterCount() + 1);
|
||||||
|
|
@ -47,326 +46,18 @@ namespace MatterHackers.MatterControl
|
||||||
return Datastore.Instance.RecordCount("Printer");
|
return Datastore.Instance.RecordCount("Printer");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadCalibrationPrints()
|
|
||||||
{
|
|
||||||
if (this.ActivePrinter.Make != null && this.ActivePrinter.Model != null)
|
|
||||||
{
|
|
||||||
// Load the calibration file names
|
|
||||||
List<string> calibrationPrintFileNames = LoadCalibrationPartNamesForPrinter(this.ActivePrinter.Make, this.ActivePrinter.Model);
|
|
||||||
|
|
||||||
var libraryProvider = new LibraryProviderSQLite(null, null, null, "Local Library");
|
|
||||||
libraryProvider.EnsureSamplePartsExist(calibrationPrintFileNames);
|
|
||||||
|
|
||||||
var queueItems = QueueData.Instance.GetItemNames();
|
|
||||||
|
|
||||||
// Finally, ensure missing calibration parts are added to the queue if missing
|
|
||||||
var filenamesWithoutExtensions = calibrationPrintFileNames.Select(f => Path.GetFileNameWithoutExtension(f));
|
|
||||||
foreach (string nameOnly in filenamesWithoutExtensions)
|
|
||||||
{
|
|
||||||
if (queueItems.Contains(nameOnly))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find the first library item with the given name and add it to the queue
|
|
||||||
PrintItem libraryItem = libraryProvider.GetLibraryItems(nameOnly).FirstOrDefault();
|
|
||||||
if (libraryItem != null)
|
|
||||||
{
|
|
||||||
QueueData.Instance.AddItem(new PrintItemWrapper(libraryItem));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
libraryProvider.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<string> LoadCalibrationPartNamesForPrinter(string make, string model)
|
|
||||||
{
|
|
||||||
string filePath = Path.Combine("PrinterSettings", make, model, "calibration.ini");
|
|
||||||
if (StaticData.Instance.FileExists(filePath))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return StaticData.Instance.ReadAllLines(filePath).Where(l => !l.StartsWith("#")).Select(l => l.Trim()).ToList();
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new List<string>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LoadSetupSettings(string make, string model)
|
|
||||||
{
|
|
||||||
Dictionary<string, string> settingsDict = LoadPrinterSetupFromFile(make, model);
|
|
||||||
Dictionary<string, string> macroDict = new Dictionary<string, string>();
|
|
||||||
macroDict["Lights On"] = "M42 P6 S255";
|
|
||||||
macroDict["Lights Off"] = "M42 P6 S0";
|
|
||||||
macroDict["Offset 0.8"] = "M565 Z0.8;\nM500";
|
|
||||||
macroDict["Offset 0.9"] = "M565 Z0.9;\nM500";
|
|
||||||
macroDict["Offset 1"] = "M565 Z1;\nM500";
|
|
||||||
macroDict["Offset 1.1"] = "M565 Z1.1;\nM500";
|
|
||||||
macroDict["Offset 1.2"] = "M565 Z1.2;\nM500";
|
|
||||||
macroDict["Z Offset"] = "G1 Z10;\nG28;\nG29;\nG1 Z10;\nG1 X5 Y5 F4000;\nM117;";
|
|
||||||
|
|
||||||
//Determine if baud rate is needed and show controls if required
|
|
||||||
string baudRate;
|
|
||||||
if (settingsDict.TryGetValue("baud_rate", out baudRate))
|
|
||||||
{
|
|
||||||
ActivePrinter.BaudRate = baudRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
string defaultSliceEngine;
|
|
||||||
if (settingsDict.TryGetValue("default_slice_engine", out defaultSliceEngine))
|
|
||||||
{
|
|
||||||
if (Enum.IsDefined(typeof(ActivePrinterProfile.SlicingEngineTypes), defaultSliceEngine))
|
|
||||||
{
|
|
||||||
ActivePrinter.CurrentSlicingEngine = defaultSliceEngine;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
string defaultPrinterDriver;
|
|
||||||
if (settingsDict.TryGetValue("driver_type", out defaultPrinterDriver))
|
|
||||||
{
|
|
||||||
ActivePrinter.DriverType = defaultPrinterDriver;
|
|
||||||
}
|
|
||||||
|
|
||||||
settingsDict.TryGetValue("default_material_presets", out defaultMaterialPreset);
|
|
||||||
settingsDict.TryGetValue("default_quality_preset", out defaultQualityPreset);
|
|
||||||
settingsDict.TryGetValue("default_movement_speeds", out defaultMovementSpeeds);
|
|
||||||
|
|
||||||
string defaultMacros;
|
|
||||||
printerCustomCommands = new List<CustomCommands>();
|
|
||||||
if (settingsDict.TryGetValue("default_macros", out defaultMacros))
|
|
||||||
{
|
|
||||||
string[] macroList = defaultMacros.Split(',');
|
|
||||||
foreach (string macroName in macroList)
|
|
||||||
{
|
|
||||||
string macroValue;
|
|
||||||
if (macroDict.TryGetValue(macroName.Trim(), out macroValue))
|
|
||||||
{
|
|
||||||
CustomCommands customMacro = new CustomCommands();
|
|
||||||
customMacro.Name = macroName.Trim();
|
|
||||||
customMacro.Value = macroValue;
|
|
||||||
|
|
||||||
printerCustomCommands.Add(customMacro);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Determine what if any drivers are needed
|
|
||||||
string infFileNames;
|
|
||||||
if (settingsDict.TryGetValue("windows_driver", out infFileNames))
|
|
||||||
{
|
|
||||||
string[] fileNames = infFileNames.Split(',');
|
|
||||||
foreach (string fileName in fileNames)
|
|
||||||
{
|
|
||||||
switch (OsInformation.OperatingSystem)
|
|
||||||
{
|
|
||||||
case OSType.Windows:
|
|
||||||
|
|
||||||
string pathForInf = Path.GetFileNameWithoutExtension(fileName);
|
|
||||||
|
|
||||||
// TODO: It's really unexpected that the driver gets copied to the temp folder everytime a printer is setup. I'd think this only needs
|
|
||||||
// to happen when the infinstaller is run (More specifically - move this to *after* the user clicks Install Driver)
|
|
||||||
|
|
||||||
string infPath = Path.Combine("Drivers", pathForInf);
|
|
||||||
string infPathAndFileToInstall = Path.Combine(infPath, fileName);
|
|
||||||
|
|
||||||
if (StaticData.Instance.FileExists(infPathAndFileToInstall))
|
|
||||||
{
|
|
||||||
// Ensure the output directory exists
|
|
||||||
string destTempPath = Path.GetFullPath(Path.Combine(ApplicationDataStorage.ApplicationUserDataPath, "data", "temp", "inf", pathForInf));
|
|
||||||
if (!Directory.Exists(destTempPath))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(destTempPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
string destTempInf = Path.GetFullPath(Path.Combine(destTempPath, fileName));
|
|
||||||
|
|
||||||
// Sync each file from StaticData to the location on disk for serial drivers
|
|
||||||
foreach (string file in StaticData.Instance.GetFiles(infPath))
|
|
||||||
{
|
|
||||||
using (Stream outstream = File.OpenWrite(Path.Combine(destTempPath, Path.GetFileName(file))))
|
|
||||||
using (Stream instream = StaticData.Instance.OpenSteam(file))
|
|
||||||
{
|
|
||||||
instream.CopyTo(outstream);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DriversToInstall.Add(destTempInf);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Dictionary<string, string> LoadPrinterSetupFromFile(string make, string model)
|
|
||||||
{
|
|
||||||
string setupSettingsPathAndFile = Path.Combine("PrinterSettings", make, model, "setup.ini");
|
|
||||||
Dictionary<string, string> settingsDict = new Dictionary<string, string>();
|
|
||||||
|
|
||||||
if (StaticData.Instance.FileExists(setupSettingsPathAndFile))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
foreach (string lineIn in StaticData.Instance.ReadAllLines(setupSettingsPathAndFile))
|
|
||||||
{
|
|
||||||
string line = lineIn.Trim();
|
|
||||||
//Ignore commented lines
|
|
||||||
if (line.Length > 0
|
|
||||||
&& !line.StartsWith("#"))
|
|
||||||
{
|
|
||||||
string[] settingLine = line.Split('=');
|
|
||||||
if (settingLine.Length > 1)
|
|
||||||
{
|
|
||||||
string keyName = settingLine[0].Trim();
|
|
||||||
string settingDefaultValue = settingLine[1].Trim();
|
|
||||||
|
|
||||||
settingsDict.Add(keyName, settingDefaultValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return settingsDict;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Loads a SliceSettingsCollection from StaticData PrinterSettings
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="make">The make to load</param>
|
|
||||||
/// <param name="model">The model to load</param>
|
|
||||||
public SliceSettingsCollection LoadSettingsFromConfigFile(string make, string model)
|
|
||||||
{
|
|
||||||
Dictionary<string, string> settingsDict = LoadSliceSettingsFromFile(Path.Combine("PrinterSettings", make, model, "config.ini"));
|
|
||||||
if (settingsDict.Count > 0)
|
|
||||||
{
|
|
||||||
SliceSettingsCollection collection = new SliceSettingsCollection();
|
|
||||||
collection.Name = this.ActivePrinter.Name;
|
|
||||||
collection.Commit();
|
|
||||||
|
|
||||||
this.ActivePrinter.DefaultSettingsCollectionId = collection.Id;
|
|
||||||
|
|
||||||
CommitSliceSettings(settingsDict, collection.Id);
|
|
||||||
|
|
||||||
return collection;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return null if the loaded settings dictionary was empty
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LoadSlicePresets(string make, string model, string tag)
|
|
||||||
{
|
|
||||||
foreach (string filePath in GetSlicePresets(make, model, tag))
|
|
||||||
{
|
|
||||||
Dictionary<string, string> settingsDict = LoadSliceSettingsFromFile(filePath);
|
|
||||||
|
|
||||||
if (settingsDict.Count > 0)
|
|
||||||
{
|
|
||||||
SliceSettingsCollection collection = new SliceSettingsCollection();
|
|
||||||
collection.Name = Path.GetFileNameWithoutExtension(filePath);
|
|
||||||
collection.PrinterId = ActivePrinter.Id;
|
|
||||||
collection.Tag = tag;
|
|
||||||
collection.Commit();
|
|
||||||
|
|
||||||
if (tag == "material" && defaultMaterialPreset != null && collection.Name == defaultMaterialPreset)
|
|
||||||
{
|
|
||||||
ActivePrinter.MaterialCollectionIds = collection.Id.ToString();
|
|
||||||
ActivePrinter.Commit();
|
|
||||||
}
|
|
||||||
else if (tag == "quality" && defaultQualityPreset != null && collection.Name == defaultQualityPreset)
|
|
||||||
{
|
|
||||||
ActivePrinter.QualityCollectionId = collection.Id;
|
|
||||||
ActivePrinter.Commit();
|
|
||||||
}
|
|
||||||
CommitSliceSettings(settingsDict, collection.Id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CommitSliceSettings(Dictionary<string, string> settingsDict, int collectionId)
|
|
||||||
{
|
|
||||||
foreach (KeyValuePair<string, string> item in settingsDict)
|
|
||||||
{
|
|
||||||
SliceSetting sliceSetting = new SliceSetting();
|
|
||||||
sliceSetting.Name = item.Key;
|
|
||||||
sliceSetting.Value = item.Value;
|
|
||||||
sliceSetting.SettingsCollectionId = collectionId;
|
|
||||||
sliceSetting.Commit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private string[] GetSlicePresets(string make, string model, string tag)
|
|
||||||
{
|
|
||||||
string[] presetPaths = new string[] { };
|
|
||||||
string folderPath = Path.Combine("PrinterSettings", make, model, tag);
|
|
||||||
if (StaticData.Instance.DirectoryExists(folderPath))
|
|
||||||
{
|
|
||||||
presetPaths = StaticData.Instance.GetFiles(folderPath).ToArray();
|
|
||||||
}
|
|
||||||
return presetPaths;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Dictionary<string, string> LoadSliceSettingsFromFile(string setupSettingsPathAndFile)
|
|
||||||
{
|
|
||||||
Dictionary<string, string> settingsDict = new Dictionary<string, string>();
|
|
||||||
if (StaticData.Instance.FileExists(setupSettingsPathAndFile))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
foreach (string line in StaticData.Instance.ReadAllLines(setupSettingsPathAndFile))
|
|
||||||
{
|
|
||||||
//Ignore commented lines
|
|
||||||
if (!line.StartsWith("#") && line.Length > 0)
|
|
||||||
{
|
|
||||||
string[] settingLine = line.Split('=');
|
|
||||||
if (settingLine.Length == 2)
|
|
||||||
{
|
|
||||||
string keyName = settingLine[0].Trim();
|
|
||||||
string settingDefaultValue = settingLine[1].Trim();
|
|
||||||
|
|
||||||
settingsDict.Add(keyName, settingDefaultValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return settingsDict;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
{
|
{
|
||||||
//Load the default slice settings for the make and model combination - if they exist
|
|
||||||
SliceSettingsCollection collection = LoadSettingsFromConfigFile(this.ActivePrinter.Make, this.ActivePrinter.Model);
|
|
||||||
|
|
||||||
if (defaultMovementSpeeds != null)
|
|
||||||
{
|
|
||||||
this.ActivePrinter.ManualMovementSpeeds = defaultMovementSpeeds;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Ordering matters - need to get Id for printer prior to loading slice presets
|
//Ordering matters - need to get Id for printer prior to loading slice presets
|
||||||
this.ActivePrinter.AutoConnectFlag = true;
|
this.ActivePrinter.AutoConnectFlag = true;
|
||||||
this.ActivePrinter.Commit();
|
|
||||||
|
|
||||||
LoadSlicePresets(this.ActivePrinter.Make, this.ActivePrinter.Model, "material");
|
// TODO: Review printerID int requirement
|
||||||
LoadSlicePresets(this.ActivePrinter.Make, this.ActivePrinter.Model, "quality");
|
int printerID;
|
||||||
|
int.TryParse(ActivePrinter.Id, out printerID);
|
||||||
|
|
||||||
foreach (CustomCommands customCommand in printerCustomCommands)
|
foreach (CustomCommands customCommand in printerCustomCommands)
|
||||||
{
|
{
|
||||||
customCommand.PrinterId = ActivePrinter.Id;
|
customCommand.PrinterId = printerID;
|
||||||
customCommand.Commit();
|
customCommand.Commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,13 @@ using MatterHackers.Agg.UI;
|
||||||
using MatterHackers.Localizations;
|
using MatterHackers.Localizations;
|
||||||
using MatterHackers.MatterControl.DataStorage;
|
using MatterHackers.MatterControl.DataStorage;
|
||||||
using MatterHackers.MatterControl.PrinterCommunication;
|
using MatterHackers.MatterControl.PrinterCommunication;
|
||||||
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
{
|
{
|
||||||
public class SetupConnectionWidgetBase : ConnectionWidgetBase
|
public class SetupConnectionWidgetBase : ConnectionWidgetBase
|
||||||
{
|
{
|
||||||
public PrinterSetupStatus currentPrinterSetupStatus;
|
|
||||||
|
|
||||||
//private GuiWidget mainContainer;
|
//private GuiWidget mainContainer;
|
||||||
|
|
||||||
protected FlowLayoutWidget headerRow;
|
protected FlowLayoutWidget headerRow;
|
||||||
|
|
@ -21,28 +20,13 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
protected TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
|
protected TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
|
||||||
protected LinkButtonFactory linkButtonFactory = new LinkButtonFactory();
|
protected LinkButtonFactory linkButtonFactory = new LinkButtonFactory();
|
||||||
|
|
||||||
public Printer ActivePrinter
|
public SetupConnectionWidgetBase(ConnectionWizard wizard) : base(wizard)
|
||||||
{
|
|
||||||
get { return currentPrinterSetupStatus.ActivePrinter; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public SetupConnectionWidgetBase(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus printerSetupStatus = null)
|
|
||||||
: base(windowController, containerWindowToClose)
|
|
||||||
{
|
{
|
||||||
SetDisplayAttributes();
|
SetDisplayAttributes();
|
||||||
|
|
||||||
if (printerSetupStatus == null)
|
cancelButton = textImageButtonFactory.Generate("Cancel".Localize());
|
||||||
{
|
|
||||||
this.currentPrinterSetupStatus = new PrinterSetupStatus();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.currentPrinterSetupStatus = printerSetupStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
cancelButton = textImageButtonFactory.Generate(LocalizedString.Get("Cancel"));
|
|
||||||
cancelButton.Name = "Setup Connection Cancel Button";
|
cancelButton.Name = "Setup Connection Cancel Button";
|
||||||
cancelButton.Click += new EventHandler(CancelButton_Click);
|
cancelButton.Click += CancelButton_Click;
|
||||||
|
|
||||||
//Create the main container
|
//Create the main container
|
||||||
GuiWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
GuiWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||||
|
|
@ -56,10 +40,9 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
headerRow.Padding = new BorderDouble(0, 3, 0, 3);
|
headerRow.Padding = new BorderDouble(0, 3, 0, 3);
|
||||||
headerRow.HAnchor = HAnchor.ParentLeftRight;
|
headerRow.HAnchor = HAnchor.ParentLeftRight;
|
||||||
{
|
{
|
||||||
string defaultHeaderTitle = LocalizedString.Get("3D Printer Setup");
|
headerLabel = new TextWidget("3D Printer Setup".Localize(), pointSize: 14);
|
||||||
headerLabel = new TextWidget(defaultHeaderTitle, pointSize: 14);
|
|
||||||
headerLabel.AutoExpandBoundsToText = true;
|
headerLabel.AutoExpandBoundsToText = true;
|
||||||
headerLabel.TextColor = this.defaultTextColor;
|
headerLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||||
headerRow.AddChild(headerLabel);
|
headerRow.AddChild(headerLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -83,9 +66,18 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
|
|
||||||
protected void SaveAndExit()
|
protected void SaveAndExit()
|
||||||
{
|
{
|
||||||
this.ActivePrinter.Commit();
|
ActiveSliceSettings.Instance.RunInTransaction(settings =>
|
||||||
ActivePrinterProfile.Instance.ActivePrinter = this.ActivePrinter;
|
{
|
||||||
this.containerWindowToClose.Close();
|
settings.AutoConnectFlag = ActivePrinter.AutoConnectFlag;
|
||||||
|
settings.BaudRate = ActivePrinter.BaudRate;
|
||||||
|
settings.ComPort = ActivePrinter.ComPort;
|
||||||
|
settings.SlicingEngine = ActivePrinter.CurrentSlicingEngine;
|
||||||
|
settings.DriverType = ActivePrinter.DriverType;
|
||||||
|
settings.Id = ActivePrinter.Id;
|
||||||
|
settings.Name = ActivePrinter.Name;
|
||||||
|
});
|
||||||
|
|
||||||
|
UiThread.RunOnIdle(connectionWizard.Close);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetDisplayAttributes()
|
private void SetDisplayAttributes()
|
||||||
|
|
@ -104,26 +96,10 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
this.Padding = new BorderDouble(0); //To be re-enabled once native borders are turned off
|
this.Padding = new BorderDouble(0); //To be re-enabled once native borders are turned off
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CloseWindow(object o, EventArgs e)
|
|
||||||
{
|
|
||||||
PrinterConnectionAndCommunication.Instance.HaltConnectionThread();
|
|
||||||
this.containerWindowToClose.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CancelButton_Click(object sender, EventArgs mouseEvent)
|
private void CancelButton_Click(object sender, EventArgs mouseEvent)
|
||||||
{
|
{
|
||||||
PrinterConnectionAndCommunication.Instance.HaltConnectionThread();
|
PrinterConnectionAndCommunication.Instance.HaltConnectionThread();
|
||||||
if (GetPrinterRecordCount() > 0)
|
UiThread.RunOnIdle(connectionWizard.Close);
|
||||||
{
|
|
||||||
this.windowController.ChangeToChoosePrinter();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(() =>
|
|
||||||
{
|
|
||||||
Parent.Close();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -19,8 +19,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
private Button printerBaudRateHelpLink;
|
private Button printerBaudRateHelpLink;
|
||||||
private TextWidget printerBaudRateHelpMessage;
|
private TextWidget printerBaudRateHelpMessage;
|
||||||
|
|
||||||
public SetupStepBaudRate(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus setupPrinterStatus)
|
public SetupStepBaudRate(ConnectionWizard connectionWizard) : base(connectionWizard)
|
||||||
: base(windowController, containerWindowToClose, setupPrinterStatus)
|
|
||||||
{
|
{
|
||||||
linkButtonFactory.fontSize = 8;
|
linkButtonFactory.fontSize = 8;
|
||||||
|
|
||||||
|
|
@ -49,7 +48,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
string baudRateLabelTextFull = string.Format("{0}:", baudRateLabelText);
|
string baudRateLabelTextFull = string.Format("{0}:", baudRateLabelText);
|
||||||
|
|
||||||
TextWidget baudRateLabel = new TextWidget(baudRateLabelTextFull, 0, 0, 12);
|
TextWidget baudRateLabel = new TextWidget(baudRateLabelTextFull, 0, 0, 12);
|
||||||
baudRateLabel.TextColor = this.defaultTextColor;
|
baudRateLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||||
baudRateLabel.Margin = new BorderDouble(0, 0, 0, 10);
|
baudRateLabel.Margin = new BorderDouble(0, 0, 0, 10);
|
||||||
baudRateLabel.HAnchor = HAnchor.ParentLeftRight;
|
baudRateLabel.HAnchor = HAnchor.ParentLeftRight;
|
||||||
|
|
||||||
|
|
@ -104,7 +103,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
BaudRateRadioButton baudOption = new BaudRateRadioButton(baudRate);
|
BaudRateRadioButton baudOption = new BaudRateRadioButton(baudRate);
|
||||||
BaudRateButtonsList.Add(baudOption);
|
BaudRateButtonsList.Add(baudOption);
|
||||||
baudOption.Margin = baudRateMargin;
|
baudOption.Margin = baudRateMargin;
|
||||||
baudOption.TextColor = this.subContainerTextColor;
|
baudOption.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||||
if (this.ActivePrinter.BaudRate == baudRate)
|
if (this.ActivePrinter.BaudRate == baudRate)
|
||||||
{
|
{
|
||||||
baudOption.Checked = true;
|
baudOption.Checked = true;
|
||||||
|
|
@ -114,7 +113,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
|
|
||||||
otherBaudRateRadioButton = new RadioButton(LocalizedString.Get("Other"));
|
otherBaudRateRadioButton = new RadioButton(LocalizedString.Get("Other"));
|
||||||
otherBaudRateRadioButton.Margin = baudRateMargin;
|
otherBaudRateRadioButton.Margin = baudRateMargin;
|
||||||
otherBaudRateRadioButton.TextColor = this.subContainerTextColor;
|
otherBaudRateRadioButton.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||||
|
|
||||||
baudRateContainer.AddChild(otherBaudRateRadioButton);
|
baudRateContainer.AddChild(otherBaudRateRadioButton);
|
||||||
|
|
||||||
|
|
@ -160,35 +159,9 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RecreateCurrentWidget()
|
|
||||||
{
|
|
||||||
// you can call this like this
|
|
||||||
// AfterUiEvents.AddAction(new AfterUIAction(RecreateCurrentWidget));
|
|
||||||
|
|
||||||
Parent.AddChild(new EditConnectionWidget((ConnectionWindow)Parent, Parent, ActivePrinter));
|
|
||||||
Parent.RemoveChild(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ReloadCurrentWidget(object sender, EventArgs mouseEvent)
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(RecreateCurrentWidget);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MoveToNextWidget()
|
private void MoveToNextWidget()
|
||||||
{
|
{
|
||||||
// you can call this like this
|
connectionWizard.ChangeToInstallDriverOrComPortOne();
|
||||||
// AfterUiEvents.AddAction(new AfterUIAction(MoveToNextWidget));
|
|
||||||
|
|
||||||
if (this.currentPrinterSetupStatus.DriversToInstall.Count > 0)
|
|
||||||
{
|
|
||||||
Parent.AddChild(new SetupStepInstallDriver((ConnectionWindow)Parent, Parent, this.currentPrinterSetupStatus));
|
|
||||||
Parent.RemoveChild(this);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Parent.AddChild(new SetupStepComPortOne((ConnectionWindow)Parent, Parent, this.currentPrinterSetupStatus));
|
|
||||||
Parent.RemoveChild(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NextButton_Click(object sender, EventArgs mouseEvent)
|
private void NextButton_Click(object sender, EventArgs mouseEvent)
|
||||||
|
|
|
||||||
|
|
@ -3,61 +3,54 @@ using MatterHackers.Agg.UI;
|
||||||
using MatterHackers.Localizations;
|
using MatterHackers.Localizations;
|
||||||
using MatterHackers.MatterControl.CustomWidgets;
|
using MatterHackers.MatterControl.CustomWidgets;
|
||||||
using MatterHackers.MatterControl.PrinterCommunication;
|
using MatterHackers.MatterControl.PrinterCommunication;
|
||||||
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
{
|
{
|
||||||
public class SetupStepComPortManual : SetupConnectionWidgetBase
|
public class SetupStepComPortManual : SetupConnectionWidgetBase
|
||||||
{
|
{
|
||||||
private TextWidget printerComPortError;
|
|
||||||
|
|
||||||
//GuiWidget comPortWidget;
|
|
||||||
private Button nextButton;
|
private Button nextButton;
|
||||||
|
|
||||||
private Button connectButton;
|
private Button connectButton;
|
||||||
private Button refreshButton;
|
private Button refreshButton;
|
||||||
private Button printerComPortHelpLink;
|
private Button printerComPortHelpLink;
|
||||||
private TextWidget printerComPortHelpMessage;
|
|
||||||
|
|
||||||
public SetupStepComPortManual(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus setupPrinterStatus)
|
private TextWidget printerComPortHelpMessage;
|
||||||
: base(windowController, containerWindowToClose, setupPrinterStatus)
|
private TextWidget printerComPortError;
|
||||||
|
|
||||||
|
private event EventHandler unregisterEvents;
|
||||||
|
|
||||||
|
public SetupStepComPortManual(ConnectionWizard connectionWizard) : base(connectionWizard)
|
||||||
{
|
{
|
||||||
linkButtonFactory.fontSize = 8;
|
linkButtonFactory.fontSize = 8;
|
||||||
|
|
||||||
FlowLayoutWidget printerComPortContainer = createComPortContainer();
|
FlowLayoutWidget printerComPortContainer = createComPortContainer();
|
||||||
contentRow.AddChild(printerComPortContainer);
|
contentRow.AddChild(printerComPortContainer);
|
||||||
{
|
|
||||||
//Construct buttons
|
|
||||||
nextButton = textImageButtonFactory.Generate(LocalizedString.Get("Done"));
|
|
||||||
nextButton.Click += new EventHandler(NextButton_Click);
|
|
||||||
nextButton.Visible = false;
|
|
||||||
|
|
||||||
connectButton = textImageButtonFactory.Generate(LocalizedString.Get("Connect"));
|
//Construct buttons
|
||||||
connectButton.Click += new EventHandler(ConnectButton_Click);
|
nextButton = textImageButtonFactory.Generate("Done".Localize());
|
||||||
|
nextButton.Click += (s, e) => UiThread.RunOnIdle(Parent.Close);
|
||||||
|
nextButton.Visible = false;
|
||||||
|
|
||||||
PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
connectButton = textImageButtonFactory.Generate("Connect".Localize());
|
||||||
|
connectButton.Click += ConnectButton_Click;
|
||||||
|
|
||||||
refreshButton = textImageButtonFactory.Generate(LocalizedString.Get("Refresh"));
|
refreshButton = textImageButtonFactory.Generate("Refresh".Localize());
|
||||||
refreshButton.Click += new EventHandler(RefreshButton_Click);
|
refreshButton.Click += (s, e) => connectionWizard.ChangeToSetupComPortManual();
|
||||||
|
|
||||||
//Add buttons to buttonContainer
|
//Add buttons to buttonContainer
|
||||||
footerRow.AddChild(nextButton);
|
footerRow.AddChild(nextButton);
|
||||||
footerRow.AddChild(connectButton);
|
footerRow.AddChild(connectButton);
|
||||||
footerRow.AddChild(refreshButton);
|
footerRow.AddChild(refreshButton);
|
||||||
footerRow.AddChild(new HorizontalSpacer());
|
footerRow.AddChild(new HorizontalSpacer());
|
||||||
footerRow.AddChild(cancelButton);
|
footerRow.AddChild(cancelButton);
|
||||||
}
|
|
||||||
|
PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
private event EventHandler unregisterEvents;
|
|
||||||
|
|
||||||
public override void OnClosed(EventArgs e)
|
public override void OnClosed(EventArgs e)
|
||||||
{
|
{
|
||||||
if (unregisterEvents != null)
|
unregisterEvents?.Invoke(this, null);
|
||||||
{
|
|
||||||
unregisterEvents(this, null);
|
|
||||||
}
|
|
||||||
base.OnClosed(e);
|
base.OnClosed(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,7 +65,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
string serialPortLabelFull = string.Format("{0}:", serialPortLabel);
|
string serialPortLabelFull = string.Format("{0}:", serialPortLabel);
|
||||||
|
|
||||||
TextWidget comPortLabel = new TextWidget(serialPortLabelFull, 0, 0, 12);
|
TextWidget comPortLabel = new TextWidget(serialPortLabelFull, 0, 0, 12);
|
||||||
comPortLabel.TextColor = this.defaultTextColor;
|
comPortLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||||
comPortLabel.Margin = new BorderDouble(0, 0, 0, 10);
|
comPortLabel.Margin = new BorderDouble(0, 0, 0, 10);
|
||||||
comPortLabel.HAnchor = HAnchor.ParentLeftRight;
|
comPortLabel.HAnchor = HAnchor.ParentLeftRight;
|
||||||
|
|
||||||
|
|
@ -83,16 +76,16 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
comPortMessageContainer.Margin = elementMargin;
|
comPortMessageContainer.Margin = elementMargin;
|
||||||
comPortMessageContainer.HAnchor = HAnchor.ParentLeftRight;
|
comPortMessageContainer.HAnchor = HAnchor.ParentLeftRight;
|
||||||
|
|
||||||
printerComPortError = new TextWidget(LocalizedString.Get("Currently available serial ports."), 0, 0, 10);
|
printerComPortError = new TextWidget("Currently available serial ports.".Localize(), 0, 0, 10);
|
||||||
printerComPortError.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
printerComPortError.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||||
printerComPortError.AutoExpandBoundsToText = true;
|
printerComPortError.AutoExpandBoundsToText = true;
|
||||||
|
|
||||||
printerComPortHelpLink = linkButtonFactory.Generate(LocalizedString.Get("What's this?"));
|
printerComPortHelpLink = linkButtonFactory.Generate("What's this?".Localize());
|
||||||
printerComPortHelpLink.Margin = new BorderDouble(left: 5);
|
printerComPortHelpLink.Margin = new BorderDouble(left: 5);
|
||||||
printerComPortHelpLink.VAnchor = VAnchor.ParentBottom;
|
printerComPortHelpLink.VAnchor = VAnchor.ParentBottom;
|
||||||
printerComPortHelpLink.Click += new EventHandler(printerComPortHelp_Click);
|
printerComPortHelpLink.Click += (s, e) => printerComPortHelpMessage.Visible = !printerComPortHelpMessage.Visible;
|
||||||
|
|
||||||
printerComPortHelpMessage = new TextWidget(LocalizedString.Get("The 'Serial Port' identifies which connected device is\nyour printer. Changing which usb plug you use may\nchange the associated serial port.\n\nTip: If you are uncertain, plug-in in your printer and hit\nrefresh. The new port that appears should be your\nprinter."), 0, 0, 10);
|
printerComPortHelpMessage = new TextWidget("The 'Serial Port' identifies which connected device is\nyour printer. Changing which usb plug you use may\nchange the associated serial port.\n\nTip: If you are uncertain, plug-in in your printer and hit\nrefresh. The new port that appears should be your\nprinter.".Localize(), 0, 0, 10);
|
||||||
printerComPortHelpMessage.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
printerComPortHelpMessage.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||||
printerComPortHelpMessage.Margin = new BorderDouble(top: 10);
|
printerComPortHelpMessage.Margin = new BorderDouble(top: 10);
|
||||||
printerComPortHelpMessage.Visible = false;
|
printerComPortHelpMessage.Visible = false;
|
||||||
|
|
@ -113,83 +106,41 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
{
|
{
|
||||||
if (PrinterConnectionAndCommunication.Instance.PrinterIsConnected)
|
if (PrinterConnectionAndCommunication.Instance.PrinterIsConnected)
|
||||||
{
|
{
|
||||||
onConnectionSuccess();
|
printerComPortHelpLink.Visible = false;
|
||||||
|
printerComPortError.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||||
|
printerComPortError.Text = "Connection succeeded".Localize() + "!";
|
||||||
|
nextButton.Visible = true;
|
||||||
|
connectButton.Visible = false;
|
||||||
|
UiThread.RunOnIdle(Parent.Close);
|
||||||
}
|
}
|
||||||
else if (PrinterConnectionAndCommunication.Instance.CommunicationState != PrinterConnectionAndCommunication.CommunicationStates.AttemptingToConnect)
|
else if (PrinterConnectionAndCommunication.Instance.CommunicationState != PrinterConnectionAndCommunication.CommunicationStates.AttemptingToConnect)
|
||||||
{
|
{
|
||||||
onConnectionFailed();
|
printerComPortHelpLink.Visible = false;
|
||||||
|
printerComPortError.TextColor = RGBA_Bytes.Red;
|
||||||
|
printerComPortError.Text = "Uh-oh! Could not connect to printer.".Localize();
|
||||||
|
connectButton.Visible = true;
|
||||||
|
nextButton.Visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onConnectionFailed()
|
|
||||||
{
|
|
||||||
printerComPortHelpLink.Visible = false;
|
|
||||||
printerComPortError.TextColor = RGBA_Bytes.Red;
|
|
||||||
printerComPortError.Text = LocalizedString.Get("Uh-oh! Could not connect to printer.");
|
|
||||||
connectButton.Visible = true;
|
|
||||||
nextButton.Visible = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onConnectionSuccess()
|
|
||||||
{
|
|
||||||
printerComPortHelpLink.Visible = false;
|
|
||||||
printerComPortError.TextColor = this.subContainerTextColor;
|
|
||||||
printerComPortError.Text = LocalizedString.Get("Connection succeeded!");
|
|
||||||
nextButton.Visible = true;
|
|
||||||
connectButton.Visible = false;
|
|
||||||
UiThread.RunOnIdle(Parent.Close);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void printerComPortHelp_Click(object sender, EventArgs mouseEvent)
|
|
||||||
{
|
|
||||||
printerComPortHelpMessage.Visible = !printerComPortHelpMessage.Visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MoveToNextWidget(object state)
|
private void MoveToNextWidget(object state)
|
||||||
{
|
{
|
||||||
// you can call this like this
|
connectionWizard.ChangeToInstallDriverOrComPortOne();
|
||||||
// AfterUiEvents.AddAction(new AfterUIAction(MoveToNextWidget));
|
|
||||||
|
|
||||||
if (this.currentPrinterSetupStatus.DriversToInstall.Count > 0)
|
|
||||||
{
|
|
||||||
Parent.AddChild(new SetupStepInstallDriver((ConnectionWindow)Parent, Parent, this.currentPrinterSetupStatus));
|
|
||||||
Parent.RemoveChild(this);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Parent.AddChild(new SetupStepComPortOne((ConnectionWindow)Parent, Parent, this.currentPrinterSetupStatus));
|
|
||||||
Parent.RemoveChild(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RecreateCurrentWidget()
|
|
||||||
{
|
|
||||||
Parent.AddChild(new SetupStepComPortManual((ConnectionWindow)Parent, Parent, this.currentPrinterSetupStatus));
|
|
||||||
Parent.RemoveChild(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RefreshButton_Click(object sender, EventArgs mouseEvent)
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(RecreateCurrentWidget);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ConnectButton_Click(object sender, EventArgs mouseEvent)
|
private void ConnectButton_Click(object sender, EventArgs mouseEvent)
|
||||||
{
|
{
|
||||||
string serialPort;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
serialPort = GetSelectedSerialPort();
|
|
||||||
this.ActivePrinter.ComPort = serialPort;
|
|
||||||
this.ActivePrinter.Commit();
|
|
||||||
printerComPortHelpLink.Visible = false;
|
printerComPortHelpLink.Visible = false;
|
||||||
printerComPortError.TextColor = this.subContainerTextColor;
|
|
||||||
string printerComPortErrorLabel = LocalizedString.Get("Attempting to connect");
|
|
||||||
string printerComPortErrorLabelFull = string.Format("{0}...", printerComPortErrorLabel);
|
|
||||||
printerComPortError.Text = printerComPortErrorLabelFull;
|
|
||||||
printerComPortError.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
printerComPortError.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||||
|
|
||||||
ActivePrinterProfile.Instance.ActivePrinter = this.ActivePrinter;
|
printerComPortError.Text = "Attempting to connect".Localize() + "...";
|
||||||
|
printerComPortError.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||||
|
|
||||||
|
ActiveSliceSettings.Instance.ComPort = GetSelectedSerialPort();
|
||||||
PrinterConnectionAndCommunication.Instance.ConnectToActivePrinter();
|
PrinterConnectionAndCommunication.Instance.ConnectToActivePrinter();
|
||||||
|
|
||||||
connectButton.Visible = false;
|
connectButton.Visible = false;
|
||||||
refreshButton.Visible = false;
|
refreshButton.Visible = false;
|
||||||
}
|
}
|
||||||
|
|
@ -197,13 +148,8 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
{
|
{
|
||||||
printerComPortHelpLink.Visible = false;
|
printerComPortHelpLink.Visible = false;
|
||||||
printerComPortError.TextColor = RGBA_Bytes.Red;
|
printerComPortError.TextColor = RGBA_Bytes.Red;
|
||||||
printerComPortError.Text = LocalizedString.Get("Oops! Please select a serial port.");
|
printerComPortError.Text = "Oops! Please select a serial port.".Localize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NextButton_Click(object sender, EventArgs mouseEvent)
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(Parent.Close);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -11,14 +11,13 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
{
|
{
|
||||||
private Button nextButton;
|
private Button nextButton;
|
||||||
|
|
||||||
public SetupStepComPortOne(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus setupPrinter)
|
public SetupStepComPortOne(ConnectionWizard connectionWizard) : base(connectionWizard)
|
||||||
: base(windowController, containerWindowToClose, setupPrinter)
|
|
||||||
{
|
{
|
||||||
contentRow.AddChild(createPrinterConnectionMessageContainer());
|
contentRow.AddChild(createPrinterConnectionMessageContainer());
|
||||||
{
|
{
|
||||||
//Construct buttons
|
//Construct buttons
|
||||||
nextButton = textImageButtonFactory.Generate(LocalizedString.Get("Continue"));
|
nextButton = textImageButtonFactory.Generate("Continue".Localize());
|
||||||
nextButton.Click += new EventHandler(NextButton_Click);
|
nextButton.Click += (s, e) => connectionWizard.ChangeToSetupCompPortTwo();
|
||||||
|
|
||||||
//Add buttons to buttonContainer
|
//Add buttons to buttonContainer
|
||||||
footerRow.AddChild(nextButton);
|
footerRow.AddChild(nextButton);
|
||||||
|
|
@ -68,7 +67,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
|
|
||||||
Button manualLink = linkButtonFactory.Generate(LocalizedString.Get("Manually Configure Connection"));
|
Button manualLink = linkButtonFactory.Generate(LocalizedString.Get("Manually Configure Connection"));
|
||||||
manualLink.Margin = new BorderDouble(0, 5);
|
manualLink.Margin = new BorderDouble(0, 5);
|
||||||
manualLink.Click += new EventHandler(ManualLink_Click);
|
manualLink.Click += (s, e) => connectionWizard.ChangeToSetupComPortManual();
|
||||||
|
|
||||||
string printerMessageFourText = LocalizedString.Get("or");
|
string printerMessageFourText = LocalizedString.Get("or");
|
||||||
TextWidget printerMessageFour = new TextWidget(printerMessageFourText, 0, 0, 10);
|
TextWidget printerMessageFour = new TextWidget(printerMessageFourText, 0, 0, 10);
|
||||||
|
|
@ -93,39 +92,10 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ManualLink_Click(object sender, EventArgs mouseEvent)
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(MoveToManualConfiguration);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MoveToManualConfiguration()
|
|
||||||
{
|
|
||||||
Parent.AddChild(new SetupStepComPortManual((ConnectionWindow)Parent, Parent, this.currentPrinterSetupStatus));
|
|
||||||
Parent.RemoveChild(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void NextButton_Click(object sender, EventArgs mouseEvent)
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(MoveToNextWidget);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MoveToNextWidget()
|
|
||||||
{
|
|
||||||
Parent.AddChild(new SetupStepComPortTwo((ConnectionWindow)Parent, Parent, this.currentPrinterSetupStatus));
|
|
||||||
Parent.RemoveChild(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SkipConnectionLink_Click(object sender, EventArgs mouseEvent)
|
private void SkipConnectionLink_Click(object sender, EventArgs mouseEvent)
|
||||||
{
|
{
|
||||||
PrinterConnectionAndCommunication.Instance.HaltConnectionThread();
|
PrinterConnectionAndCommunication.Instance.HaltConnectionThread();
|
||||||
if (GetPrinterRecordCount() > 0)
|
Parent.Close();
|
||||||
{
|
|
||||||
this.windowController.ChangeToChoosePrinter();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Parent.Close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3,6 +3,7 @@ using MatterHackers.Agg.UI;
|
||||||
using MatterHackers.Localizations;
|
using MatterHackers.Localizations;
|
||||||
using MatterHackers.MatterControl.CustomWidgets;
|
using MatterHackers.MatterControl.CustomWidgets;
|
||||||
using MatterHackers.MatterControl.PrinterCommunication;
|
using MatterHackers.MatterControl.PrinterCommunication;
|
||||||
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||||
using MatterHackers.SerialPortCommunication.FrostedSerial;
|
using MatterHackers.SerialPortCommunication.FrostedSerial;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
@ -19,19 +20,18 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
|
|
||||||
private event EventHandler unregisterEvents;
|
private event EventHandler unregisterEvents;
|
||||||
|
|
||||||
public SetupStepComPortTwo(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus setupPrinterStatus)
|
public SetupStepComPortTwo(ConnectionWizard windowController) : base(windowController)
|
||||||
: base(windowController, containerWindowToClose, setupPrinterStatus)
|
|
||||||
{
|
{
|
||||||
startingPortNames = FrostedSerialPort.GetPortNames();
|
startingPortNames = FrostedSerialPort.GetPortNames();
|
||||||
contentRow.AddChild(createPrinterConnectionMessageContainer());
|
contentRow.AddChild(createPrinterConnectionMessageContainer());
|
||||||
{
|
{
|
||||||
//Construct buttons
|
//Construct buttons
|
||||||
nextButton = textImageButtonFactory.Generate(LocalizedString.Get("Done"));
|
nextButton = textImageButtonFactory.Generate("Done".Localize());
|
||||||
nextButton.Click += new EventHandler(NextButton_Click);
|
nextButton.Click += (s, e) => UiThread.RunOnIdle(Parent.Close);
|
||||||
nextButton.Visible = false;
|
nextButton.Visible = false;
|
||||||
|
|
||||||
connectButton = textImageButtonFactory.Generate(LocalizedString.Get("Connect"));
|
connectButton = textImageButtonFactory.Generate("Connect".Localize());
|
||||||
connectButton.Click += new EventHandler(ConnectButton_Click);
|
connectButton.Click += ConnectButton_Click;
|
||||||
|
|
||||||
PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||||
|
|
||||||
|
|
@ -45,10 +45,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
|
|
||||||
public override void OnClosed(EventArgs e)
|
public override void OnClosed(EventArgs e)
|
||||||
{
|
{
|
||||||
if (unregisterEvents != null)
|
unregisterEvents?.Invoke(this, null);
|
||||||
{
|
|
||||||
unregisterEvents(this, null);
|
|
||||||
}
|
|
||||||
base.OnClosed(e);
|
base.OnClosed(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,38 +56,36 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
container.Margin = new BorderDouble(5);
|
container.Margin = new BorderDouble(5);
|
||||||
BorderDouble elementMargin = new BorderDouble(top: 5);
|
BorderDouble elementMargin = new BorderDouble(top: 5);
|
||||||
|
|
||||||
string printerMessageOneText = LocalizedString.Get("MatterControl will now attempt to auto-detect printer.");
|
string printerMessageOneText = "MatterControl will now attempt to auto-detect printer.".Localize();
|
||||||
TextWidget printerMessageOne = new TextWidget(printerMessageOneText, 0, 0, 10);
|
TextWidget printerMessageOne = new TextWidget(printerMessageOneText, 0, 0, 10);
|
||||||
printerMessageOne.Margin = new BorderDouble(0, 10, 0, 5);
|
printerMessageOne.Margin = new BorderDouble(0, 10, 0, 5);
|
||||||
printerMessageOne.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
printerMessageOne.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||||
printerMessageOne.HAnchor = HAnchor.ParentLeftRight;
|
printerMessageOne.HAnchor = HAnchor.ParentLeftRight;
|
||||||
printerMessageOne.Margin = elementMargin;
|
printerMessageOne.Margin = elementMargin;
|
||||||
|
|
||||||
string printerMessageTwoTxtBeg = LocalizedString.Get("Disconnect printer");
|
string disconnectMessage = string.Format("1.) {0} ({1}).", "Disconnect printer".Localize(), "if currently connected".Localize());
|
||||||
string printerMessageTwoTxtEnd = LocalizedString.Get("if currently connected");
|
TextWidget printerMessageTwo = new TextWidget(disconnectMessage, 0, 0, 12);
|
||||||
string printerMessageTwoTxtFull = string.Format("1.) {0} ({1}).", printerMessageTwoTxtBeg, printerMessageTwoTxtEnd);
|
|
||||||
TextWidget printerMessageTwo = new TextWidget(printerMessageTwoTxtFull, 0, 0, 12);
|
|
||||||
printerMessageTwo.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
printerMessageTwo.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||||
printerMessageTwo.HAnchor = HAnchor.ParentLeftRight;
|
printerMessageTwo.HAnchor = HAnchor.ParentLeftRight;
|
||||||
printerMessageTwo.Margin = elementMargin;
|
printerMessageTwo.Margin = elementMargin;
|
||||||
|
|
||||||
string printerMessageThreeTxtBeg = LocalizedString.Get("Press");
|
string printerMessageThreeTxtBeg = "Press".Localize();
|
||||||
string printerMessageThreeTxtEnd = LocalizedString.Get("Continue");
|
string printerMessageThreeTxtEnd = "Continue".Localize();
|
||||||
string printerMessageThreeTxtFull = string.Format("2.) {0} '{1}'.", printerMessageThreeTxtBeg, printerMessageThreeTxtEnd);
|
string printerMessageThreeTxtFull = string.Format("2.) {0} '{1}'.", printerMessageThreeTxtBeg, printerMessageThreeTxtEnd);
|
||||||
TextWidget printerMessageThree = new TextWidget(printerMessageThreeTxtFull, 0, 0, 12);
|
TextWidget printerMessageThree = new TextWidget(printerMessageThreeTxtFull, 0, 0, 12);
|
||||||
printerMessageThree.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
printerMessageThree.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||||
printerMessageThree.HAnchor = HAnchor.ParentLeftRight;
|
printerMessageThree.HAnchor = HAnchor.ParentLeftRight;
|
||||||
printerMessageThree.Margin = elementMargin;
|
printerMessageThree.Margin = elementMargin;
|
||||||
|
|
||||||
string printerMessageFourBeg = LocalizedString.Get("Power on and connect printer");
|
string printerMessageFourBeg = "Power on and connect printer".Localize();
|
||||||
string printerMessageFourFull = string.Format("3.) {0}.", printerMessageFourBeg);
|
string printerMessageFourFull = string.Format("3.) {0}.", printerMessageFourBeg);
|
||||||
TextWidget printerMessageFour = new TextWidget(printerMessageFourFull, 0, 0, 12);
|
TextWidget printerMessageFour = new TextWidget(printerMessageFourFull, 0, 0, 12);
|
||||||
printerMessageFour.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
printerMessageFour.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||||
printerMessageFour.HAnchor = HAnchor.ParentLeftRight;
|
printerMessageFour.HAnchor = HAnchor.ParentLeftRight;
|
||||||
printerMessageFour.Margin = elementMargin;
|
printerMessageFour.Margin = elementMargin;
|
||||||
|
|
||||||
string printerMessageFiveTxtBeg = LocalizedString.Get("Press");
|
string printerMessageFiveTxtBeg = "Press".Localize();
|
||||||
string printerMessageFiveTxtEnd = LocalizedString.Get("Connect");
|
string printerMessageFiveTxtEnd = "Connect".Localize();
|
||||||
string printerMessageFiveTxtFull = string.Format("4.) {0} '{1}'.", printerMessageFiveTxtBeg, printerMessageFiveTxtEnd);
|
string printerMessageFiveTxtFull = string.Format("4.) {0} '{1}'.", printerMessageFiveTxtBeg, printerMessageFiveTxtEnd);
|
||||||
TextWidget printerMessageFive = new TextWidget(printerMessageFiveTxtFull, 0, 0, 12);
|
TextWidget printerMessageFive = new TextWidget(printerMessageFiveTxtFull, 0, 0, 12);
|
||||||
printerMessageFive.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
printerMessageFive.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||||
|
|
@ -100,9 +95,9 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
GuiWidget vSpacer = new GuiWidget();
|
GuiWidget vSpacer = new GuiWidget();
|
||||||
vSpacer.VAnchor = VAnchor.ParentBottomTop;
|
vSpacer.VAnchor = VAnchor.ParentBottomTop;
|
||||||
|
|
||||||
Button manualLink = linkButtonFactory.Generate(LocalizedString.Get("Manual Configuration"));
|
Button manualLink = linkButtonFactory.Generate("Manual Configuration".Localize());
|
||||||
manualLink.Margin = new BorderDouble(0, 5);
|
manualLink.Margin = new BorderDouble(0, 5);
|
||||||
manualLink.Click += new EventHandler(ManualLink_Click);
|
manualLink.Click += (s, e) => connectionWizard.ChangeToSetupComPortManual();
|
||||||
|
|
||||||
printerErrorMessage = new TextWidget("", 0, 0, 10);
|
printerErrorMessage = new TextWidget("", 0, 0, 10);
|
||||||
printerErrorMessage.AutoExpandBoundsToText = true;
|
printerErrorMessage.AutoExpandBoundsToText = true;
|
||||||
|
|
@ -123,17 +118,6 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ManualLink_Click(object sender, EventArgs mouseEvent)
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(MoveToManualConfiguration);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MoveToManualConfiguration()
|
|
||||||
{
|
|
||||||
Parent.AddChild(new SetupStepComPortManual((ConnectionWindow)Parent, Parent, this.currentPrinterSetupStatus));
|
|
||||||
Parent.RemoveChild(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ConnectButton_Click(object sender, EventArgs mouseEvent)
|
private void ConnectButton_Click(object sender, EventArgs mouseEvent)
|
||||||
{
|
{
|
||||||
// Select the first port that's in GetPortNames() but not in startingPortNames
|
// Select the first port that's in GetPortNames() but not in startingPortNames
|
||||||
|
|
@ -141,18 +125,14 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
if (candidatePort == null)
|
if (candidatePort == null)
|
||||||
{
|
{
|
||||||
printerErrorMessage.TextColor = RGBA_Bytes.Red;
|
printerErrorMessage.TextColor = RGBA_Bytes.Red;
|
||||||
string printerErrorMessageLabelFull = LocalizedString.Get("Oops! Printer could not be detected ");
|
printerErrorMessage.Text = "Oops! Printer could not be detected ".Localize();
|
||||||
printerErrorMessage.Text = printerErrorMessageLabelFull;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ActivePrinter.ComPort = candidatePort;
|
|
||||||
printerErrorMessage.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
printerErrorMessage.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||||
string printerErrorMessageLabelTwo = LocalizedString.Get("Attempting to connect");
|
printerErrorMessage.Text = "Attempting to connect".Localize() + "...";
|
||||||
string printerErrorMessageLabelTwoFull = string.Format("{0}...", printerErrorMessageLabelTwo);
|
|
||||||
printerErrorMessage.Text = printerErrorMessageLabelTwoFull;
|
ActiveSliceSettings.Instance.ComPort = candidatePort;
|
||||||
this.ActivePrinter.Commit();
|
|
||||||
ActivePrinterProfile.Instance.ActivePrinter = this.ActivePrinter;
|
|
||||||
PrinterConnectionAndCommunication.Instance.ConnectToActivePrinter();
|
PrinterConnectionAndCommunication.Instance.ConnectToActivePrinter();
|
||||||
connectButton.Visible = false;
|
connectButton.Visible = false;
|
||||||
}
|
}
|
||||||
|
|
@ -162,36 +142,19 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
{
|
{
|
||||||
if (PrinterConnectionAndCommunication.Instance.PrinterIsConnected)
|
if (PrinterConnectionAndCommunication.Instance.PrinterIsConnected)
|
||||||
{
|
{
|
||||||
onConnectionSuccess();
|
printerErrorMessage.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||||
|
printerErrorMessage.Text = "Connection succeeded".Localize() + "!";
|
||||||
|
nextButton.Visible = true;
|
||||||
|
connectButton.Visible = false;
|
||||||
|
UiThread.RunOnIdle(Parent.Close);
|
||||||
}
|
}
|
||||||
else if (PrinterConnectionAndCommunication.Instance.CommunicationState != PrinterConnectionAndCommunication.CommunicationStates.AttemptingToConnect)
|
else if (PrinterConnectionAndCommunication.Instance.CommunicationState != PrinterConnectionAndCommunication.CommunicationStates.AttemptingToConnect)
|
||||||
{
|
{
|
||||||
onConnectionFailed();
|
printerErrorMessage.TextColor = RGBA_Bytes.Red;
|
||||||
|
printerErrorMessage.Text = "Uh-oh! Could not connect to printer.".Localize();
|
||||||
|
connectButton.Visible = true;
|
||||||
|
nextButton.Visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onConnectionFailed()
|
|
||||||
{
|
|
||||||
printerErrorMessage.TextColor = RGBA_Bytes.Red;
|
|
||||||
printerErrorMessage.Text = LocalizedString.Get("Uh-oh! Could not connect to printer.");
|
|
||||||
connectButton.Visible = true;
|
|
||||||
nextButton.Visible = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onConnectionSuccess()
|
|
||||||
{
|
|
||||||
printerErrorMessage.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
|
||||||
string printerErrorMessageLabelThree = LocalizedString.Get("Connection succeeded");
|
|
||||||
string printerErrorMessageLabelThreeFull = string.Format("{0}!", printerErrorMessageLabelThree);
|
|
||||||
printerErrorMessage.Text = printerErrorMessageLabelThreeFull;
|
|
||||||
nextButton.Visible = true;
|
|
||||||
connectButton.Visible = false;
|
|
||||||
UiThread.RunOnIdle(Parent.Close);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void NextButton_Click(object sender, EventArgs mouseEvent)
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(Parent.Close);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -36,93 +36,47 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
{
|
{
|
||||||
public class SetupStepConfigureConnection : SetupConnectionWidgetBase
|
public class SetupStepConfigureConnection : SetupConnectionWidgetBase
|
||||||
{
|
{
|
||||||
private Button nextButton;
|
public SetupStepConfigureConnection(ConnectionWizard connectionWizard) : base(connectionWizard)
|
||||||
private Button skipButton;
|
|
||||||
private TextWidget printerErrorMessage;
|
|
||||||
|
|
||||||
public SetupStepConfigureConnection(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus setupPrinter)
|
|
||||||
: base(windowController, containerWindowToClose, setupPrinter)
|
|
||||||
{
|
{
|
||||||
contentRow.AddChild(createPrinterConnectionMessageContainer());
|
|
||||||
{
|
|
||||||
//Construct buttons
|
|
||||||
nextButton = textImageButtonFactory.Generate("Connect");
|
|
||||||
nextButton.Click += new EventHandler(NextButton_Click);
|
|
||||||
|
|
||||||
skipButton = textImageButtonFactory.Generate("Skip");
|
|
||||||
skipButton.Click += new EventHandler(SkipButton_Click);
|
|
||||||
|
|
||||||
//Add buttons to buttonContainer
|
|
||||||
footerRow.AddChild(nextButton);
|
|
||||||
footerRow.AddChild(skipButton);
|
|
||||||
footerRow.AddChild(new HorizontalSpacer());
|
|
||||||
footerRow.AddChild(cancelButton);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public FlowLayoutWidget createPrinterConnectionMessageContainer()
|
|
||||||
{
|
|
||||||
FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
|
||||||
container.Margin = new BorderDouble(5);
|
|
||||||
BorderDouble elementMargin = new BorderDouble(top: 5);
|
BorderDouble elementMargin = new BorderDouble(top: 5);
|
||||||
|
|
||||||
TextWidget continueMessage = new TextWidget("Would you like to connect to this printer now?", 0, 0, 12);
|
var continueMessage = new TextWidget("Would you like to connect to this printer now?", 0, 0, 12);
|
||||||
continueMessage.AutoExpandBoundsToText = true;
|
continueMessage.AutoExpandBoundsToText = true;
|
||||||
continueMessage.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
continueMessage.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||||
continueMessage.HAnchor = HAnchor.ParentLeftRight;
|
continueMessage.HAnchor = HAnchor.ParentLeftRight;
|
||||||
continueMessage.Margin = elementMargin;
|
continueMessage.Margin = elementMargin;
|
||||||
|
|
||||||
TextWidget continueMessageTwo = new TextWidget("You can always configure this later.", 0, 0, 10);
|
var continueMessageTwo = new TextWidget("You can always configure this later.", 0, 0, 10);
|
||||||
continueMessageTwo.AutoExpandBoundsToText = true;
|
continueMessageTwo.AutoExpandBoundsToText = true;
|
||||||
continueMessageTwo.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
continueMessageTwo.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||||
continueMessageTwo.HAnchor = HAnchor.ParentLeftRight;
|
continueMessageTwo.HAnchor = HAnchor.ParentLeftRight;
|
||||||
continueMessageTwo.Margin = elementMargin;
|
continueMessageTwo.Margin = elementMargin;
|
||||||
|
|
||||||
printerErrorMessage = new TextWidget("", 0, 0, 10);
|
var printerErrorMessage = new TextWidget("", 0, 0, 10);
|
||||||
printerErrorMessage.AutoExpandBoundsToText = true;
|
printerErrorMessage.AutoExpandBoundsToText = true;
|
||||||
printerErrorMessage.TextColor = RGBA_Bytes.Red;
|
printerErrorMessage.TextColor = RGBA_Bytes.Red;
|
||||||
printerErrorMessage.HAnchor = HAnchor.ParentLeftRight;
|
printerErrorMessage.HAnchor = HAnchor.ParentLeftRight;
|
||||||
printerErrorMessage.Margin = elementMargin;
|
printerErrorMessage.Margin = elementMargin;
|
||||||
|
|
||||||
|
var container = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||||
|
container.Margin = new BorderDouble(5);
|
||||||
container.AddChild(continueMessage);
|
container.AddChild(continueMessage);
|
||||||
container.AddChild(continueMessageTwo);
|
container.AddChild(continueMessageTwo);
|
||||||
container.AddChild(printerErrorMessage);
|
container.AddChild(printerErrorMessage);
|
||||||
|
|
||||||
container.HAnchor = HAnchor.ParentLeftRight;
|
container.HAnchor = HAnchor.ParentLeftRight;
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SkipButton_Click(object sender, EventArgs e)
|
//Construct buttons
|
||||||
{
|
var nextButton = textImageButtonFactory.Generate("Connect");
|
||||||
//Save the printer info to the datastore and exit the setup process
|
nextButton.Click += (s, e) => base.connectionWizard.ChangeToSetupBaudOrComPortOne();
|
||||||
this.ActivePrinter.Commit();
|
|
||||||
SaveAndExit();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MoveToNextWidget()
|
var skipButton = textImageButtonFactory.Generate("Skip");
|
||||||
{
|
skipButton.Click += (s, e) => SaveAndExit();
|
||||||
// you can call this like this
|
|
||||||
// AfterUiEvents.AddAction(new AfterUIAction(MoveToNextWidget));
|
|
||||||
if (this.ActivePrinter.BaudRate == null)
|
|
||||||
{
|
|
||||||
Parent.AddChild(new SetupStepBaudRate((ConnectionWindow)Parent, Parent, this.currentPrinterSetupStatus));
|
|
||||||
Parent.RemoveChild(this);
|
|
||||||
}
|
|
||||||
else if (this.currentPrinterSetupStatus.DriversToInstall.Count > 0)
|
|
||||||
{
|
|
||||||
Parent.AddChild(new SetupStepInstallDriver((ConnectionWindow)Parent, Parent, this.currentPrinterSetupStatus));
|
|
||||||
Parent.RemoveChild(this);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Parent.AddChild(new SetupStepComPortOne((ConnectionWindow)Parent, Parent, this.currentPrinterSetupStatus));
|
|
||||||
Parent.RemoveChild(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void NextButton_Click(object sender, EventArgs mouseEvent)
|
//Add buttons to buttonContainer
|
||||||
{
|
footerRow.AddChild(nextButton);
|
||||||
UiThread.RunOnIdle(MoveToNextWidget);
|
footerRow.AddChild(skipButton);
|
||||||
|
footerRow.AddChild(new HorizontalSpacer());
|
||||||
|
footerRow.AddChild(cancelButton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3,6 +3,7 @@ using MatterHackers.Agg.PlatformAbstract;
|
||||||
using MatterHackers.Agg.UI;
|
using MatterHackers.Agg.UI;
|
||||||
using MatterHackers.Localizations;
|
using MatterHackers.Localizations;
|
||||||
using MatterHackers.MatterControl.CustomWidgets;
|
using MatterHackers.MatterControl.CustomWidgets;
|
||||||
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
@ -14,18 +15,13 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
{
|
{
|
||||||
private FlowLayoutWidget printerDriverContainer;
|
private FlowLayoutWidget printerDriverContainer;
|
||||||
private TextWidget printerDriverMessage;
|
private TextWidget printerDriverMessage;
|
||||||
private List<string> driversToInstall;
|
|
||||||
|
|
||||||
//bool driverInstallFinished;
|
|
||||||
|
|
||||||
private Button installButton;
|
private Button installButton;
|
||||||
private Button skipButton;
|
private Button skipButton;
|
||||||
|
|
||||||
public SetupStepInstallDriver(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus setupPrinterStatus)
|
public SetupStepInstallDriver(ConnectionWizard windowController)
|
||||||
: base(windowController, containerWindowToClose, setupPrinterStatus)
|
: base(windowController)
|
||||||
{
|
{
|
||||||
this.driversToInstall = this.currentPrinterSetupStatus.DriversToInstall;
|
|
||||||
|
|
||||||
headerLabel.Text = string.Format(LocalizedString.Get("Install Communication Driver"));
|
headerLabel.Text = string.Format(LocalizedString.Get("Install Communication Driver"));
|
||||||
printerDriverContainer = createPrinterDriverContainer();
|
printerDriverContainer = createPrinterDriverContainer();
|
||||||
contentRow.AddChild(printerDriverContainer);
|
contentRow.AddChild(printerDriverContainer);
|
||||||
|
|
@ -34,35 +30,27 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
installButton = textImageButtonFactory.Generate(LocalizedString.Get("Install Driver"));
|
installButton = textImageButtonFactory.Generate(LocalizedString.Get("Install Driver"));
|
||||||
installButton.Click += (sender, e) =>
|
installButton.Click += (sender, e) =>
|
||||||
{
|
{
|
||||||
UiThread.RunOnIdle(installButton_Click);
|
UiThread.RunOnIdle(() =>
|
||||||
|
{
|
||||||
|
bool canContinue = this.InstallDriver();
|
||||||
|
if (canContinue)
|
||||||
|
{
|
||||||
|
connectionWizard.ChangeToSetupBaudOrComPortOne();
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
skipButton = textImageButtonFactory.Generate(LocalizedString.Get("Skip"));
|
skipButton = textImageButtonFactory.Generate(LocalizedString.Get("Skip"));
|
||||||
skipButton.Click += new EventHandler(skipButton_Click);
|
skipButton.Click += (s, e) => connectionWizard.ChangeToSetupBaudOrComPortOne();
|
||||||
|
|
||||||
//Add buttons to buttonContainer
|
//Add buttons to buttonContainer
|
||||||
footerRow.AddChild(installButton);
|
footerRow.AddChild(installButton);
|
||||||
footerRow.AddChild(skipButton);
|
footerRow.AddChild(skipButton);
|
||||||
footerRow.AddChild(new HorizontalSpacer());
|
footerRow.AddChild(new HorizontalSpacer());
|
||||||
|
|
||||||
footerRow.AddChild(cancelButton);
|
footerRow.AddChild(cancelButton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void installButton_Click()
|
|
||||||
{
|
|
||||||
bool canContinue = this.OnSave();
|
|
||||||
if (canContinue)
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(MoveToNextWidget);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void skipButton_Click(object sender, EventArgs mouseEvent)
|
|
||||||
{
|
|
||||||
UiThread.RunOnIdle(MoveToNextWidget);
|
|
||||||
}
|
|
||||||
|
|
||||||
private FlowLayoutWidget createPrinterDriverContainer()
|
private FlowLayoutWidget createPrinterDriverContainer()
|
||||||
{
|
{
|
||||||
FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||||
|
|
@ -86,23 +74,6 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MoveToNextWidget()
|
|
||||||
{
|
|
||||||
// you can call this like this
|
|
||||||
// AfterUiEvents.AddAction(new AfterUIAction(MoveToNextWidget));
|
|
||||||
|
|
||||||
if (this.ActivePrinter.BaudRate == null)
|
|
||||||
{
|
|
||||||
Parent.AddChild(new SetupStepBaudRate((ConnectionWindow)Parent, Parent, this.currentPrinterSetupStatus));
|
|
||||||
Parent.RemoveChild(this);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Parent.AddChild(new SetupStepComPortOne((ConnectionWindow)Parent, Parent, this.currentPrinterSetupStatus));
|
|
||||||
Parent.RemoveChild(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InstallDriver(string fileName)
|
private void InstallDriver(string fileName)
|
||||||
{
|
{
|
||||||
switch (OsInformation.OperatingSystem)
|
switch (OsInformation.OperatingSystem)
|
||||||
|
|
@ -114,9 +85,10 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
{
|
{
|
||||||
Process driverInstallerProcess = new Process();
|
Process driverInstallerProcess = new Process();
|
||||||
// Prepare the process to run
|
// Prepare the process to run
|
||||||
|
|
||||||
// Enter in the command line arguments, everything you would enter after the executable name itself
|
// Enter in the command line arguments, everything you would enter after the executable name itself
|
||||||
|
|
||||||
driverInstallerProcess.StartInfo.Arguments = Path.GetFullPath(fileName);
|
driverInstallerProcess.StartInfo.Arguments = Path.GetFullPath(fileName);
|
||||||
|
|
||||||
// Enter the executable to run, including the complete path
|
// Enter the executable to run, including the complete path
|
||||||
string printerDriverInstallerExePathAndFileName = Path.GetFullPath(Path.Combine(".", "InfInstaller.exe"));
|
string printerDriverInstallerExePathAndFileName = Path.GetFullPath(Path.Combine(".", "InfInstaller.exe"));
|
||||||
|
|
||||||
|
|
@ -137,7 +109,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Exception(string.Format("Can't find dirver {0}.", fileName));
|
throw new Exception(string.Format("Can't find driver {0}.", fileName));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -151,8 +123,10 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
{
|
{
|
||||||
var driverInstallerProcess = new Process();
|
var driverInstallerProcess = new Process();
|
||||||
// Prepare the process to run
|
// Prepare the process to run
|
||||||
|
|
||||||
// Enter in the command line arguments, everything you would enter after the executable name itself
|
// Enter in the command line arguments, everything you would enter after the executable name itself
|
||||||
driverInstallerProcess.StartInfo.Arguments = Path.GetFullPath(fileName);
|
driverInstallerProcess.StartInfo.Arguments = Path.GetFullPath(fileName);
|
||||||
|
|
||||||
// Enter the executable to run, including the complete path
|
// Enter the executable to run, including the complete path
|
||||||
string printerDriverInstallerExePathAndFileName = Path.Combine(".", "InfInstaller.exe");
|
string printerDriverInstallerExePathAndFileName = Path.Combine(".", "InfInstaller.exe");
|
||||||
|
|
||||||
|
|
@ -177,28 +151,28 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Exception(string.Format("Can't find dirver {0}.", fileName));
|
throw new Exception("Can't find driver: " + fileName);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool OnSave()
|
private bool InstallDriver()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string printerDriverMessageLabel = LocalizedString.Get("Installing");
|
printerDriverMessage.Text = "Installing".Localize() + "...";
|
||||||
string printerDriverMessageLabelFull = string.Format("{0}...", printerDriverMessageLabel);
|
|
||||||
printerDriverMessage.Text = printerDriverMessageLabelFull;
|
foreach (string driverPath in ActiveSliceSettings.Instance.PrinterDrivers())
|
||||||
foreach (string driverPath in this.driversToInstall)
|
|
||||||
{
|
{
|
||||||
InstallDriver(driverPath);
|
InstallDriver(driverPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
printerDriverMessage.Text = LocalizedString.Get("Sorry, we were unable to install the driver.");
|
printerDriverMessage.Text = "Sorry, we were unable to install the driver.".Localize();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ using MatterHackers.MatterControl.SettingsManagement;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using MatterHackers.MatterControl.CustomWidgets;
|
using MatterHackers.MatterControl.CustomWidgets;
|
||||||
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
{
|
{
|
||||||
|
|
@ -19,8 +20,6 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
|
|
||||||
private MHTextEditWidget printerNameInput;
|
private MHTextEditWidget printerNameInput;
|
||||||
|
|
||||||
private List<CustomCommands> printerCustomCommands;
|
|
||||||
|
|
||||||
private TextWidget printerNameError;
|
private TextWidget printerNameError;
|
||||||
private TextWidget printerModelError;
|
private TextWidget printerModelError;
|
||||||
private TextWidget printerMakeError;
|
private TextWidget printerMakeError;
|
||||||
|
|
@ -31,8 +30,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
|
|
||||||
private bool usingDefaultName;
|
private bool usingDefaultName;
|
||||||
|
|
||||||
public SetupStepMakeModelName(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus printerSetupStatus = null)
|
public SetupStepMakeModelName(ConnectionWizard windowController) : base(windowController)
|
||||||
: base(windowController, containerWindowToClose, printerSetupStatus)
|
|
||||||
{
|
{
|
||||||
//Construct inputs
|
//Construct inputs
|
||||||
printerNameContainer = createPrinterNameContainer();
|
printerNameContainer = createPrinterNameContainer();
|
||||||
|
|
@ -59,7 +57,14 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
//Construct buttons
|
//Construct buttons
|
||||||
nextButton = textImageButtonFactory.Generate(LocalizedString.Get("Save & Continue"));
|
nextButton = textImageButtonFactory.Generate(LocalizedString.Get("Save & Continue"));
|
||||||
nextButton.Name = "Save & Continue Button";
|
nextButton.Name = "Save & Continue Button";
|
||||||
nextButton.Click += new EventHandler(NextButton_Click);
|
nextButton.Click += (s, e) =>
|
||||||
|
{
|
||||||
|
bool canContinue = this.OnSave();
|
||||||
|
if (canContinue)
|
||||||
|
{
|
||||||
|
UiThread.RunOnIdle(connectionWizard.Close);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//Add buttons to buttonContainer
|
//Add buttons to buttonContainer
|
||||||
footerRow.AddChild(nextButton);
|
footerRow.AddChild(nextButton);
|
||||||
|
|
@ -68,10 +73,10 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
|
|
||||||
usingDefaultName = true;
|
usingDefaultName = true;
|
||||||
|
|
||||||
SetElementState();
|
SetElementVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetElementState()
|
private void SetElementVisibility()
|
||||||
{
|
{
|
||||||
printerModelContainer.Visible = (this.ActivePrinter.Make != null);
|
printerModelContainer.Visible = (this.ActivePrinter.Make != null);
|
||||||
nextButton.Visible = (this.ActivePrinter.Model != null && this.ActivePrinter.Make != null);
|
nextButton.Visible = (this.ActivePrinter.Model != null && this.ActivePrinter.Make != null);
|
||||||
|
|
@ -79,93 +84,104 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
|
|
||||||
private FlowLayoutWidget createPrinterNameContainer()
|
private FlowLayoutWidget createPrinterNameContainer()
|
||||||
{
|
{
|
||||||
|
TextWidget printerNameLabel = new TextWidget("Name".Localize() + ":", 0, 0, 12)
|
||||||
|
{
|
||||||
|
TextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||||
|
HAnchor = HAnchor.ParentLeftRight,
|
||||||
|
Margin = new BorderDouble(0, 0, 0, 1)
|
||||||
|
};
|
||||||
|
|
||||||
|
printerNameInput = new MHTextEditWidget(this.ActivePrinter.Name)
|
||||||
|
{
|
||||||
|
HAnchor = HAnchor.ParentLeftRight,
|
||||||
|
};
|
||||||
|
printerNameInput.KeyPressed += (s, e) => this.usingDefaultName = false;
|
||||||
|
|
||||||
|
printerNameError = new TextWidget("Give your printer a name.".Localize(), 0, 0, 10)
|
||||||
|
{
|
||||||
|
TextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||||
|
HAnchor = HAnchor.ParentLeftRight,
|
||||||
|
Margin = new BorderDouble(top: 3)
|
||||||
|
};
|
||||||
|
|
||||||
FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||||
container.Margin = new BorderDouble(0, 5);
|
container.Margin = new BorderDouble(0, 5);
|
||||||
BorderDouble elementMargin = new BorderDouble(top: 3);
|
|
||||||
|
|
||||||
string printerNameLabelTxt = LocalizedString.Get("Name");
|
|
||||||
string printerNameLabelTxtFull = string.Format("{0}:", printerNameLabelTxt);
|
|
||||||
TextWidget printerNameLabel = new TextWidget(printerNameLabelTxtFull, 0, 0, 12);
|
|
||||||
printerNameLabel.TextColor = this.defaultTextColor;
|
|
||||||
printerNameLabel.HAnchor = HAnchor.ParentLeftRight;
|
|
||||||
printerNameLabel.Margin = new BorderDouble(0, 0, 0, 1);
|
|
||||||
|
|
||||||
printerNameInput = new MHTextEditWidget(this.ActivePrinter.Name);
|
|
||||||
printerNameInput.HAnchor = HAnchor.ParentLeftRight;
|
|
||||||
printerNameInput.KeyPressed += PrinterNameInput_KeyPressed;
|
|
||||||
|
|
||||||
printerNameError = new TextWidget(LocalizedString.Get("Give your printer a name."), 0, 0, 10);
|
|
||||||
printerNameError.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
|
||||||
printerNameError.HAnchor = HAnchor.ParentLeftRight;
|
|
||||||
printerNameError.Margin = elementMargin;
|
|
||||||
|
|
||||||
container.AddChild(printerNameLabel);
|
container.AddChild(printerNameLabel);
|
||||||
container.AddChild(printerNameInput);
|
container.AddChild(printerNameInput);
|
||||||
container.AddChild(printerNameError);
|
container.AddChild(printerNameError);
|
||||||
container.HAnchor = HAnchor.ParentLeftRight;
|
container.HAnchor = HAnchor.ParentLeftRight;
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FlowLayoutWidget createPrinterMakeContainer()
|
private FlowLayoutWidget createPrinterMakeContainer()
|
||||||
{
|
{
|
||||||
FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
|
||||||
container.Margin = new BorderDouble(0, 5);
|
|
||||||
BorderDouble elementMargin = new BorderDouble(top: 3);
|
BorderDouble elementMargin = new BorderDouble(top: 3);
|
||||||
|
|
||||||
string printerManufacturerLabelTxt = LocalizedString.Get("Make");
|
TextWidget printerManufacturerLabel = new TextWidget("Make".Localize() + ":", 0, 0, 12)
|
||||||
string printerManufacturerLabelTxtFull = string.Format("{0}:", printerManufacturerLabelTxt);
|
{
|
||||||
TextWidget printerManufacturerLabel = new TextWidget(printerManufacturerLabelTxtFull, 0, 0, 12);
|
TextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||||
printerManufacturerLabel.TextColor = this.defaultTextColor;
|
HAnchor = HAnchor.ParentLeftRight,
|
||||||
printerManufacturerLabel.HAnchor = HAnchor.ParentLeftRight;
|
Margin = elementMargin
|
||||||
printerManufacturerLabel.Margin = elementMargin;
|
};
|
||||||
|
|
||||||
printerManufacturerSelector = new PrinterChooser();
|
printerManufacturerSelector = new PrinterChooser()
|
||||||
printerManufacturerSelector.HAnchor = HAnchor.ParentLeftRight;
|
{
|
||||||
printerManufacturerSelector.Margin = elementMargin;
|
HAnchor = HAnchor.ParentLeftRight,
|
||||||
printerManufacturerSelector.ManufacturerDropList.SelectionChanged += new EventHandler(ManufacturerDropList_SelectionChanged);
|
Margin = elementMargin
|
||||||
|
};
|
||||||
|
printerManufacturerSelector.ManufacturerDropList.SelectionChanged += ManufacturerDropList_SelectionChanged;
|
||||||
|
|
||||||
printerMakeError = new TextWidget(LocalizedString.Get("Select the printer manufacturer"), 0, 0, 10);
|
printerMakeError = new TextWidget("Select the printer manufacturer".Localize(), 0, 0, 10)
|
||||||
printerMakeError.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
{
|
||||||
printerMakeError.HAnchor = HAnchor.ParentLeftRight;
|
TextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||||
printerMakeError.Margin = elementMargin;
|
HAnchor = HAnchor.ParentLeftRight,
|
||||||
|
Margin = elementMargin
|
||||||
|
};
|
||||||
|
|
||||||
|
FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||||
|
container.Margin = new BorderDouble(0, 5);
|
||||||
container.AddChild(printerManufacturerLabel);
|
container.AddChild(printerManufacturerLabel);
|
||||||
container.AddChild(printerManufacturerSelector);
|
container.AddChild(printerManufacturerSelector);
|
||||||
container.AddChild(printerMakeError);
|
container.AddChild(printerMakeError);
|
||||||
|
|
||||||
container.HAnchor = HAnchor.ParentLeftRight;
|
container.HAnchor = HAnchor.ParentLeftRight;
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FlowLayoutWidget createPrinterModelContainer(string make = "Other")
|
private FlowLayoutWidget createPrinterModelContainer(string make = "Other")
|
||||||
{
|
{
|
||||||
FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
|
||||||
container.Margin = new BorderDouble(0, 5);
|
|
||||||
BorderDouble elementMargin = new BorderDouble(top: 3);
|
BorderDouble elementMargin = new BorderDouble(top: 3);
|
||||||
|
|
||||||
string printerModelLabelTxt = LocalizedString.Get("Model");
|
TextWidget printerModelLabel = new TextWidget("Model".Localize() + ":", 0, 0, 12)
|
||||||
string printerModelLabelTxtFull = string.Format("{0}:", printerModelLabelTxt);
|
{
|
||||||
TextWidget printerModelLabel = new TextWidget(printerModelLabelTxtFull, 0, 0, 12);
|
TextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||||
printerModelLabel.TextColor = this.defaultTextColor;
|
HAnchor = HAnchor.ParentLeftRight,
|
||||||
printerModelLabel.HAnchor = HAnchor.ParentLeftRight;
|
Margin = elementMargin
|
||||||
printerModelLabel.Margin = elementMargin;
|
};
|
||||||
|
|
||||||
ModelChooser printerModelSelector = new ModelChooser(make);
|
ModelChooser printerModelSelector = new ModelChooser(make)
|
||||||
printerModelSelector.HAnchor = HAnchor.ParentLeftRight;
|
{
|
||||||
printerModelSelector.Margin = elementMargin;
|
HAnchor = HAnchor.ParentLeftRight,
|
||||||
|
Margin = elementMargin
|
||||||
|
};
|
||||||
printerModelSelector.ModelDropList.SelectionChanged += new EventHandler(ModelDropList_SelectionChanged);
|
printerModelSelector.ModelDropList.SelectionChanged += new EventHandler(ModelDropList_SelectionChanged);
|
||||||
printerModelSelector.SelectIfOnlyOneModel();
|
printerModelSelector.SelectIfOnlyOneModel();
|
||||||
|
|
||||||
printerModelError = new TextWidget(LocalizedString.Get("Select the printer model"), 0, 0, 10);
|
printerModelError = new TextWidget("Select the printer model".Localize(), 0, 0, 10)
|
||||||
printerModelError.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
{
|
||||||
printerModelError.HAnchor = HAnchor.ParentLeftRight;
|
TextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||||
printerModelError.Margin = elementMargin;
|
HAnchor = HAnchor.ParentLeftRight,
|
||||||
|
Margin = elementMargin
|
||||||
|
};
|
||||||
|
|
||||||
|
FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||||
|
container.Margin = new BorderDouble(0, 5);
|
||||||
container.AddChild(printerModelLabel);
|
container.AddChild(printerModelLabel);
|
||||||
container.AddChild(printerModelSelector);
|
container.AddChild(printerModelSelector);
|
||||||
container.AddChild(printerModelError);
|
container.AddChild(printerModelError);
|
||||||
|
|
||||||
container.HAnchor = HAnchor.ParentLeftRight;
|
container.HAnchor = HAnchor.ParentLeftRight;
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -174,7 +190,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
ActivePrinter.Make = ((DropDownList)sender).SelectedValue;
|
ActivePrinter.Make = ((DropDownList)sender).SelectedValue;
|
||||||
ActivePrinter.Model = null;
|
ActivePrinter.Model = null;
|
||||||
ReconstructModelSelector();
|
ReconstructModelSelector();
|
||||||
SetElementState();
|
SetElementVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReconstructModelSelector()
|
private void ReconstructModelSelector()
|
||||||
|
|
@ -183,8 +199,6 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
int currentIndex = contentRow.GetChildIndex(printerModelContainer);
|
int currentIndex = contentRow.GetChildIndex(printerModelContainer);
|
||||||
contentRow.RemoveChild(printerModelContainer);
|
contentRow.RemoveChild(printerModelContainer);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
printerModelContainer = createPrinterModelContainer(ActivePrinter.Make);
|
printerModelContainer = createPrinterModelContainer(ActivePrinter.Make);
|
||||||
contentRow.AddChild(printerModelContainer, currentIndex);
|
contentRow.AddChild(printerModelContainer, currentIndex);
|
||||||
contentRow.Invalidate();
|
contentRow.Invalidate();
|
||||||
|
|
@ -197,101 +211,53 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
ActivePrinter.Model = ((DropDownList)sender).SelectedLabel;
|
ActivePrinter.Model = ((DropDownList)sender).SelectedLabel;
|
||||||
currentPrinterSetupStatus.LoadSetupSettings(ActivePrinter.Make, ActivePrinter.Model);
|
|
||||||
printerModelError.Visible = false;
|
printerModelError.Visible = false;
|
||||||
SetElementState();
|
SetElementVisibility();
|
||||||
if (usingDefaultName)
|
if (usingDefaultName)
|
||||||
{
|
{
|
||||||
// Use ManufacturerDropList.SelectedLabel instead of ActivePrinter.Make to ensure the mapped Unicode values are picked up
|
// Use ManufacturerDropList.SelectedLabel instead of ActivePrinter.Make to ensure the mapped Unicode values are picked up
|
||||||
string mappedMakeText = printerManufacturerSelector.ManufacturerDropList.SelectedLabel;
|
string mappedMakeText = printerManufacturerSelector.ManufacturerDropList.SelectedLabel;
|
||||||
|
|
||||||
string printerInputName = String.Format("{0} {1}", mappedMakeText, this.ActivePrinter.Model);
|
string printerInputName = String.Format("{0} {1}", mappedMakeText, this.ActivePrinter.Model);
|
||||||
string query = "SELECT Name FROM Printer WHERE Name LIKE @printerName;";
|
var names = ActiveSliceSettings.ProfileData.Profiles.Where(p => p.Name.StartsWith(printerInputName)).Select(p => p.Name).ToList();
|
||||||
var names = Datastore.Instance.dbSQLite.Query<sqlName>(query, printerInputName + "%").Select(item => item.Name).ToList();
|
if (!names.Contains(printerInputName))
|
||||||
|
{
|
||||||
|
printerNameInput.Text = printerInputName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
if (!names.Contains(printerInputName))
|
int printerModelCount = 1; //Used to keep track of how many of the printer models we run into before and empty one
|
||||||
{
|
string possiblePrinterName;
|
||||||
printerNameInput.Text = printerInputName;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
int printerModelCount = 0; //Used to keep track of how many of the printer models we run into before and empty one
|
|
||||||
string possiblePrinterName;
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
printerModelCount++;
|
possiblePrinterName = String.Format("{0} ({1})", printerInputName, printerModelCount++);
|
||||||
possiblePrinterName = String.Format("{0} ({1})", printerInputName, printerModelCount);
|
} while (names.Contains(possiblePrinterName));
|
||||||
} while (names.Contains(possiblePrinterName));
|
|
||||||
|
|
||||||
|
|
||||||
printerNameInput.Text = possiblePrinterName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
printerNameInput.Text = possiblePrinterName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PrinterNameInput_KeyPressed(object sender, KeyPressEventArgs e)
|
|
||||||
{
|
|
||||||
this.usingDefaultName = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MoveToNextWidget()
|
|
||||||
{
|
|
||||||
if (Parent != null) // if it hasn't been closed
|
|
||||||
{
|
|
||||||
if (this.ActivePrinter.BaudRate == null)
|
|
||||||
{
|
|
||||||
Parent.AddChild(new SetupStepBaudRate((ConnectionWindow)Parent, Parent, this.currentPrinterSetupStatus));
|
|
||||||
Parent.RemoveChild(this);
|
|
||||||
}
|
|
||||||
else if (this.currentPrinterSetupStatus.DriversToInstall.Count > 0)
|
|
||||||
{
|
|
||||||
Parent.AddChild(new SetupStepInstallDriver((ConnectionWindow)Parent, Parent, this.currentPrinterSetupStatus));
|
|
||||||
Parent.RemoveChild(this);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Parent.AddChild(new SetupStepComPortOne((ConnectionWindow)Parent, Parent, this.currentPrinterSetupStatus));
|
|
||||||
Parent.RemoveChild(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void NextButton_Click(object sender, EventArgs mouseEvent)
|
|
||||||
{
|
|
||||||
bool canContinue = this.OnSave();
|
|
||||||
if (canContinue)
|
|
||||||
{
|
|
||||||
this.currentPrinterSetupStatus.LoadCalibrationPrints();
|
|
||||||
UiThread.RunOnIdle(MoveToNextWidget);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int ExistingPrinterCount()
|
|
||||||
{
|
|
||||||
return Datastore.Instance.RecordCount("Printer");
|
|
||||||
}
|
|
||||||
|
|
||||||
private class sqlName
|
|
||||||
{
|
|
||||||
public string Name { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool OnSave()
|
private bool OnSave()
|
||||||
{
|
{
|
||||||
if (printerNameInput.Text != "")
|
if (!string.IsNullOrEmpty(printerNameInput.Text))
|
||||||
{
|
{
|
||||||
this.ActivePrinter.Name = printerNameInput.Text;
|
this.ActivePrinter.Name = printerNameInput.Text;
|
||||||
|
|
||||||
if (this.ActivePrinter.Make == null || this.ActivePrinter.Model == null)
|
if (this.ActivePrinter.Make == null || this.ActivePrinter.Model == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Datastore.Instance.dbSQLite.RunInTransaction(currentPrinterSetupStatus.Save);
|
// TODO: Plumb in saving the profile to disk, then setting the instance to be the active profile
|
||||||
|
System.Diagnostics.Debugger.Launch();
|
||||||
|
|
||||||
|
ActiveSliceSettings.AcquireNewProfile(ActivePrinter.Make, ActivePrinter.Model, ActivePrinter.Name);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -300,6 +266,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
this.printerNameError.TextColor = RGBA_Bytes.Red;
|
this.printerNameError.TextColor = RGBA_Bytes.Red;
|
||||||
this.printerNameError.Text = "Printer name cannot be blank";
|
this.printerNameError.Text = "Printer name cannot be blank";
|
||||||
this.printerNameError.Visible = true;
|
this.printerNameError.Visible = true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -493,8 +493,8 @@ namespace MatterHackers.MatterControl
|
||||||
|
|
||||||
protected override double GetPreheatTemperature()
|
protected override double GetPreheatTemperature()
|
||||||
{
|
{
|
||||||
string tempValue = ActiveSliceSettings.Instance.GetMaterialValue("temperature", extruderIndex0Based + 1);
|
string tempValue = ActiveSliceSettings.Instance.GetExtruderTemperature(extruderIndex0Based);
|
||||||
if (tempValue == "Unknown")
|
if (string.IsNullOrEmpty(tempValue))
|
||||||
{
|
{
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ namespace MatterHackers.MatterControl.PrintQueue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(ActivePrinterProfile.Instance.ActivePrinter);
|
PrintLevelingData levelingData = ActiveSliceSettings.Instance.PrintLevelingData;
|
||||||
|
|
||||||
// now copy all the gcode to the path given
|
// now copy all the gcode to the path given
|
||||||
for (int i = 0; i < savedGCodeFileNames.Count; i++)
|
for (int i = 0; i < savedGCodeFileNames.Count; i++)
|
||||||
|
|
@ -191,7 +191,7 @@ namespace MatterHackers.MatterControl.PrintQueue
|
||||||
string outputFileName = Path.ChangeExtension(originalFileName, ".gcode");
|
string outputFileName = Path.ChangeExtension(originalFileName, ".gcode");
|
||||||
string outputPathAndName = Path.Combine(exportPath, outputFileName);
|
string outputPathAndName = Path.Combine(exportPath, outputFileName);
|
||||||
|
|
||||||
if (ActivePrinterProfile.Instance.DoPrintLeveling)
|
if (ActiveSliceSettings.Instance.DoPrintLeveling)
|
||||||
{
|
{
|
||||||
GCodeFileLoaded unleveledGCode = new GCodeFileLoaded(savedGcodeFileName);
|
GCodeFileLoaded unleveledGCode = new GCodeFileLoaded(savedGcodeFileName);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@ namespace MatterHackers.MatterControl.PrintQueue
|
||||||
|
|
||||||
private bool exportGCodeToFolderButton_Click()
|
private bool exportGCodeToFolderButton_Click()
|
||||||
{
|
{
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter == null)
|
if (ActiveSliceSettings.Instance == null)
|
||||||
{
|
{
|
||||||
UiThread.RunOnIdle(MustSelectPrinterMessage);
|
UiThread.RunOnIdle(MustSelectPrinterMessage);
|
||||||
}
|
}
|
||||||
|
|
@ -192,7 +192,7 @@ namespace MatterHackers.MatterControl.PrintQueue
|
||||||
|
|
||||||
private bool exportX3GButton_Click()
|
private bool exportX3GButton_Click()
|
||||||
{
|
{
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter == null)
|
if (ActiveSliceSettings.Instance == null)
|
||||||
{
|
{
|
||||||
UiThread.RunOnIdle(MustSelectPrinterMessage);
|
UiThread.RunOnIdle(MustSelectPrinterMessage);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -268,7 +268,7 @@ namespace MatterHackers.MatterControl.PrintQueue
|
||||||
return FileLocation;
|
return FileLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
string engineString = ((int)ActivePrinterProfile.Instance.ActiveSliceEngineType).ToString();
|
string engineString = ((int)ActiveSliceSettings.Instance.ActiveSliceEngineType).ToString();
|
||||||
|
|
||||||
string gcodeFileName = this.FileHashCode.ToString() + "_" + engineString + "_" + ActiveSliceSettings.Instance.GetHashCode().ToString();
|
string gcodeFileName = this.FileHashCode.ToString() + "_" + engineString + "_" + ActiveSliceSettings.Instance.GetHashCode().ToString();
|
||||||
string gcodePathAndFileName = Path.Combine(ApplicationDataStorage.Instance.GCodeOutputPath, gcodeFileName + ".gcode");
|
string gcodePathAndFileName = Path.Combine(ApplicationDataStorage.Instance.GCodeOutputPath, gcodeFileName + ".gcode");
|
||||||
|
|
@ -300,11 +300,11 @@ namespace MatterHackers.MatterControl.PrintQueue
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if there is a known line at the end of the file (this will let us know if slicer finished building the file).
|
// check if there is a known line at the end of the file (this will let us know if slicer finished building the file).
|
||||||
switch (ActivePrinterProfile.Instance.ActiveSliceEngineType)
|
switch (ActiveSliceSettings.Instance.ActiveSliceEngineType)
|
||||||
{
|
{
|
||||||
case ActivePrinterProfile.SlicingEngineTypes.CuraEngine:
|
case SlicingEngineTypes.CuraEngine:
|
||||||
case ActivePrinterProfile.SlicingEngineTypes.MatterSlice:
|
case SlicingEngineTypes.MatterSlice:
|
||||||
case ActivePrinterProfile.SlicingEngineTypes.Slic3r:
|
case SlicingEngineTypes.Slic3r:
|
||||||
if (gcodeFileContents.Contains("filament used ="))
|
if (gcodeFileContents.Contains("filament used ="))
|
||||||
{
|
{
|
||||||
gCodeFileIsComplete = true;
|
gCodeFileIsComplete = true;
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,7 @@ namespace MatterHackers.MatterControl.PrintQueue
|
||||||
shopButton.Click += (sender, e) =>
|
shopButton.Click += (sender, e) =>
|
||||||
{
|
{
|
||||||
double activeFilamentDiameter = 0;
|
double activeFilamentDiameter = 0;
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter != null)
|
if (ActiveSliceSettings.Instance != null)
|
||||||
{
|
{
|
||||||
activeFilamentDiameter = 3;
|
activeFilamentDiameter = 3;
|
||||||
if (ActiveSliceSettings.Instance.FilamentDiameter < 2)
|
if (ActiveSliceSettings.Instance.FilamentDiameter < 2)
|
||||||
|
|
@ -217,7 +217,7 @@ namespace MatterHackers.MatterControl.PrintQueue
|
||||||
buttonPanel1.AddChild(queueMenuContainer);
|
buttonPanel1.AddChild(queueMenuContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent((object sender, EventArgs e) =>
|
ActiveSliceSettings.ActivePrinterChanged.RegisterEvent((object sender, EventArgs e) =>
|
||||||
{
|
{
|
||||||
queueMenuContainer.RemoveAllChildren();
|
queueMenuContainer.RemoveAllChildren();
|
||||||
// the printer changed reload the queueMenue
|
// the printer changed reload the queueMenue
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using MatterHackers.MatterControl.DataStorage;
|
using MatterHackers.MatterControl.DataStorage;
|
||||||
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl
|
namespace MatterHackers.MatterControl
|
||||||
|
|
@ -25,8 +26,12 @@ namespace MatterHackers.MatterControl
|
||||||
|
|
||||||
private void LoadDataIfNeeded()
|
private void LoadDataIfNeeded()
|
||||||
{
|
{
|
||||||
|
// TODO: Review int printerID
|
||||||
|
int printerID;
|
||||||
|
int.TryParse(ActiveSliceSettings.Instance.Id, out printerID);
|
||||||
|
|
||||||
//Lazy load the data (rather than hook to printer change event)
|
//Lazy load the data (rather than hook to printer change event)
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter.Id != ActiveSettingsPrinterId)
|
if (printerID != ActiveSettingsPrinterId)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
|
|
@ -35,7 +40,7 @@ namespace MatterHackers.MatterControl
|
||||||
public string get(string key)
|
public string get(string key)
|
||||||
{
|
{
|
||||||
string result = null;
|
string result = null;
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter == null)
|
if (ActiveSliceSettings.Instance == null)
|
||||||
{
|
{
|
||||||
//No printer selected
|
//No printer selected
|
||||||
}
|
}
|
||||||
|
|
@ -53,7 +58,7 @@ namespace MatterHackers.MatterControl
|
||||||
|
|
||||||
public void set(string key, string value)
|
public void set(string key, string value)
|
||||||
{
|
{
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter == null)
|
if (ActiveSliceSettings.Instance == null)
|
||||||
{
|
{
|
||||||
//No printer selected
|
//No printer selected
|
||||||
}
|
}
|
||||||
|
|
@ -68,9 +73,13 @@ namespace MatterHackers.MatterControl
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// TODO: Review int printerID
|
||||||
|
int printerID;
|
||||||
|
int.TryParse(ActiveSliceSettings.Instance.Id, out printerID);
|
||||||
|
|
||||||
setting = new PrinterSetting();
|
setting = new PrinterSetting();
|
||||||
setting.Name = key;
|
setting.Name = key;
|
||||||
setting.PrinterId = ActivePrinterProfile.Instance.ActivePrinter.Id;
|
setting.PrinterId = printerID;
|
||||||
|
|
||||||
settingsDictionary[key] = setting;
|
settingsDictionary[key] = setting;
|
||||||
}
|
}
|
||||||
|
|
@ -82,21 +91,25 @@ namespace MatterHackers.MatterControl
|
||||||
|
|
||||||
private void LoadData()
|
private void LoadData()
|
||||||
{
|
{
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter != null)
|
if (ActiveSliceSettings.Instance != null)
|
||||||
{
|
{
|
||||||
settingsDictionary = new Dictionary<string, PrinterSetting>();
|
settingsDictionary = new Dictionary<string, PrinterSetting>();
|
||||||
foreach (PrinterSetting s in GetPrinterSettings())
|
foreach (PrinterSetting s in GetPrinterSettings())
|
||||||
{
|
{
|
||||||
settingsDictionary[s.Name] = s;
|
settingsDictionary[s.Name] = s;
|
||||||
}
|
}
|
||||||
ActiveSettingsPrinterId = ActivePrinterProfile.Instance.ActivePrinter.Id;
|
// TODO: Review int printerID
|
||||||
|
int printerID;
|
||||||
|
int.TryParse(ActiveSliceSettings.Instance.Id, out printerID);
|
||||||
|
|
||||||
|
ActiveSettingsPrinterId = printerID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<PrinterSetting> GetPrinterSettings()
|
private IEnumerable<PrinterSetting> GetPrinterSettings()
|
||||||
{
|
{
|
||||||
//Retrieve a list of settings from the Datastore
|
//Retrieve a list of settings from the Datastore
|
||||||
string query = string.Format("SELECT * FROM PrinterSetting WHERE PrinterId = {0};", ActivePrinterProfile.Instance.ActivePrinter.Id);
|
string query = string.Format("SELECT * FROM PrinterSetting WHERE PrinterId = {0};", ActiveSliceSettings.Instance.Id);
|
||||||
return Datastore.Instance.dbSQLite.Query<PrinterSetting>(query);
|
return Datastore.Instance.dbSQLite.Query<PrinterSetting>(query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ActivePrinterProfile.SlicingEngineTypes GetSliceEngineType()
|
public override SlicingEngineTypes GetSliceEngineType()
|
||||||
{
|
{
|
||||||
return ActivePrinterProfile.SlicingEngineTypes.CuraEngine;
|
return SlicingEngineTypes.CuraEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string getWindowsPath()
|
protected override string getWindowsPath()
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
|
|
||||||
public static string DisplayName = "MatterSlice";
|
public static string DisplayName = "MatterSlice";
|
||||||
|
|
||||||
public override ActivePrinterProfile.SlicingEngineTypes GetSliceEngineType()
|
public override SlicingEngineTypes GetSliceEngineType()
|
||||||
{
|
{
|
||||||
return ActivePrinterProfile.SlicingEngineTypes.MatterSlice;
|
return SlicingEngineTypes.MatterSlice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Exists()
|
public override bool Exists()
|
||||||
|
|
|
||||||
281
SlicerConfiguration/Settings/ActiveSliceSettings.cs
Normal file
281
SlicerConfiguration/Settings/ActiveSliceSettings.cs
Normal file
|
|
@ -0,0 +1,281 @@
|
||||||
|
/*
|
||||||
|
Copyright (c) 2016, Lars Brubaker, John Lewin
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
The views and conclusions contained in the software and documentation are those
|
||||||
|
of the authors and should not be interpreted as representing official policies,
|
||||||
|
either expressed or implied, of the FreeBSD Project.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using MatterHackers.MatterControl.PrinterCommunication;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using MatterHackers.MatterControl.SettingsManagement;
|
||||||
|
using MatterHackers.Agg;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
|
{
|
||||||
|
public enum NamedSettingsLayers { MHBaseSettings, OEMSettings, Quality, Material, User, All }
|
||||||
|
|
||||||
|
public class ActiveSliceSettings
|
||||||
|
{
|
||||||
|
private static readonly string userDataPath = DataStorage.ApplicationDataStorage.ApplicationUserDataPath;
|
||||||
|
private static readonly string profilesPath = Path.Combine(userDataPath, "Profiles");
|
||||||
|
private static readonly string profilesDBPath = Path.Combine(profilesPath, "profiles.json");
|
||||||
|
|
||||||
|
public static RootedObjectEventHandler ActivePrinterChanged = new RootedObjectEventHandler();
|
||||||
|
|
||||||
|
private static SettingsProfile activeInstance = null;
|
||||||
|
public static SettingsProfile Instance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return activeInstance;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (activeInstance != value)
|
||||||
|
{
|
||||||
|
// If we have an active printer, run Disable otherwise skip to prevent empty ActiveSliceSettings due to null ActivePrinter
|
||||||
|
if (activeInstance != null)
|
||||||
|
{
|
||||||
|
PrinterConnectionAndCommunication.Instance.Disable();
|
||||||
|
}
|
||||||
|
|
||||||
|
activeInstance = value;
|
||||||
|
if (activeInstance != null)
|
||||||
|
{
|
||||||
|
BedSettings.SetMakeAndModel(activeInstance.Make, activeInstance.Model);
|
||||||
|
}
|
||||||
|
|
||||||
|
OnActivePrinterChanged(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static ActiveSliceSettings()
|
||||||
|
{
|
||||||
|
// Ensure the profiles directory exists
|
||||||
|
Directory.CreateDirectory(profilesPath);
|
||||||
|
|
||||||
|
// Load or import the profiles.json document
|
||||||
|
if (File.Exists(profilesDBPath))
|
||||||
|
{
|
||||||
|
ProfileData = JsonConvert.DeserializeObject<ProfileData>(File.ReadAllText(profilesDBPath));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ProfileData = new ProfileData();
|
||||||
|
|
||||||
|
// Import class profiles from the db into local json files
|
||||||
|
DataStorage.ClassicDB.ClassicSqlitePrinterProfiles.ImportPrinters(ProfileData, profilesPath);
|
||||||
|
File.WriteAllText(profilesDBPath, JsonConvert.SerializeObject(ProfileData, Formatting.Indented));
|
||||||
|
|
||||||
|
// TODO: Upload new profiles to webservice
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(ProfileData.ActiveProfileID))
|
||||||
|
{
|
||||||
|
Instance = LoadProfile(ProfileData.ActiveProfileID);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Load an empty profile with just the MatterHackers base settings from config.json
|
||||||
|
Instance = new SettingsProfile(LoadEmptyProfile());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetActiveProfileID(int id)
|
||||||
|
{
|
||||||
|
ProfileData.ActiveProfileID = id.ToString();
|
||||||
|
File.WriteAllText(profilesDBPath, JsonConvert.SerializeObject(ProfileData, Formatting.Indented));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LayeredProfile LoadEmptyProfile()
|
||||||
|
{
|
||||||
|
return new LayeredProfile(new OemProfile(), LoadMatterHackersBaseLayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProfileData ProfileData { get; private set; }
|
||||||
|
|
||||||
|
public static void CheckForAndDoAutoConnect()
|
||||||
|
{
|
||||||
|
bool connectionAvailable;
|
||||||
|
|
||||||
|
var autoConnectProfile = GetAutoConnectProfile(out connectionAvailable);
|
||||||
|
if (autoConnectProfile != null)
|
||||||
|
{
|
||||||
|
//ActiveSliceSettings.Instance = autoConnectProfile;
|
||||||
|
if (connectionAvailable)
|
||||||
|
{
|
||||||
|
PrinterConnectionAndCommunication.Instance.HaltConnectionThread();
|
||||||
|
PrinterConnectionAndCommunication.Instance.ConnectToActivePrinter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void SwitchToProfile(int id)
|
||||||
|
{
|
||||||
|
var profile = LoadProfile(id);
|
||||||
|
|
||||||
|
SetActiveProfileID(id);
|
||||||
|
|
||||||
|
if (profile != null)
|
||||||
|
{
|
||||||
|
Instance = profile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static SettingsProfile LoadProfile(int id)
|
||||||
|
{
|
||||||
|
string profileID = ProfileData.Profiles.Where(p => p.Id == id.ToString()).FirstOrDefault()?.Id.ToString();
|
||||||
|
if (!string.IsNullOrEmpty(profileID))
|
||||||
|
{
|
||||||
|
return LoadProfile(profileID);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static SettingsProfile LoadProfile(string profileID)
|
||||||
|
{
|
||||||
|
string profilePath = Path.Combine(profilesPath, profileID + ".json");
|
||||||
|
return File.Exists(profilePath) ? LoadProfileFromDisk(profilePath) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void AcquireNewProfile(string make, string model, string printerName)
|
||||||
|
{
|
||||||
|
string guid = Guid.NewGuid().ToString();
|
||||||
|
|
||||||
|
OemProfile printerProfile = LoadHttpOemProfile(make, model);
|
||||||
|
SettingsLayer baseConfig = LoadMatterHackersBaseLayer();
|
||||||
|
|
||||||
|
var layeredProfile = new LayeredProfile(
|
||||||
|
printerProfile,
|
||||||
|
baseConfig);
|
||||||
|
layeredProfile.DocumentPath = Path.Combine(profilesPath, guid + ".json");
|
||||||
|
layeredProfile.Save();
|
||||||
|
|
||||||
|
ProfileData.Profiles.Add(new PrinterInfo
|
||||||
|
{
|
||||||
|
Name = printerName,
|
||||||
|
Id = guid
|
||||||
|
});
|
||||||
|
|
||||||
|
Instance = new SettingsProfile(layeredProfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SettingsProfile LoadProfileFromDisk(string profilePath)
|
||||||
|
{
|
||||||
|
return new SettingsProfile(LayeredProfile.LoadFile(profilePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SettingsLayer LoadMatterHackersBaseLayer()
|
||||||
|
{
|
||||||
|
// TODO: Build if missing?
|
||||||
|
string baseConfigPath = Path.Combine(profilesPath, "config.json");
|
||||||
|
return JsonConvert.DeserializeObject<SettingsLayer>(File.ReadAllText(baseConfigPath));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static OemProfile LoadHttpOemProfile(string make, string model)
|
||||||
|
{
|
||||||
|
var client = new WebClient();
|
||||||
|
string profileText = client.DownloadString(string.Format("http://matterdata.azurewebsites.net/api/oemprofiles/{0}/{1}/", make, model));
|
||||||
|
var printerProfile = JsonConvert.DeserializeObject<OemProfile>(profileText);
|
||||||
|
return printerProfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnActivePrinterChanged(EventArgs e)
|
||||||
|
{
|
||||||
|
ActivePrinterChanged.CallEvents(null, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SettingsProfile GetAutoConnectProfile(out bool connectionAvailable)
|
||||||
|
{
|
||||||
|
// Load the last selected profile, see if the port is active
|
||||||
|
|
||||||
|
// Return the profile if valid
|
||||||
|
|
||||||
|
// otherwise (not the best idea IMO), iterate all profiles, trying to find relevant matches and change the selection dynamically rather than as last selected by the user
|
||||||
|
|
||||||
|
/*
|
||||||
|
string[] comportNames = FrostedSerialPort.GetPortNames();
|
||||||
|
|
||||||
|
Printer printerToSelect = null;
|
||||||
|
connectionAvailable = false;
|
||||||
|
|
||||||
|
foreach (Printer printer in Datastore.Instance.dbSQLite.Query<Printer>("SELECT * FROM Printer;"))
|
||||||
|
{
|
||||||
|
if (printer.AutoConnectFlag)
|
||||||
|
{
|
||||||
|
printerToSelect = printer;
|
||||||
|
bool portIsAvailable = comportNames.Contains(printer.ComPort);
|
||||||
|
if (portIsAvailable)
|
||||||
|
{
|
||||||
|
// We found a printer that we can select and connect to.
|
||||||
|
connectionAvailable = true;
|
||||||
|
return printer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// return a printer we can connect to even though we can't connect
|
||||||
|
return printerToSelect;
|
||||||
|
*/
|
||||||
|
|
||||||
|
connectionAvailable = false;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
private static SettingsProfile LoadBestProfile()
|
||||||
|
{
|
||||||
|
// Conceptually, load settings means
|
||||||
|
// Read from state the currently selected profile/printer token
|
||||||
|
// - Check for/update/load the base MatterHackers layer
|
||||||
|
// - Check for/update/load the OEM layer
|
||||||
|
// - Set the quality layer to the currently selected quality profile
|
||||||
|
// - Set the material layer to the currently selected material profile
|
||||||
|
// - Check for/update/load the customer layer
|
||||||
|
|
||||||
|
// Load profiles document
|
||||||
|
|
||||||
|
var activeProfile = ProfileData.Profiles.Where(p => p.ProfileToken == ProfileData.ActiveProfileID).FirstOrDefault();
|
||||||
|
if (activeProfile != null)
|
||||||
|
{
|
||||||
|
printerProfilePath = Path.Combine(profilesPath, activeProfile.ProfileToken + ".json");
|
||||||
|
}
|
||||||
|
|
||||||
|
// or this
|
||||||
|
return LoadProfileFromDisk(printerProfilePath);
|
||||||
|
} */
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum SlicingEngineTypes { Slic3r, CuraEngine, MatterSlice };
|
||||||
|
}
|
||||||
306
SlicerConfiguration/Settings/LayeredProfile.cs
Normal file
306
SlicerConfiguration/Settings/LayeredProfile.cs
Normal file
|
|
@ -0,0 +1,306 @@
|
||||||
|
/*
|
||||||
|
Copyright (c) 2016, Lars Brubaker, John Lewin
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
The views and conclusions contained in the software and documentation are those
|
||||||
|
of the authors and should not be interpreted as representing official policies,
|
||||||
|
either expressed or implied, of the FreeBSD Project.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
|
{
|
||||||
|
public class LayeredProfile
|
||||||
|
{
|
||||||
|
[JsonIgnore]
|
||||||
|
internal SettingsLayer QualityLayer { get; private set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
internal SettingsLayer MaterialLayer { get; private set; }
|
||||||
|
|
||||||
|
public LayeredProfile(OemProfile printerProfile, SettingsLayer baseConfig)
|
||||||
|
{
|
||||||
|
this.OemProfile = printerProfile;
|
||||||
|
this.BaseLayer = baseConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
[OnDeserialized]
|
||||||
|
internal void OnDeserializedMethod(StreamingContext context)
|
||||||
|
{
|
||||||
|
QualityLayer = GetQualityLayer(ActiveQualityKey);
|
||||||
|
MaterialLayer = GetMaterialLayer(ActiveMaterialKey); ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OemProfile OemProfile { get; set; }
|
||||||
|
|
||||||
|
internal SettingsLayer GetMaterialLayer(string key)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(key))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the first matching layer in either the user or the OEM layers
|
||||||
|
SettingsLayer layer = null;
|
||||||
|
if (!MaterialLayers.TryGetValue(key, out layer))
|
||||||
|
{
|
||||||
|
OemProfile.MaterialLayers.TryGetValue(key, out layer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return layer;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal SettingsLayer GetQualityLayer(string key)
|
||||||
|
{
|
||||||
|
// Find the first matching layer in either the user or the OEM layers
|
||||||
|
SettingsLayer layer = null;
|
||||||
|
if (key != null && !QualityLayers.TryGetValue(key, out layer))
|
||||||
|
{
|
||||||
|
OemProfile.QualityLayers.TryGetValue(key, out layer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return layer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ActiveMaterialKey
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetValue("MatterControl.ActiveMaterialKey");
|
||||||
|
}
|
||||||
|
internal set
|
||||||
|
{
|
||||||
|
SetActiveValue("MatterControl.ActiveMaterialKey", value);
|
||||||
|
MaterialLayer = GetMaterialLayer(value);
|
||||||
|
Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ActiveQualityKey
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetValue("MatterControl.ActiveQualityKey");
|
||||||
|
}
|
||||||
|
internal set
|
||||||
|
{
|
||||||
|
SetActiveValue("MatterControl.ActiveQualityKey", value);
|
||||||
|
QualityLayer = GetQualityLayer(value);
|
||||||
|
|
||||||
|
Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public string GetMaterialPresetKey(int extruderIndex)
|
||||||
|
{
|
||||||
|
if (extruderIndex >= MaterialSettingsKeys.Count)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MaterialSettingsKeys[extruderIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetMaterialPreset(int extruderIndex, string materialKey)
|
||||||
|
{
|
||||||
|
if (extruderIndex >= PrinterCommunication.PrinterConnectionAndCommunication.MAX_EXTRUDERS)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException("Requested extruder index is outside of bounds: " + extruderIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: This should really be in SettingsProfile and should be run when the extruder count changes
|
||||||
|
if (MaterialSettingsKeys.Count <= extruderIndex)
|
||||||
|
{
|
||||||
|
var resizedArray = new string[extruderIndex + 1];
|
||||||
|
MaterialSettingsKeys.CopyTo(resizedArray);
|
||||||
|
MaterialSettingsKeys = new List<string>(resizedArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialSettingsKeys[extruderIndex] = materialKey;
|
||||||
|
|
||||||
|
if (extruderIndex == 0)
|
||||||
|
{
|
||||||
|
ActiveMaterialKey = materialKey;
|
||||||
|
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
||||||
|
}
|
||||||
|
|
||||||
|
Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<string> MaterialSettingsKeys { get; set; } = new List<string>();
|
||||||
|
|
||||||
|
public string DocumentPath { get; set; }
|
||||||
|
|
||||||
|
internal void Save()
|
||||||
|
{
|
||||||
|
File.WriteAllText(DocumentPath, JsonConvert.SerializeObject(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// User settings overrides
|
||||||
|
/// </summary>
|
||||||
|
public SettingsLayer UserLayer { get; } = new SettingsLayer();
|
||||||
|
|
||||||
|
public IEnumerable<string> AllMaterialKeys()
|
||||||
|
{
|
||||||
|
return MaterialLayers.Keys.Union(this.OemProfile.MaterialLayers.Keys);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<string> AllQualityKeys()
|
||||||
|
{
|
||||||
|
return QualityLayers.Keys.Union(this.OemProfile.QualityLayers.Keys);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static LayeredProfile LoadFile(string printerProfilePath)
|
||||||
|
{
|
||||||
|
var layeredProfile = JsonConvert.DeserializeObject<LayeredProfile>(File.ReadAllText(printerProfilePath));
|
||||||
|
layeredProfile.DocumentPath = printerProfilePath;
|
||||||
|
|
||||||
|
return layeredProfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Hookup OEM layers
|
||||||
|
/// <summary>
|
||||||
|
/// Should contain both user created and oem specified material layers
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, SettingsLayer> MaterialLayers { get; } = new Dictionary<string, SettingsLayer>();
|
||||||
|
|
||||||
|
// TODO: Hookup OEM layers
|
||||||
|
/// <summary>
|
||||||
|
/// Should contain both user created and oem specified quality layers
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, SettingsLayer> QualityLayers { get; } = new Dictionary<string, SettingsLayer>();
|
||||||
|
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
///Returns the settings value at the 'top' of the stack
|
||||||
|
///</summary>
|
||||||
|
public string GetValue(string sliceSetting)
|
||||||
|
{
|
||||||
|
return GetValue(sliceSetting, settingsLayers);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetValue(string sliceSetting, IEnumerable<SettingsLayer> layers)
|
||||||
|
{
|
||||||
|
foreach (SettingsLayer layer in layers)
|
||||||
|
{
|
||||||
|
string value;
|
||||||
|
if (layer.TryGetValue(sliceSetting, out value))
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public SettingsLayer BaseLayer { get; set; }
|
||||||
|
|
||||||
|
private IEnumerable<SettingsLayer> settingsLayers
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (this.UserLayer != null)
|
||||||
|
{
|
||||||
|
yield return this.UserLayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.MaterialLayer != null)
|
||||||
|
{
|
||||||
|
yield return this.MaterialLayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.QualityLayer != null)
|
||||||
|
{
|
||||||
|
yield return this.QualityLayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.OemProfile.OemLayer != null)
|
||||||
|
{
|
||||||
|
yield return this.OemProfile.OemLayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
yield return this.BaseLayer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void SetActiveValue(string sliceSetting, string sliceValue)
|
||||||
|
{
|
||||||
|
SetActiveValue(sliceSetting, sliceValue, UserLayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void SetActiveValue(string sliceSetting, string sliceValue, SettingsLayer layer)
|
||||||
|
{
|
||||||
|
layer[sliceSetting] = sliceValue;
|
||||||
|
Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void ClearValue(string sliceSetting)
|
||||||
|
{
|
||||||
|
ClearValue(sliceSetting, UserLayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void ClearValue(string sliceSetting, SettingsLayer layer)
|
||||||
|
{
|
||||||
|
if(layer.ContainsKey(sliceSetting))
|
||||||
|
{
|
||||||
|
layer.Remove(sliceSetting);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Reconsider this frequency
|
||||||
|
Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class OemProfile
|
||||||
|
{
|
||||||
|
public OemProfile() { }
|
||||||
|
|
||||||
|
public OemProfile(Dictionary<string, string> settingsDictionary)
|
||||||
|
{
|
||||||
|
OemLayer = new SettingsLayer(settingsDictionary);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Printer settings from OEM
|
||||||
|
/// </summary>
|
||||||
|
public SettingsLayer OemLayer { get; } = new SettingsLayer();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of Material presets from OEM
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, SettingsLayer> MaterialLayers { get; } = new Dictionary<string, SettingsLayer>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of Quality presets from OEM
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, SettingsLayer> QualityLayers { get; } = new Dictionary<string, SettingsLayer>();
|
||||||
|
}
|
||||||
|
}
|
||||||
77
SlicerConfiguration/Settings/SettingsDiagram.cd
Normal file
77
SlicerConfiguration/Settings/SettingsDiagram.cd
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ClassDiagram MajorVersion="1" MinorVersion="1">
|
||||||
|
<Class Name="MatterHackers.MatterControl.SlicerConfiguration.ActiveSliceSettings">
|
||||||
|
<Position X="7.25" Y="0.5" Width="1.75" />
|
||||||
|
<AssociationLine Name="Instance" Type="MatterHackers.MatterControl.SlicerConfiguration.SettingsProfile">
|
||||||
|
<MemberNameLabel ManuallyPlaced="true" ManuallySized="true">
|
||||||
|
<Position X="0.574" Y="-0.225" Height="0.182" Width="1.128" />
|
||||||
|
</MemberNameLabel>
|
||||||
|
</AssociationLine>
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>IBAAAAEAAABAAAAAAAAAAAAAAIAAABAAQAgAAEAAAAA=</HashCode>
|
||||||
|
<FileName>SlicerConfiguration\Settings\ActiveSliceSettings.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<ShowAsAssociation>
|
||||||
|
<Property Name="Instance" />
|
||||||
|
</ShowAsAssociation>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MatterHackers.MatterControl.SlicerConfiguration.SettingsProfile">
|
||||||
|
<Position X="3.5" Y="0.5" Width="2" />
|
||||||
|
<NestedTypes>
|
||||||
|
<Class Name="MatterHackers.MatterControl.SlicerConfiguration.SettingsProfile.SettingsConverter" Collapsed="true">
|
||||||
|
<TypeIdentifier>
|
||||||
|
<NewMemberFileName>SlicerConfiguration\Settings\SettingsProfile.cs</NewMemberFileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
</NestedTypes>
|
||||||
|
<AssociationLine Name="profileLayers" Type="MatterHackers.MatterControl.SlicerConfiguration.LayeredProfile">
|
||||||
|
<MemberNameLabel ManuallyPlaced="true">
|
||||||
|
<Position X="0.102" Y="0.256" />
|
||||||
|
</MemberNameLabel>
|
||||||
|
</AssociationLine>
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>JCADAcoArLgkCEwJMG9CQD0AAEAjEMYASRgMAA5VAAQ=</HashCode>
|
||||||
|
<FileName>SlicerConfiguration\Settings\SettingsProfile.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<ShowAsAssociation>
|
||||||
|
<Field Name="profileLayers" />
|
||||||
|
</ShowAsAssociation>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MatterHackers.MatterControl.SlicerConfiguration.LayeredProfile">
|
||||||
|
<Position X="7.25" Y="2" Width="1.75" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAACMQEKABAAAABEEAGAAQBAgABAAQEAAQIAAAQBAA=</HashCode>
|
||||||
|
<FileName>SlicerConfiguration\Settings\LayeredProfile.cs</FileName>
|
||||||
|
<NewMemberFileName>SlicerConfiguration\ActiveSliceSettings.cs</NewMemberFileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<ShowAsAssociation>
|
||||||
|
<Property Name="QualityLayer" />
|
||||||
|
<Property Name="MaterialLayer" />
|
||||||
|
<Property Name="OemProfile" />
|
||||||
|
<Property Name="UserLayer" />
|
||||||
|
</ShowAsAssociation>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MatterHackers.MatterControl.SlicerConfiguration.SettingsLayer">
|
||||||
|
<Position X="10.25" Y="2.25" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAIAAAgAAAAAAEAAAAAQAAAAAAAAAAEAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>SlicerConfiguration\Settings\SettingsProfile.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MatterHackers.MatterControl.SlicerConfiguration.OemProfile">
|
||||||
|
<Position X="7.25" Y="7.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAASAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>SlicerConfiguration\Settings\LayeredProfile.cs</FileName>
|
||||||
|
<NewMemberFileName>SlicerConfiguration\ActiveSliceSettings.cs</NewMemberFileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MatterHackers.MatterControl.DataStorage.Printer" Collapsed="true">
|
||||||
|
<Position X="0.75" Y="7.25" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>IAAAgQgCCCAAAAAAIAAAAgQAAAAAEAAAAAwAIBJEAAA=</HashCode>
|
||||||
|
<FileName>DataStorage\Models.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Font Name="Segoe UI" Size="9" />
|
||||||
|
</ClassDiagram>
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -37,23 +37,13 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
{
|
{
|
||||||
public class SettingsControlBar : FlowLayoutWidget
|
public class SettingsControlBar : FlowLayoutWidget
|
||||||
{
|
{
|
||||||
private event EventHandler unregisterEvents;
|
|
||||||
public string activeMaterialPreset;
|
|
||||||
public string activeQualityPreset;
|
|
||||||
|
|
||||||
public SettingsControlBar()
|
public SettingsControlBar()
|
||||||
{
|
{
|
||||||
this.HAnchor = HAnchor.ParentLeftRight;
|
this.HAnchor = HAnchor.ParentLeftRight;
|
||||||
|
|
||||||
int numberOfHeatedExtruders = 1;
|
int numberOfHeatedExtruders = ActiveSliceSettings.Instance.ExtruderCount;
|
||||||
if (!ActiveSliceSettings.Instance.ExtrudersShareTemperature)
|
|
||||||
{
|
|
||||||
numberOfHeatedExtruders = ActiveSliceSettings.Instance.ExtruderCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
SliceSelectorWidget qualityPresetDropDown = new SliceSelectorWidget("Quality".Localize(), RGBA_Bytes.Yellow, "quality");
|
this.AddChild(new PresetSelectorWidget("Quality".Localize(), RGBA_Bytes.Yellow, "quality", 0));
|
||||||
this.activeQualityPreset = qualityPresetDropDown.DropDownList.SelectedLabel;
|
|
||||||
this.AddChild(qualityPresetDropDown);
|
|
||||||
this.AddChild(new GuiWidget(8, 0));
|
this.AddChild(new GuiWidget(8, 0));
|
||||||
|
|
||||||
if (numberOfHeatedExtruders > 1)
|
if (numberOfHeatedExtruders > 1)
|
||||||
|
|
@ -68,28 +58,17 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
}
|
}
|
||||||
int colorIndex = i % colorList.Count;
|
int colorIndex = i % colorList.Count;
|
||||||
RGBA_Bytes color = colorList[colorIndex];
|
RGBA_Bytes color = colorList[colorIndex];
|
||||||
this.AddChild(new SliceSelectorWidget(string.Format("{0} {1}", "Material".Localize(), i + 1), color, "material", i + 1));
|
this.AddChild(new PresetSelectorWidget(string.Format("{0} {1}", "Material".Localize(), i), color, "material", i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SliceSelectorWidget materialPresetDropDown = new SliceSelectorWidget("Material".Localize(), RGBA_Bytes.Orange, "material");
|
this.AddChild(new PresetSelectorWidget("Material".Localize(), RGBA_Bytes.Orange, "material", 0));
|
||||||
this.activeMaterialPreset = materialPresetDropDown.DropDownList.SelectedLabel;
|
|
||||||
this.AddChild(materialPresetDropDown);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Height = 60 * TextWidget.GlobalPointSizeScaleRatio;
|
this.Height = 60 * TextWidget.GlobalPointSizeScaleRatio;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnClosed(EventArgs e)
|
|
||||||
{
|
|
||||||
if (unregisterEvents != null)
|
|
||||||
{
|
|
||||||
unregisterEvents(this, null);
|
|
||||||
}
|
|
||||||
base.OnClosed(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -44,7 +44,7 @@ using System.Linq;
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl.SlicerConfiguration
|
namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
{
|
{
|
||||||
public class SliceSelectorWidget : FlowLayoutWidget
|
public class PresetSelectorWidget : FlowLayoutWidget
|
||||||
{
|
{
|
||||||
private Button editButton;
|
private Button editButton;
|
||||||
private ImageButtonFactory imageButtonFactory = new ImageButtonFactory();
|
private ImageButtonFactory imageButtonFactory = new ImageButtonFactory();
|
||||||
|
|
@ -53,35 +53,32 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
private string filterLabel;
|
private string filterLabel;
|
||||||
public AnchoredDropDownList DropDownList;
|
public AnchoredDropDownList DropDownList;
|
||||||
private TupleList<string, Func<bool>> DropDownMenuItems = new TupleList<string, Func<bool>>();
|
private TupleList<string, Func<bool>> DropDownMenuItems = new TupleList<string, Func<bool>>();
|
||||||
private int presetIndex; //For multiple materials
|
|
||||||
|
|
||||||
public SliceSelectorWidget(string label, RGBA_Bytes accentColor, string tag = null, int presetIndex = 1)
|
private int extruderIndex; //For multiple materials
|
||||||
|
|
||||||
|
public PresetSelectorWidget(string label, RGBA_Bytes accentColor, string tag, int extruderIndex)
|
||||||
: base(FlowDirection.TopToBottom)
|
: base(FlowDirection.TopToBottom)
|
||||||
{
|
{
|
||||||
this.presetIndex = presetIndex;
|
this.extruderIndex = extruderIndex;
|
||||||
this.filterLabel = label;
|
this.filterLabel = label;
|
||||||
if (tag == null)
|
this.filterTag = (tag == null) ? label.ToLower() : tag;
|
||||||
{
|
|
||||||
this.filterTag = label.ToLower();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.filterTag = tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.HAnchor = HAnchor.ParentLeftRight;
|
this.HAnchor = HAnchor.ParentLeftRight;
|
||||||
this.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;
|
this.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;
|
||||||
this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
||||||
|
|
||||||
GuiWidget accentBar = new GuiWidget(7, 5);
|
GuiWidget accentBar = new GuiWidget(7, 5)
|
||||||
accentBar.BackgroundColor = accentColor;
|
{
|
||||||
accentBar.HAnchor = HAnchor.ParentLeftRight;
|
BackgroundColor = accentColor,
|
||||||
|
HAnchor = HAnchor.ParentLeftRight
|
||||||
|
};
|
||||||
|
|
||||||
|
TextWidget labelText = new TextWidget(label.Localize().ToUpper())
|
||||||
TextWidget labelText = new TextWidget(LocalizedString.Get(label).ToUpper());
|
{
|
||||||
labelText.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
TextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||||
labelText.HAnchor = Agg.UI.HAnchor.ParentCenter;
|
HAnchor = Agg.UI.HAnchor.ParentCenter,
|
||||||
labelText.Margin = new BorderDouble(0, 3, 0, 6);
|
Margin = new BorderDouble(0, 3, 0, 6)
|
||||||
|
};
|
||||||
|
|
||||||
this.AddChild(labelText);
|
this.AddChild(labelText);
|
||||||
this.AddChild(GetPulldownContainer());
|
this.AddChild(GetPulldownContainer());
|
||||||
|
|
@ -159,38 +156,27 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<SliceSettingsCollection> GetCollections()
|
|
||||||
{
|
|
||||||
//Retrieve a list of collections matching from the Datastore
|
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter != null)
|
|
||||||
{
|
|
||||||
string query = string.Format("SELECT * FROM SliceSettingsCollection WHERE Tag = '{0}' AND PrinterId = {1} ORDER BY Name;", filterTag, ActivePrinterProfile.Instance.ActivePrinter.Id);
|
|
||||||
return Datastore.Instance.dbSQLite.Query<SliceSettingsCollection>(query);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Enumerable.Empty<SliceSettingsCollection>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onItemSelect(object sender, EventArgs e)
|
private void onItemSelect(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
var activeSettings = ActiveSliceSettings.Instance;
|
||||||
MenuItem item = (MenuItem)sender;
|
MenuItem item = (MenuItem)sender;
|
||||||
if (filterTag == "material")
|
if (filterTag == "material")
|
||||||
{
|
{
|
||||||
if (ActivePrinterProfile.Instance.GetMaterialSetting(presetIndex) != Int32.Parse(item.Value))
|
if (activeSettings.GetMaterialPresetKey(extruderIndex) != item.Text)
|
||||||
{
|
{
|
||||||
ActivePrinterProfile.Instance.SetMaterialSetting(presetIndex, Int32.Parse(item.Value));
|
activeSettings.SetMaterialPreset(extruderIndex, item.Text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (filterTag == "quality")
|
else if (filterTag == "quality")
|
||||||
{
|
{
|
||||||
if (ActivePrinterProfile.Instance.ActiveQualitySettingsID != Int32.Parse(item.Value))
|
if (activeSettings.ActiveQualityKey != item.Text)
|
||||||
{
|
{
|
||||||
ActivePrinterProfile.Instance.ActiveQualitySettingsID = Int32.Parse(item.Value);
|
activeSettings.ActiveQualityKey = item.Text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
ActiveSliceSettings.Instance.LoadAllSettings();
|
|
||||||
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -204,18 +190,17 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
#else
|
#else
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
ActiveSliceSettings.Instance.LoadAllSettings();
|
|
||||||
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
||||||
if (filterTag == "material")
|
if (filterTag == "material")
|
||||||
{
|
{
|
||||||
if (ApplicationController.Instance.EditMaterialPresetsWindow == null)
|
if (ApplicationController.Instance.EditMaterialPresetsWindow == null)
|
||||||
{
|
{
|
||||||
ApplicationController.Instance.EditMaterialPresetsWindow = new SlicePresetsWindow(ReloadOptions, filterLabel, filterTag, false, 0);
|
ApplicationController.Instance.EditMaterialPresetsWindow = new SlicePresetsWindow(ReloadOptions, filterLabel, filterTag, false);
|
||||||
ApplicationController.Instance.EditMaterialPresetsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { ApplicationController.Instance.EditMaterialPresetsWindow = null; };
|
ApplicationController.Instance.EditMaterialPresetsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { ApplicationController.Instance.EditMaterialPresetsWindow = null; };
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ApplicationController.Instance.EditMaterialPresetsWindow.ChangeToSlicePresetFromID(0);
|
ApplicationController.Instance.EditMaterialPresetsWindow.ChangeToSlicePresetFromID("");
|
||||||
ApplicationController.Instance.EditMaterialPresetsWindow.BringToFront();
|
ApplicationController.Instance.EditMaterialPresetsWindow.BringToFront();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -223,12 +208,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
{
|
{
|
||||||
if (ApplicationController.Instance.EditQualityPresetsWindow == null)
|
if (ApplicationController.Instance.EditQualityPresetsWindow == null)
|
||||||
{
|
{
|
||||||
ApplicationController.Instance.EditQualityPresetsWindow = new SlicePresetsWindow(ReloadOptions, filterLabel, filterTag, false, 0);
|
ApplicationController.Instance.EditQualityPresetsWindow = new SlicePresetsWindow(ReloadOptions, filterLabel, filterTag, false);
|
||||||
ApplicationController.Instance.EditQualityPresetsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { ApplicationController.Instance.EditQualityPresetsWindow = null; };
|
ApplicationController.Instance.EditQualityPresetsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { ApplicationController.Instance.EditQualityPresetsWindow = null; };
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ApplicationController.Instance.EditQualityPresetsWindow.ChangeToSlicePresetFromID(0);
|
ApplicationController.Instance.EditQualityPresetsWindow.ChangeToSlicePresetFromID("");
|
||||||
ApplicationController.Instance.EditQualityPresetsWindow.BringToFront();
|
ApplicationController.Instance.EditQualityPresetsWindow.BringToFront();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -241,13 +226,15 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
AnchoredDropDownList dropDownList = new AnchoredDropDownList("- default -", maxHeight: 300);
|
AnchoredDropDownList dropDownList = new AnchoredDropDownList("- default -", maxHeight: 300);
|
||||||
dropDownList.Margin = new BorderDouble(0, 3);
|
dropDownList.Margin = new BorderDouble(0, 3);
|
||||||
dropDownList.MinimumSize = new Vector2(dropDownList.LocalBounds.Width, dropDownList.LocalBounds.Height);
|
dropDownList.MinimumSize = new Vector2(dropDownList.LocalBounds.Width, dropDownList.LocalBounds.Height);
|
||||||
|
|
||||||
MenuItem defaultMenuItem = dropDownList.AddItem("- default -", "0");
|
MenuItem defaultMenuItem = dropDownList.AddItem("- default -", "0");
|
||||||
defaultMenuItem.Selected += new EventHandler(onItemSelect);
|
defaultMenuItem.Selected += new EventHandler(onItemSelect);
|
||||||
|
|
||||||
foreach (SliceSettingsCollection collection in GetCollections())
|
var listSource = (filterTag == "material") ? ActiveSliceSettings.Instance.AllMaterialKeys() : ActiveSliceSettings.Instance.AllQualityKeys();
|
||||||
|
foreach (var presetName in listSource)
|
||||||
{
|
{
|
||||||
MenuItem menuItem = dropDownList.AddItem(collection.Name, collection.Id.ToString());
|
MenuItem menuItem = dropDownList.AddItem(presetName, presetName);
|
||||||
menuItem.Selected += new EventHandler(onItemSelect);
|
menuItem.Selected += onItemSelect;
|
||||||
}
|
}
|
||||||
|
|
||||||
// put in a small bottom region
|
// put in a small bottom region
|
||||||
|
|
@ -280,33 +267,29 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
dropDownList.MenuItems.Add(new MenuItem(container));
|
dropDownList.MenuItems.Add(new MenuItem(container));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filterTag == "material")
|
try
|
||||||
{
|
{
|
||||||
try
|
string settingsKey;
|
||||||
{
|
|
||||||
dropDownList.SelectedValue = ActivePrinterProfile.Instance.GetMaterialSetting(presetIndex).ToString();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Debug.Print(e.Message);
|
|
||||||
GuiWidget.BreakInDebugger();
|
|
||||||
//Unable to set selected value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (filterTag == "quality")
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
dropDownList.SelectedValue = ActivePrinterProfile.Instance.ActiveQualitySettingsID.ToString();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Debug.Print(e.Message);
|
|
||||||
GuiWidget.BreakInDebugger();
|
|
||||||
//Unable to set selected value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (filterTag == "material")
|
||||||
|
{
|
||||||
|
settingsKey = ActiveSliceSettings.Instance.GetMaterialPresetKey(extruderIndex);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
settingsKey = ActiveSliceSettings.Instance.ActiveQualityKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(settingsKey))
|
||||||
|
{
|
||||||
|
dropDownList.SelectedValue = settingsKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GuiWidget.BreakInDebugger(ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
return dropDownList;
|
return dropDownList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -332,18 +315,18 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
if (engineAllowed)
|
if (engineAllowed)
|
||||||
{
|
{
|
||||||
MenuItem item = AddItem(engineMenuItem.Name);
|
MenuItem item = AddItem(engineMenuItem.Name);
|
||||||
ActivePrinterProfile.SlicingEngineTypes itemEngineType = engineMenuItem.GetSliceEngineType();
|
SlicingEngineTypes itemEngineType = engineMenuItem.GetSliceEngineType();
|
||||||
item.Selected += (sender, e) =>
|
item.Selected += (sender, e) =>
|
||||||
{
|
{
|
||||||
if (ActivePrinterProfile.Instance.ActiveSliceEngineType != itemEngineType)
|
if (ActiveSliceSettings.Instance.ActiveSliceEngineType != itemEngineType)
|
||||||
{
|
{
|
||||||
ActivePrinterProfile.Instance.ActiveSliceEngineType = itemEngineType;
|
ActiveSliceSettings.Instance.ActiveSliceEngineType = itemEngineType;
|
||||||
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Set item as selected if it matches the active slice engine
|
//Set item as selected if it matches the active slice engine
|
||||||
if (engineMenuItem.GetSliceEngineType() == ActivePrinterProfile.Instance.ActiveSliceEngineType)
|
if (engineMenuItem.GetSliceEngineType() == ActiveSliceSettings.Instance.ActiveSliceEngineType)
|
||||||
{
|
{
|
||||||
SelectedLabel = engineMenuItem.Name;
|
SelectedLabel = engineMenuItem.Name;
|
||||||
}
|
}
|
||||||
|
|
@ -357,11 +340,10 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
{
|
{
|
||||||
SelectedLabel = MatterSliceInfo.DisplayName;
|
SelectedLabel = MatterSliceInfo.DisplayName;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.Print(e.Message);
|
GuiWidget.BreakInDebugger(ex.Message);
|
||||||
GuiWidget.BreakInDebugger();
|
throw new Exception("Unable to find MatterSlice executable");
|
||||||
throw new Exception("MatterSlice is not available, for some strange reason");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ActivePrinterProfile.SlicingEngineTypes GetSliceEngineType()
|
public override SlicingEngineTypes GetSliceEngineType()
|
||||||
{
|
{
|
||||||
return ActivePrinterProfile.SlicingEngineTypes.Slic3r;
|
return SlicingEngineTypes.Slic3r;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string getWindowsPath()
|
protected override string getWindowsPath()
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
|
|
||||||
protected abstract string getLinuxPath();
|
protected abstract string getLinuxPath();
|
||||||
|
|
||||||
public abstract ActivePrinterProfile.SlicingEngineTypes GetSliceEngineType();
|
public abstract SlicingEngineTypes GetSliceEngineType();
|
||||||
|
|
||||||
public SliceEngineInfo(string name)
|
public SliceEngineInfo(string name)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2014, Lars Brubaker
|
Copyright (c) 2016, Lars Brubaker, John Lewin
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
@ -32,6 +32,7 @@ using MatterHackers.Agg.UI;
|
||||||
using MatterHackers.Localizations;
|
using MatterHackers.Localizations;
|
||||||
using MatterHackers.MatterControl.CustomWidgets;
|
using MatterHackers.MatterControl.CustomWidgets;
|
||||||
using MatterHackers.MatterControl.DataStorage;
|
using MatterHackers.MatterControl.DataStorage;
|
||||||
|
using MatterHackers.MatterControl.DataStorage.ClassicDB;
|
||||||
using MatterHackers.MatterControl.FieldValidation;
|
using MatterHackers.MatterControl.FieldValidation;
|
||||||
using MatterHackers.VectorMath;
|
using MatterHackers.VectorMath;
|
||||||
using System;
|
using System;
|
||||||
|
|
@ -145,53 +146,37 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
private PresetListControl settingsRowContainer;
|
private PresetListControl settingsRowContainer;
|
||||||
private FlowLayoutWidget errorMessageContainer;
|
private FlowLayoutWidget errorMessageContainer;
|
||||||
|
|
||||||
private FlowLayoutWidget GetMiddleRow()
|
private GuiWidget GetMiddleRow()
|
||||||
{
|
{
|
||||||
FlowLayoutWidget container = new FlowLayoutWidget();
|
NamedSettingsLayers layerFilter = NamedSettingsLayers.Material;
|
||||||
container.HAnchor = HAnchor.ParentLeftRight;
|
List<SettingsLayer> layerFilters = null;
|
||||||
container.VAnchor = Agg.UI.VAnchor.ParentBottomTop;
|
|
||||||
container.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
|
|
||||||
|
|
||||||
FlowLayoutWidget topBottomContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
if (layerFilter != NamedSettingsLayers.All)
|
||||||
topBottomContainer.AnchorAll();
|
{
|
||||||
|
var settings = ActiveSliceSettings.Instance;
|
||||||
|
|
||||||
FlowLayoutWidget addContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
// TODO: The editing context needs to provide the key
|
||||||
addContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
System.Diagnostics.Debugger.Break();
|
||||||
addContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
|
string layerKey = settings.ActiveMaterialKey;
|
||||||
|
|
||||||
TextWidget errorMessage = new TextWidget("Oops! Please select a setting first.", pointSize: 10);
|
layerFilters = new List<SettingsLayer> { settings.BaseLayer, settings.OemLayer };
|
||||||
errorMessage.TextColor = ActiveTheme.Instance.SecondaryAccentColor;
|
|
||||||
|
|
||||||
errorMessageContainer = new FlowLayoutWidget();
|
switch (layerFilter)
|
||||||
errorMessageContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
|
{
|
||||||
errorMessageContainer.BackgroundColor = ActiveTheme.Instance.TransparentDarkOverlay;
|
case NamedSettingsLayers.Material:
|
||||||
errorMessageContainer.Visible = false;
|
layerFilters.Add(settings.GetMaterialLayer(layerKey));
|
||||||
errorMessageContainer.Padding = new BorderDouble(3);
|
break;
|
||||||
|
|
||||||
errorMessageContainer.AddChild(new HorizontalSpacer());
|
case NamedSettingsLayers.Quality:
|
||||||
errorMessageContainer.AddChild(errorMessage);
|
layerFilters.Add(settings.GetQualityLayer(layerKey));
|
||||||
errorMessageContainer.AddChild(new HorizontalSpacer());
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
addSettingsContainer = new FlowLayoutWidget();
|
var settingsWidget = new SliceSettingsWidget(layerFilters, NamedSettingsLayers.Material);
|
||||||
addSettingsContainer.Padding = new BorderDouble(3);
|
settingsWidget.settingsControlBar.Visible = false;
|
||||||
addSettingsContainer.BackgroundColor = ActiveTheme.Instance.TransparentDarkOverlay;
|
|
||||||
addSettingsContainer.HAnchor = HAnchor.ParentLeftRight;
|
|
||||||
|
|
||||||
PopulateAddSettingRow();
|
return settingsWidget;
|
||||||
|
|
||||||
addContainer.AddChild(addSettingsContainer);
|
|
||||||
addContainer.AddChild(errorMessageContainer);
|
|
||||||
|
|
||||||
settingsRowContainer = new PresetListControl();
|
|
||||||
settingsRowContainer.HAnchor = HAnchor.ParentLeftRight;
|
|
||||||
|
|
||||||
LoadSettingsRows();
|
|
||||||
|
|
||||||
topBottomContainer.AddChild(addContainer);
|
|
||||||
topBottomContainer.AddChild(settingsRowContainer);
|
|
||||||
|
|
||||||
container.AddChild(topBottomContainer);
|
|
||||||
return container;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private FlowLayoutWidget GetBottomRow()
|
private FlowLayoutWidget GetBottomRow()
|
||||||
|
|
@ -326,7 +311,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
{
|
{
|
||||||
itemName = "{0} ({1})".FormatWith(itemName, setting.ExtraSettings.Replace("\\n", " "));
|
itemName = "{0} ({1})".FormatWith(itemName, setting.ExtraSettings.Replace("\\n", " "));
|
||||||
}
|
}
|
||||||
if (ActivePrinterProfile.Instance.ActiveSliceEngine.MapContains(setting.SlicerConfigName))
|
if (ActiveSliceSettings.Instance.ActiveSliceEngine.MapContains(setting.SlicerConfigName))
|
||||||
{
|
{
|
||||||
MenuItem settingMenuItem = settingDropDownList.AddItem(itemName, itemValue);
|
MenuItem settingMenuItem = settingDropDownList.AddItem(itemName, itemValue);
|
||||||
settingMenuItem.Selected += new EventHandler(OnItemSelected);
|
settingMenuItem.Selected += new EventHandler(OnItemSelected);
|
||||||
|
|
@ -376,7 +361,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
OrganizerSettingsData settingData = SliceSettingsOrganizer.Instance.GetSettingsData(item.Key);
|
OrganizerSettingsData settingData = SliceSettingsOrganizer.Instance.GetSettingsData(item.Key);
|
||||||
|
|
||||||
// Don't add row if there is no entry
|
// Don't add row if there is no entry
|
||||||
if (settingData != null && ActivePrinterProfile.Instance.ActiveSliceEngine.MapContains(settingData.SlicerConfigName))
|
if (settingData != null && ActiveSliceSettings.Instance.ActiveSliceEngine.MapContains(settingData.SlicerConfigName))
|
||||||
{
|
{
|
||||||
FlowLayoutWidget row = GetSettingsRow(settingData, item.Value.Value);
|
FlowLayoutWidget row = GetSettingsRow(settingData, item.Value.Value);
|
||||||
row.Padding = new BorderDouble(3, 3, 3, 6);
|
row.Padding = new BorderDouble(3, 3, 3, 6);
|
||||||
|
|
@ -510,7 +495,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
|
|
||||||
double minSettingNameWidth = 400;
|
double minSettingNameWidth = 400;
|
||||||
|
|
||||||
if (ActiveSliceSettings.Instance.Contains(settingData.SlicerConfigName))
|
if (ActiveSliceSettings.Instance.InBaseConfig(settingData.SlicerConfigName))
|
||||||
{
|
{
|
||||||
int intEditWidth = 60;
|
int intEditWidth = 60;
|
||||||
int doubleEditWidth = 60;
|
int doubleEditWidth = 60;
|
||||||
|
|
@ -897,14 +882,18 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
Dictionary<string, SliceSetting> settingsDictionary = new Dictionary<string, SliceSetting>();
|
Dictionary<string, SliceSetting> settingsDictionary = new Dictionary<string, SliceSetting>();
|
||||||
SliceSettingsCollection collection = new SliceSettingsCollection();
|
SliceSettingsCollection collection = new SliceSettingsCollection();
|
||||||
|
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter != null)
|
if (ActiveSliceSettings.Instance != null)
|
||||||
{
|
{
|
||||||
|
// TODO: Review bindings to int printerID
|
||||||
|
int printerID;
|
||||||
|
int.TryParse(ActiveSliceSettings.Instance.Id, out printerID);
|
||||||
|
|
||||||
collection.Name = string.Format("{0} ({1})", windowController.filterLabel, noExistingPresets.ToString());
|
collection.Name = string.Format("{0} ({1})", windowController.filterLabel, noExistingPresets.ToString());
|
||||||
collection.Tag = windowController.filterTag;
|
collection.Tag = windowController.filterTag;
|
||||||
collection.PrinterId = ActivePrinterProfile.Instance.ActivePrinter.Id;
|
collection.PrinterId = printerID;
|
||||||
}
|
}
|
||||||
|
|
||||||
windowController.ActivePresetLayer = new SettingsLayer(collection, settingsDictionary);
|
windowController.ActivePresetLayer = new ClassicSqlitePrinterProfiles.ClassicSettingsLayer(collection, settingsDictionary);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ExistingPresetsCount()
|
public int ExistingPresetsCount()
|
||||||
|
|
@ -923,9 +912,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
saveActivePresets();
|
saveActivePresets();
|
||||||
windowController.functionToCallOnSave(this, null);
|
windowController.functionToCallOnSave(this, null);
|
||||||
windowController.ChangeToSlicePresetList();
|
windowController.ChangeToSlicePresetList();
|
||||||
ActiveSliceSettings.Instance.LoadAllSettings();
|
|
||||||
// Disabled this as the panel is already reloaded from LoadAllSettings LBB 2015 01 03.
|
|
||||||
//ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -950,7 +936,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
settingsDictionary.Add(s.Name, newSetting);
|
settingsDictionary.Add(s.Name, newSetting);
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsLayer duplicateLayer = new SettingsLayer(duplicateCollection, settingsDictionary);
|
var duplicateLayer = new ClassicSqlitePrinterProfiles.ClassicSettingsLayer(duplicateCollection, settingsDictionary);
|
||||||
windowController.ActivePresetLayer = duplicateLayer;
|
windowController.ActivePresetLayer = duplicateLayer;
|
||||||
windowController.ChangeToSlicePresetDetail();
|
windowController.ChangeToSlicePresetDetail();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -174,10 +174,14 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
{
|
{
|
||||||
if (File.Exists(openParams.FileName))
|
if (File.Exists(openParams.FileName))
|
||||||
{
|
{
|
||||||
|
// TODO: Review bindings to int printerID
|
||||||
|
int printerID;
|
||||||
|
int.TryParse(ActiveSliceSettings.Instance.Id, out printerID);
|
||||||
|
|
||||||
//Create collection to hold preset settings
|
//Create collection to hold preset settings
|
||||||
settingsCollection = new SliceSettingsCollection();
|
settingsCollection = new SliceSettingsCollection();
|
||||||
settingsCollection.Tag = windowController.filterTag;
|
settingsCollection.Tag = windowController.filterTag;
|
||||||
settingsCollection.PrinterId = ActivePrinterProfile.Instance.ActivePrinter.Id;
|
settingsCollection.PrinterId = printerID;
|
||||||
settingsCollection.Name = System.IO.Path.GetFileNameWithoutExtension(openParams.FileName);
|
settingsCollection.Name = System.IO.Path.GetFileNameWithoutExtension(openParams.FileName);
|
||||||
settingsCollection.Commit();
|
settingsCollection.Commit();
|
||||||
|
|
||||||
|
|
@ -211,10 +215,10 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
|
|
||||||
private IEnumerable<SliceSettingsCollection> GetCollections()
|
private IEnumerable<SliceSettingsCollection> GetCollections()
|
||||||
{
|
{
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter != null)
|
if (ActiveSliceSettings.Instance != null)
|
||||||
{
|
{
|
||||||
//Retrieve a list of collections matching from the Datastore
|
//Retrieve a list of collections matching from the Datastore
|
||||||
string query = string.Format("SELECT * FROM SliceSettingsCollection WHERE Tag = '{0}' AND PrinterId = {1} ORDER BY Name;", windowController.filterTag, ActivePrinterProfile.Instance.ActivePrinter.Id);
|
string query = string.Format("SELECT * FROM SliceSettingsCollection WHERE Tag = '{0}' AND PrinterId = {1} ORDER BY Name;", windowController.filterTag, ActiveSliceSettings.Instance.Id);
|
||||||
return Datastore.Instance.dbSQLite.Query<SliceSettingsCollection>(query);
|
return Datastore.Instance.dbSQLite.Query<SliceSettingsCollection>(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -257,33 +261,34 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
|
|
||||||
Button materialRemoveLink = linkButtonFactory.Generate("remove");
|
Button materialRemoveLink = linkButtonFactory.Generate("remove");
|
||||||
materialRemoveLink.Margin = new BorderDouble(left: 4);
|
materialRemoveLink.Margin = new BorderDouble(left: 4);
|
||||||
|
this.DebugShowBounds = true;
|
||||||
materialRemoveLink.VAnchor = Agg.UI.VAnchor.ParentCenter;
|
materialRemoveLink.VAnchor = Agg.UI.VAnchor.ParentCenter;
|
||||||
materialRemoveLink.Click += (sender, e) =>
|
materialRemoveLink.Click += (sender, e) =>
|
||||||
{
|
{
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
//Unwind this setting if it is currently active
|
//Unwind this setting if it is currently active
|
||||||
if (ActivePrinterProfile.Instance.ActivePrinter != null)
|
if (ActiveSliceSettings.Instance != null)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if (preset.Id == ActivePrinterProfile.Instance.ActiveQualitySettingsID)
|
if (preset.Id == ActivePrinterProfile.Instance.ActiveQualitySettingsID)
|
||||||
{
|
{
|
||||||
ActivePrinterProfile.Instance.ActiveQualitySettingsID = 0;
|
ActivePrinterProfile.Instance.ActiveQualitySettingsID = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
string[] activeMaterialPresets = ActivePrinterProfile.Instance.ActivePrinter.MaterialCollectionIds.Split(',');
|
string[] activeMaterialPresets = ActiveSliceSettings.Instance.MaterialCollectionIds.Split(',');
|
||||||
for (int i = 0; i < activeMaterialPresets.Count(); i++)
|
for (int i = 0; i < activeMaterialPresets.Count(); i++)
|
||||||
{
|
{
|
||||||
int index = 0;
|
int index = 0;
|
||||||
Int32.TryParse(activeMaterialPresets[i], out index);
|
Int32.TryParse(activeMaterialPresets[i], out index);
|
||||||
if (preset.Id == index)
|
if (preset.Id == index)
|
||||||
{
|
{
|
||||||
ActivePrinterProfile.Instance.SetMaterialSetting(i + 1, 0);
|
ActiveSliceSettings.Instance.SetMaterialPreset(i, "");
|
||||||
}
|
}
|
||||||
}
|
} */
|
||||||
}
|
}
|
||||||
preset.Delete();
|
preset.Delete();
|
||||||
windowController.ChangeToSlicePresetList();
|
windowController.ChangeToSlicePresetList();
|
||||||
ActiveSliceSettings.Instance.LoadAllSettings();
|
|
||||||
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2014, Lars Brubaker
|
Copyright (c) 2016, Lars Brubaker, John Lewin
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
@ -30,6 +30,7 @@ either expressed or implied, of the FreeBSD Project.
|
||||||
using MatterHackers.Agg.UI;
|
using MatterHackers.Agg.UI;
|
||||||
using MatterHackers.Localizations;
|
using MatterHackers.Localizations;
|
||||||
using MatterHackers.MatterControl.DataStorage;
|
using MatterHackers.MatterControl.DataStorage;
|
||||||
|
using MatterHackers.MatterControl.DataStorage.ClassicDB;
|
||||||
using MatterHackers.VectorMath;
|
using MatterHackers.VectorMath;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
@ -41,9 +42,15 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
public EventHandler functionToCallOnSave;
|
public EventHandler functionToCallOnSave;
|
||||||
public string filterTag;
|
public string filterTag;
|
||||||
public string filterLabel;
|
public string filterLabel;
|
||||||
public SettingsLayer ActivePresetLayer;
|
|
||||||
|
|
||||||
public SlicePresetsWindow(EventHandler functionToCallOnSave, string filterLabel, string filterTag, bool showList = true, int collectionID = 0)
|
// TODO: Short term compile hack
|
||||||
|
public ClassicSqlitePrinterProfiles.ClassicSettingsLayer ActivePresetLayer
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SlicePresetsWindow(EventHandler functionToCallOnSave, string filterLabel, string filterTag, bool showList = true, string presetKey = null)
|
||||||
: base(640, 480)
|
: base(640, 480)
|
||||||
{
|
{
|
||||||
AlwaysOnTopOfMain = true;
|
AlwaysOnTopOfMain = true;
|
||||||
|
|
@ -61,6 +68,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if (collectionID == 0)
|
if (collectionID == 0)
|
||||||
{
|
{
|
||||||
ChangeToSlicePresetDetail();
|
ChangeToSlicePresetDetail();
|
||||||
|
|
@ -68,7 +76,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ChangeToSlicePresetDetail(GetCollection(collectionID));
|
ChangeToSlicePresetDetail(GetCollection(collectionID));
|
||||||
}
|
} */
|
||||||
}
|
}
|
||||||
ShowAsSystemWindow();
|
ShowAsSystemWindow();
|
||||||
this.MinimumSize = new Vector2(640, 480);
|
this.MinimumSize = new Vector2(640, 480);
|
||||||
|
|
@ -86,13 +94,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
this.RemoveAllChildren();
|
this.RemoveAllChildren();
|
||||||
this.AddChild(slicePresetWidget);
|
this.AddChild(slicePresetWidget);
|
||||||
this.Invalidate();
|
this.Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
public void ChangeToSlicePresetFromID(string collectionId)
|
||||||
}
|
|
||||||
|
|
||||||
public void ChangeToSlicePresetFromID(int collectionId)
|
|
||||||
{
|
{
|
||||||
ChangeToSlicePresetDetail(GetCollection(collectionId));
|
throw new NotImplementedException();
|
||||||
|
//ChangeToSlicePresetDetail(GetCollection(collectionId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeToSlicePresetDetail(SliceSettingsCollection collection = null)
|
public void ChangeToSlicePresetDetail(SliceSettingsCollection collection = null)
|
||||||
|
|
@ -104,8 +111,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
{
|
{
|
||||||
settingsDictionary[s.Name] = s;
|
settingsDictionary[s.Name] = s;
|
||||||
}
|
}
|
||||||
|
this.ActivePresetLayer = new ClassicSqlitePrinterProfiles.ClassicSettingsLayer(collection, settingsDictionary);
|
||||||
this.ActivePresetLayer = new SettingsLayer(collection, settingsDictionary);
|
|
||||||
}
|
}
|
||||||
UiThread.RunOnIdle(DoChangeToSlicePresetDetail);
|
UiThread.RunOnIdle(DoChangeToSlicePresetDetail);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
{
|
{
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
ActiveSliceSettings.Instance.LoadSettingsFromIni();
|
// TODO: jlewin
|
||||||
|
throw new NotImplementedException();
|
||||||
|
// ActiveSliceSettings.Instance.LoadSettingsFromIni();
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -128,9 +130,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
//Set the name and callback function of the menu items
|
//Set the name and callback function of the menu items
|
||||||
slicerOptionsMenuItems = new TupleList<string, Func<bool>>
|
slicerOptionsMenuItems = new TupleList<string, Func<bool>>
|
||||||
{
|
{
|
||||||
{ "Import".Localize(), ImportSettingsMenu_Click},
|
{ "Import".Localize(), ImportSettingsMenu_Click },
|
||||||
{"Export".Localize(), ExportSettingsMenu_Click},
|
{ "Export".Localize(), ExportSettingsMenu_Click },
|
||||||
{"Restore All".Localize(), RestoreAllSettingsMenu_Click},
|
{ "Restore All".Localize(), RestoreAllSettingsMenu_Click },
|
||||||
};
|
};
|
||||||
|
|
||||||
//Add the menu items to the menu itself
|
//Add the menu items to the menu itself
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -175,7 +175,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
AddDefaultIfNotPresent(preStartGCode, setBedTempString, preStartGCodeLines, "wait for bed temperature to be reached");
|
AddDefaultIfNotPresent(preStartGCode, setBedTempString, preStartGCodeLines, "wait for bed temperature to be reached");
|
||||||
}
|
}
|
||||||
|
|
||||||
int numberOfHeatedExtruders = (ActiveSliceSettings.Instance.ExtrudersShareTemperature) ? 1 : ActiveSliceSettings.Instance.ExtruderCount;
|
int numberOfHeatedExtruders = ActiveSliceSettings.Instance.ExtruderCount;
|
||||||
|
|
||||||
// Start heating all the extruder that we are going to use.
|
// Start heating all the extruder that we are going to use.
|
||||||
for (int extruderIndex0Based = 0; extruderIndex0Based < numberOfHeatedExtruders; extruderIndex0Based++)
|
for (int extruderIndex0Based = 0; extruderIndex0Based < numberOfHeatedExtruders; extruderIndex0Based++)
|
||||||
|
|
@ -183,8 +183,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
if (extrudersUsed.Count > extruderIndex0Based
|
if (extrudersUsed.Count > extruderIndex0Based
|
||||||
&& extrudersUsed[extruderIndex0Based])
|
&& extrudersUsed[extruderIndex0Based])
|
||||||
{
|
{
|
||||||
string materialTemperature = ActiveSliceSettings.Instance.GetMaterialValue("temperature", extruderIndex0Based + 1);
|
string materialTemperature = ActiveSliceSettings.Instance.GetExtruderTemperature(extruderIndex0Based);
|
||||||
if (materialTemperature != "0")
|
if (!string.IsNullOrEmpty(materialTemperature) && materialTemperature != "0")
|
||||||
{
|
{
|
||||||
string setTempString = "M104 T{0} S{1}".FormatWith(extruderIndex0Based, materialTemperature);
|
string setTempString = "M104 T{0} S{1}".FormatWith(extruderIndex0Based, materialTemperature);
|
||||||
AddDefaultIfNotPresent(preStartGCode, setTempString, preStartGCodeLines, string.Format("start heating extruder {0}", extruderIndex0Based + 1));
|
AddDefaultIfNotPresent(preStartGCode, setTempString, preStartGCodeLines, string.Format("start heating extruder {0}", extruderIndex0Based + 1));
|
||||||
|
|
@ -200,8 +200,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
if (extrudersUsed.Count > extruderIndex0Based
|
if (extrudersUsed.Count > extruderIndex0Based
|
||||||
&& extrudersUsed[extruderIndex0Based])
|
&& extrudersUsed[extruderIndex0Based])
|
||||||
{
|
{
|
||||||
string materialTemperature = ActiveSliceSettings.Instance.GetMaterialValue("temperature", extruderIndex0Based + 1);
|
string materialTemperature = ActiveSliceSettings.Instance.GetExtruderTemperature(extruderIndex0Based);
|
||||||
if (materialTemperature != "0")
|
if (!string.IsNullOrEmpty(materialTemperature) && materialTemperature != "0")
|
||||||
{
|
{
|
||||||
string setTempString = "M109 T{0} S{1}".FormatWith(extruderIndex0Based, materialTemperature);
|
string setTempString = "M109 T{0} S{1}".FormatWith(extruderIndex0Based, materialTemperature);
|
||||||
AddDefaultIfNotPresent(preStartGCode, setTempString, preStartGCodeLines, string.Format("wait for extruder {0}", extruderIndex0Based + 1));
|
AddDefaultIfNotPresent(preStartGCode, setTempString, preStartGCodeLines, string.Format("wait for extruder {0}", extruderIndex0Based + 1));
|
||||||
|
|
@ -238,7 +238,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
List<string> postStartGCode = new List<string>();
|
List<string> postStartGCode = new List<string>();
|
||||||
postStartGCode.Add("; automatic settings after start_gcode");
|
postStartGCode.Add("; automatic settings after start_gcode");
|
||||||
|
|
||||||
int numberOfHeatedExtruders = (ActiveSliceSettings.Instance.ExtrudersShareTemperature) ? 1 : ActiveSliceSettings.Instance.ExtruderCount;
|
int numberOfHeatedExtruders = ActiveSliceSettings.Instance.ExtruderCount;
|
||||||
|
|
||||||
// don't set the extruders to heating if we already waited for them to reach temp
|
// don't set the extruders to heating if we already waited for them to reach temp
|
||||||
if (ActiveSliceSettings.Instance.GetActiveValue("heat_extruder_before_homing") != "1")
|
if (ActiveSliceSettings.Instance.GetActiveValue("heat_extruder_before_homing") != "1")
|
||||||
|
|
@ -248,8 +248,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
if (extrudersUsed.Count > extruderIndex0Based
|
if (extrudersUsed.Count > extruderIndex0Based
|
||||||
&& extrudersUsed[extruderIndex0Based])
|
&& extrudersUsed[extruderIndex0Based])
|
||||||
{
|
{
|
||||||
string materialTemperature = ActiveSliceSettings.Instance.GetMaterialValue("temperature", extruderIndex0Based + 1);
|
string materialTemperature = ActiveSliceSettings.Instance.GetExtruderTemperature(extruderIndex0Based);
|
||||||
if (materialTemperature != "0")
|
if (!string.IsNullOrEmpty(materialTemperature) && materialTemperature != "0")
|
||||||
{
|
{
|
||||||
string setTempString = "M109 T{0} S{1}".FormatWith(extruderIndex0Based, materialTemperature);
|
string setTempString = "M109 T{0} S{1}".FormatWith(extruderIndex0Based, materialTemperature);
|
||||||
AddDefaultIfNotPresent(postStartGCode, setTempString, postStartGCodeLines, string.Format("wait for extruder {0} to reach temperature", extruderIndex0Based + 1));
|
AddDefaultIfNotPresent(postStartGCode, setTempString, postStartGCodeLines, string.Format("wait for extruder {0} to reach temperature", extruderIndex0Based + 1));
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static private SliceEngineInfo getSliceEngineInfoByType(ActivePrinterProfile.SlicingEngineTypes engineType)
|
static private SliceEngineInfo getSliceEngineInfoByType(SlicingEngineTypes engineType)
|
||||||
{
|
{
|
||||||
foreach (SliceEngineInfo info in AvailableSliceEngines)
|
foreach (SliceEngineInfo info in AvailableSliceEngines)
|
||||||
{
|
{
|
||||||
|
|
@ -150,7 +150,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
|
|
||||||
private static string getSlicerFullPath()
|
private static string getSlicerFullPath()
|
||||||
{
|
{
|
||||||
SliceEngineInfo info = getSliceEngineInfoByType(ActivePrinterProfile.Instance.ActiveSliceEngineType);
|
SliceEngineInfo info = getSliceEngineInfoByType(ActiveSliceSettings.Instance.ActiveSliceEngineType);
|
||||||
if (info != null)
|
if (info != null)
|
||||||
{
|
{
|
||||||
return info.GetEnginePath();
|
return info.GetEnginePath();
|
||||||
|
|
@ -337,7 +337,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
PrintItemWrapper itemToSlice = listOfSlicingItems[0];
|
PrintItemWrapper itemToSlice = listOfSlicingItems[0];
|
||||||
bool doMergeInSlicer = false;
|
bool doMergeInSlicer = false;
|
||||||
string mergeRules = "";
|
string mergeRules = "";
|
||||||
doMergeInSlicer = ActivePrinterProfile.Instance.ActiveSliceEngineType == ActivePrinterProfile.SlicingEngineTypes.MatterSlice;
|
doMergeInSlicer = ActiveSliceSettings.Instance.ActiveSliceEngineType == SlicingEngineTypes.MatterSlice;
|
||||||
string[] stlFileLocations = GetStlFileLocations(itemToSlice.FileLocation, doMergeInSlicer, ref mergeRules);
|
string[] stlFileLocations = GetStlFileLocations(itemToSlice.FileLocation, doMergeInSlicer, ref mergeRules);
|
||||||
string fileToSlice = stlFileLocations[0];
|
string fileToSlice = stlFileLocations[0];
|
||||||
// check that the STL file is currently on disk
|
// check that the STL file is currently on disk
|
||||||
|
|
@ -355,17 +355,17 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
{
|
{
|
||||||
string commandArgs = "";
|
string commandArgs = "";
|
||||||
|
|
||||||
switch (ActivePrinterProfile.Instance.ActiveSliceEngineType)
|
switch (ActiveSliceSettings.Instance.ActiveSliceEngineType)
|
||||||
{
|
{
|
||||||
case ActivePrinterProfile.SlicingEngineTypes.Slic3r:
|
case SlicingEngineTypes.Slic3r:
|
||||||
commandArgs = "--load \"" + currentConfigurationFileAndPath + "\" --output \"" + gcodePathAndFileName + "\" \"" + fileToSlice + "\"";
|
commandArgs = "--load \"" + currentConfigurationFileAndPath + "\" --output \"" + gcodePathAndFileName + "\" \"" + fileToSlice + "\"";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ActivePrinterProfile.SlicingEngineTypes.CuraEngine:
|
case SlicingEngineTypes.CuraEngine:
|
||||||
commandArgs = "-v -o \"" + gcodePathAndFileName + "\" " + EngineMappingCura.GetCuraCommandLineSettings() + " \"" + fileToSlice + "\"";
|
commandArgs = "-v -o \"" + gcodePathAndFileName + "\" " + EngineMappingCura.GetCuraCommandLineSettings() + " \"" + fileToSlice + "\"";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ActivePrinterProfile.SlicingEngineTypes.MatterSlice:
|
case SlicingEngineTypes.MatterSlice:
|
||||||
{
|
{
|
||||||
EngineMappingsMatterSlice.WriteMatterSliceSettingsFile(currentConfigurationFileAndPath);
|
EngineMappingsMatterSlice.WriteMatterSliceSettingsFile(currentConfigurationFileAndPath);
|
||||||
if (mergeRules == "")
|
if (mergeRules == "")
|
||||||
|
|
@ -393,7 +393,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
|
|
||||||
if (OsInformation.OperatingSystem == OSType.Android ||
|
if (OsInformation.OperatingSystem == OSType.Android ||
|
||||||
((OsInformation.OperatingSystem == OSType.Mac || runInProcess)
|
((OsInformation.OperatingSystem == OSType.Mac || runInProcess)
|
||||||
&& ActivePrinterProfile.Instance.ActiveSliceEngineType == ActivePrinterProfile.SlicingEngineTypes.MatterSlice))
|
&& ActiveSliceSettings.Instance.ActiveSliceEngineType == SlicingEngineTypes.MatterSlice))
|
||||||
{
|
{
|
||||||
itemCurrentlySlicing = itemToSlice;
|
itemCurrentlySlicing = itemToSlice;
|
||||||
MatterHackers.MatterSlice.LogOutput.GetLogWrites += SendProgressToItem;
|
MatterHackers.MatterSlice.LogOutput.GetLogWrites += SendProgressToItem;
|
||||||
|
|
|
||||||
|
|
@ -3203,7 +3203,7 @@ English:Specify if your printer can control the power supply
|
||||||
Translated:Specify if your printer can control the power supply
|
Translated:Specify if your printer can control the power supply
|
||||||
|
|
||||||
English:Has Power Control
|
English:Has Power Control
|
||||||
Translated:Has Power Control
|
Translated:Has Power ControlEnglish:The temperature the extruder will be when extruder wipes.
|
||||||
|
|
||||||
English:The temperature the bed temperature will be set to when part is to be removed.
|
English:The temperature the bed temperature will be set to when part is to be removed.
|
||||||
Translated:The temperature the bed temperature will be set to when part is to be removed.
|
Translated:The temperature the bed temperature will be set to when part is to be removed.
|
||||||
|
|
@ -4666,65 +4666,47 @@ Translated:Honey Comb
|
||||||
English:Apply leveling to G-Code during export
|
English:Apply leveling to G-Code during export
|
||||||
Translated:Apply leveling to G-Code during export
|
Translated:Apply leveling to G-Code during export
|
||||||
|
|
||||||
English:Resume Print
|
English:Material 0
|
||||||
Translated:Resume Print
|
Translated:Material 0
|
||||||
|
|
||||||
English:It appears your last print failed to complete. Would your like to resume from the last know layer?
|
English:Printers
|
||||||
Translated:It appears your last print failed to complete. Would your like to resume from the last know layer?
|
Translated:Printers
|
||||||
|
|
||||||
English:Resume Last Print
|
|
||||||
Translated:Resume Last Print
|
|
||||||
|
|
||||||
English:It appears your last print failed to complete.\n\nWould your like to attempt to resume from the last know position?
|
|
||||||
Translated:It appears your last print failed to complete.\n\nWould your like to attempt to resume from the last know position?
|
|
||||||
|
|
||||||
English:Unable to Connect
|
|
||||||
Translated:Unable to Connect
|
|
||||||
|
|
||||||
English:The speed at which the nozzle will move when resuming a failed print, for 1 layer.
|
English:The speed at which the nozzle will move when resuming a failed print, for 1 layer.
|
||||||
Translated:The speed at which the nozzle will move when resuming a failed print, for 1 layer.
|
Translated:The speed at which the nozzle will move when resuming a failed print, for 1 layer.
|
||||||
|
|
||||||
English:Resume Layer Speed
|
|
||||||
Translated:Resume Layer Speed
|
|
||||||
|
|
||||||
English:Set if the z homing moves the extruder away from the bed (z-max homing)
|
English:Set if the z homing moves the extruder away from the bed (z-max homing)
|
||||||
Translated:Set if the z homing moves the extruder away from the bed (z-max homing)
|
Translated:Set if the z homing moves the extruder away from the bed (z-max homing)
|
||||||
|
|
||||||
English:The X and Y position of the extruder that minimizes the chance of colliding with the parts on the bed.
|
English:The X and Y position of the extruder that minimizes the chance of colliding with the parts on the bed.
|
||||||
Translated:The X and Y position of the extruder that minimizes the chance of colliding with the parts on the bed.
|
Translated:The X and Y position of the extruder that minimizes the chance of colliding with the parts on the bed.
|
||||||
|
|
||||||
English:Resume Failed Print
|
English:Restore All
|
||||||
Translated:Resume Failed Print
|
Translated:Restore All
|
||||||
|
|
||||||
English:Home Z Max
|
|
||||||
Translated:Home Z Max
|
|
||||||
|
|
||||||
English:XY Resume Position
|
|
||||||
Translated:XY Resume Position
|
|
||||||
|
|
||||||
English:Homing
|
|
||||||
Translated:Homing
|
|
||||||
|
|
||||||
English:Outer Surface
|
|
||||||
Translated:Outer Surface
|
|
||||||
|
|
||||||
English:Restore Default
|
English:Restore Default
|
||||||
Translated:Restore Default
|
Translated:Restore Default
|
||||||
|
|
||||||
|
English:Outer Surface
|
||||||
|
Translated:Outer Surface
|
||||||
|
|
||||||
English:Minimum Travel equiring Retraction
|
English:Minimum Travel equiring Retraction
|
||||||
Translated:Minimum Travel equiring Retraction
|
Translated:Minimum Travel equiring Retraction
|
||||||
|
|
||||||
|
English:Retract When Changing Islands
|
||||||
|
Translated:Retract When Changing Islands
|
||||||
|
|
||||||
English:Minimum Extrusion Requiring Retraction
|
English:Minimum Extrusion Requiring Retraction
|
||||||
Translated:Minimum Extrusion Requiring Retraction
|
Translated:Minimum Extrusion Requiring Retraction
|
||||||
|
|
||||||
English:Slow Down If Layer Print Time Is Below
|
English:Slow Down If Layer Print Time Is Below
|
||||||
Translated:Slow Down If Layer Print Time Is Below
|
Translated:Slow Down If Layer Print Time Is Below
|
||||||
|
|
||||||
English:Restore All
|
English:Resume Failed Print
|
||||||
Translated:Restore All
|
Translated:Resume Failed Print
|
||||||
|
|
||||||
English:Retract When Changing Islands
|
English:Homing
|
||||||
Translated:Retract When Changing Islands
|
Translated:Homing
|
||||||
|
|
||||||
English:G-Code to be run before every tool change.
|
English:G-Code to be run before every tool change.
|
||||||
Translated:G-Code to be run before every tool change.
|
Translated:G-Code to be run before every tool change.
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 71a61f2b0dc0ff2da3dbb80084f9ec0c9df13078
|
Subproject commit 686f8389fd1a84dd8ab98bc6cbe1625b91389ed2
|
||||||
|
|
@ -79,7 +79,6 @@
|
||||||
<Compile Include="MatterControl\PrinterWhiteListTests.cs" />
|
<Compile Include="MatterControl\PrinterWhiteListTests.cs" />
|
||||||
<Compile Include="MatterControl\ReleaseBuildTests.cs" />
|
<Compile Include="MatterControl\ReleaseBuildTests.cs" />
|
||||||
<Compile Include="MatterControl\SetupIniTests.cs" />
|
<Compile Include="MatterControl\SetupIniTests.cs" />
|
||||||
<Compile Include="MatterControl\Slicing\SliceMappingCLassesTets.cs" />
|
|
||||||
<Compile Include="MatterControl\Slicing\SliceLayersTests.cs" />
|
<Compile Include="MatterControl\Slicing\SliceLayersTests.cs" />
|
||||||
<Compile Include="MatterControl\LevelingTests.cs" />
|
<Compile Include="MatterControl\LevelingTests.cs" />
|
||||||
<Compile Include="MatterControl\GCodeStreamTests.cs" />
|
<Compile Include="MatterControl\GCodeStreamTests.cs" />
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ either expressed or implied, of the FreeBSD Project.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using MatterHackers.Agg.PlatformAbstract;
|
using MatterHackers.Agg.PlatformAbstract;
|
||||||
|
using MatterHackers.MatterControl.DataStorage.ClassicDB;
|
||||||
using MatterHackers.PolygonMesh;
|
using MatterHackers.PolygonMesh;
|
||||||
using MatterHackers.PolygonMesh.Processors;
|
using MatterHackers.PolygonMesh.Processors;
|
||||||
using MatterHackers.VectorMath;
|
using MatterHackers.VectorMath;
|
||||||
|
|
@ -46,10 +47,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration.Tests
|
||||||
// Set the static data to point to the directory of MatterControl
|
// Set the static data to point to the directory of MatterControl
|
||||||
StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData"));
|
StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData"));
|
||||||
|
|
||||||
|
var classicProfile = new ClassicSqlitePrinterProfiles();
|
||||||
|
|
||||||
// dirrect values work
|
// dirrect values work
|
||||||
{
|
{
|
||||||
ActiveSliceSettings.Instance.SaveValue("primary", "1", 0);
|
classicProfile.SaveValue("primary", "1", 0);
|
||||||
ActiveSliceSettings.Instance.SaveValue("reference", "10", 0);
|
classicProfile.SaveValue("reference", "10", 0);
|
||||||
|
|
||||||
AsPercentOfReferenceOrDirect mapper = new AsPercentOfReferenceOrDirect("primary", "notused", "reference");
|
AsPercentOfReferenceOrDirect mapper = new AsPercentOfReferenceOrDirect("primary", "notused", "reference");
|
||||||
Assert.IsTrue(mapper.Value == "1");
|
Assert.IsTrue(mapper.Value == "1");
|
||||||
|
|
@ -61,8 +64,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration.Tests
|
||||||
|
|
||||||
// % reference values work
|
// % reference values work
|
||||||
{
|
{
|
||||||
ActiveSliceSettings.Instance.SaveValue("primary", "13%", 0);
|
classicProfile.SaveValue("primary", "13%", 0);
|
||||||
ActiveSliceSettings.Instance.SaveValue("reference", "100", 0);
|
classicProfile.SaveValue("reference", "100", 0);
|
||||||
|
|
||||||
AsPercentOfReferenceOrDirect mapper = new AsPercentOfReferenceOrDirect("primary", "notused", "reference");
|
AsPercentOfReferenceOrDirect mapper = new AsPercentOfReferenceOrDirect("primary", "notused", "reference");
|
||||||
Assert.IsTrue(mapper.Value == "13");
|
Assert.IsTrue(mapper.Value == "13");
|
||||||
|
|
@ -74,8 +77,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration.Tests
|
||||||
|
|
||||||
// and also check for 0
|
// and also check for 0
|
||||||
{
|
{
|
||||||
ActiveSliceSettings.Instance.SaveValue("primary", "0", 0);
|
classicProfile.SaveValue("primary", "0", 0);
|
||||||
ActiveSliceSettings.Instance.SaveValue("reference", "100", 0);
|
classicProfile.SaveValue("reference", "100", 0);
|
||||||
|
|
||||||
AsPercentOfReferenceOrDirect mapper = new AsPercentOfReferenceOrDirect("primary", "notused", "reference");
|
AsPercentOfReferenceOrDirect mapper = new AsPercentOfReferenceOrDirect("primary", "notused", "reference");
|
||||||
Assert.IsTrue(mapper.Value == "100");
|
Assert.IsTrue(mapper.Value == "100");
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
|
||||||
|
|
@ -128,8 +128,10 @@ namespace MatterHackers.MatterControl.VersionManagement
|
||||||
{
|
{
|
||||||
RequestManager requestManager = new RequestManager();
|
RequestManager requestManager = new RequestManager();
|
||||||
|
|
||||||
|
// Prevent constant exceptions on debug builds when stepping through code. In debug, let requests stay in limbo until resumed and prevent the timeout exceptions
|
||||||
|
#if !DEBUG
|
||||||
requestManager.Timeout = this.Timeout;
|
requestManager.Timeout = this.Timeout;
|
||||||
|
#endif
|
||||||
string jsonToSend = JsonConvert.SerializeObject(requestValues);
|
string jsonToSend = JsonConvert.SerializeObject(requestValues);
|
||||||
|
|
||||||
System.Diagnostics.Trace.Write(string.Format("ServiceRequest: {0}\r\n {1}\r\n", uri, string.Join("\r\n\t", jsonToSend.Split(','))));
|
System.Diagnostics.Trace.Write(string.Format("ServiceRequest: {0}\r\n {1}\r\n", uri, string.Join("\r\n\t", jsonToSend.Split(','))));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue