Merge branch 'development' of https://github.com/MatterHackers/MatterControl into development

This commit is contained in:
Kevin Pope 2014-02-20 18:39:01 -08:00
commit 919874d34b
10 changed files with 182 additions and 79 deletions

View file

@ -129,20 +129,20 @@ namespace MatterHackers.MatterControl
switch (PrinterCommunication.Instance.CommunicationState)
{
case PrinterCommunication.CommunicationStates.Disconnected:
return new LocalizedString("Not connected. Press 'Connect' to enable printing.").Translated;
return new LocalizedString("Not connected. Press 'Connect' to enable printing.").Translated;
case PrinterCommunication.CommunicationStates.AttemptingToConnect:
return new LocalizedString("Attempting to connect...").Translated;
return new LocalizedString("Attempting to connect...").Translated;
case PrinterCommunication.CommunicationStates.ConnectionLost:
case PrinterCommunication.CommunicationStates.FailedToConnect:
return new LocalizedString("Unable to communicate with printer.").Translated;
return new LocalizedString("Unable to communicate with printer.").Translated;
case PrinterCommunication.CommunicationStates.Connected:
if (PrinterCommunication.Instance.ActivePrintItem != null)
{
return new LocalizedString("Item selected. Press 'Start' to begin your print.").Translated;
return new LocalizedString("Item selected. Press 'Start' to begin your print.").Translated;
}
else
{
return new LocalizedString("No items to select. Press 'Add' to select a file to print.").Translated;
return new LocalizedString("No items to select. Press 'Add' to select a file to print.").Translated;
}
default:
return "";

View file

@ -70,10 +70,10 @@ namespace MatterHackers.MatterControl
string exportStlTxt = new LocalizedString("Export as").Translated;
string exportStlTxtFull = string.Format("{0} STL", exportStlTxt);
Button exportSTL = textImageButtonFactory.Generate(exportStlTxtFull);
exportSTL.Click += new ButtonBase.ButtonEventHandler(exportSTL_Click);
Button exportAsStlButton = textImageButtonFactory.Generate(exportStlTxtFull);
exportAsStlButton.Click += new ButtonBase.ButtonEventHandler(exportSTL_Click);
//exportSTL.HAnchor = Agg.UI.HAnchor.ParentCenter;
topToBottom.AddChild(exportSTL);
topToBottom.AddChild(exportAsStlButton);
}
bool showExportGCodeButton = ActivePrinterProfile.Instance.ActivePrinter != null || partIsGCode;
@ -115,11 +115,12 @@ namespace MatterHackers.MatterControl
UiThread.RunOnIdle(DoExportGCode_Click);
}
string GetExtension (string filename)
string GetExtension (string filename)
{
string extension;
int indexOfDot = filename.LastIndexOf(".");
if (indexOfDot == -1) {
if (indexOfDot == -1)
{
extension = "";
}
else
@ -141,21 +142,17 @@ namespace MatterHackers.MatterControl
if (streamToSaveTo != null)
{
streamToSaveTo.Close ();
string filePathToSave = saveParams.FileName;
string extension = GetExtension(filePathToSave);
if(extension == "")
{
File.Delete (filePathToSave);
filePathToSave += ".gcode";
}
if (System.IO.Path.GetExtension(printQueueItem.PrintItemWrapper.FileLocation).ToUpper() == ".STL")
{
pathAndFilenameToSave = saveParams.FileName;
Close();
SlicingQueue.Instance.QueuePartForSlicing(printQueueItem.PrintItemWrapper);
printQueueItem.PrintItemWrapper.Done += new EventHandler(sliceItem_Done);
@ -163,7 +160,7 @@ namespace MatterHackers.MatterControl
else if (partIsGCode)
{
Close();
SaveGCodeToNewLocation(printQueueItem.PrintItemWrapper.FileLocation, saveParams.FileName);
SaveGCodeToNewLocation(printQueueItem.PrintItemWrapper.FileLocation, filePathToSave);
}
}
}
@ -249,13 +246,11 @@ namespace MatterHackers.MatterControl
string filePathToSave = saveParams.FileName;
string extension = CheckExtension(filePathToSave);
if (extension == "")
{
{
File.Delete (filePathToSave);
filePathToSave += ".stl";
}
File.Copy (printQueueItem.PrintItemWrapper.FileLocation, filePathToSave, true);
ShowFileIfRequested (filePathToSave);
}

View file

@ -34,7 +34,7 @@ using System.Text;
namespace MatterHackers.MatterControl.EeProm
{
public class EePromRepatierParameter
public class EePromRepatierParameter : EventArgs
{
public string description;
public int type;

View file

@ -32,6 +32,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using MatterHackers.Agg.UI;
namespace MatterHackers.MatterControl.EeProm
{
public delegate void OnEePromRepatierAdded(EePromRepatierParameter param);
@ -39,7 +41,7 @@ namespace MatterHackers.MatterControl.EeProm
public class EePromRepatierStorage
{
public Dictionary<int, EePromRepatierParameter> eePromSettingsList;
public event OnEePromRepatierAdded eventAdded = null;
public event EventHandler eventAdded = null;
public EePromRepatierStorage()
{
@ -59,8 +61,17 @@ namespace MatterHackers.MatterControl.EeProm
}
}
public void Add(string line)
public void Add(object sender, EventArgs e)
{
StringEventArgs lineString = e as StringEventArgs;
if (e == null)
{
return;
}
string line = lineString.Data;
if (!line.StartsWith("EPR:"))
{
return;
@ -75,7 +86,7 @@ namespace MatterHackers.MatterControl.EeProm
eePromSettingsList.Add(parameter.position, parameter);
if (eventAdded != null)
{
eventAdded(parameter);
eventAdded(this, parameter);
}
}

View file

@ -41,43 +41,67 @@ namespace MatterHackers.MatterControl.EeProm
{
public partial class EePromRepetierWidget : SystemWindow
{
protected TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
EePromRepatierStorage storage;
BindingList<EePromRepatierParameter> data = new BindingList<EePromRepatierParameter>();
FlowLayoutWidget descriptionColmun;
FlowLayoutWidget valueColmun;
FlowLayoutWidget settingsColmun;
event EventHandler unregisterEvents;
Button buttonCancel;
Button buttonSave;
bool reinit = true;
public EePromRepetierWidget()
: base(640, 480)
: base(540, 480)
{
BackgroundColor = RGBA_Bytes.White;
BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
storage = new EePromRepatierStorage();
FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
topToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;
topToBottom.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
FlowLayoutWidget row = new FlowLayoutWidget();
row.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
row.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
row.AddChild(AddDescription(new LocalizedString("Description").Translated));
GuiWidget valueText = new TextWidget(new LocalizedString("Value").Translated, textColor: ActiveTheme.Instance.PrimaryTextColor);
valueText.VAnchor = Agg.UI.VAnchor.ParentCenter;
valueText.Margin = new BorderDouble(left: 5);
row.AddChild(valueText);
topToBottom.AddChild(row);
{
FlowLayoutWidget columnHolder = new FlowLayoutWidget();
descriptionColmun = new FlowLayoutWidget(FlowDirection.TopToBottom);
columnHolder.AddChild(descriptionColmun);
ScrollableWidget settingsAreaScrollBox = new ScrollableWidget(true);
settingsAreaScrollBox.ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
settingsAreaScrollBox.AnchorAll();
topToBottom.AddChild(settingsAreaScrollBox);
valueColmun = new FlowLayoutWidget(FlowDirection.TopToBottom);
columnHolder.AddChild(valueColmun);
settingsColmun = new FlowLayoutWidget(FlowDirection.TopToBottom);
settingsColmun.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
descriptionColmun.AddChild(new TextWidget(new LocalizedString("Description").Translated));
valueColmun.AddChild(new TextWidget(new LocalizedString("Value").Translated));
topToBottom.AddChild(columnHolder);
settingsAreaScrollBox.AddChild(settingsColmun);
}
buttonCancel = new Button(new LocalizedString("Cancel").Translated);
topToBottom.AddChild(buttonCancel);
FlowLayoutWidget buttonBar = new FlowLayoutWidget();
buttonBar.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
buttonBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
buttonSave = textImageButtonFactory.Generate(new LocalizedString("Save To EEPROM").Translated);
buttonSave.Margin = new BorderDouble(3);
buttonBar.AddChild(buttonSave);
buttonSave = new Button(new LocalizedString("Save To EEPROM").Translated);
topToBottom.AddChild(buttonSave);
GuiWidget spacer = new GuiWidget(1, 1);
spacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
buttonBar.AddChild(spacer);
buttonCancel = textImageButtonFactory.Generate(new LocalizedString("Cancel").Translated);
buttonCancel.Margin = new BorderDouble(3);
buttonBar.AddChild(buttonCancel);
topToBottom.AddChild(buttonBar);
//MatterControlApplication.Instance.LanguageChanged += translate;
this.AddChild(topToBottom);
@ -85,6 +109,20 @@ namespace MatterHackers.MatterControl.EeProm
translate();
ShowAsSystemWindow();
storage.Clear();
PrinterCommunication.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(storage.Add, ref unregisterEvents);
storage.eventAdded += NewSettingReadFromPrinter;
storage.AskPrinterForSettings();
}
public override void OnClosed(EventArgs e)
{
if (unregisterEvents != null)
{
unregisterEvents(this, null);
}
base.OnClosed(e);
}
public void translate()
@ -97,34 +135,83 @@ namespace MatterHackers.MatterControl.EeProm
buttonSave.Click += buttonSave_Click;
}
private void newline(EePromRepatierParameter p)
private void NewSettingReadFromPrinter(object sender, EventArgs e)
{
data.Add(p);
EePromRepatierParameter newSetting = e as EePromRepatierParameter;
if (newSetting != null)
{
data.Add(newSetting);
UiThread.RunOnIdle(AddItemToUi, newSetting);
}
}
void AddItemToUi(object state)
{
EePromRepatierParameter newSetting = state as EePromRepatierParameter;
if (newSetting != null)
{
FlowLayoutWidget row = new FlowLayoutWidget();
row.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
row.AddChild(AddDescription(newSetting.Description));
row.Padding = new BorderDouble(5, 0);
if ((settingsColmun.Children.Count % 2) == 1)
{
row.BackgroundColor = new RGBA_Bytes(0, 0, 0, 50);
}
GuiWidget spacer = new GuiWidget(1, 1);
spacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
row.AddChild(spacer);
double currentValue;
double.TryParse(newSetting.Value, out currentValue);
MHNumberEdit valueEdit = new MHNumberEdit(currentValue, pixelWidth: 80, allowNegatives: true, allowDecimals: true);
valueEdit.VAnchor = Agg.UI.VAnchor.ParentCenter;
valueEdit.ActuallNumberEdit.EditComplete += (sender, e) =>
{
newSetting.Value = valueEdit.ActuallNumberEdit.Value.ToString();
};
row.AddChild(valueEdit);
settingsColmun.AddChild(row);
}
}
private GuiWidget AddDescription(string description)
{
GuiWidget holder = new GuiWidget(340, 40);
TextWidget textWidget = new TextWidget(description, textColor: ActiveTheme.Instance.PrimaryTextColor);
textWidget.VAnchor = Agg.UI.VAnchor.ParentCenter;
holder.AddChild(textWidget);
return holder;
}
private void buttonSave_Click(object sender, EventArgs e)
{
UiThread.RunOnIdle(DoButtonSave_Click);
}
private void DoButtonSave_Click(object state)
{
storage.Save();
storage.Clear();
storage.eventAdded -= newline;
storage.eventAdded -= NewSettingReadFromPrinter;
Close();
}
private void buttonAbort_Click(object sender, EventArgs e)
{
storage.Clear();
data.Clear();
storage.eventAdded -= newline;
UiThread.RunOnIdle(DoButtonAbort_Click);
}
private void EEPROMRepetier_Activated(object sender, EventArgs e)
private void DoButtonAbort_Click(object state)
{
if (reinit)
{
reinit = false;
storage.Clear();
storage.eventAdded += newline;
storage.AskPrinterForSettings();
}
storage.Clear();
data.Clear();
storage.eventAdded -= NewSettingReadFromPrinter;
Close();
}
}
}

View file

@ -1,26 +1,19 @@
<Properties>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.Workbench ActiveDocument="MainSlidePanel.cs">
<MonoDevelop.Ide.Workbench ActiveDocument="Localizations\LocalizedString.cs">
<Files>
<File FileName="PrinterCommunication.cs" Line="1" Column="1" />
<File FileName="PrinterControls\PrinterConnections\ConnectionWindow.cs" Line="1" Column="1" />
<File FileName="WidescreenPanel.cs" Line="1" Column="1" />
<File FileName="PrintQueue\QueueControlsWidget.cs" Line="1" Column="1" />
<File FileName="PrintLibrary\ExportLibraryItemWindow.cs" Line="1" Column="1" />
<File FileName="MainSlidePanel.cs" Line="328" Column="14" />
<File FileName="CustomWidgets\WizardControl.cs" Line="1" Column="1" />
<File FileName="PartPreviewWindow\PartPreviewMainWindow.cs" Line="1" Column="1" />
<File FileName="CustomWidgets\SavePartsSheetFeedbackWindow.cs" Line="1" Column="1" />
<File FileName="Localizations\LocalizedString.cs" Line="1" Column="1" />
<File FileName="PrintQueue\PrintQueueItem.cs" Line="1" Column="1" />
<File FileName="c:\Users\Matter Hackers 1\Development\agg-sharp\Gui\SystemWindow.cs" Line="1" Column="1" />
<File FileName="Localizations\LocalizedString.cs" Line="14" Column="10" />
<File FileName="PrintLibrary\PrintLibraryListItem.cs" Line="1" Column="1" />
<File FileName="ActionBar\ActionBarBaseControls.cs" Line="1" Column="1" />
<File FileName="ActionBar\HelpTextWidget.cs" Line="1" Column="1" />
<File FileName="PrintQueue\PrintQueueMenu.cs" Line="1" Column="1" />
<File FileName="..\MatterControlPlugins\PrintNotifications\NotificationForm.cs" Line="1" Column="1" />
<File FileName="PrinterCommunication.cs" Line="1" Column="1" />
<File FileName="PrintLevelWizard.cs" Line="1" Column="1" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore>
<Breakpoint file="C:\Users\Matter Hackers 1\Development\mattercontrol\PrintQueue\PrintQueueMenu.cs" line="148" column="1" />
</BreakpointStore>
<BreakpointStore />
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
</Properties>

View file

@ -61,10 +61,10 @@ namespace MatterHackers.MatterControl.PrintQueue
//Set the name and callback function of the menu items
menuItems = new TupleList<string, Func<bool>>
{
{new LocalizedString("STL").Translated, null},
{"STL", null},
{new LocalizedString(" Import from Zip").Translated, importQueueFromZipMenu_Click},
{new LocalizedString(" Export to Zip").Translated, exportQueueToZipMenu_Click},
{new LocalizedString("GCode").Translated, null},
{"GCode", null},
{new LocalizedString(" Export to Folder").Translated, exportGCodeToFolderButton_Click},
//{" Export to SD Card", exportToSDCardButton_Click},
{new LocalizedString("Extra").Translated, null},

View file

@ -114,7 +114,8 @@ namespace MatterHackers.MatterControl
public RootedObjectEventHandler ActivePrintItemChanged = new RootedObjectEventHandler();
public RootedObjectEventHandler BedTemperatureRead = new RootedObjectEventHandler();
public RootedObjectEventHandler BedTemperatureSet = new RootedObjectEventHandler();
public RootedObjectEventHandler CommunicationUnconditional = new RootedObjectEventHandler();
public RootedObjectEventHandler CommunicationUnconditionalFromPrinter = new RootedObjectEventHandler();
public RootedObjectEventHandler CommunicationUnconditionalToPrinter = new RootedObjectEventHandler();
public RootedObjectEventHandler ConnectionFailed = new RootedObjectEventHandler();
public RootedObjectEventHandler ConnectionStateChanged = new RootedObjectEventHandler();
public RootedObjectEventHandler ConnectionSucceeded = new RootedObjectEventHandler();
@ -1432,7 +1433,7 @@ namespace MatterHackers.MatterControl
// write data to communication
{
StringEventArgs currentEvent = new StringEventArgs(lineToWrite);
CommunicationUnconditional.CallEvents(this, new StringEventArgs("->" + currentEvent.Data));
CommunicationUnconditionalToPrinter.CallEvents(this, currentEvent);
if (lineWithoutChecksum != null)
{
@ -1791,7 +1792,7 @@ namespace MatterHackers.MatterControl
// process this command
{
StringEventArgs currentEvent = new StringEventArgs(lastLineRead);
CommunicationUnconditional.CallEvents(this, new StringEventArgs("<-" + currentEvent.Data));
CommunicationUnconditionalFromPrinter.CallEvents(this, currentEvent);
FoundStringEventArgs foundResponse = new FoundStringEventArgs(currentEvent.Data);
ReadLineStartCallBacks.CheckForKeys(foundResponse);

View file

@ -252,16 +252,30 @@ namespace MatterHackers.MatterControl
{
if (filterOutput.Checked)
{
PrinterCommunication.Instance.CommunicationUnconditional.UnregisterEvent(outputScrollWidget.WriteLine, ref unregisterEvents);
PrinterCommunication.Instance.CommunicationUnconditionalFromPrinter.UnregisterEvent(FromPrinter, ref unregisterEvents);
PrinterCommunication.Instance.CommunicationUnconditionalToPrinter.UnregisterEvent(ToPrinter, ref unregisterEvents);
PrinterCommunication.Instance.ReadLine.RegisterEvent(outputScrollWidget.WriteLine, ref unregisterEvents);
}
else
{
PrinterCommunication.Instance.CommunicationUnconditional.RegisterEvent(outputScrollWidget.WriteLine, ref unregisterEvents);
PrinterCommunication.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(FromPrinter, ref unregisterEvents);
PrinterCommunication.Instance.CommunicationUnconditionalToPrinter.RegisterEvent(ToPrinter, ref unregisterEvents);
PrinterCommunication.Instance.ReadLine.UnregisterEvent(outputScrollWidget.WriteLine, ref unregisterEvents);
}
}
void FromPrinter(Object sender, EventArgs e)
{
StringEventArgs lineString = e as StringEventArgs;
outputScrollWidget.WriteLine(sender, new StringEventArgs("<-" + lineString.Data));
}
void ToPrinter(Object sender, EventArgs e)
{
StringEventArgs lineString = e as StringEventArgs;
outputScrollWidget.WriteLine(sender, new StringEventArgs("->" + lineString.Data));
}
void Instance_ConnectionFailed(object sender, EventArgs e)
{
outputScrollWidget.WriteLine(sender, new StringEventArgs("Lost connection to printer."));

View file

@ -57,6 +57,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
hideItems.Add("cool_extruder_lift");
hideItems.Add("support_material_create_internal_support");
hideItems.Add("min_extrusion_before_retract");
hideItems.Add("support_material_xy_distance");
hideItems.Add("support_material_z_distance");
}
return instance;
}