From cbefcfdfeece24b7855396fae31ff14de305b158 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Tue, 19 May 2015 14:43:24 -0700 Subject: [PATCH] Put in a Settings menu that can open the various pop out windows --- ApplicationView/MenuRow/ApplicationMenuRow.cs | 2 + ApplicationView/MenuRow/MenuOptionSettings.cs | 108 ++++++++++++++++++ ApplicationView/ThirdPanelTabView.cs | 14 ++- CustomWidgets/PopOutTextTab.cs | 5 + MatterControl.csproj | 1 + 5 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 ApplicationView/MenuRow/MenuOptionSettings.cs diff --git a/ApplicationView/MenuRow/ApplicationMenuRow.cs b/ApplicationView/MenuRow/ApplicationMenuRow.cs index c7d657ba3..e822fa691 100644 --- a/ApplicationView/MenuRow/ApplicationMenuRow.cs +++ b/ApplicationView/MenuRow/ApplicationMenuRow.cs @@ -31,6 +31,8 @@ namespace MatterHackers.MatterControl MenuOptionView menuOptionView = new MenuOptionView(); this.AddChild(menuOptionView); #endif + MenuOptionSettings menuOptionSettings = new MenuOptionSettings(); + this.AddChild(menuOptionSettings); // put in the help menu MenuOptionHelp menuOptionHelp = new MenuOptionHelp(); diff --git a/ApplicationView/MenuRow/MenuOptionSettings.cs b/ApplicationView/MenuRow/MenuOptionSettings.cs new file mode 100644 index 000000000..3da43eafe --- /dev/null +++ b/ApplicationView/MenuRow/MenuOptionSettings.cs @@ -0,0 +1,108 @@ +using MatterHackers.Agg; +using MatterHackers.Agg.UI; +using MatterHackers.Localizations; +using MatterHackers.MatterControl.DataStorage; +using MatterHackers.MatterControl.PrinterCommunication; +using MatterHackers.MatterControl.PrinterControls.PrinterConnections; +using MatterHackers.MatterControl.PrintQueue; +using MatterHackers.VectorMath; +using System; +using System.IO; + +namespace MatterHackers.MatterControl +{ + public class MenuOptionSettings : GuiWidget + { + public DropDownMenu MenuDropList; + private TupleList> menuItems; + + static public PopOutTextTabWidget sliceSettingsPopOut = null; + static public PopOutTextTabWidget controlsPopOut = null; + + public MenuOptionSettings() + { + MenuDropList = new DropDownMenu("Settings".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 = 84 * TextWidget.GlobalPointSizeScaleRatio; ; + this.Height = 22 * TextWidget.GlobalPointSizeScaleRatio; ; + 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); + } + + private 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(); + } + } + } + } + + private void SetMenuItems() + { + menuItems = new TupleList> + { + {LocalizedString.Get("Printing"), openPrintingPannel_Click}, + {LocalizedString.Get("Controls"), openControlsPannel_Click}, + {LocalizedString.Get("Show Terminal"), openTermanialPannel_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) * TextWidget.GlobalPointSizeScaleRatio; + MenuDropList.AddItem(item.Item1, pointSize: 10); + } + MenuDropList.Padding = padding; + } + + private bool openPrintingPannel_Click() + { + UiThread.RunOnIdle((state) => + { + if (sliceSettingsPopOut != null) + { + sliceSettingsPopOut.ShowInWindow(); + } + }); + return true; + } + + private bool openControlsPannel_Click() + { + UiThread.RunOnIdle((state) => + { + if (controlsPopOut != null) + { + controlsPopOut.ShowInWindow(); + } + }); + return true; + } + + private bool openTermanialPannel_Click() + { + UiThread.RunOnIdle((state) => + { + TerminalWindow.Show(); + }); + return true; + } + } +} \ No newline at end of file diff --git a/ApplicationView/ThirdPanelTabView.cs b/ApplicationView/ThirdPanelTabView.cs index 3625e1ded..248581bc6 100644 --- a/ApplicationView/ThirdPanelTabView.cs +++ b/ApplicationView/ThirdPanelTabView.cs @@ -127,8 +127,18 @@ namespace MatterHackers.MatterControl string printerControlsLabel = LocalizedString.Get("Controls").ToUpper(); sliceSettingsWidget = new SliceSettingsWidget(); - advancedControls.AddTab(new PopOutTextTabWidget(new TabPage(sliceSettingsWidget, sliceSettingsLabel), SliceSettingsTabName, new Vector2(590, 400), textSize)); - advancedControls.AddTab(new PopOutTextTabWidget(new TabPage(manualPrinterControlsScrollArea, printerControlsLabel), ControlsTabName, new Vector2(400, 300), textSize)); + TabPage sliceSettingsTabPage = new TabPage(sliceSettingsWidget, sliceSettingsLabel); + PopOutTextTabWidget sliceSettingPopOut = new PopOutTextTabWidget(sliceSettingsTabPage, SliceSettingsTabName, new Vector2(590, 400), textSize); + advancedControls.AddTab(sliceSettingPopOut); + + TabPage controlsTabPage = new TabPage(manualPrinterControlsScrollArea, printerControlsLabel); + PopOutTextTabWidget controlsPopOut = new PopOutTextTabWidget(controlsTabPage, ControlsTabName, new Vector2(400, 300), textSize); + advancedControls.AddTab(controlsPopOut); + +#if !__ANDROID__ + MenuOptionSettings.sliceSettingsPopOut = sliceSettingPopOut; + MenuOptionSettings.controlsPopOut = controlsPopOut; +#endif string configurationLabel = LocalizedString.Get("Configuration").ToUpper(); ScrollableWidget configurationControls = new PrinterConfigurationScrollWidget(); diff --git a/CustomWidgets/PopOutTextTab.cs b/CustomWidgets/PopOutTextTab.cs index 7d0c8cb43..5c5519403 100644 --- a/CustomWidgets/PopOutTextTab.cs +++ b/CustomWidgets/PopOutTextTab.cs @@ -64,6 +64,11 @@ namespace MatterHackers.Agg.UI popOutManager = new PopOutManager(TabPageControlledByTab, minSize, tabPageControledByTab.Text, internalTabName); } + public void ShowInWindow() + { + popOutManager.ShowContentInWindow(); + } + public override void OnMouseDown(MouseEventArgs mouseEvent) { if (leftToRight.FirstWidgetUnderMouse) diff --git a/MatterControl.csproj b/MatterControl.csproj index fca757503..768b4740d 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -136,6 +136,7 @@ +