diff --git a/ActionBar/ActionBarBaseControls.cs b/ActionBar/ActionBarBaseControls.cs index 03506d6eb..0920825d8 100644 --- a/ActionBar/ActionBarBaseControls.cs +++ b/ActionBar/ActionBarBaseControls.cs @@ -110,7 +110,7 @@ namespace MatterHackers.MatterControl.ActionBar protected double borderWidth; protected double borderRadius; protected double padding; - protected double statusTextHeight = 10; + protected double statusTextHeight = 8; TextWidget printerStatusText; TextWidget printerNameText; @@ -133,7 +133,7 @@ namespace MatterHackers.MatterControl.ActionBar this.fillColor = fillColor; this.borderColor = borderColor; this.padding = padding; - this.Padding = new BorderDouble(10, 5); + this.Padding = new BorderDouble(10, 3); this.HAnchor = HAnchor.ParentLeftRight; FlowLayoutWidget textContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); @@ -240,10 +240,10 @@ namespace MatterHackers.MatterControl.ActionBar public class PrinterSelectButton : Button { double width = 180; - double height = 48; + double height = 40; double borderRadius = 0; double borderWidth = 1; - double fontSize = 16; + double fontSize = 14; double padding = 3; BorderDouble margin = new BorderDouble(0, 0); diff --git a/ActionBar/PrinterActionRow.cs b/ActionBar/PrinterActionRow.cs index 70482649b..d4a7c3a22 100644 --- a/ActionBar/PrinterActionRow.cs +++ b/ActionBar/PrinterActionRow.cs @@ -48,14 +48,14 @@ namespace MatterHackers.MatterControl.ActionBar actionBarButtonFactory.invertImageLocation = false; 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.Margin = new BorderDouble(0, 0, 3, 3); + connectPrinterButton.VAnchor = VAnchor.ParentTop; connectPrinterButton.Cursor = Cursors.Hand; string disconnectString = "Disconnect".Localize().ToUpper(); disconnectPrinterButton = actionBarButtonFactory.Generate(disconnectString, "icon_power_32x32.png"); - disconnectPrinterButton.Margin = new BorderDouble(0, 0, 3); - disconnectPrinterButton.VAnchor = VAnchor.ParentCenter; + disconnectPrinterButton.Margin = new BorderDouble(0, 0, 3, 3); + disconnectPrinterButton.VAnchor = VAnchor.ParentTop; disconnectPrinterButton.Visible = false; disconnectPrinterButton.Cursor = Cursors.Hand; @@ -64,11 +64,11 @@ namespace MatterHackers.MatterControl.ActionBar selectActivePrinterButton.Cursor = Cursors.Hand; if (ApplicationWidget.Instance.WidescreenMode) { - selectActivePrinterButton.Margin = new BorderDouble(0, 6); + selectActivePrinterButton.Margin = new BorderDouble(0, 6,0,3); } else { - selectActivePrinterButton.Margin = new BorderDouble(0, 6, 6, 6); + selectActivePrinterButton.Margin = new BorderDouble(0, 6, 6, 3); } @@ -80,33 +80,6 @@ namespace MatterHackers.MatterControl.ActionBar //this.AddChild(CreateOptionsMenu()); } - GuiWidget CreateOptionsMenu() - { - ImageBuffer gearImage = new ImageBuffer(); - string imagePathAndFile = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "gear_icon.png"); - ImageIO.LoadImageData(imagePathAndFile, gearImage); - - FlowLayoutWidget leftToRight = new FlowLayoutWidget(); - leftToRight.Margin = new BorderDouble(5, 0); - 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); - leftToRight.AddChild(optionsText); - GuiWidget gearWidget = new ImageWidget(gearImage); - gearWidget.VAnchor = Agg.UI.VAnchor.ParentCenter; - leftToRight.AddChild(gearWidget); - leftToRight.HAnchor = HAnchor.FitToChildren; - leftToRight.VAnchor = VAnchor.FitToChildren; - - Menu optionMenu = new Menu(leftToRight); - optionMenu.OpenOffset = new Vector2(-2, -10); - optionMenu.VAnchor = Agg.UI.VAnchor.ParentCenter; - optionMenu.MenuItems.Add(new MenuItem(new ThemeColorSelectorWidget())); - - return optionMenu; - } - event EventHandler unregisterEvents; protected override void AddHandlers() { diff --git a/ApplicationView/ApplicationMenuRow.cs b/ApplicationView/ApplicationMenuRow.cs new file mode 100644 index 000000000..f54b165a2 --- /dev/null +++ b/ApplicationView/ApplicationMenuRow.cs @@ -0,0 +1,266 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; + + + +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; + +using MatterHackers.MatterControl.PrintQueue; +using MatterHackers.MatterControl.CustomWidgets; +using MatterHackers.MatterControl.DataStorage; +using MatterHackers.Localizations; + +namespace MatterHackers.MatterControl +{ + public class ApplicationMenuRow : FlowLayoutWidget + { + static FlowLayoutWidget rightElement; + + public ApplicationMenuRow() + :base(FlowDirection.LeftToRight) + { + LinkButtonFactory linkButtonFactory = new LinkButtonFactory(); + linkButtonFactory.textColor = ActiveTheme.Instance.PrimaryTextColor; + linkButtonFactory.fontSize = 8; + + Button signInLink = linkButtonFactory.Generate("(Sign Out)"); + signInLink.VAnchor = Agg.UI.VAnchor.ParentCenter; + signInLink.Margin = new BorderDouble(top: 0); + + this.HAnchor = HAnchor.ParentLeftRight; + this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; + + MenuOptionFile menuOptionFile = new MenuOptionFile(); + + //TextWidget menuOptionFile = new TextWidget("FILE", pointSize: 10); + + //menuOptionFile.TextColor = ActiveTheme.Instance.PrimaryTextColor; + + MenuOptionHelp menuOptionHelp = new MenuOptionHelp(); + + rightElement = new FlowLayoutWidget(FlowDirection.LeftToRight); + rightElement.Height = 24; + rightElement.Margin = new BorderDouble(bottom: 4); + //rightElement.VAnchor = Agg.UI.VAnchor.ParentCenter; + + this.AddChild(menuOptionFile); + this.AddChild(menuOptionHelp); + this.AddChild(new HorizontalSpacer()); + this.AddChild(rightElement); + + this.Padding = new BorderDouble(0, 0, 6, 0); + + if (privateAddRightElement != null) + { + privateAddRightElement(rightElement); + } + } + + public delegate void AddRightElementDelegate(GuiWidget iconContainer); + private static event AddRightElementDelegate privateAddRightElement; + public static event AddRightElementDelegate AddRightElement + { + add + { + privateAddRightElement += value; + // and call it right away + value(rightElement); + } + + remove + { + privateAddRightElement -= value; + } + } + } + + public class MenuOptionFile : GuiWidget + { + public DropDownMenu MenuDropList; + private TupleList> menuItems; + + public MenuOptionFile() + { + MenuDropList = new DropDownMenu("File".Localize().ToUpper(), Direction.Down,pointSize:10); + MenuDropList.MenuItemsPadding = new BorderDouble(0); + MenuDropList.Margin = new BorderDouble(0); + MenuDropList.Padding = new BorderDouble(0); + + SetMenuItems(); + + AddChild(MenuDropList); + this.Width = 44; + this.Height = 22; + this.Margin = new BorderDouble(0); + this.Padding = new BorderDouble(0); + this.VAnchor = Agg.UI.VAnchor.ParentCenter; + this.MenuDropList.SelectionChanged += new EventHandler(MenuDropList_SelectionChanged); + this.MenuDropList.OpenOffset = new Vector2(0, 0); + } + + void MenuDropList_SelectionChanged(object sender, EventArgs e) + { + string menuSelection = ((DropDownMenu)sender).SelectedValue; + foreach (Tuple> item in menuItems) + { + if (item.Item1 == menuSelection) + { + if (item.Item2 != null) + { + item.Item2(); + } + } + } + } + + void SetMenuItems() + { + menuItems = new TupleList> + { + {LocalizedString.Get("Import File"), importFile_Click}, + {LocalizedString.Get("Exit"), exit_Click}, + }; + + BorderDouble padding = MenuDropList.MenuItemsPadding; + //Add the menu items to the menu itself + foreach (Tuple> item in menuItems) + { + MenuDropList.MenuItemsPadding = new BorderDouble(8,4,8,4); + MenuDropList.AddItem(item.Item1,pointSize:10); + } + MenuDropList.Padding = padding; + } + + bool importFile_Click() + { + UiThread.RunOnIdle((state) => + { + OpenFileDialogParams openParams = new OpenFileDialogParams("Select an STL file, Select a GCODE file|*.stl;*.gcode", multiSelect: true); + openParams.ActionButtonLabel = "Add to Queue"; + openParams.Title = "MatterControl: Select A File"; + + FileDialog.OpenFileDialog(ref openParams); + if (openParams.FileNames != null) + { + foreach (string loadedFileName in openParams.FileNames) + { + QueueData.Instance.AddItem(new PrintItemWrapper(new PrintItem(Path.GetFileNameWithoutExtension(loadedFileName), Path.GetFullPath(loadedFileName)))); + } + } + }); + return true; + } + + bool exit_Click() + { + UiThread.RunOnIdle((state) => + { + GuiWidget parent = this; + while (parent as MatterControlApplication == null) + { + parent = parent.Parent; + } + MatterControlApplication app = parent as MatterControlApplication; + app.RestartOnClose = false; + app.Close(); + }); + return true; + } + } + + public class MenuOptionHelp : GuiWidget + { + public DropDownMenu MenuDropList; + private TupleList> menuItems; + + public MenuOptionHelp() + { + MenuDropList = new DropDownMenu("Help".Localize().ToUpper(), Direction.Down, pointSize: 10); + MenuDropList.MenuItemsPadding = new BorderDouble(0); + MenuDropList.Margin = new BorderDouble(0); + MenuDropList.Padding = new BorderDouble(0); + + SetMenuItems(); + + AddChild(MenuDropList); + this.Width = 48; + this.Height = 22; + this.Margin = new BorderDouble(0); + this.Padding = new BorderDouble(0); + this.VAnchor = Agg.UI.VAnchor.ParentCenter; + this.MenuDropList.SelectionChanged += new EventHandler(MenuDropList_SelectionChanged); + this.MenuDropList.OpenOffset = new Vector2(0, 0); + } + + void MenuDropList_SelectionChanged(object sender, EventArgs e) + { + string menuSelection = ((DropDownMenu)sender).SelectedValue; + foreach (Tuple> item in menuItems) + { + if (item.Item1 == menuSelection) + { + if (item.Item2 != null) + { + item.Item2(); + } + } + } + } + + void SetMenuItems() + { + menuItems = new TupleList> + { + {LocalizedString.Get("Getting Started"), gettingStarted_Click}, + {LocalizedString.Get("View Help"), help_Click}, + {LocalizedString.Get("About"), about_Click}, + }; + + BorderDouble padding = MenuDropList.MenuItemsPadding; + //Add the menu items to the menu itself + foreach (Tuple> item in menuItems) + { + MenuDropList.MenuItemsPadding = new BorderDouble(8, 4, 8, 4); + MenuDropList.AddItem(item.Item1, pointSize: 10); + } + MenuDropList.Padding = padding; + } + + bool help_Click() + { + UiThread.RunOnIdle((state) => + { + System.Diagnostics.Process.Start("http://www.mattercontrol.com/articles"); + }); + return true; + } + + bool about_Click() + { + UiThread.RunOnIdle((state) => + { + System.Diagnostics.Process.Start("http://www.mattercontrol.com/"); + }); + return true; + } + + bool gettingStarted_Click() + { + UiThread.RunOnIdle((state) => + { + System.Diagnostics.Process.Start("http://www.mattercontrol.com/articles/mattercontrol-getting-started"); + }); + + return true; + } + } +} diff --git a/ApplicationView/MainApplicationWidget.cs b/ApplicationView/MainApplicationWidget.cs index bad0f9a4b..7cbea949b 100644 --- a/ApplicationView/MainApplicationWidget.cs +++ b/ApplicationView/MainApplicationWidget.cs @@ -45,6 +45,7 @@ using MatterHackers.MatterControl.PrintQueue; using MatterHackers.MatterControl.PrintLibrary; using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.MatterControl.DataStorage; +using MatterHackers.MatterControl.CustomWidgets; using MatterHackers.Localizations; namespace MatterHackers.MatterControl @@ -68,13 +69,30 @@ namespace MatterHackers.MatterControl } WidescreenPanel widescreenPanel; - public void AddElements() + void AddElements() { - //this.AddChild(new CompactSlidePanel()); + this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; + + FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom); + container.AnchorAll(); + + ApplicationMenuRow menuRow = new ApplicationMenuRow(); + container.AddChild(menuRow); + + GuiWidget menuSeparator = new GuiWidget(); + menuSeparator.BackgroundColor = new RGBA_Bytes(200, 200, 200); + menuSeparator.Height = 2; + menuSeparator.HAnchor = HAnchor.ParentLeftRight; + menuSeparator.Margin = new BorderDouble(3, 0); + + container.AddChild(menuSeparator); + widescreenPanel = new WidescreenPanel(); - this.AddChild(widescreenPanel); - this.AnchorAll(); - SetUpdateNotification(this, null); + container.AddChild(widescreenPanel); + + this.AddChild(container); + + } public void ReloadAll(object sender, EventArgs e) @@ -82,19 +100,25 @@ namespace MatterHackers.MatterControl UiThread.RunOnIdle((state) => { this.RemoveAllChildren(); - widescreenPanel = new WidescreenPanel(); - this.AddChild(widescreenPanel); + AddElements(); }); } + void Initialize() + { + this.AnchorAll(); + SetUpdateNotification(this, null); + } + public static ApplicationWidget Instance { get { if (globalInstance == null) { - globalInstance = new ApplicationWidget(); + globalInstance = new ApplicationWidget(); globalInstance.AddElements(); + globalInstance.Initialize(); } return globalInstance; } diff --git a/MatterControl.csproj b/MatterControl.csproj index 2b3e5d365..e0b7d9edd 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -92,6 +92,7 @@ + @@ -105,7 +106,7 @@ - + @@ -151,7 +152,7 @@ - + @@ -170,7 +171,7 @@ - + @@ -195,13 +196,13 @@ - + - + diff --git a/MatterControl.sln b/MatterControl.sln index 35f720c66..8d0354caf 100644 --- a/MatterControl.sln +++ b/MatterControl.sln @@ -58,6 +58,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MatterSlice", "..\MatterSli EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher", "Launcher\Launcher.csproj", "{3DF4CB3D-9A03-4256-9A81-70523AAD828B}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MatterControlAuth", "..\MatterControlAuth\MatterControlAuth\MatterControlAuth.csproj", "{5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -410,6 +412,18 @@ Global {3DF4CB3D-9A03-4256-9A81-70523AAD828B}.Release64|x64.ActiveCfg = Release64|Any CPU {3DF4CB3D-9A03-4256-9A81-70523AAD828B}.Release64|x64.Build.0 = Release64|Any CPU {3DF4CB3D-9A03-4256-9A81-70523AAD828B}.Release64|x86.ActiveCfg = Release64|Any CPU + {5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}.Debug|x64.ActiveCfg = Debug|Any CPU + {5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}.Debug|x86.ActiveCfg = Debug|Any CPU + {5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}.Release|Any CPU.Build.0 = Release|Any CPU + {5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}.Release|x64.ActiveCfg = Release|Any CPU + {5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}.Release|x86.ActiveCfg = Release|Any CPU + {5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}.Release64|Any CPU.ActiveCfg = Release|Any CPU + {5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}.Release64|Any CPU.Build.0 = Release|Any CPU + {5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}.Release64|x64.ActiveCfg = Release|Any CPU + {5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}.Release64|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/PrintQueue/OptionsMenue/ExportToFolderFeedbackWindow.cs b/PrintQueue/OptionsMenu/ExportToFolderFeedbackWindow.cs similarity index 100% rename from PrintQueue/OptionsMenue/ExportToFolderFeedbackWindow.cs rename to PrintQueue/OptionsMenu/ExportToFolderFeedbackWindow.cs diff --git a/PrintQueue/OptionsMenue/ExportToFolderProcess.cs b/PrintQueue/OptionsMenu/ExportToFolderProcess.cs similarity index 100% rename from PrintQueue/OptionsMenue/ExportToFolderProcess.cs rename to PrintQueue/OptionsMenu/ExportToFolderProcess.cs diff --git a/PrintQueue/OptionsMenue/ExportToSdCardFeedbackWindow.cs b/PrintQueue/OptionsMenu/ExportToSdCardFeedbackWindow.cs similarity index 100% rename from PrintQueue/OptionsMenue/ExportToSdCardFeedbackWindow.cs rename to PrintQueue/OptionsMenu/ExportToSdCardFeedbackWindow.cs diff --git a/PrintQueue/OptionsMenue/PartsSheetCreator.cs b/PrintQueue/OptionsMenu/PartsSheetCreator.cs similarity index 100% rename from PrintQueue/OptionsMenue/PartsSheetCreator.cs rename to PrintQueue/OptionsMenu/PartsSheetCreator.cs diff --git a/PrintQueue/OptionsMenue/QueueOptionsMenu.cs b/PrintQueue/OptionsMenu/QueueOptionsMenu.cs similarity index 100% rename from PrintQueue/OptionsMenue/QueueOptionsMenu.cs rename to PrintQueue/OptionsMenu/QueueOptionsMenu.cs diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index 0c555134e..b2cc5f4d6 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -2052,3 +2052,21 @@ Translated:Build: English:Update Feed Translated:Update Feed +English:File +Translated:File + +English:Import File +Translated:Import File + +English:Exit +Translated:Exit + +English:Help +Translated:Help + +English:Getting Started +Translated:Getting Started + +English:View Help +Translated:View Help +