From 86218c47108ed57683d447f9d743c10d615a6e6d Mon Sep 17 00:00:00 2001 From: gregory-diaz Date: Tue, 18 Feb 2014 12:51:11 -0800 Subject: [PATCH 1/4] Fixed export windows in Print Queue Item and Library Item from opening multiple times. I also added a test for adding ".stl" and ".gcode" file extensions and did more localization. --- CustomWidgets/ExportQueueItemWindow.cs | 82 +++++++++++++++--- CustomWidgets/ExportToFolderFeedbackWindow.cs | 5 +- CustomWidgets/SavePartsSheetFeedbackWindow.cs | 5 +- CustomWidgets/WizardControl.cs | 1 - Localizations/LocalizedString.cs | 2 +- MainSlidePanel.cs | 7 +- MatterControl.csproj | 13 +-- MatterControl.userprefs | 19 +++-- PartPreviewWindow/PartPreviewMainWindow.cs | 4 +- PrintLevelWizard.cs | 4 - PrintLibrary/ExportLibraryItemWindow.cs | 84 ++++++++++++++++--- PrintLibrary/PrintLibraryListItem.cs | 29 ++++++- PrintQueue/PrintQueueItem.cs | 31 ++++++- PrintQueue/PrintQueueMenu.cs | 45 ++++++++-- PrinterCommunication.cs | 2 +- .../EditManualMovementSpeedsWindow.cs | 16 ++-- .../EditTemperaturePresetsWindow.cs | 2 +- .../PrinterConnections/ConnectionWindow.cs | 5 +- WidescreenPanel.cs | 2 +- 19 files changed, 286 insertions(+), 72 deletions(-) diff --git a/CustomWidgets/ExportQueueItemWindow.cs b/CustomWidgets/ExportQueueItemWindow.cs index 1177440d7..5ad45d517 100644 --- a/CustomWidgets/ExportQueueItemWindow.cs +++ b/CustomWidgets/ExportQueueItemWindow.cs @@ -80,7 +80,7 @@ namespace MatterHackers.MatterControl if(showExportGCodeButton) { - Button exportGCode = textImageButtonFactory.Generate("Export as GCode"); + Button exportGCode = textImageButtonFactory.Generate(new LocalizedString("Export as GCode").Translated); //exportGCode.HAnchor = Agg.UI.HAnchor.ParentCenter; exportGCode.Click += new ButtonBase.ButtonEventHandler(exportGCode_Click); topToBottom.AddChild(exportGCode); @@ -115,6 +115,22 @@ namespace MatterHackers.MatterControl UiThread.RunOnIdle(DoExportGCode_Click); } + string GetExtension (string filename) + { + string extension; + int indexOfDot = filename.LastIndexOf("."); + if (indexOfDot == -1) { + extension = ""; + } + else + { + extension = filename.Substring (indexOfDot); + } + + return extension; + } + + void DoExportGCode_Click(object state) { SaveFileDialogParams saveParams = new SaveFileDialogParams("Export GCode|*.gcode", title: "Export GCode"); @@ -122,9 +138,21 @@ namespace MatterHackers.MatterControl saveParams.ActionButtonLabel = "Export"; System.IO.Stream streamToSaveTo = FileDialog.SaveFileDialog(ref saveParams); - if (streamToSaveTo != null) - { - streamToSaveTo.Close(); + if (streamToSaveTo != null) + { + streamToSaveTo.Close (); + + + string filePathToSave = saveParams.FileName; + string extension = GetExtension(filePathToSave); + + if(extension == "") + { + filePathToSave += ".gcode"; + } + + + if (System.IO.Path.GetExtension(printQueueItem.PrintItemWrapper.FileLocation).ToUpper() == ".STL") { pathAndFilenameToSave = saveParams.FileName; @@ -187,22 +215,52 @@ namespace MatterHackers.MatterControl UiThread.RunOnIdle(DoExportSTL_Click); } + + string CheckExtension(string fileName) + { + string extension; + int indexOfDot = fileName.LastIndexOf("."); + if (indexOfDot == -1) + { + extension = ""; + } + else + { + extension = fileName.Substring(indexOfDot); + } + return extension; + } + void DoExportSTL_Click(object state) { - SaveFileDialogParams saveParams = new SaveFileDialogParams("Save as STL|*.stl"); + SaveFileDialogParams saveParams = new SaveFileDialogParams("Save as STL|*.stl"); saveParams.Title = "MatterControl: Export File"; saveParams.ActionButtonLabel = "Export"; System.IO.Stream streamToSaveTo = FileDialog.SaveFileDialog(ref saveParams); - if (streamToSaveTo != null) - { - streamToSaveTo.Close(); - Close(); - File.Copy(printQueueItem.PrintItemWrapper.FileLocation, saveParams.FileName, true); - ShowFileIfRequested(saveParams.FileName); - } + + if (streamToSaveTo != null) + { + streamToSaveTo.Close (); + Close (); + } + // windows vista +: filePathToSave 'test.stl' + // windows xp: filePathToSave 'test' + + string filePathToSave = saveParams.FileName; + string extension = CheckExtension(filePathToSave); + + if (extension == "") + { + + filePathToSave += ".stl"; + } + + File.Copy (printQueueItem.PrintItemWrapper.FileLocation, filePathToSave, true); + ShowFileIfRequested (filePathToSave); } + void sliceItem_Done(object sender, EventArgs e) { PrintItemWrapper sliceItem = (PrintItemWrapper)sender; diff --git a/CustomWidgets/ExportToFolderFeedbackWindow.cs b/CustomWidgets/ExportToFolderFeedbackWindow.cs index c295bf402..b012106c1 100644 --- a/CustomWidgets/ExportToFolderFeedbackWindow.cs +++ b/CustomWidgets/ExportToFolderFeedbackWindow.cs @@ -5,6 +5,7 @@ using System.Text; using MatterHackers.Agg; using MatterHackers.Agg.UI; +using MatterHackers.Localizations; namespace MatterHackers.MatterControl { @@ -19,7 +20,9 @@ namespace MatterHackers.MatterControl : base(300, 500) { BackgroundColor = backgroundColor; - Title = "MatterControl - Exporting to Folder"; + string exportingToFolderTitle = new LocalizedString("MatterControl").Translated; + string exportingToFolderTitleFull = new LocalizedString("Exporting to Folder").Translated; + Title = string.Format("{0} - {1}", exportingToFolderTitle, exportingToFolderTitleFull); this.totalParts = totalParts; feedback.Padding = new BorderDouble(5, 5); diff --git a/CustomWidgets/SavePartsSheetFeedbackWindow.cs b/CustomWidgets/SavePartsSheetFeedbackWindow.cs index 863f3a0c8..62f96a544 100644 --- a/CustomWidgets/SavePartsSheetFeedbackWindow.cs +++ b/CustomWidgets/SavePartsSheetFeedbackWindow.cs @@ -5,6 +5,7 @@ using System.Text; using MatterHackers.Agg; using MatterHackers.Agg.UI; +using MatterHackers.Localizations; namespace MatterHackers.MatterControl { @@ -18,7 +19,9 @@ namespace MatterHackers.MatterControl : base(300, 500) { BackgroundColor = backgroundColor; - Title = "MatterControl - Saving to Parts Sheet"; + string savePartSheetTitle = new LocalizedString("MatterControl").Translated; + string savePartSheetTitleFull = new LocalizedString("Saving to Parts Sheet").Translated; + Title = string.Format("{0} - {1}",savePartSheetTitle, savePartSheetTitleFull) ; this.totalParts = totalParts; feedback.Padding = new BorderDouble(5, 5); diff --git a/CustomWidgets/WizardControl.cs b/CustomWidgets/WizardControl.cs index bba51d793..96473c077 100644 --- a/CustomWidgets/WizardControl.cs +++ b/CustomWidgets/WizardControl.cs @@ -43,7 +43,6 @@ namespace MatterHackers.MatterControl public WizardControl() { Padding = new BorderDouble(10); - textImageButtonFactory.normalTextColor = RGBA_Bytes.White; textImageButtonFactory.hoverTextColor = RGBA_Bytes.White; textImageButtonFactory.disabledTextColor = new RGBA_Bytes(200, 200, 200); diff --git a/Localizations/LocalizedString.cs b/Localizations/LocalizedString.cs index 2493af082..f7bb8bfb6 100644 --- a/Localizations/LocalizedString.cs +++ b/Localizations/LocalizedString.cs @@ -1,4 +1,4 @@ -//#define DEBUG_SHOW_TRANSLATED_STRINGS +#define DEBUG_SHOW_TRANSLATED_STRINGS using System; using System.Collections.Generic; diff --git a/MainSlidePanel.cs b/MainSlidePanel.cs index 12259f6de..034962e73 100644 --- a/MainSlidePanel.cs +++ b/MainSlidePanel.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -306,9 +306,8 @@ namespace MatterHackers.MatterControl void NumQueueItemsChanged(object sender, EventArgs widgetEvent) { - - string queueString = new LocalizedString("Queue ({0})").Translated; - QueueTabPage.Text = string.Format(queueString, PrintQueue.PrintQueueControl.Instance.Count); + string queueString = ("Queue ({0})"); + QueueTabPage.Text = string.Format(queueString, PrintQueue.PrintQueueControl.Instance.Count); } private void onThemeChanged(object sender, EventArgs e) diff --git a/MatterControl.csproj b/MatterControl.csproj index 2d009ad14..f4f924f61 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -38,7 +38,6 @@ 1.0.0.%2a false true - 0.8.2 True @@ -98,7 +97,9 @@ - + + ExportQueueItemWindow.cs + @@ -307,10 +308,6 @@ {670BDDFF-927B-425D-9DD1-22ACB14356EB} PlatformWin32 - - {657DBC6D-C3EA-4398-A3FA-DDB73C14F71B} - Agg - {CA96058C-1A37-465D-A357-D6D695B13D25} Localizations @@ -319,5 +316,9 @@ {865172A0-A1A9-49C2-9386-F2FDB4E141B7} MatterControlPluginSystem + + {657DBC6D-C3EA-4398-A3FA-DDB73C14F71B} + Agg + \ No newline at end of file diff --git a/MatterControl.userprefs b/MatterControl.userprefs index bd0a41553..f7cab3e51 100644 --- a/MatterControl.userprefs +++ b/MatterControl.userprefs @@ -1,15 +1,22 @@  - + - - - - + + + + + + + + + - + + + \ No newline at end of file diff --git a/PartPreviewWindow/PartPreviewMainWindow.cs b/PartPreviewWindow/PartPreviewMainWindow.cs index 604b86697..423c591e1 100644 --- a/PartPreviewWindow/PartPreviewMainWindow.cs +++ b/PartPreviewWindow/PartPreviewMainWindow.cs @@ -37,6 +37,7 @@ using MatterHackers.Localizations; using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.PrintQueue; using MatterHackers.VectorMath; +using MatterHackers.Localizations; namespace MatterHackers.MatterControl.PartPreviewWindow { @@ -49,7 +50,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public PartPreviewMainWindow(PrintItemWrapper printItem) : base(690, 340) { - Title = "MatterControl: " + Path.GetFileName(printItem.Name); + string partPreviewTitle = new LocalizedString ("MatterControl").Translated; + Title = string.Format("{0}: ", partPreviewTitle) + Path.GetFileName(printItem.Name); BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; diff --git a/PrintLevelWizard.cs b/PrintLevelWizard.cs index e365350e7..18bf6924d 100644 --- a/PrintLevelWizard.cs +++ b/PrintLevelWizard.cs @@ -389,10 +389,6 @@ namespace MatterHackers.MatterControl { UiThread.RunOnIdle (DoDoneButton_Click); } - void DoDoneButton_Click(object state) - { - UiThread.RunOnIdle(DoDoneButton_Click); - } void DoDoneButton_Click(object state) { diff --git a/PrintLibrary/ExportLibraryItemWindow.cs b/PrintLibrary/ExportLibraryItemWindow.cs index bc8c71b20..1f129395d 100644 --- a/PrintLibrary/ExportLibraryItemWindow.cs +++ b/PrintLibrary/ExportLibraryItemWindow.cs @@ -9,6 +9,7 @@ using MatterHackers.Agg.UI; using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.PrintQueue; using MatterHackers.GCodeVisualizer; +using MatterHackers.Localizations; namespace MatterHackers.MatterControl.PrintLibrary { @@ -27,7 +28,9 @@ namespace MatterHackers.MatterControl.PrintLibrary partIsGCode = true; } - this.Title = "MatterControl: Export File"; + string exportLibraryFileTitle = new LocalizedString("MatterControl").Translated; + string exportLibraryFileTitleFull = new LocalizedString("Export File").Translated; + this.Title = string.Format("{0}: {1}", exportLibraryFileTitle, exportLibraryFileTitleFull); this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; // TODO: Complete member initialization @@ -47,7 +50,8 @@ namespace MatterHackers.MatterControl.PrintLibrary topToBottom.Padding = new BorderDouble(10); topToBottom.AnchorAll(); - TextWidget exportLabel = new TextWidget("File export options:"); + string fileExportLabelTxt = new LocalizedString("File export options").Translated; + TextWidget exportLabel = new TextWidget(string.Format("{0}:", fileExportLabelTxt)); exportLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; topToBottom.AddChild(exportLabel); @@ -60,7 +64,7 @@ namespace MatterHackers.MatterControl.PrintLibrary if (!partIsGCode) { - Button exportSTL = textImageButtonFactory.Generate("Export as STL"); + Button exportSTL = textImageButtonFactory.Generate(new LocalizedString("Export as STL").Translated); exportSTL.Click += new ButtonBase.ButtonEventHandler(exportSTL_Click); //exportSTL.HAnchor = Agg.UI.HAnchor.ParentCenter; topToBottom.AddChild(exportSTL); @@ -70,7 +74,7 @@ namespace MatterHackers.MatterControl.PrintLibrary if (showExportGCodeButton) { - Button exportGCode = textImageButtonFactory.Generate("Export as GCode"); + Button exportGCode = textImageButtonFactory.Generate(new LocalizedString("Export as GCode").Translated); //exportGCode.HAnchor = Agg.UI.HAnchor.ParentCenter; exportGCode.Click += new ButtonBase.ButtonEventHandler(exportGCode_Click); topToBottom.AddChild(exportGCode); @@ -82,14 +86,16 @@ namespace MatterHackers.MatterControl.PrintLibrary if (!showExportGCodeButton) { - TextWidget noGCodeMessage = new TextWidget("Note: To enable GCode export, select a printer profile.", textColor: RGBA_Bytes.White, pointSize: 10); + string noGCodeMessageText = new LocalizedString("Note").Translated; + string noGCodeMessageTextFull = new LocalizedString("To enable GCode export, select a printer profile").Translated; + TextWidget noGCodeMessage = new TextWidget(string.Format("{0}: {1}.", noGCodeMessageText, noGCodeMessageTextFull), textColor: RGBA_Bytes.White, pointSize: 10); topToBottom.AddChild(noGCodeMessage); } // TODO: make this work on the mac and then delete this if if (MatterHackers.Agg.UI.WindowsFormsAbstract.GetOSType() == WindowsFormsAbstract.OSType.Windows) { - showInFolderAfterSave = new CheckBox("Show file in folder after save", RGBA_Bytes.White, 10); + showInFolderAfterSave = new CheckBox(new LocalizedString("Show file in folder after save").Translated, RGBA_Bytes.White, 10); showInFolderAfterSave.Margin = new BorderDouble(top: 10); topToBottom.AddChild(showInFolderAfterSave); } @@ -102,6 +108,21 @@ namespace MatterHackers.MatterControl.PrintLibrary UiThread.RunOnIdle(DoExportGCode_Click); } + string GetExtension (string filename) + { + string extension; + int indexOfDot = filename.LastIndexOf("."); + if (indexOfDot == -1) + { + extension = ""; + } + else + { + extension = filename.Substring(indexOfDot); + } + return extension; + } + void DoExportGCode_Click(object state) { SaveFileDialogParams saveParams = new SaveFileDialogParams("Export GCode|*.gcode", title: "Export GCode"); @@ -112,6 +133,16 @@ namespace MatterHackers.MatterControl.PrintLibrary if (streamToSaveTo != null) { streamToSaveTo.Close(); + + + string filePathToSave = saveParams.FileName; + string extension = GetExtension(filePathToSave); + + if(extension == "") + { + filePathToSave += ".gcode"; + } + if (System.IO.Path.GetExtension(printQueueItem.printItem.FileLocation).ToUpper() == ".STL") { pathAndFilenameToSave = saveParams.FileName; @@ -174,6 +205,22 @@ namespace MatterHackers.MatterControl.PrintLibrary UiThread.RunOnIdle(DoExportSTL_Click); } + + string CheckExtension(string fileName) + { + string extension; + int indexOfDot = fileName.LastIndexOf("."); + if (indexOfDot == -1) + { + extension = ""; + } + else + { + extension = fileName.Substring(indexOfDot); + } + return extension; + } + void DoExportSTL_Click(object state) { SaveFileDialogParams saveParams = new SaveFileDialogParams("Save as STL|*.stl"); @@ -181,13 +228,24 @@ namespace MatterHackers.MatterControl.PrintLibrary saveParams.ActionButtonLabel = "Export"; System.IO.Stream streamToSaveTo = FileDialog.SaveFileDialog(ref saveParams); - if (streamToSaveTo != null) - { - streamToSaveTo.Close(); - Close(); - File.Copy(printQueueItem.printItem.FileLocation, saveParams.FileName, true); - ShowFileIfRequested(saveParams.FileName); - } + if (streamToSaveTo != null) + { + streamToSaveTo.Close (); + Close (); + } + + + string filePathToSave = saveParams.FileName; + string extension = CheckExtension(filePathToSave); + + if(extension == "") + { + filePathToSave += ".stl"; + } + + File.Copy(printQueueItem.printItem.FileLocation, filePathToSave, true); + ShowFileIfRequested(filePathToSave); + } void sliceItem_Done(object sender, EventArgs e) diff --git a/PrintLibrary/PrintLibraryListItem.cs b/PrintLibrary/PrintLibraryListItem.cs index 9d361a1da..6bbd14205 100644 --- a/PrintLibrary/PrintLibraryListItem.cs +++ b/PrintLibrary/PrintLibraryListItem.cs @@ -281,6 +281,32 @@ namespace MatterHackers.MatterControl.PrintLibrary public CheckBox selectionCheckBox; FlowLayoutWidget buttonContainer; LinkButtonFactory linkButtonFactory = new LinkButtonFactory(); + bool exportWindowIsOpen = false; + ExportLibraryItemWindow exportingWindow; + + private void OpenExportWindow() + { + if (exportWindowIsOpen == false) + { + exportingWindow = new ExportLibraryItemWindow(this); + this.exportWindowIsOpen = true; + exportingWindow.Closed += new EventHandler(ExportLibraryItemWindow_Closed); + exportingWindow.ShowAsSystemWindow (); + } + else + { + if (exportingWindow != null) + { + exportingWindow.BringToFront (); + } + } + + } + + void ExportLibraryItemWindow_Closed(object sender, EventArgs e) + { + this.exportWindowIsOpen = false; + } public PrintLibraryListItem(PrintItemWrapper printItem) { @@ -352,8 +378,7 @@ namespace MatterHackers.MatterControl.PrintLibrary exportLink.Click += (sender, e) => { - ExportLibraryItemWindow exportingWindow = new ExportLibraryItemWindow(this); - exportingWindow.ShowAsSystemWindow(); + OpenExportWindow(); }; removeLink = linkButtonFactory.Generate(new LocalizedString("Remove").Translated); diff --git a/PrintQueue/PrintQueueItem.cs b/PrintQueue/PrintQueueItem.cs index f67931c85..3d39b4342 100644 --- a/PrintQueue/PrintQueueItem.cs +++ b/PrintQueue/PrintQueueItem.cs @@ -32,6 +32,9 @@ namespace MatterHackers.MatterControl.PrintQueue TextWidget partStatus; FlowLayoutWidget editControls; LinkButtonFactory linkButtonFactory = new LinkButtonFactory(); + ExportQueueItemWindow exportingWindow; + bool exportingWindowIsOpen = false; + public PrintQueueItem(PrintItemWrapper printItem) { @@ -114,6 +117,30 @@ namespace MatterHackers.MatterControl.PrintQueue AddHandlers(); } + private void OpenExportWindow() + { + if(exportingWindowIsOpen == false) + { + exportingWindow = new ExportQueueItemWindow (this); + this.exportingWindowIsOpen = true; + exportingWindow.Closed += new EventHandler (ExportQueueItemWindow_Closed); + exportingWindow.ShowAsSystemWindow(); + } + else + { + if (exportingWindow != null) + { + exportingWindow.BringToFront (); + } + } + } + + void ExportQueueItemWindow_Closed(object sender, EventArgs e) + { + this.exportingWindowIsOpen = false; + } + + private void CreateEditControls() { editControls = new FlowLayoutWidget(); @@ -165,8 +192,8 @@ namespace MatterHackers.MatterControl.PrintQueue Button exportLink = linkButtonFactory.Generate(new LocalizedString("Export").Translated); exportLink.Click += (sender, e) => { - ExportQueueItemWindow exportingWindow = new ExportQueueItemWindow(this); - exportingWindow.ShowAsSystemWindow(); + OpenExportWindow(); + }; layoutLeftToRight.AddChild(exportLink); } diff --git a/PrintQueue/PrintQueueMenu.cs b/PrintQueue/PrintQueueMenu.cs index d0145384a..312163654 100644 --- a/PrintQueue/PrintQueueMenu.cs +++ b/PrintQueue/PrintQueueMenu.cs @@ -22,6 +22,10 @@ namespace MatterHackers.MatterControl.PrintQueue public DropDownMenu MenuDropList; private TupleList> menuItems; + + ExportToFolderFeedbackWindow exportingWindow; + bool exportingWindowIsOpen = false; + public PrintQueueMenu() { MenuDropList = new DropDownMenu(new LocalizedString("Queue Options").Translated, Direction.Up); @@ -98,8 +102,10 @@ namespace MatterHackers.MatterControl.PrintQueue if (parts.Count > 0) { SaveFileDialogParams saveParams = new SaveFileDialogParams("Save Parts Sheet|*.pdf"); - saveParams.ActionButtonLabel = "Save Parts Sheet"; - saveParams.Title = "MatterControl: Save"; + saveParams.ActionButtonLabel = new LocalizedString("Save Parts Sheet").Translated; + string saveParamsTitleLbl = new LocalizedString("MatterContol").Translated; + string saveParamsTitleLblFull = new LocalizedString ("Save").Translated; + saveParams.Title = string.Format("{0}: {1}",saveParamsTitleLbl,saveParamsTitleLblFull); System.IO.Stream streamToSaveTo = FileDialog.SaveFileDialog(ref saveParams); if (streamToSaveTo != null) @@ -136,10 +142,35 @@ namespace MatterHackers.MatterControl.PrintQueue return true; } - private static void SelectLocationToExportGCode(object state) + + private void OpenExportWindow(List parts) + { + if (this.exportingWindowIsOpen == false) + { + exportingWindow = new ExportToFolderFeedbackWindow(parts.Count, parts [0].Name, ActiveTheme.Instance.PrimaryBackgroundColor); + this.exportingWindowIsOpen = true; + exportingWindow.Closed += new EventHandler(ExportToFolderFeedbackWindow_Closed); + } + else + { + if (exportingWindow != null) + { + exportingWindow.BringToFront(); + } + } + } + + + void ExportToFolderFeedbackWindow_Closed(object sender, EventArgs e) + { + this.exportingWindowIsOpen = false; + } + + + private void SelectLocationToExportGCode(object state) { SelectFolderDialogParams selectParams = new SelectFolderDialogParams("Select Location To Save Files"); - selectParams.ActionButtonLabel = "Export"; + selectParams.ActionButtonLabel = new LocalizedString("Export").Translated; selectParams.Title = "MatterControl: Select A Folder"; string path = FileDialog.SelectFolderDialog(ref selectParams); @@ -148,10 +179,8 @@ namespace MatterHackers.MatterControl.PrintQueue List parts = PrintQueueControl.Instance.CreateReadOnlyPartList(); if (parts.Count > 0) { - ExportToFolderFeedbackWindow exportingWindow = new ExportToFolderFeedbackWindow(parts.Count, parts[0].Name, ActiveTheme.Instance.PrimaryBackgroundColor); - exportingWindow.ShowAsSystemWindow(); - - ExportToFolderProcess exportToFolderProcess = new ExportToFolderProcess(parts, path); + OpenExportWindow (parts); + ExportToFolderProcess exportToFolderProcess = new ExportToFolderProcess(parts, path); exportToFolderProcess.StartingNextPart += exportingWindow.StartingNextPart; exportToFolderProcess.UpdatePartStatus += exportingWindow.UpdatePartStatus; exportToFolderProcess.DoneSaving += exportingWindow.DoneSaving; diff --git a/PrinterCommunication.cs b/PrinterCommunication.cs index f23325f90..0bc3736e9 100644 --- a/PrinterCommunication.cs +++ b/PrinterCommunication.cs @@ -1178,7 +1178,7 @@ namespace MatterHackers.MatterControl //Create and start connection thread connectThread = new Thread(Connect_Thread); - connectThread.Name = "Connect To Printer"; + connectThread.Name = "Connect To Printer"; connectThread.IsBackground = true; connectThread.Start(); } diff --git a/PrinterControls/EditManualMovementSpeedsWindow.cs b/PrinterControls/EditManualMovementSpeedsWindow.cs index fc5ef488f..1049561ca 100644 --- a/PrinterControls/EditManualMovementSpeedsWindow.cs +++ b/PrinterControls/EditManualMovementSpeedsWindow.cs @@ -38,6 +38,7 @@ using MatterHackers.Agg.UI; using MatterHackers.VectorMath; using MatterHackers.Agg.Image; using MatterHackers.MatterControl.DataStorage; +using MatterHackers.Localizations; namespace MatterHackers.MatterControl { @@ -50,7 +51,7 @@ namespace MatterHackers.MatterControl public EditManualMovementSpeedsWindow(string windowTitle, string movementSpeedsString, EventHandler functionToCallOnSave) : base(260, 300) { - Title = windowTitle; + Title = new LocalizedString(windowTitle).Translated; FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.AnchorAll(); @@ -62,7 +63,8 @@ namespace MatterHackers.MatterControl headerRow.Padding = new BorderDouble(0, 3, 0, 3); { - TextWidget elementHeader = new TextWidget(string.Format("Movement Speeds Presets:"), pointSize: 14); + string movementSpeedsLbl = new LocalizedString("Movement Speeds Presets").Translated; + TextWidget elementHeader = new TextWidget(string.Format("{0}:",movementSpeedsLbl), pointSize: 14); elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; elementHeader.HAnchor = HAnchor.ParentLeftRight; elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom; @@ -131,11 +133,13 @@ namespace MatterHackers.MatterControl if (settingsArray[i].StartsWith("e")) { int extruderIndex = (int)double.Parse(settingsArray[i].Substring(1)) + 1; - axisLabel = new TextWidget(string.Format("Extruder {0}", extruderIndex), textColor: ActiveTheme.Instance.PrimaryTextColor); + string extruderLblTxt = new LocalizedString ("Extruder").Translated; + axisLabel = new TextWidget(string.Format("{0} {1}",extruderLblTxt ,extruderIndex), textColor: ActiveTheme.Instance.PrimaryTextColor); } else { - axisLabel = new TextWidget(string.Format("Axis {0}", settingsArray[i]), textColor: ActiveTheme.Instance.PrimaryTextColor); + string axisLblText = new LocalizedString("Axis").Translated; + axisLabel = new TextWidget(string.Format("{0} {1}",axisLblText, settingsArray[i]), textColor: ActiveTheme.Instance.PrimaryTextColor); } axisLabel.VAnchor = VAnchor.ParentCenter; leftRightEdit.AddChild(axisLabel); @@ -165,10 +169,10 @@ namespace MatterHackers.MatterControl ShowAsSystemWindow(); - Button savePresetsButton = textImageButtonFactory.Generate("Save"); + Button savePresetsButton = textImageButtonFactory.Generate(new LocalizedString("Save").Translated); savePresetsButton.Click += new ButtonBase.ButtonEventHandler(save_Click); - Button cancelPresetsButton = textImageButtonFactory.Generate("Cancel"); + Button cancelPresetsButton = textImageButtonFactory.Generate(new LocalizedString("Cancel").Translated); cancelPresetsButton.Click += (sender, e) => { Close(); }; FlowLayoutWidget buttonRow = new FlowLayoutWidget(); diff --git a/PrinterControls/EditTemperaturePresetsWindow.cs b/PrinterControls/EditTemperaturePresetsWindow.cs index 8be20292e..eab134094 100644 --- a/PrinterControls/EditTemperaturePresetsWindow.cs +++ b/PrinterControls/EditTemperaturePresetsWindow.cs @@ -51,7 +51,7 @@ namespace MatterHackers.MatterControl public EditTemperaturePresetsWindow(string windowTitle, string temperatureSettings, EventHandler functionToCallOnSave) : base(360, 300) { - Title = windowTitle; + Title = new LocalizedString(windowTitle).Translated; FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.AnchorAll(); diff --git a/PrinterControls/PrinterConnections/ConnectionWindow.cs b/PrinterControls/PrinterConnections/ConnectionWindow.cs index ffee05031..48bb266ae 100644 --- a/PrinterControls/PrinterConnections/ConnectionWindow.cs +++ b/PrinterControls/PrinterConnections/ConnectionWindow.cs @@ -24,7 +24,10 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections public ConnectionWindow() : base(350, 500) { - Title = new LocalizedString("MatterControl - Connect to Printer").Translated; + string connectToPrinterTitle = new LocalizedString("MatterControl").Translated; + string connectToPrinterTitleEnd = new LocalizedString ("Connect to Printer").Translated; + Title = string.Format("{0} - {1}",connectToPrinterTitle,connectToPrinterTitleEnd); + if (GetPrinterRecordCount() > 0) { ChangeToChoosePrinter(); diff --git a/WidescreenPanel.cs b/WidescreenPanel.cs index 80078b80e..b393984a6 100644 --- a/WidescreenPanel.cs +++ b/WidescreenPanel.cs @@ -292,7 +292,7 @@ namespace MatterHackers.MatterControl void NumQueueItemsChanged(object sender, EventArgs widgetEvent) { - string queueString = new LocalizedString("Queue ({0})").Translated; + string queueString = "Queue ({0})"; QueueTabPage.Text = string.Format(queueString, PrintQueue.PrintQueueControl.Instance.Count); } From 0e592f7317ecd56eb8e3948650e7231ef3883945 Mon Sep 17 00:00:00 2001 From: gregory-diaz Date: Tue, 18 Feb 2014 15:18:58 -0800 Subject: [PATCH 2/4] Corrected problems with the view window Print Item Every time the "view" link on a "print queue item" is clicked a new window would open. I made changes so that it only opens once regardless of how many times it is clicked on. --- MainSlidePanel.cs | 6 ++--- PrintLibrary/ExportLibraryItemWindow.cs | 6 ++--- PrintLibrary/ExportLibraryItemWindow.cs.rej | 13 ++++++++++ PrintQueue/PrintQueueItem.cs | 28 +++++++++++++++++++-- 4 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 PrintLibrary/ExportLibraryItemWindow.cs.rej diff --git a/MainSlidePanel.cs b/MainSlidePanel.cs index 044ae8c47..37df0a45e 100644 --- a/MainSlidePanel.cs +++ b/MainSlidePanel.cs @@ -1,5 +1,5 @@ -<<<<<<< HEAD -======= +//<<<<<<< HEAD +//======= /* Copyright (c) 2014, Lars Brubaker All rights reserved. @@ -29,7 +29,7 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ ->>>>>>> upstream/development +//>>>>>>> upstream/development using System; using System.Collections.Generic; using System.Linq; diff --git a/PrintLibrary/ExportLibraryItemWindow.cs b/PrintLibrary/ExportLibraryItemWindow.cs index 1037ec0ca..516de3487 100644 --- a/PrintLibrary/ExportLibraryItemWindow.cs +++ b/PrintLibrary/ExportLibraryItemWindow.cs @@ -9,11 +9,11 @@ using MatterHackers.Agg.UI; using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.PrintQueue; using MatterHackers.GCodeVisualizer; -<<<<<<< HEAD +//<<<<<<< HEAD using MatterHackers.Localizations; -======= +//======= using MatterHackers.MatterControl.SlicerConfiguration; ->>>>>>> upstream/development +//>>>>>>> upstream/development namespace MatterHackers.MatterControl.PrintLibrary { diff --git a/PrintLibrary/ExportLibraryItemWindow.cs.rej b/PrintLibrary/ExportLibraryItemWindow.cs.rej new file mode 100644 index 000000000..4dedb63b9 --- /dev/null +++ b/PrintLibrary/ExportLibraryItemWindow.cs.rej @@ -0,0 +1,13 @@ +diff a/PrintLibrary/ExportLibraryItemWindow.cs b/PrintLibrary/ExportLibraryItemWindow.cs (rejected hunks) +@@ -9,7 +9,11 @@ + using MatterHackers.MatterControl.DataStorage; + using MatterHackers.MatterControl.PrintQueue; + using MatterHackers.GCodeVisualizer; ++<<<<<<< HEAD + using MatterHackers.Localizations; ++======= ++using MatterHackers.MatterControl.SlicerConfiguration; ++>>>>>>> upstream/development + + namespace MatterHackers.MatterControl.PrintLibrary + { diff --git a/PrintQueue/PrintQueueItem.cs b/PrintQueue/PrintQueueItem.cs index 3d39b4342..ea11b8809 100644 --- a/PrintQueue/PrintQueueItem.cs +++ b/PrintQueue/PrintQueueItem.cs @@ -33,7 +33,9 @@ namespace MatterHackers.MatterControl.PrintQueue FlowLayoutWidget editControls; LinkButtonFactory linkButtonFactory = new LinkButtonFactory(); ExportQueueItemWindow exportingWindow; + PartPreviewMainWindow viewingWindow; bool exportingWindowIsOpen = false; + bool viewWindowIsOpen = false; public PrintQueueItem(PrintItemWrapper printItem) @@ -140,7 +142,28 @@ namespace MatterHackers.MatterControl.PrintQueue this.exportingWindowIsOpen = false; } - + private void OpenViewWindow() + { + if (viewWindowIsOpen == false) + { + viewingWindow = new PartPreviewMainWindow(PrintItemWrapper); + this.viewWindowIsOpen = true; + viewingWindow.Closed += new EventHandler(PartPreviewWindow_Closed); + } + else + { + if(viewingWindow != null) + { + viewingWindow.BringToFront(); + } + } + } + + void PartPreviewWindow_Closed(object sender, EventArgs e) + { + this.viewWindowIsOpen = false; + } + private void CreateEditControls() { editControls = new FlowLayoutWidget(); @@ -156,10 +179,11 @@ namespace MatterHackers.MatterControl.PrintQueue Button viewLink = linkButtonFactory.Generate(new LocalizedString("View").Translated); viewLink.Click += (sender, e) => { + string pathAndFile = PrintItemWrapper.FileLocation; if (File.Exists(pathAndFile)) { - new PartPreviewMainWindow(PrintItemWrapper); + OpenViewWindow(); } else { From 5cd02561412c910601ded0c0b24fc1732b3842c8 Mon Sep 17 00:00:00 2001 From: gregory-diaz Date: Tue, 18 Feb 2014 16:21:07 -0800 Subject: [PATCH 3/4] Made Adjustments to view window in Print Library Adjusted code in Print Library for the view window so that any given window can only be opened once regardless of how many times the user selects the view link. --- PrintLibrary/PrintLibraryListItem.cs | 59 ++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 3 deletions(-) diff --git a/PrintLibrary/PrintLibraryListItem.cs b/PrintLibrary/PrintLibraryListItem.cs index 6bbd14205..f00a29a73 100644 --- a/PrintLibrary/PrintLibraryListItem.cs +++ b/PrintLibrary/PrintLibraryListItem.cs @@ -25,7 +25,8 @@ namespace MatterHackers.MatterControl.PrintLibrary public class LibraryThumbnailWidget : ClickWidget { static Thread thumbNailThread = null; - + bool viewWindowIsOpen = false; + PartPreviewMainWindow viewingWindow; private PrintItemWrapper printItem; public PrintItemWrapper PrintItem { @@ -203,6 +204,30 @@ namespace MatterHackers.MatterControl.PrintLibrary this.Invalidate(); } + /* + private void OpenPartViewWindow() + { + if (viewWindowIsOpen == false) + { + viewingWindow = new PartPreviewMainWindow(printItem); + this.viewWindowIsOpen = true; + viewingWindow.Closed += new EventHandler(PartPreviewMainWindow_Closed); + } + else + { + if(viewingWindow != null) + { + viewingWindow.BringToFront(); + } + } + + } + + void PartPreviewMainWindow_Closed(object sender, EventArgs e) + { + viewWindowIsOpen = false; + } + */ private void onMouseClick(object sender, MouseEventArgs e) { if (printItem != null) @@ -210,7 +235,7 @@ namespace MatterHackers.MatterControl.PrintLibrary string pathAndFile = printItem.FileLocation; if (File.Exists(pathAndFile)) { - new PartPreviewMainWindow(printItem); + new PartPreviewMainWindow(printItem); } else { @@ -282,6 +307,8 @@ namespace MatterHackers.MatterControl.PrintLibrary FlowLayoutWidget buttonContainer; LinkButtonFactory linkButtonFactory = new LinkButtonFactory(); bool exportWindowIsOpen = false; + bool viewWindowIsOpen = false; + PartPreviewMainWindow viewingWindow; ExportLibraryItemWindow exportingWindow; private void OpenExportWindow() @@ -483,13 +510,39 @@ namespace MatterHackers.MatterControl.PrintLibrary UiThread.RunOnIdle(onViewLinkClick); } + + private void OpenPartViewWindow() + { + if (viewWindowIsOpen == false) + { + viewingWindow = new PartPreviewMainWindow(this.printItem); + this.viewWindowIsOpen = true; + viewingWindow.Closed += new EventHandler(PartPreviewMainWindow_Closed); + } + else + { + if(viewingWindow != null) + { + viewingWindow.BringToFront(); + } + } + + } + + void PartPreviewMainWindow_Closed(object sender, EventArgs e) + { + viewWindowIsOpen = false; + } + + private void onViewLinkClick(object state) { string pathAndFile = this.printItem.FileLocation; Console.WriteLine(pathAndFile); if (File.Exists(pathAndFile)) { - new PartPreviewMainWindow(this.printItem); + OpenPartViewWindow (); + //new PartPreviewMainWindow(this.printItem); } else { From 81b566f5fe037e52dd393c726e845bb421c4158e Mon Sep 17 00:00:00 2001 From: gregory-diaz Date: Tue, 18 Feb 2014 17:56:58 -0800 Subject: [PATCH 4/4] More Localization Fixed the translation for the queue widget on main slide panel and also added translation for printer connection status on Action Bar. Made corrections to previously modified strings. --- ActionBar/ActionBarBaseControls.cs | 10 ++++++--- ActionBar/HelpTextWidget.cs | 2 +- MainSlidePanel.cs | 8 +++---- MatterControl.userprefs | 14 +++++++----- PrintLibrary/ExportLibraryItemWindow.cs | 6 ++--- PrintLibrary/PrintLibraryListItem.cs | 29 +------------------------ PrintQueue/PrintQueueItem.cs | 1 - PrinterCommunication.cs | 16 +++++++------- 8 files changed, 33 insertions(+), 53 deletions(-) diff --git a/ActionBar/ActionBarBaseControls.cs b/ActionBar/ActionBarBaseControls.cs index 25cdc4df9..998c81a92 100644 --- a/ActionBar/ActionBarBaseControls.cs +++ b/ActionBar/ActionBarBaseControls.cs @@ -146,7 +146,10 @@ namespace MatterHackers.MatterControl.ActionBar printerNameText.HAnchor = HAnchor.ParentCenter; printerNameText.TextColor = textColor; - printerStatusText = new TextWidget("Status: Connected", pointSize:statusTextHeight); + string printerStatusTxtBeg = new LocalizedString("Status").Translated; + string printerStatusTxtEnd = new LocalizedString("Connected").Translated; + string printerStatusTxtFull = string.Format("{0}: {1}", printerStatusTxtBeg, printerStatusTxtEnd); + printerStatusText = new TextWidget(printerStatusTxtFull, pointSize:statusTextHeight); printerStatusText.AutoExpandBoundsToText = true; printerStatusText.HAnchor = HAnchor.ParentCenter; printerStatusText.TextColor = textColor; @@ -191,8 +194,9 @@ namespace MatterHackers.MatterControl.ActionBar } else { - string statusString = new LocalizedString("Status: {0}").Translated; - printerStatusText.Text = string.Format(statusString, PrinterCommunication.Instance.PrinterConnectionStatusVerbose); + string statusStringBeg = new LocalizedString ("Status").Translated; + string statusString = string.Format("{1}: {0}", PrinterCommunication.Instance.PrinterConnectionStatusVerbose, statusStringBeg); + printerStatusText.Text = string.Format(statusString,PrinterCommunication.Instance.PrinterConnectionStatusVerbose); } if (ActivePrinterProfile.Instance.ActivePrinter != null) { diff --git a/ActionBar/HelpTextWidget.cs b/ActionBar/HelpTextWidget.cs index 3a66701f7..5c6bed18a 100644 --- a/ActionBar/HelpTextWidget.cs +++ b/ActionBar/HelpTextWidget.cs @@ -131,7 +131,7 @@ namespace MatterHackers.MatterControl case PrinterCommunication.CommunicationStates.Disconnected: return new LocalizedString("Not connected. Press 'Connect' to enable printing.").Translated; case PrinterCommunication.CommunicationStates.AttemptingToConnect: - return "Attempting to connect..."; + return new LocalizedString("Attempting to connect...").Translated; case PrinterCommunication.CommunicationStates.ConnectionLost: case PrinterCommunication.CommunicationStates.FailedToConnect: return new LocalizedString("Unable to communicate with printer.").Translated; diff --git a/MainSlidePanel.cs b/MainSlidePanel.cs index 37df0a45e..84f502ffc 100644 --- a/MainSlidePanel.cs +++ b/MainSlidePanel.cs @@ -1,5 +1,4 @@ -//<<<<<<< HEAD -//======= + /* Copyright (c) 2014, Lars Brubaker All rights reserved. @@ -29,7 +28,7 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ -//>>>>>>> upstream/development + using System; using System.Collections.Generic; using System.Linq; @@ -339,7 +338,8 @@ namespace MatterHackers.MatterControl void NumQueueItemsChanged(object sender, EventArgs widgetEvent) { - string queueString = ("Queue ({0})"); + string queueStringBeg = new LocalizedString("Queue").Translated; + string queueString = string.Format("{1} ({0})",PrintQueue.PrintQueueControl.Instance.Count, queueStringBeg); QueueTabPage.Text = string.Format(queueString, PrintQueue.PrintQueueControl.Instance.Count); } diff --git a/MatterControl.userprefs b/MatterControl.userprefs index f7cab3e51..5728f2341 100644 --- a/MatterControl.userprefs +++ b/MatterControl.userprefs @@ -2,15 +2,19 @@ - - - - - + + + + + + + + + diff --git a/PrintLibrary/ExportLibraryItemWindow.cs b/PrintLibrary/ExportLibraryItemWindow.cs index 516de3487..ae207963a 100644 --- a/PrintLibrary/ExportLibraryItemWindow.cs +++ b/PrintLibrary/ExportLibraryItemWindow.cs @@ -9,11 +9,11 @@ using MatterHackers.Agg.UI; using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.PrintQueue; using MatterHackers.GCodeVisualizer; -//<<<<<<< HEAD + using MatterHackers.Localizations; -//======= + using MatterHackers.MatterControl.SlicerConfiguration; -//>>>>>>> upstream/development + namespace MatterHackers.MatterControl.PrintLibrary { diff --git a/PrintLibrary/PrintLibraryListItem.cs b/PrintLibrary/PrintLibraryListItem.cs index f00a29a73..b55ba67be 100644 --- a/PrintLibrary/PrintLibraryListItem.cs +++ b/PrintLibrary/PrintLibraryListItem.cs @@ -25,8 +25,6 @@ namespace MatterHackers.MatterControl.PrintLibrary public class LibraryThumbnailWidget : ClickWidget { static Thread thumbNailThread = null; - bool viewWindowIsOpen = false; - PartPreviewMainWindow viewingWindow; private PrintItemWrapper printItem; public PrintItemWrapper PrintItem { @@ -203,31 +201,7 @@ namespace MatterHackers.MatterControl.PrintLibrary //this.thumbNailHasBeenRequested = false; this.Invalidate(); } - - /* - private void OpenPartViewWindow() - { - if (viewWindowIsOpen == false) - { - viewingWindow = new PartPreviewMainWindow(printItem); - this.viewWindowIsOpen = true; - viewingWindow.Closed += new EventHandler(PartPreviewMainWindow_Closed); - } - else - { - if(viewingWindow != null) - { - viewingWindow.BringToFront(); - } - } - - } - - void PartPreviewMainWindow_Closed(object sender, EventArgs e) - { - viewWindowIsOpen = false; - } - */ + private void onMouseClick(object sender, MouseEventArgs e) { if (printItem != null) @@ -542,7 +516,6 @@ namespace MatterHackers.MatterControl.PrintLibrary if (File.Exists(pathAndFile)) { OpenPartViewWindow (); - //new PartPreviewMainWindow(this.printItem); } else { diff --git a/PrintQueue/PrintQueueItem.cs b/PrintQueue/PrintQueueItem.cs index ea11b8809..10931edb4 100644 --- a/PrintQueue/PrintQueueItem.cs +++ b/PrintQueue/PrintQueueItem.cs @@ -86,7 +86,6 @@ namespace MatterHackers.MatterControl.PrintQueue { string labelName = textInfo.ToTitleCase(PrintItemWrapper.Name); labelName = labelName.Replace('_', ' '); - labelName = new LocalizedString (labelName).Translated; partLabel = new TextWidget(labelName, pointSize: 14); partLabel.TextColor = WidgetTextColor; partLabel.MinimumSize = new Vector2(1, 16); diff --git a/PrinterCommunication.cs b/PrinterCommunication.cs index 139d82b6e..2675e1219 100644 --- a/PrinterCommunication.cs +++ b/PrinterCommunication.cs @@ -473,25 +473,25 @@ namespace MatterHackers.MatterControl switch (CommunicationState) { case CommunicationStates.Disconnected: - return "Not Connected"; + return new LocalizedString("Not Connected").Translated; case CommunicationStates.Disconnecting: - return "Disconnecting"; + return new LocalizedString("Disconnecting").Translated; case CommunicationStates.AttemptingToConnect: return "Connecting..."; case CommunicationStates.ConnectionLost: - return "Connection Lost"; + return new LocalizedString("Connection Lost").Translated; case CommunicationStates.FailedToConnect: return string.Format("Unable to Connect"); case CommunicationStates.Connected: - return "Connected"; + return new LocalizedString("Connected").Translated; case CommunicationStates.PreparingToPrint: - return "Preparing To Print"; + return new LocalizedString("Preparing To Print").Translated; case CommunicationStates.Printing: - return "Printing"; + return new LocalizedString("Printing").Translated; case CommunicationStates.Paused: - return "Paused"; + return new LocalizedString("Paused").Translated; case CommunicationStates.FinishedPrint: - return "Finished Print"; + return new LocalizedString("Finished Print").Translated; default: throw new NotImplementedException("Make sure very satus returns the correct connected state."); }