From 50ead93c1e84adb7c24b755d22d76bf6d52ef25b Mon Sep 17 00:00:00 2001 From: larsbrubaker Date: Thu, 10 Apr 2014 10:36:59 -0700 Subject: [PATCH 01/13] Made the language restart actually restart the app. --- ConfigurationPage/ConfigurationPage.cs | 38 ++----- ConfigurationPage/LanguageSelector.cs | 39 +++++-- Launcher/Launcher.cs | 38 +++++++ Launcher/Launcher.csproj | 50 +++++++++ MatterControl.csproj | 4 + MatterControl.sln | 8 ++ MatterControlApplication.cs | 13 +++ StaticData/Translations/Master.txt | 3 + StaticData/Translations/de/Translation.txt | 120 +++++++++++++++++++++ StaticData/Translations/readme.txt | 5 +- 10 files changed, 279 insertions(+), 39 deletions(-) create mode 100644 Launcher/Launcher.cs create mode 100644 Launcher/Launcher.csproj diff --git a/ConfigurationPage/ConfigurationPage.cs b/ConfigurationPage/ConfigurationPage.cs index d835facc7..bec082f3a 100644 --- a/ConfigurationPage/ConfigurationPage.cs +++ b/ConfigurationPage/ConfigurationPage.cs @@ -117,15 +117,11 @@ namespace MatterHackers.MatterControl } Button restartButton; - Dictionary languageDict; private void AddLanguageControls(FlowLayoutWidget controlsTopToBottomLayout) { - CreateLanguageDict(); - DisableableWidget container = new DisableableWidget(); - GroupBox languageControlsGroupBox = new GroupBox(LocalizedString.Get("Language Settings")); languageControlsGroupBox.TextColor = ActiveTheme.Instance.PrimaryTextColor; languageControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor; @@ -137,22 +133,7 @@ namespace MatterHackers.MatterControl FlowLayoutWidget controlsContainer = new FlowLayoutWidget(); controlsContainer.HAnchor = HAnchor.ParentLeftRight; - string languageCode = UserSettings.Instance.get("Language"); - string languageVerbose = "Default"; - - foreach(KeyValuePair entry in languageDict) - { - if (languageCode == entry.Value) - { - languageVerbose = entry.Key; - } - } - - LanguageSelector languageSelector = new LanguageSelector(languageVerbose); - foreach (KeyValuePair entry in languageDict) - { - languageSelector.AddItem(entry.Key,entry.Value); - } + LanguageSelector languageSelector = new LanguageSelector(); languageSelector.Margin = new BorderDouble(0); languageSelector.SelectionChanged += new EventHandler(LanguageDropList_SelectionChanged); @@ -182,22 +163,17 @@ namespace MatterHackers.MatterControl UiThread.RunOnIdle((state) => { //horrible hack - to be replaced - MatterControlApplication app = (MatterControlApplication)this.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent; + GuiWidget parent = this; + while (parent as MatterControlApplication == null) + { + parent = parent.Parent; + } + MatterControlApplication app = parent as MatterControlApplication; app.RestartOnClose = true; app.Close(); }); } - private void CreateLanguageDict() - { - languageDict = new Dictionary(); - languageDict["Default"] = "EN"; - languageDict["English"] = "EN"; - languageDict["Español"] = "ES"; - languageDict["Français"] = "FR"; - languageDict["Deutsch"] = "DE"; - } - private void LanguageDropList_SelectionChanged(object sender, EventArgs e) { string languageCode = ((DropDownList)sender).SelectedLabel; diff --git a/ConfigurationPage/LanguageSelector.cs b/ConfigurationPage/LanguageSelector.cs index 8fbdf4136..8c43a3ee3 100644 --- a/ConfigurationPage/LanguageSelector.cs +++ b/ConfigurationPage/LanguageSelector.cs @@ -10,17 +10,15 @@ using MatterHackers.VectorMath; using MatterHackers.MatterControl.DataStorage; using MatterHackers.Localizations; - namespace MatterHackers.MatterControl { public class LanguageSelector : StyledDropDownList - { + { + Dictionary languageDict; - public LanguageSelector(string selection) - : base(selection) + public LanguageSelector() + : base("Default") { - - //string pathToModels = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "PrinterSettings", manufacturer); //if (Directory.Exists(pathToModels)) //{ @@ -32,7 +30,34 @@ namespace MatterHackers.MatterControl //} this.MinimumSize = new Vector2(this.LocalBounds.Width, this.LocalBounds.Height); + + CreateLanguageDict(); + + string languageCode = UserSettings.Instance.get("Language"); + + foreach (KeyValuePair entry in languageDict) + { + AddItem(entry.Key, entry.Value); + } + + foreach (KeyValuePair entry in languageDict) + { + if (languageCode == entry.Value) + { + SelectedLabel = entry.Key; + break; + } + } + } + + private void CreateLanguageDict() + { + languageDict = new Dictionary(); + languageDict["Default"] = "EN"; + languageDict["English"] = "EN"; + languageDict["Español"] = "ES"; + languageDict["Français"] = "FR"; + languageDict["Deutsch"] = "DE"; } } - } diff --git a/Launcher/Launcher.cs b/Launcher/Launcher.cs new file mode 100644 index 000000000..14744064e --- /dev/null +++ b/Launcher/Launcher.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Linq; +using System.Text; +using System.IO; +using System.Diagnostics; + +namespace MatterHackers.MatterControl.Launcher +{ + public class LauncherApp + { + public LauncherApp() + { + } + + [STAThread] + public static void Main(string[] args) + { + if (args.Length == 2 && File.Exists(args[0])) + { + ProcessStartInfo runAppLauncherStartInfo = new ProcessStartInfo(); + runAppLauncherStartInfo.FileName = args[0]; + + int timeToWait = 0; + int.TryParse(args[1], out timeToWait); + + Stopwatch waitTime = new Stopwatch(); + waitTime.Start(); + while (waitTime.ElapsedMilliseconds < timeToWait) + { + } + + Process.Start(runAppLauncherStartInfo); + } + } + } +} diff --git a/Launcher/Launcher.csproj b/Launcher/Launcher.csproj new file mode 100644 index 000000000..c7401dcc9 --- /dev/null +++ b/Launcher/Launcher.csproj @@ -0,0 +1,50 @@ + + + + Release + AnyCPU + 8.0.50727 + 2.0 + Exe + bin\Release\ + Properties + MatterHackers.MatterControl.Launcher + Launcher + + + + + 2.0 + 0.8.2 + + + True + full + False + bin\Debug\ + DEBUG;TRACE + prompt + 4 + True + AnyCPU + + + pdbonly + True + TRACE + prompt + 4 + True + AnyCPU + + + + + + + + + + + + \ No newline at end of file diff --git a/MatterControl.csproj b/MatterControl.csproj index 38fc1d61f..eff377183 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -316,6 +316,10 @@ {AE37DE1F-22F7-49EE-8732-FC6BC8DC58D9} Tesselate + + {3DF4CB3D-9A03-4256-9A81-70523AAD828B} + Launcher + {990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9} InfInstaller diff --git a/MatterControl.sln b/MatterControl.sln index e0ac77f0b..609afede1 100644 --- a/MatterControl.sln +++ b/MatterControl.sln @@ -58,6 +58,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OutlineCreator", "..\Matter EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MatterSlice", "..\MatterSlice\MatterSlice.csproj", "{C46CA728-DD2F-4DD1-971A-AAA89D9DFF95}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher", "Launcher\Launcher.csproj", "{3DF4CB3D-9A03-4256-9A81-70523AAD828B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -224,6 +226,12 @@ Global {C46CA728-DD2F-4DD1-971A-AAA89D9DFF95}.Release|Any CPU.ActiveCfg = Release|Any CPU {C46CA728-DD2F-4DD1-971A-AAA89D9DFF95}.Release|Any CPU.Build.0 = Release|Any CPU {C46CA728-DD2F-4DD1-971A-AAA89D9DFF95}.Release|x86.ActiveCfg = Release|Any CPU + {3DF4CB3D-9A03-4256-9A81-70523AAD828B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3DF4CB3D-9A03-4256-9A81-70523AAD828B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3DF4CB3D-9A03-4256-9A81-70523AAD828B}.Debug|x86.ActiveCfg = Debug|Any CPU + {3DF4CB3D-9A03-4256-9A81-70523AAD828B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3DF4CB3D-9A03-4256-9A81-70523AAD828B}.Release|Any CPU.Build.0 = Release|Any CPU + {3DF4CB3D-9A03-4256-9A81-70523AAD828B}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/MatterControlApplication.cs b/MatterControlApplication.cs index eadd37549..f14c7145e 100644 --- a/MatterControlApplication.cs +++ b/MatterControlApplication.cs @@ -322,6 +322,19 @@ namespace MatterHackers.MatterControl Datastore.Instance.Exit(); PrinterCommunication.Instance.HaltConnectionThread(); SlicingQueue.Instance.ShutDownSlicingThread(); + if (RestartOnClose) + { + string appPathAndFile = System.Reflection.Assembly.GetExecutingAssembly().Location; + string pathToAppFolder = Path.GetDirectoryName(appPathAndFile); + + ProcessStartInfo runAppLauncherStartInfo = new ProcessStartInfo(); + runAppLauncherStartInfo.Arguments = "\"{0}\" \"{1}\"".FormatWith(appPathAndFile, 1000); + runAppLauncherStartInfo.FileName = Path.Combine(pathToAppFolder, "Launcher.exe"); + runAppLauncherStartInfo.WindowStyle = ProcessWindowStyle.Hidden; + runAppLauncherStartInfo.CreateNoWindow = true; + + Process.Start(runAppLauncherStartInfo); + } base.OnClosed(e); } diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index 9890882e8..0ccb37324 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -1932,3 +1932,6 @@ Translated:You cannot move any lower. This position on your bed is too low for t English:Edit Preset Translated:Edit Preset +English:Slice-Engine +Translated:Slice-Engine + diff --git a/StaticData/Translations/de/Translation.txt b/StaticData/Translations/de/Translation.txt index 2ddacc37a..b662e96ac 100644 --- a/StaticData/Translations/de/Translation.txt +++ b/StaticData/Translations/de/Translation.txt @@ -1816,3 +1816,123 @@ Translated:MatterContol English:Saving to Parts Sheet Translated:Saving to Parts Sheet +English:The default temperature to set the bed to. Can sometimes be overriden on the first layer. Set to 0 to eliminate bed temperature commands. +Translated:The default temperature to set the bed to. Can sometimes be overriden on the first layer. Set to 0 to eliminate bed temperature commands. + +English:The default temperature to set the extruder to. Can sometimes be overriden on the first layer. +Translated:The default temperature to set the extruder to. Can sometimes be overriden on the first layer. + +English:Macro Editor +Translated:Macro Editor + +English:Macro Presets +Translated:Macro Presets + +English:Edit Macro +Translated:Edit Macro + +English:Macro Name +Translated:Macro Name + +English:Give your macro a name +Translated:Give your macro a name + +English:Macro Commands +Translated:Macro Commands + +English:This should be in 'Gcode' +Translated:This should be in 'Gcode' + +English:3D Printer Setup +Translated:3D Printer Setup + +English:Give your printer a name. +Translated:Give your printer a name. + +English:Select Make +Translated:Select Make + +English:Select the printer manufacturer +Translated:Select the printer manufacturer + +English:Select the printer model +Translated:Select the printer model + +English:Save & Continue +Translated:Save & Continue + +English:MatterControl will now attempt to auto-detect printer. +Translated:MatterControl will now attempt to auto-detect printer. + +English:Disconnect printer +Translated:Disconnect printer + +English:if currently connected +Translated:if currently connected + +English:Press +Translated:Press + +English:Continue +Translated:Continue + +English:Manual Configuration +Translated:Manual Configuration + +English:Setup Manual Configuration +Translated:Setup Manual Configuration + +English:or +Translated:or + +English:Skip Printer Connection +Translated:Skip Printer Connection + +English:You can either +Translated:You can either + +English:You can also +Translated:You can also + +English:Extruder Temperature Settings +Translated:Extruder Temperature Settings + +English:Temperature Shortcut Presets +Translated:Temperature Shortcut Presets + +English:Label +Translated:Label + +English:Preset +Translated:Preset + +English:Max Temp. +Translated:Max Temp. + +English:Bed Temperature Settings +Translated:Bed Temperature Settings + +English:Movement Speeds +Translated:Movement Speeds + +English:Extruder +Translated:Extruder + +English:Power on and connect printer +Translated:Power on and connect printer + +English:Attempting to connect +Translated:Attempting to connect + +English:Connection succeeded +Translated:Connection succeeded + +English:You cannot move any lower. This position on your bed is too low for the extruder to reach. You need to raise your bed, or adjust your limits to allow the extruder to go lower. +Translated:You cannot move any lower. This position on your bed is too low for the extruder to reach. You need to raise your bed, or adjust your limits to allow the extruder to go lower. + +English:Edit Preset +Translated:Edit Preset + +English:Slice-Engine +Translated:Slice-Engine + diff --git a/StaticData/Translations/readme.txt b/StaticData/Translations/readme.txt index 30303082d..85ab9790a 100644 --- a/StaticData/Translations/readme.txt +++ b/StaticData/Translations/readme.txt @@ -5,4 +5,7 @@ should appear at the bottom of that file. There is a folder for each langage. The names of these folders match the ISO 639 standard which can be found at: -http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes \ No newline at end of file +http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes + +Special thanks to: +Filip Bartoszek - original German Translation \ No newline at end of file From a749bdc6c2853a4d0b0e08ad2b32b3b6419922af Mon Sep 17 00:00:00 2001 From: larsbrubaker Date: Thu, 10 Apr 2014 11:00:26 -0700 Subject: [PATCH 02/13] Fixed some strings to not be all caps. Put in a project guid. --- ActionBar/PrinterActionRow.cs | 6 +++--- Launcher/Launcher.csproj | 1 + PrinterControls/ManualPrinterControls.cs | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ActionBar/PrinterActionRow.cs b/ActionBar/PrinterActionRow.cs index 9db3f9b28..7b7882cf6 100644 --- a/ActionBar/PrinterActionRow.cs +++ b/ActionBar/PrinterActionRow.cs @@ -46,13 +46,13 @@ namespace MatterHackers.MatterControl.ActionBar protected override void AddChildElements() { actionBarButtonFactory.invertImageLocation = false; - string connectString = "CONNECT".Localize(); + string connectString = "Connect".Localize().ToUpper(); connectPrinterButton = actionBarButtonFactory.Generate(connectString, "icon_power_32x32.png"); connectPrinterButton.Margin = new BorderDouble(0, 0, 3); connectPrinterButton.VAnchor = VAnchor.ParentCenter; connectPrinterButton.Cursor = Cursors.Hand; - string disconnectString = "DISCONNECT".Localize(); + string disconnectString = "Disconnect".Localize().ToUpper(); disconnectPrinterButton = actionBarButtonFactory.Generate(disconnectString, "icon_power_32x32.png"); disconnectPrinterButton.Margin = new BorderDouble(0, 0, 3); disconnectPrinterButton.VAnchor = VAnchor.ParentCenter; @@ -88,7 +88,7 @@ namespace MatterHackers.MatterControl.ActionBar FlowLayoutWidget leftToRight = new FlowLayoutWidget(); leftToRight.Margin = new BorderDouble(5, 0); - string optionsString = LocalizedString.Get("OPTIONS"); + string optionsString = "Options".Localize().ToUpper(); TextWidget optionsText = new TextWidget(optionsString, textColor: ActiveTheme.Instance.PrimaryTextColor); optionsText.VAnchor = Agg.UI.VAnchor.ParentCenter; optionsText.Margin = new BorderDouble(0, 0, 3, 0); diff --git a/Launcher/Launcher.csproj b/Launcher/Launcher.csproj index c7401dcc9..f1a3407df 100644 --- a/Launcher/Launcher.csproj +++ b/Launcher/Launcher.csproj @@ -6,6 +6,7 @@ 8.0.50727 2.0 Exe + {990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9} bin\Release\ Properties MatterHackers.MatterControl.Launcher diff --git a/PrinterControls/ManualPrinterControls.cs b/PrinterControls/ManualPrinterControls.cs index 2d1d0e68d..dc5a6b10d 100644 --- a/PrinterControls/ManualPrinterControls.cs +++ b/PrinterControls/ManualPrinterControls.cs @@ -547,7 +547,7 @@ namespace MatterHackers.MatterControl ImageWidget terminalIcon = new ImageWidget(terminalImage); terminalIcon.Margin = new BorderDouble (right: 6); - Button showTerminal = textImageButtonFactory.Generate(LocalizedString.Get("SHOW TERMINAL")); + Button showTerminal = textImageButtonFactory.Generate("Show Terminal".Localize().ToUpper()); showTerminal.Margin = new BorderDouble(0); showTerminal.Click += (sender, e) => { @@ -738,7 +738,7 @@ namespace MatterHackers.MatterControl GuiWidget spacer = new GuiWidget(); spacer.HAnchor = HAnchor.ParentLeftRight; - disableMotors = textImageButtonFactory.Generate(LocalizedString.Get("UNLOCK")); + disableMotors = textImageButtonFactory.Generate("Unlock".Localize().ToUpper()); disableMotors.Margin = new BorderDouble(0); disableMotors.Click += new ButtonBase.ButtonEventHandler(disableMotors_Click); From 771280f6dff7b40f4a4bfc33761352d3789eb48a Mon Sep 17 00:00:00 2001 From: larsbrubaker Date: Thu, 10 Apr 2014 14:07:25 -0700 Subject: [PATCH 03/13] Fixed many all upper case words to be Title case instead. --- ConfigurationPage/ConfigurationPage.cs | 8 ++++---- Launcher/Launcher.csproj | 3 +-- PartPreviewWindow/GcodeViewBasic.cs | 26 ++++++++++++------------ PrintHistory/PrintHistoryListItem.cs | 18 +++++++++------- PrinterControls/ManualPrinterControls.cs | 2 +- StaticData/Translations/Master.txt | 15 ++++++++++++++ 6 files changed, 45 insertions(+), 27 deletions(-) diff --git a/ConfigurationPage/ConfigurationPage.cs b/ConfigurationPage/ConfigurationPage.cs index bec082f3a..86f02693c 100644 --- a/ConfigurationPage/ConfigurationPage.cs +++ b/ConfigurationPage/ConfigurationPage.cs @@ -207,7 +207,7 @@ namespace MatterHackers.MatterControl ImageWidget eePromIcon = new ImageWidget(eePromImage); eePromIcon.Margin = new BorderDouble (right: 6); - Button openEePromWindow = textImageButtonFactory.Generate(LocalizedString.Get("CONFIGURE")); + Button openEePromWindow = textImageButtonFactory.Generate("Configure".Localize().ToUpper()); openEePromWindow.Click += (sender, e) => { #if false // This is to force the creation of the repetier window for testing when we don't have repetier firmware. @@ -311,7 +311,7 @@ namespace MatterHackers.MatterControl this.textImageButtonFactory.FixedHeight = TallButtonHeight; - Button runPrintLevelingButton = textImageButtonFactory.Generate(LocalizedString.Get("CONFIGURE")); + Button runPrintLevelingButton = textImageButtonFactory.Generate("Configure".Localize().ToUpper()); runPrintLevelingButton.Margin = new BorderDouble(left:6); runPrintLevelingButton.VAnchor = VAnchor.ParentCenter; runPrintLevelingButton.Click += new ButtonBase.ButtonEventHandler(runPrintLeveling_Click); @@ -326,12 +326,12 @@ namespace MatterHackers.MatterControl ImageWidget levelingIcon = new ImageWidget(levelingImage); levelingIcon.Margin = new BorderDouble (right: 6); - enablePrintLevelingButton = textImageButtonFactory.Generate(LocalizedString.Get("ENABLE")); + enablePrintLevelingButton = textImageButtonFactory.Generate("Enable".Localize().ToUpper()); enablePrintLevelingButton.Margin = new BorderDouble(left:6); enablePrintLevelingButton.VAnchor = VAnchor.ParentCenter; enablePrintLevelingButton.Click += new ButtonBase.ButtonEventHandler(enablePrintLeveling_Click); - disablePrintLevelingButton = textImageButtonFactory.Generate(LocalizedString.Get("DISABLE")); + disablePrintLevelingButton = textImageButtonFactory.Generate("Disable".Localize().ToUpper()); disablePrintLevelingButton.Margin = new BorderDouble(left:6); disablePrintLevelingButton.VAnchor = VAnchor.ParentCenter; disablePrintLevelingButton.Click += new ButtonBase.ButtonEventHandler(disablePrintLeveling_Click); diff --git a/Launcher/Launcher.csproj b/Launcher/Launcher.csproj index f1a3407df..cc7380825 100644 --- a/Launcher/Launcher.csproj +++ b/Launcher/Launcher.csproj @@ -6,7 +6,7 @@ 8.0.50727 2.0 Exe - {990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9} + {3DF4CB3D-9A03-4256-9A81-70523AAD828B} bin\Release\ Properties MatterHackers.MatterControl.Launcher @@ -42,7 +42,6 @@ - diff --git a/PartPreviewWindow/GcodeViewBasic.cs b/PartPreviewWindow/GcodeViewBasic.cs index 47076543f..16ef7a2a1 100644 --- a/PartPreviewWindow/GcodeViewBasic.cs +++ b/PartPreviewWindow/GcodeViewBasic.cs @@ -205,7 +205,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { BorderDouble buttonMargin = new BorderDouble(top: 3); - string label = LocalizedString.Get("MODEL"); + string label = "MODEL".Localize().ToUpper(); expandModelOptions = expandMenuOptionFactory.GenerateCheckBoxButton(label, "icon_arrow_right_no_border_32x32.png", "icon_arrow_down_no_border_32x32.png"); expandModelOptions.Margin = new BorderDouble(bottom: 2); buttonRightPanel.AddChild(expandModelOptions); @@ -216,7 +216,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow //modelOptionsContainer.Visible = false; buttonRightPanel.AddChild(modelOptionsContainer); - expandLayerOptions = expandMenuOptionFactory.GenerateCheckBoxButton(LocalizedString.Get("LAYER"), "icon_arrow_right_no_border_32x32.png", "icon_arrow_down_no_border_32x32.png"); + expandLayerOptions = expandMenuOptionFactory.GenerateCheckBoxButton("Layer".Localize().ToUpper(), "icon_arrow_right_no_border_32x32.png", "icon_arrow_down_no_border_32x32.png"); expandLayerOptions.Margin = new BorderDouble(bottom: 2); //buttonRightPanel.AddChild(expandLayerOptions); @@ -225,7 +225,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow layerOptionsContainer.Visible = false; buttonRightPanel.AddChild(layerOptionsContainer); - expandDisplayOptions = expandMenuOptionFactory.GenerateCheckBoxButton(LocalizedString.Get("DISPLAY"), "icon_arrow_right_no_border_32x32.png", "icon_arrow_down_no_border_32x32.png"); + expandDisplayOptions = expandMenuOptionFactory.GenerateCheckBoxButton("Display".Localize().ToUpper(), "icon_arrow_right_no_border_32x32.png", "icon_arrow_down_no_border_32x32.png"); expandDisplayOptions.Margin = new BorderDouble(bottom: 2); buttonRightPanel.AddChild(expandDisplayOptions); expandDisplayOptions.Checked = true; @@ -263,10 +263,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow modelInfoContainer.HAnchor = HAnchor.ParentLeftRight; modelInfoContainer.Padding = new BorderDouble(5); - string printTimeLbl = LocalizedString.Get ("PRINT TIME"); - string printTimeLblFull = string.Format ("{0}:", printTimeLbl); + string printTimeLabel = "Print Time".Localize().ToUpper(); + string printTimeLabelFull = string.Format ("{0}:", printTimeLabel); // put in the print time - modelInfoContainer.AddChild(new TextWidget(printTimeLblFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize:10)); + modelInfoContainer.AddChild(new TextWidget(printTimeLabelFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize:10)); { string timeRemainingText = "---"; @@ -294,7 +294,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow //modelInfoContainer.AddChild(new TextWidget("Size:", textColor: ActiveTheme.Instance.PrimaryTextColor)); - string filamentLengthLbl = LocalizedString.Get ("FILAMENT LENGTH"); + string filamentLengthLbl = "Filament Length".Localize().ToUpper(); string filamentLengthLblFull = string.Format ("{0}:", filamentLengthLbl); // show the filament used modelInfoContainer.AddChild(new TextWidget(filamentLengthLblFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 9)); @@ -307,9 +307,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow modelInfoContainer.AddChild(estimatedPrintTime); } - string filamentVolumeLbl = LocalizedString.Get ("FILAMENT VOLUME"); - string filamentVolumeLblFull = string.Format("{0}:", filamentVolumeLbl); - modelInfoContainer.AddChild(new TextWidget(filamentVolumeLblFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 9)); + string filamentVolumeLabel = "Filament Volume".Localize().ToUpper(); + string filamentVolumeLabelFull = string.Format("{0}:", filamentVolumeLabel); + modelInfoContainer.AddChild(new TextWidget(filamentVolumeLabelFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 9)); { double filamentMm3 = gcodeViewWidget.LoadedGCode.GetFilamentCubicMm(ActiveSliceSettings.Instance.FilamentDiameter); @@ -319,9 +319,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow modelInfoContainer.AddChild(estimatedPrintTime); } - string weightLbl = LocalizedString.Get("EST. WEIGHT"); - string weightLblFull = string.Format("{0}:", weightLbl); - modelInfoContainer.AddChild(new TextWidget(weightLblFull, pointSize: 9, textColor: ActiveTheme.Instance.PrimaryTextColor)); + string weightLabel = "Est. Weight".Localize().ToUpper(); + string weightLabelFull = string.Format("{0}:", weightLabel); + modelInfoContainer.AddChild(new TextWidget(weightLabelFull, pointSize: 9, textColor: ActiveTheme.Instance.PrimaryTextColor)); { var density = 1.0; string filamentType = "PLA"; diff --git a/PrintHistory/PrintHistoryListItem.cs b/PrintHistory/PrintHistoryListItem.cs index 7f5dd576c..23210d660 100644 --- a/PrintHistory/PrintHistoryListItem.cs +++ b/PrintHistory/PrintHistoryListItem.cs @@ -119,18 +119,20 @@ namespace MatterHackers.MatterControl.PrintHistory buttonContainer.Margin = new BorderDouble(0); buttonContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; { - TextWidget statusIndicator = new TextWidget("Status: Completed", pointSize:8); + TextWidget statusIndicator = new TextWidget("Status: Completed".Localize(), pointSize:8); statusIndicator.Margin = new BorderDouble(right: 3); //buttonContainer.AddChild(statusIndicator); - TextWidget timeLabel = new TextWidget("PRINT TIME: ", pointSize:8); + string printTimeLabel = "Print Time".Localize().ToUpper(); + string printTimeLabelFull = string.Format("{0}: ", printTimeLabel); + TextWidget timeLabel = new TextWidget(printTimeLabelFull, pointSize: 8); timeLabel.TextColor = timeTextColor; TextWidget timeIndicator; int minutes = printTask.PrintTimeMinutes; if (minutes < 0) { - timeIndicator = new TextWidget("Unknown"); + timeIndicator = new TextWidget("Unknown".Localize()); } else if (minutes > 60) { @@ -147,7 +149,7 @@ namespace MatterHackers.MatterControl.PrintHistory buttonContainer.AddChild(timeLabel); buttonContainer.AddChild(timeIndicator); - printAgainLink = linkButtonFactory.Generate(LocalizedString.Get("Print Again")); + printAgainLink = linkButtonFactory.Generate("Print Again".Localize()); printAgainLink.Margin = new BorderDouble(left: 0, right: 10); printAgainLink.VAnchor = VAnchor.ParentCenter; @@ -176,7 +178,8 @@ namespace MatterHackers.MatterControl.PrintHistory startTimeContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; startTimeContainer.Padding = new BorderDouble(0, 3); - TextWidget startLabel = new TextWidget("START:", pointSize: 8); + string startLabelFull = "{0}:".FormatWith("Start".Localize().ToUpper()); + TextWidget startLabel = new TextWidget(startLabelFull, pointSize: 8); startLabel.TextColor = timeTextColor; string startTimeString = printTask.PrintStart.ToString("MMM d yyyy h:mm ") + printTask.PrintStart.ToString("tt").ToLower(); @@ -192,7 +195,8 @@ namespace MatterHackers.MatterControl.PrintHistory endTimeContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; endTimeContainer.Padding = new BorderDouble(0, 3); - TextWidget endLabel = new TextWidget("END:", pointSize: 8); + string endLabelFull = "{0}:".FormatWith("End".Localize().ToUpper()); + TextWidget endLabel = new TextWidget(endLabelFull, pointSize: 8); endLabel.TextColor = timeTextColor; string endTimeString; @@ -202,7 +206,7 @@ namespace MatterHackers.MatterControl.PrintHistory } else { - endTimeString = "Unknown"; + endTimeString = "Unknown".Localize(); } TextWidget endDate = new TextWidget(endTimeString, pointSize: 12); diff --git a/PrinterControls/ManualPrinterControls.cs b/PrinterControls/ManualPrinterControls.cs index dc5a6b10d..a486fb3fd 100644 --- a/PrinterControls/ManualPrinterControls.cs +++ b/PrinterControls/ManualPrinterControls.cs @@ -246,7 +246,7 @@ namespace MatterHackers.MatterControl ImageWidget eePromIcon = new ImageWidget(eePromImage); eePromIcon.Margin = new BorderDouble (right: 6); - Button openEePromWindow = textImageButtonFactory.Generate(LocalizedString.Get("CONFIGURE")); + Button openEePromWindow = textImageButtonFactory.Generate("Configure".Localize().ToUpper()); openEePromWindow.Click += (sender, e) => { #if false // This is to force the creation of the repetier window for testing when we don't have repetier firmware. diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index 0ccb37324..37db07e46 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -1935,3 +1935,18 @@ Translated:Edit Preset English:Slice-Engine Translated:Slice-Engine +English:Status: Completed +Translated:Status: Completed + +English:Unlock +Translated:Unlock + +English:Show Terminal +Translated:Show Terminal + +English:Configure +Translated:Configure + +English:Disable +Translated:Disable + From fbb673117b379711fffd2a15f264aeb2ec2158d7 Mon Sep 17 00:00:00 2001 From: larsbrubaker Date: Thu, 10 Apr 2014 14:51:06 -0700 Subject: [PATCH 04/13] more localizations --- StaticData/Translations/Master.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index 37db07e46..01401631c 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -1950,3 +1950,6 @@ Translated:Configure English:Disable Translated:Disable +English:Est. Weight +Translated:Est. Weight + From 84654d5e68d9bc6cc4e0aacee631bddae0bc085b Mon Sep 17 00:00:00 2001 From: larsbrubaker Date: Thu, 10 Apr 2014 15:56:15 -0700 Subject: [PATCH 05/13] Restore the main window position. Always show the 'show terminal' button. --- MatterControlApplication.cs | 8 ++++++++ PrinterControls/ManualPrinterControls.cs | 22 +++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/MatterControlApplication.cs b/MatterControlApplication.cs index f14c7145e..dbbe3581d 100644 --- a/MatterControlApplication.cs +++ b/MatterControlApplication.cs @@ -274,6 +274,13 @@ namespace MatterHackers.MatterControl if (firstDraw) { + string desktopPosition = ApplicationSettings.Instance.get("DesktopPosition"); + if (desktopPosition != null && desktopPosition != "") + { + string[] sizes = desktopPosition.Split(','); + DesktopPosition = new Point2D(int.Parse(sizes[0]), int.Parse(sizes[1])); + } + firstDraw = false; foreach (string arg in commandLineArgs) { @@ -317,6 +324,7 @@ namespace MatterHackers.MatterControl { // save the last size of the window so we can restore it next time. ApplicationSettings.Instance.set("WindowSize", string.Format("{0},{1}", Width, Height)); + ApplicationSettings.Instance.set("DesktopPosition", string.Format("{0},{1}", DesktopPosition.x, DesktopPosition.y)); PrinterCommunication.Instance.Disable(); //Close connection to the local datastore Datastore.Instance.Exit(); diff --git a/PrinterControls/ManualPrinterControls.cs b/PrinterControls/ManualPrinterControls.cs index a486fb3fd..1a6c03926 100644 --- a/PrinterControls/ManualPrinterControls.cs +++ b/PrinterControls/ManualPrinterControls.cs @@ -565,14 +565,14 @@ namespace MatterHackers.MatterControl private GuiWidget CreateSdCardManagerContainer() { - GroupBox terminalControlsContainer; - terminalControlsContainer = new GroupBox("SD Card Printing"); + GroupBox sdCardControlsContainer; + sdCardControlsContainer = new GroupBox("SD Card Printing"); - terminalControlsContainer.Margin = new BorderDouble(top: 10); - terminalControlsContainer.TextColor = ActiveTheme.Instance.PrimaryTextColor; - terminalControlsContainer.BorderColor = ActiveTheme.Instance.PrimaryTextColor; - terminalControlsContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; - terminalControlsContainer.Height = 68; + sdCardControlsContainer.Margin = new BorderDouble(top: 10); + sdCardControlsContainer.TextColor = ActiveTheme.Instance.PrimaryTextColor; + sdCardControlsContainer.BorderColor = ActiveTheme.Instance.PrimaryTextColor; + sdCardControlsContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; + sdCardControlsContainer.Height = 68; { FlowLayoutWidget buttonBar = new FlowLayoutWidget(); @@ -583,7 +583,7 @@ namespace MatterHackers.MatterControl this.textImageButtonFactory.FixedHeight = TallButtonHeight; - Button showSDPrintingPannel = textImageButtonFactory.Generate("SD CARD MANAGER"); + Button showSDPrintingPannel = textImageButtonFactory.Generate("SD Card Manager".ToUpper()); showSDPrintingPannel.Margin = new BorderDouble(left: 10); showSDPrintingPannel.Click += (sender, e) => { @@ -591,10 +591,10 @@ namespace MatterHackers.MatterControl }; buttonBar.AddChild(showSDPrintingPannel); - terminalControlsContainer.AddChild(buttonBar); + sdCardControlsContainer.AddChild(buttonBar); } - return terminalControlsContainer; + return sdCardControlsContainer; } private void SetDisplayAttributes() @@ -623,7 +623,7 @@ namespace MatterHackers.MatterControl movementControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled); fanControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled); tuningAdjustmentControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled); - terminalCommunicationsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled); + terminalCommunicationsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled); sdCardManagerContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled); macroControls.SetEnableLevel(DisableableWidget.EnableLevel.Disabled); } From 141c51b5206781dd5ce60a018ea5c18978a01ede Mon Sep 17 00:00:00 2001 From: Kevin Pope Date: Thu, 10 Apr 2014 16:37:39 -0700 Subject: [PATCH 06/13] Made slice presets tie to PrinterProfile --- DataStorage/Models.cs | 1 + .../SettingsControlSelectors.cs | 27 +++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/DataStorage/Models.cs b/DataStorage/Models.cs index 85bb7fed2..4418c9689 100644 --- a/DataStorage/Models.cs +++ b/DataStorage/Models.cs @@ -164,6 +164,7 @@ namespace MatterHackers.MatterControl.DataStorage { public string Name { get; set; } public string Tag { get; set; } //ex. 'material' or 'quality' + public int PrinterId { get; set; } } public class SliceSetting : Entity diff --git a/SlicerConfiguration/SettingsControlSelectors.cs b/SlicerConfiguration/SettingsControlSelectors.cs index 9e1a934e8..4163452a1 100644 --- a/SlicerConfiguration/SettingsControlSelectors.cs +++ b/SlicerConfiguration/SettingsControlSelectors.cs @@ -128,8 +128,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration IEnumerable results = Enumerable.Empty(); //Retrieve a list of collections matching from the Datastore - string query = string.Format("SELECT * FROM SliceSettingsCollection WHERE Tag = '{0}';", filterTag); - results = (IEnumerable)DataStorage.Datastore.Instance.dbSQLite.Query(query); + if (ActivePrinterProfile.Instance.ActivePrinter != null) + { + string query = string.Format("SELECT * FROM SliceSettingsCollection WHERE Tag = '{0}' AND PrinterId = {1};", filterTag, ActivePrinterProfile.Instance.ActivePrinter.Id); + results = (IEnumerable)DataStorage.Datastore.Instance.dbSQLite.Query(query); + } return results; } @@ -193,16 +196,30 @@ namespace MatterHackers.MatterControl.SlicerConfiguration menuItem.Selected += new EventHandler(onItemSelect); } - MenuItem addNewPreset = dropDownList.AddItem("<< Add New >>", "new"); + MenuItem addNewPreset = dropDownList.AddItem("<< Add >>", "new"); addNewPreset.Selected += new EventHandler(onNewItemSelect); if (filterTag == "material") { - dropDownList.SelectedValue = ActivePrinterProfile.Instance.GetMaterialSetting(1).ToString(); + try + { + dropDownList.SelectedValue = ActivePrinterProfile.Instance.GetMaterialSetting(1).ToString(); + } + catch + { + //Unable to set selected value + } } else if (filterTag == "quality") { - dropDownList.SelectedValue = ActivePrinterProfile.Instance.ActiveQualitySettingsID.ToString(); + try + { + dropDownList.SelectedValue = ActivePrinterProfile.Instance.ActiveQualitySettingsID.ToString(); + } + catch + { + //Unable to set selected value + } } return dropDownList; From 96ea37f86fe63e65b994f73c1494b31fd5c7dbbd Mon Sep 17 00:00:00 2001 From: Kevin Pope Date: Thu, 10 Apr 2014 16:38:18 -0700 Subject: [PATCH 07/13] Changed slice config extension (for export) to ".slice" --- SlicerConfiguration/ActiveSliceSettings.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SlicerConfiguration/ActiveSliceSettings.cs b/SlicerConfiguration/ActiveSliceSettings.cs index 698240b98..5f3502f0b 100644 --- a/SlicerConfiguration/ActiveSliceSettings.cs +++ b/SlicerConfiguration/ActiveSliceSettings.cs @@ -59,7 +59,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration public class ActiveSliceSettings { static ActiveSliceSettings globalInstance = null; - static string configFileExtension = "ini"; + static string configFileExtension = "slice"; private List activeSettingsLayers; public RootedObjectEventHandler CommitStatusChanged = new RootedObjectEventHandler(); public RootedObjectEventHandler SettingsChanged = new RootedObjectEventHandler(); @@ -480,7 +480,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration public bool LoadSettingsFromIni() { - OpenFileDialogParams openParams = new OpenFileDialogParams("Load Slice Configuration|*." + configFileExtension); + OpenFileDialogParams openParams = new OpenFileDialogParams("Load Slice Configuration|*.slice;*.ini"); openParams.ActionButtonLabel = "Load Configuration"; openParams.Title = "MatterControl: Select A File"; From 2c88fdc1fc00402d4be6c440ac4f97eacc010ddb Mon Sep 17 00:00:00 2001 From: larsbrubaker Date: Thu, 10 Apr 2014 16:38:22 -0700 Subject: [PATCH 08/13] Got the 'connect' button to do a connect after selecting a printer if a printer was not selected. --- ActionBar/PrinterActionRow.cs | 14 +++++++++++--- PartPreviewWindow/GcodeViewBasic.cs | 3 ++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ActionBar/PrinterActionRow.cs b/ActionBar/PrinterActionRow.cs index 7b7882cf6..70482649b 100644 --- a/ActionBar/PrinterActionRow.cs +++ b/ActionBar/PrinterActionRow.cs @@ -139,7 +139,7 @@ namespace MatterHackers.MatterControl.ActionBar { if (ActivePrinterProfile.Instance.ActivePrinter == null) { - OpenConnectionWindow(); + OpenConnectionWindow(ConnectToActivePrinter); } else { @@ -159,12 +159,15 @@ namespace MatterHackers.MatterControl.ActionBar OpenConnectionWindow(); } - void OpenConnectionWindow() + public delegate void ConnectOnSelectFunction(); + ConnectOnSelectFunction functionToCallOnSelect; + void OpenConnectionWindow(ConnectOnSelectFunction functionToCallOnSelect = null) { if (this.connectionWindowIsOpen == false) { connectionWindow = new ConnectionWindow(); this.connectionWindowIsOpen = true; + this.functionToCallOnSelect = functionToCallOnSelect; connectionWindow.Closed += new EventHandler(ConnectionWindow_Closed); } else @@ -188,7 +191,12 @@ namespace MatterHackers.MatterControl.ActionBar void onActivePrinterChanged(object sender, EventArgs e) { - connectPrinterButton.Enabled = true; + connectPrinterButton.Enabled = true; + if (functionToCallOnSelect != null) + { + functionToCallOnSelect(); + functionToCallOnSelect = null; + } } void onDisconnectButtonClick(object sender, MouseEventArgs e) diff --git a/PartPreviewWindow/GcodeViewBasic.cs b/PartPreviewWindow/GcodeViewBasic.cs index 16ef7a2a1..5ce14ba05 100644 --- a/PartPreviewWindow/GcodeViewBasic.cs +++ b/PartPreviewWindow/GcodeViewBasic.cs @@ -130,9 +130,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow gcodeDispalyWidget = new GuiWidget(HAnchor.ParentLeftRight, Agg.UI.VAnchor.ParentBottomTop); - string startingMessage = LocalizedString.Get("No GCode Available..."); + string startingMessage = ""; if (printItem != null) { + startingMessage = LocalizedString.Get("No GCode Available..."); startingMessage = LocalizedString.Get("Loading GCode..."); if (Path.GetExtension(printItem.FileLocation).ToUpper() == ".GCODE") { From 321a3fd4d5a6bc0bc3c8eeed7d6832f5f07f7bc9 Mon Sep 17 00:00:00 2001 From: Kevin Pope Date: Thu, 10 Apr 2014 16:41:48 -0700 Subject: [PATCH 09/13] Added 'copy', 'import', and 'export' function to slice presets. --- .../SlicePresetDetailWidget.cs | 148 ++++++++++++++++-- .../SlicePresetListWidget.cs | 10 +- .../SlicePresetsWindow/SlicePresetsWindow.cs | 3 +- 3 files changed, 143 insertions(+), 18 deletions(-) diff --git a/SlicerConfiguration/SlicePresetsWindow/SlicePresetDetailWidget.cs b/SlicerConfiguration/SlicePresetsWindow/SlicePresetDetailWidget.cs index d5f8ef9b9..4710d9638 100644 --- a/SlicerConfiguration/SlicePresetsWindow/SlicePresetDetailWidget.cs +++ b/SlicerConfiguration/SlicePresetsWindow/SlicePresetDetailWidget.cs @@ -51,7 +51,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration SlicePresetsWindow windowController; TextWidget presetNameError; MHTextEditWidget presetNameInput; + Button savePresetButton; + Button duplicatePresetButton; + Button importPresetButton; + Button exportPresetButton; + int tabIndexForItem = 0; public SlicePresetDetailWidget(SlicePresetsWindow windowController) @@ -79,7 +84,10 @@ namespace MatterHackers.MatterControl.SlicerConfiguration void AddHandlers() { - savePresetButton.Click += savePresets_Click; + savePresetButton.Click += new ButtonBase.ButtonEventHandler(savePresets_Click); + duplicatePresetButton.Click += new ButtonBase.ButtonEventHandler(duplicatePresets_Click); + importPresetButton.Click += new ButtonBase.ButtonEventHandler(importPresets_Click); + exportPresetButton.Click += new ButtonBase.ButtonEventHandler(exportPresets_Click); } @@ -199,6 +207,10 @@ namespace MatterHackers.MatterControl.SlicerConfiguration container.Margin = new BorderDouble(top: 3); savePresetButton = buttonFactory.Generate(LocalizedString.Get("Save")); + duplicatePresetButton = buttonFactory.Generate(LocalizedString.Get("Duplicate")); + importPresetButton = buttonFactory.Generate(LocalizedString.Get("Import")); + exportPresetButton = buttonFactory.Generate(LocalizedString.Get("Export")); + Button cancelButton = buttonFactory.Generate(LocalizedString.Get("Cancel")); cancelButton.Click += (sender, e) => { @@ -209,9 +221,15 @@ namespace MatterHackers.MatterControl.SlicerConfiguration }; container.AddChild(savePresetButton); + //Only show duplicate/import/export buttons if setting has been saved. + if (windowController.ActivePresetLayer.settingsCollectionData.Id != 0) + { + container.AddChild(duplicatePresetButton); + container.AddChild(importPresetButton); + container.AddChild(exportPresetButton); + } container.AddChild(new HorizontalSpacer()); container.AddChild(cancelButton); - return container; } @@ -344,15 +362,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration settingDropDownList.SelectedValue = selectedSettingValue; } - Button addButton = buttonFactory.Generate("Add"); - addButton.Click += new ButtonBase.ButtonEventHandler(OnAddSettingClick); - addButton.Margin = new BorderDouble(right: 3); - addSettingsContainer.RemoveAllChildren(); addSettingsContainer.AddChild(categoryDropDownList); addSettingsContainer.AddChild(groupDropDownList); addSettingsContainer.AddChild(settingDropDownList); - addSettingsContainer.AddChild(addButton); + //addSettingsContainer.AddChild(addButton); } void OnItemSelected(object sender, EventArgs e) @@ -390,10 +404,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration MenuItem item = (MenuItem)sender; string[] valueArray = item.Value.Split(':'); string configName = valueArray[2]; - addRowSettingData = SliceSettingsOrganizer.Instance.GetSettingsData(configName); + addRowSettingData = SliceSettingsOrganizer.Instance.GetSettingsData(configName); + AddSettingToPreset(); } - void OnAddSettingClick(object sender, EventArgs e) + void AddSettingToPreset() { UiThread.RunOnIdle((state) => { @@ -801,8 +816,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration Dictionary settingsDictionary = new Dictionary(); DataStorage.SliceSettingsCollection collection = new DataStorage.SliceSettingsCollection(); - collection.Name = string.Format("{0} ({1})", windowController.filterLabel, noExistingPresets.ToString()); - collection.Tag = windowController.filterTag; + if (ActivePrinterProfile.Instance.ActivePrinter != null) + { + collection.Name = string.Format("{0} ({1})", windowController.filterLabel, noExistingPresets.ToString()); + collection.Tag = windowController.filterTag; + collection.PrinterId = ActivePrinterProfile.Instance.ActivePrinter.Id; + } windowController.ActivePresetLayer = new SettingsLayer(collection, settingsDictionary); } @@ -829,6 +848,112 @@ namespace MatterHackers.MatterControl.SlicerConfiguration }); } + + void duplicatePresets_Click(object sender, MouseEventArgs mouseEvent) + { + UiThread.RunOnIdle((state) => + { + DataStorage.SliceSettingsCollection duplicateCollection = new SliceSettingsCollection(); + duplicateCollection.Name = string.Format("{0} (copy)".FormatWith(windowController.ActivePresetLayer.settingsCollectionData.Name)); + duplicateCollection.Tag = windowController.ActivePresetLayer.settingsCollectionData.Tag; + duplicateCollection.PrinterId = windowController.ActivePresetLayer.settingsCollectionData.PrinterId; + + + Dictionary settingsDictionary = new Dictionary(); + IEnumerable settingsList = this.windowController.GetCollectionSettings(windowController.ActivePresetLayer.settingsCollectionData.Id); + foreach (DataStorage.SliceSetting s in settingsList) + { + settingsDictionary[s.Name] = s; + } + SettingsLayer duplicateLayer = new SettingsLayer(duplicateCollection, settingsDictionary); + windowController.ActivePresetLayer = duplicateLayer; + windowController.ChangeToSlicePresetDetail(); + }); + } + + + string configFileExtension = "slice"; + void importPresets_Click(object sender, MouseEventArgs mouseEvent) + { + OpenFileDialogParams openParams = new OpenFileDialogParams("Load Slice Preset|*.slice;*.ini"); + openParams.ActionButtonLabel = "Load Slice Preset"; + openParams.Title = "MatterControl: Select A File"; + + FileDialog.OpenFileDialog(ref openParams); + if (openParams.FileNames != null) + { + Dictionary settingsDictionary = new Dictionary(); + try + { + if (File.Exists(openParams.FileName)) + { + string[] lines = System.IO.File.ReadAllLines(openParams.FileName); + foreach (string line in lines) + { + //Ignore commented lines + if (!line.StartsWith("#")) + { + string[] settingLine = line.Split('='); + string keyName = settingLine[0].Trim(); + string settingDefaultValue = settingLine[1].Trim(); + + DataStorage.SliceSetting sliceSetting = new DataStorage.SliceSetting(); + sliceSetting.Name = keyName; + sliceSetting.Value = settingDefaultValue; + sliceSetting.SettingsCollectionId = windowController.ActivePresetLayer.settingsCollectionData.Id; + + settingsDictionary.Add(keyName, sliceSetting); + } + } + windowController.ActivePresetLayer.settingsDictionary = settingsDictionary; + LoadSettingsRows(); + } + } + catch (Exception e) + { + // Error loading configuration + } + } + } + + + + + void exportPresets_Click(object sender, MouseEventArgs mouseEvent) + { + SaveAs(); + } + + public void SaveAs() + { + string documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); + SaveFileDialogParams saveParams = new SaveFileDialogParams("Save Slice Preset|*." + configFileExtension, documentsPath); + + System.IO.Stream streamToSaveTo = FileDialog.SaveFileDialog(ref saveParams); + if (streamToSaveTo != null) + { + streamToSaveTo.Close(); + GenerateConfigFile(saveParams.FileName); + } + } + + public void GenerateConfigFile(string fileName) + { + List configFileAsList = new List(); + + foreach (KeyValuePair setting in windowController.ActivePresetLayer.settingsDictionary) + { + string settingString = string.Format("{0} = {1}", setting.Value.Name, setting.Value.Value); + configFileAsList.Add(settingString); + } + string configFileAsString = string.Join("\n", configFileAsList.ToArray()); + + FileStream fs = new FileStream(fileName, FileMode.Create); + StreamWriter sw = new System.IO.StreamWriter(fs); + sw.Write(configFileAsString); + sw.Close(); + } + void saveActivePresets() { windowController.ActivePresetLayer.settingsCollectionData.Name = presetNameInput.Text; @@ -839,7 +964,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration public class SettingsDropDownList : DropDownList { - static RGBA_Bytes whiteSemiTransparent = new RGBA_Bytes(255, 255, 255, 100); static RGBA_Bytes whiteTransparent = new RGBA_Bytes(255, 255, 255, 0); diff --git a/SlicerConfiguration/SlicePresetsWindow/SlicePresetListWidget.cs b/SlicerConfiguration/SlicePresetsWindow/SlicePresetListWidget.cs index db94e02e1..f2f322f95 100644 --- a/SlicerConfiguration/SlicePresetsWindow/SlicePresetListWidget.cs +++ b/SlicerConfiguration/SlicePresetsWindow/SlicePresetListWidget.cs @@ -148,10 +148,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration IEnumerable GetCollections() { IEnumerable results = Enumerable.Empty(); - - //Retrieve a list of collections matching from the Datastore - string query = string.Format("SELECT * FROM SliceSettingsCollection WHERE Tag = '{0}';", windowController.filterTag); - results = (IEnumerable)DataStorage.Datastore.Instance.dbSQLite.Query(query); + if (ActivePrinterProfile.Instance.ActivePrinter != null) + { + //Retrieve a list of collections matching from the Datastore + string query = string.Format("SELECT * FROM SliceSettingsCollection WHERE Tag = '{0}' AND PrinterId = {1};", windowController.filterTag, ActivePrinterProfile.Instance.ActivePrinter.Id); + results = (IEnumerable)DataStorage.Datastore.Instance.dbSQLite.Query(query); + } return results; } diff --git a/SlicerConfiguration/SlicePresetsWindow/SlicePresetsWindow.cs b/SlicerConfiguration/SlicePresetsWindow/SlicePresetsWindow.cs index bd10a88df..e2a0a85f8 100644 --- a/SlicerConfiguration/SlicePresetsWindow/SlicePresetsWindow.cs +++ b/SlicerConfiguration/SlicePresetsWindow/SlicePresetsWindow.cs @@ -82,7 +82,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration this.MinimumSize = new Vector2(640, 480); } - public void ChangeToSlicePresetList() { this.ActivePresetLayer = null; @@ -130,7 +129,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration return result; } - IEnumerable GetCollectionSettings(int collectionId) + public IEnumerable GetCollectionSettings(int collectionId) { //Retrieve a list of slice settings from the Datastore string query = string.Format("SELECT * FROM SliceSetting WHERE SettingsCollectionID = {0};", collectionId); From 8aa4b7bca0f33a12984e9eaed17e825ad3a3e630 Mon Sep 17 00:00:00 2001 From: Kevin Pope Date: Thu, 10 Apr 2014 16:42:06 -0700 Subject: [PATCH 10/13] Fixed button text color. --- SlicerConfiguration/SliceSettingsWidget.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/SlicerConfiguration/SliceSettingsWidget.cs b/SlicerConfiguration/SliceSettingsWidget.cs index aacc45aed..c3419915c 100644 --- a/SlicerConfiguration/SliceSettingsWidget.cs +++ b/SlicerConfiguration/SliceSettingsWidget.cs @@ -128,6 +128,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration buttonFactory.FixedHeight = 20; buttonFactory.fontSize = 10; buttonFactory.normalFillColor = RGBA_Bytes.White; + buttonFactory.normalTextColor = RGBA_Bytes.DarkGray; showHelpBox = new CheckBox(0, 0, LocalizedString.Get("Show Help"), textSize: 10); showHelpBox.Checked = UserSettings.Instance.get(SliceSettingsShowHelpEntry) == "true"; From ca734fe7b5cda9cddc4ee23b604614b661723afa Mon Sep 17 00:00:00 2001 From: Kevin Pope Date: Thu, 10 Apr 2014 16:42:28 -0700 Subject: [PATCH 11/13] Update PLA default settings for AW HD --- StaticData/PrinterSettings/Airwolf 3D/HD Series PLA/config.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StaticData/PrinterSettings/Airwolf 3D/HD Series PLA/config.ini b/StaticData/PrinterSettings/Airwolf 3D/HD Series PLA/config.ini index d1e27b662..4e63724af 100644 --- a/StaticData/PrinterSettings/Airwolf 3D/HD Series PLA/config.ini +++ b/StaticData/PrinterSettings/Airwolf 3D/HD Series PLA/config.ini @@ -48,7 +48,7 @@ infill_speed = 50 layer_gcode = layer_height = 0.21 max_fan_speed = 100 -min_fan_speed = 35 +min_fan_speed = 100 min_print_speed = 2 min_skirt_length = 0 notes = From 84b531915b5605142f340d497e3fdb201cb3690d Mon Sep 17 00:00:00 2001 From: Kevin Pope Date: Thu, 10 Apr 2014 18:32:43 -0700 Subject: [PATCH 12/13] Order slice presets alphabetically. --- SlicerConfiguration/SettingsControlSelectors.cs | 2 +- SlicerConfiguration/SlicePresetsWindow/SlicePresetListWidget.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SlicerConfiguration/SettingsControlSelectors.cs b/SlicerConfiguration/SettingsControlSelectors.cs index 4163452a1..382546158 100644 --- a/SlicerConfiguration/SettingsControlSelectors.cs +++ b/SlicerConfiguration/SettingsControlSelectors.cs @@ -130,7 +130,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration //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};", filterTag, ActivePrinterProfile.Instance.ActivePrinter.Id); + string query = string.Format("SELECT * FROM SliceSettingsCollection WHERE Tag = '{0}' AND PrinterId = {1} ORDER BY Name;", filterTag, ActivePrinterProfile.Instance.ActivePrinter.Id); results = (IEnumerable)DataStorage.Datastore.Instance.dbSQLite.Query(query); } return results; diff --git a/SlicerConfiguration/SlicePresetsWindow/SlicePresetListWidget.cs b/SlicerConfiguration/SlicePresetsWindow/SlicePresetListWidget.cs index f2f322f95..2be902c71 100644 --- a/SlicerConfiguration/SlicePresetsWindow/SlicePresetListWidget.cs +++ b/SlicerConfiguration/SlicePresetsWindow/SlicePresetListWidget.cs @@ -151,7 +151,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration if (ActivePrinterProfile.Instance.ActivePrinter != null) { //Retrieve a list of collections matching from the Datastore - string query = string.Format("SELECT * FROM SliceSettingsCollection WHERE Tag = '{0}' AND PrinterId = {1};", windowController.filterTag, ActivePrinterProfile.Instance.ActivePrinter.Id); + string query = string.Format("SELECT * FROM SliceSettingsCollection WHERE Tag = '{0}' AND PrinterId = {1} ORDER BY Name;", windowController.filterTag, ActivePrinterProfile.Instance.ActivePrinter.Id); results = (IEnumerable)DataStorage.Datastore.Instance.dbSQLite.Query(query); } return results; From 86bb40903edafc13bf6394b19f6c7b8b9e52e39e Mon Sep 17 00:00:00 2001 From: Kevin Pope Date: Thu, 10 Apr 2014 19:08:02 -0700 Subject: [PATCH 13/13] Started work on improving panel separators. --- ApplicationView/WidescreenPanel.cs | 15 ++------- CustomWidgets/PanelSeparator.cs | 54 ++++++++++++++++++++++++++++++ MatterControl.csproj | 1 + 3 files changed, 58 insertions(+), 12 deletions(-) create mode 100644 CustomWidgets/PanelSeparator.cs diff --git a/ApplicationView/WidescreenPanel.cs b/ApplicationView/WidescreenPanel.cs index 998e5725a..ed60766d7 100644 --- a/ApplicationView/WidescreenPanel.cs +++ b/ApplicationView/WidescreenPanel.cs @@ -45,6 +45,7 @@ using MatterHackers.MatterControl.PrintQueue; using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.MatterControl.PrintLibrary; using MatterHackers.MatterControl.DataStorage; +using MatterHackers.MatterControl.CustomWidgets; using MatterHackers.Localizations; using MatterHackers.MatterControl.PartPreviewWindow; @@ -95,8 +96,8 @@ namespace MatterHackers.MatterControl //ColumnTwo.Padding = new BorderDouble(4, 0); //ColumnThree.Padding = new BorderDouble(4); - LeftBorderLine = CreateBorderLine(); - RightBorderLine = CreateBorderLine(); + LeftBorderLine = new PanelSeparator(); + RightBorderLine = new PanelSeparator(); LoadColumnTwo(); @@ -117,16 +118,6 @@ namespace MatterHackers.MatterControl } - private static ClickWidget CreateBorderLine() - { - ClickWidget topLine = new ClickWidget(3, 1); - topLine.BackgroundColor = new RGBA_Bytes(200,200,200); - topLine.VAnchor = VAnchor.ParentBottomTop; - topLine.Margin = new BorderDouble(8, 0); - topLine.Cursor = Cursors.Hand; - return topLine; - } - void onBoundsChanges(Object sender, EventArgs e) { SetVisibleStatus(); diff --git a/CustomWidgets/PanelSeparator.cs b/CustomWidgets/PanelSeparator.cs new file mode 100644 index 000000000..fd56d2ffc --- /dev/null +++ b/CustomWidgets/PanelSeparator.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using MatterHackers.Agg; +using MatterHackers.Agg.Transform; +using MatterHackers.Agg.Image; +using MatterHackers.Agg.VertexSource; +using MatterHackers.Agg.UI; +using MatterHackers.Agg.Font; +using MatterHackers.VectorMath; + +namespace MatterHackers.MatterControl.CustomWidgets +{ + class PanelSeparator : ClickWidget + { + RGBA_Bytes defaultBackgroundColor; + RGBA_Bytes hoverBackgroundColor; + + public bool Hidden { get; set; } + + public PanelSeparator() + : base(4, 1) + { + AddHandlers(); + + defaultBackgroundColor = new RGBA_Bytes(200, 200, 200); + hoverBackgroundColor = new RGBA_Bytes(100, 100, 100); + + this.Hidden = false; + this.BackgroundColor = defaultBackgroundColor; + this.VAnchor = VAnchor.ParentBottomTop; + this.Margin = new BorderDouble(8, 0); + this.Cursor = Cursors.Hand; + } + + void AddHandlers() + { + this.MouseEnterBounds += new EventHandler(PanelSeparator_MouseEnterBounds); + this.MouseLeaveBounds += new EventHandler(PanelSeparator_MouseLeaveBounds); + } + + void PanelSeparator_MouseLeaveBounds(object sender, EventArgs e) + { + this.BackgroundColor = defaultBackgroundColor; + } + + void PanelSeparator_MouseEnterBounds(object sender, EventArgs e) + { + this.BackgroundColor = hoverBackgroundColor; + } + } +} diff --git a/MatterControl.csproj b/MatterControl.csproj index eff377183..23bd5b7d7 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -75,6 +75,7 @@ +