Merge branch 'master' of https://github.com/MatterHackers/MatterControl
This commit is contained in:
commit
555dcbf2f0
6 changed files with 23 additions and 69 deletions
|
|
@ -10,47 +10,9 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
{
|
||||
public class ConnectionWizardPage : WizardPage
|
||||
{
|
||||
private PrinterInfo activePrinter;
|
||||
|
||||
public ConnectionWizardPage() : base("Cancel")
|
||||
{
|
||||
cancelButton.Click += (s, e) => PrinterConnectionAndCommunication.Instance.HaltConnectionThread();
|
||||
}
|
||||
|
||||
public PrinterInfo ActivePrinter
|
||||
{
|
||||
get
|
||||
{
|
||||
if (activePrinter == null)
|
||||
{
|
||||
var settings = ActiveSliceSettings.Instance;
|
||||
activePrinter = new PrinterInfo
|
||||
{
|
||||
AutoConnect = settings.DoAutoConnect(),
|
||||
BaudRate = settings.BaudRate(),
|
||||
ComPort = settings.ComPort(),
|
||||
DriverType = settings.DriverType(),
|
||||
Id = settings.ID,
|
||||
Name = settings.Name()
|
||||
};
|
||||
}
|
||||
|
||||
return activePrinter;
|
||||
}
|
||||
}
|
||||
|
||||
protected void SaveAndExit()
|
||||
{
|
||||
ActiveSliceSettings.Instance.RunInTransaction(settings =>
|
||||
{
|
||||
settings.SetAutoConnect(ActivePrinter.AutoConnect);
|
||||
settings.SetBaudRate(ActivePrinter.BaudRate);
|
||||
settings.SetComPort(ActivePrinter.ComPort);
|
||||
settings.SetDriverType(ActivePrinter.DriverType);
|
||||
settings.SetName(ActivePrinter.Name);
|
||||
});
|
||||
|
||||
UiThread.RunOnIdle(WizardWindow.Close);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
|
@ -104,7 +105,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
BaudRateButtonsList.Add(baudOption);
|
||||
baudOption.Margin = baudRateMargin;
|
||||
baudOption.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
if (this.ActivePrinter.BaudRate == baudRate)
|
||||
if (ActiveSliceSettings.Instance.BaudRate() == baudRate)
|
||||
{
|
||||
baudOption.Checked = true;
|
||||
}
|
||||
|
|
@ -123,12 +124,13 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
otherBaudRateInput.Visible = false;
|
||||
otherBaudRateInput.HAnchor = HAnchor.ParentLeftRight;
|
||||
|
||||
if (this.ActivePrinter.BaudRate != null)
|
||||
string currentBaudRate = ActiveSliceSettings.Instance.BaudRate();
|
||||
if (currentBaudRate != null)
|
||||
{
|
||||
if (!baudRates.Contains(this.ActivePrinter.BaudRate.ToString()))
|
||||
if (!baudRates.Contains(currentBaudRate))
|
||||
{
|
||||
otherBaudRateRadioButton.Checked = true;
|
||||
otherBaudRateInput.Text = this.ActivePrinter.BaudRate.ToString();
|
||||
otherBaudRateInput.Text = currentBaudRate;
|
||||
otherBaudRateInput.Visible = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -191,8 +193,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
{
|
||||
try
|
||||
{
|
||||
int baudRateInt = Convert.ToInt32(baudRate);
|
||||
this.ActivePrinter.BaudRate = baudRate;
|
||||
ActiveSliceSettings.Instance.SetBaudRate(baudRate);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
|
|
|
|||
|
|
@ -121,7 +121,6 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
printerComPortError.Text = "Connection succeeded".Localize() + "!";
|
||||
nextButton.Visible = true;
|
||||
connectButton.Visible = false;
|
||||
UiThread.RunOnIdle(Parent.Close);
|
||||
}
|
||||
else if (PrinterConnectionAndCommunication.Instance.CommunicationState != PrinterConnectionAndCommunication.CommunicationStates.AttemptingToConnect)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
private BoundDropList printerManufacturerSelector;
|
||||
private BoundDropList printerModelSelector;
|
||||
|
||||
string activeMake;
|
||||
string activeModel;
|
||||
string activeName;
|
||||
|
||||
public SetupStepMakeModelName()
|
||||
{
|
||||
printerManufacturerSelector = new BoundDropList(string.Format("- {0} -", "Select Make".Localize()), maxHeight: 200)
|
||||
|
|
@ -51,7 +55,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
|
||||
if (printerManufacturerSelector.MenuItems.Count == 1)
|
||||
{
|
||||
ActivePrinter.Make = printerManufacturerSelector.SelectedValue;
|
||||
activeMake = printerManufacturerSelector.SelectedValue;
|
||||
}
|
||||
|
||||
printerModelSelector = new BoundDropList(string.Format("- {0} -", "Select Model".Localize()), maxHeight: 200)
|
||||
|
|
@ -103,8 +107,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
|
||||
private void SetElementVisibility()
|
||||
{
|
||||
printerModelContainer.Visible = (this.ActivePrinter.Make != null);
|
||||
nextButton.Visible = (this.ActivePrinter.Model != null && this.ActivePrinter.Make != null);
|
||||
nextButton.Visible = (activeModel != null && this.activeMake != null);
|
||||
}
|
||||
|
||||
private FlowLayoutWidget createPrinterNameContainer()
|
||||
|
|
@ -175,11 +178,11 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
|
||||
private void ManufacturerDropList_SelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
ActivePrinter.Make = ((Agg.UI.DropDownList)sender).SelectedValue;
|
||||
ActivePrinter.Model = null;
|
||||
activeMake = ((Agg.UI.DropDownList)sender).SelectedValue;
|
||||
activeModel = null;
|
||||
|
||||
List<string> printers;
|
||||
if (!OemSettings.Instance.OemProfiles.TryGetValue(ActivePrinter.Make, out printers))
|
||||
if (!OemSettings.Instance.OemProfiles.TryGetValue(activeMake, out printers))
|
||||
{
|
||||
printers = new List<string>();
|
||||
}
|
||||
|
|
@ -196,15 +199,15 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
DropDownList dropList = (DropDownList) sender;
|
||||
ActivePrinter.Model = dropList.SelectedLabel;
|
||||
activeModel = dropList.SelectedLabel;
|
||||
|
||||
SetElementVisibility();
|
||||
if (usingDefaultName)
|
||||
{
|
||||
// Use ManufacturerDropList.SelectedLabel instead of ActivePrinter.Make to ensure the mapped Unicode values are picked up
|
||||
// Use ManufacturerDropList.SelectedLabel instead of activeMake to ensure the mapped Unicode values are picked up
|
||||
string mappedMakeText = printerManufacturerSelector.SelectedLabel;
|
||||
|
||||
string printerInputName = string.Format("{0} {1}", mappedMakeText, this.ActivePrinter.Model);
|
||||
string printerInputName = string.Format("{0} {1}", mappedMakeText, activeModel);
|
||||
var names = ActiveSliceSettings.ProfileData.Profiles.Where(p => p.Name.StartsWith(printerInputName)).Select(p => p.Name).ToList();
|
||||
if (!names.Contains(printerInputName))
|
||||
{
|
||||
|
|
@ -231,15 +234,15 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
{
|
||||
if (!string.IsNullOrEmpty(printerNameInput.Text))
|
||||
{
|
||||
this.ActivePrinter.Name = printerNameInput.Text;
|
||||
activeName = printerNameInput.Text;
|
||||
|
||||
if (this.ActivePrinter.Make == null || this.ActivePrinter.Model == null)
|
||||
if (this.activeMake == null || activeModel == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ActiveSliceSettings.AcquireNewProfile(ActivePrinter.Make, ActivePrinter.Model, ActivePrinter.Name);
|
||||
ActiveSliceSettings.AcquireNewProfile(activeMake, activeModel, activeName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,13 +144,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
var profile = new SettingsProfile(LayeredProfile.LoadFile(filePath));
|
||||
ProfileData.Profiles.Add(new PrinterInfo()
|
||||
{
|
||||
AutoConnect = profile.DoAutoConnect(),
|
||||
BaudRate = profile.BaudRate(),
|
||||
ComPort = profile.ComPort(),
|
||||
DriverType = profile.DriverType(),
|
||||
Id = profile.ID,
|
||||
Make = profile.Make,
|
||||
Model = profile.Model,
|
||||
Name = profile.Name(),
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1216,14 +1216,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
public class PrinterInfo
|
||||
{
|
||||
public string Make { get; set; } = "Unknown";
|
||||
public string Model { get; set; } = "Unknown";
|
||||
public string Name { get; set; }
|
||||
public string ComPort { get; set; }
|
||||
public bool AutoConnect { get; set; }
|
||||
public string Id { get; set; }
|
||||
public string BaudRate { get; set; }
|
||||
public string DriverType { get; internal set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
internal void Delete()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue