diff --git a/ApplicationView/MenuRow/ApplicationMenuRow.cs b/ApplicationView/MenuRow/ApplicationMenuRow.cs index 0e173e865..8453c8106 100644 --- a/ApplicationView/MenuRow/ApplicationMenuRow.cs +++ b/ApplicationView/MenuRow/ApplicationMenuRow.cs @@ -31,11 +31,17 @@ namespace MatterHackers.MatterControl this.HAnchor = HAnchor.ParentLeftRight; this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; - // put in the file menu - MenuOptionFile menuOptionFile = new MenuOptionFile(); - this.AddChild(menuOptionFile); + // put in the file menu + MenuOptionFile menuOptionFile = new MenuOptionFile(); + this.AddChild(menuOptionFile); - // put in the help menu +#if false + // put in the view menu + MenuOptionView menuOptionView = new MenuOptionView(); + this.AddChild(menuOptionView); +#endif + + // put in the help menu MenuOptionHelp menuOptionHelp = new MenuOptionHelp(); this.AddChild(menuOptionHelp); diff --git a/ApplicationView/MenuRow/MenuOptionView.cs b/ApplicationView/MenuRow/MenuOptionView.cs new file mode 100644 index 000000000..17d99964c --- /dev/null +++ b/ApplicationView/MenuRow/MenuOptionView.cs @@ -0,0 +1,113 @@ +using System; +using System.IO; +using MatterHackers.Agg; +using MatterHackers.Agg.UI; +using MatterHackers.Localizations; +using MatterHackers.MatterControl.CustomWidgets; +using MatterHackers.MatterControl.DataStorage; +using MatterHackers.MatterControl.ContactForm; +using MatterHackers.MatterControl.PrinterCommunication; +using MatterHackers.MatterControl.PrinterControls.PrinterConnections; +using MatterHackers.MatterControl.PrintQueue; +using MatterHackers.VectorMath; + +namespace MatterHackers.MatterControl +{ + public class MenuOptionView : GuiWidget + { + public DropDownMenu MenuDropList; + private TupleList> menuItems; + + public MenuOptionView() + { + MenuDropList = new DropDownMenu("View".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 * 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); + } + + 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("Layout 1"), layout1_Click}, + {LocalizedString.Get("Layout 2"), layout2_Click}, + //{LocalizedString.Get("Layout 3"), layout3_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; + } + + int widthAdjust = -14; + int heightAdjust = -35; + bool layout1_Click() + { + UiThread.RunOnIdle((state) => + { + double width = System.Windows.SystemParameters.FullPrimaryScreenWidth; + double height = System.Windows.SystemParameters.FullPrimaryScreenHeight; + + MatterControlApplication.Instance.DesktopPosition = new Point2D(0, 0); + MatterControlApplication.Instance.Width = width / 3; + MatterControlApplication.Instance.Height = height; + + PopOutManager.SetStates(ThirdPanelTabView.SliceSettingsTabName, true, width / 3, height + heightAdjust, width / 3 * 2 + widthAdjust, 0); + PopOutManager.SetStates(ThirdPanelTabView.ControlsTabName, false, width / 3, height / 2 + heightAdjust, width / 3 * 2 + widthAdjust, height / 2); + ApplicationController.Instance.ReloadAll(null, null); + + }); + return true; + } + + bool layout2_Click() + { + UiThread.RunOnIdle((state) => + { + double width = System.Windows.SystemParameters.PrimaryScreenWidth; + double height = System.Windows.SystemParameters.PrimaryScreenHeight; + + MatterControlApplication.Instance.DesktopPosition = new Point2D(0, 0); + MatterControlApplication.Instance.Width = width / 3; + MatterControlApplication.Instance.Height = height; + + PopOutManager.SetStates(ThirdPanelTabView.SliceSettingsTabName, true, width / 3, height / 2 + heightAdjust, width / 3 * 2 + widthAdjust, 0); + PopOutManager.SetStates(ThirdPanelTabView.ControlsTabName, true, width / 3, height / 2 + heightAdjust * 2, width / 3 * 2 + widthAdjust, height / 2); + ApplicationController.Instance.ReloadAll(null, null); + }); + return true; + } + } +} diff --git a/ApplicationView/ThirdPanelTabView.cs b/ApplicationView/ThirdPanelTabView.cs index 08ebb93a0..8398bc97c 100644 --- a/ApplicationView/ThirdPanelTabView.cs +++ b/ApplicationView/ThirdPanelTabView.cs @@ -152,18 +152,11 @@ namespace MatterHackers.MatterControl string sliceSettingsLabel = LocalizedString.Get("Settings").ToUpper(); string printerControlsLabel = LocalizedString.Get("Controls").ToUpper(); sliceSettingsWidget = new SliceSettingsWidget(sliceSettingsUiState); -#if false // LBB 2014 12 23 (soon to be dead code I expect) - advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(sliceSettingsWidget, sliceSettingsLabel), "Slice Settings Tab", textSize, - ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); - advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(manualPrinterControlsScrollArea, printerControlsLabel), "Controls Tab", textSize, - ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); -#else // use the pop out tabs - advancedControls.AddTab(new PopOutTextTabWidget(new TabPage(sliceSettingsWidget, sliceSettingsLabel), "Slice Settings Tab", new Vector2(590, 400), textSize)); + 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)); - advancedControls.AddTab(new PopOutTextTabWidget(new TabPage(manualPrinterControlsScrollArea, printerControlsLabel), "Controls Tab", new Vector2(400, 300), textSize)); -#endif - string configurationLabel = LocalizedString.Get("Configuration").ToUpper(); + string configurationLabel = LocalizedString.Get("Configuration").ToUpper(); ScrollableWidget configurationControls = new PrinterConfigurationScrollWidget(); advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(configurationControls, configurationLabel), "Configuration Tab", textSize, ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); @@ -173,7 +166,17 @@ namespace MatterHackers.MatterControl return advancedControls; } - public void ReloadSliceSettings(object state) + public static string SliceSettingsTabName + { + get { return "Slice Settings Tab"; } + } + + public static string ControlsTabName + { + get { return "Controls Tab"; } + } + + public void ReloadSliceSettings(object state) { lastAdvanceControlsIndex = advancedControls2.SelectedTabIndex; diff --git a/ControlElements/PopOutManager.cs b/ControlElements/PopOutManager.cs index 7b27922ce..6aafbd288 100644 --- a/ControlElements/PopOutManager.cs +++ b/ControlElements/PopOutManager.cs @@ -79,6 +79,24 @@ namespace MatterHackers.MatterControl PositionKey = dataBaseKeyPrefix + PositionSufix; } + public static void SetPopOutState(string dataBaseKeyPrefix, bool poppedOut) + { + string windowLeftOpenKey = dataBaseKeyPrefix + WindowLeftOpenSufix; + UserSettings.Instance.Fields.SetBool(windowLeftOpenKey, poppedOut); + } + + public static void SetStates(string dataBaseKeyPrefix, bool poppedOut, double width, double height, double positionX, double positionY) + { + string windowLeftOpenKey = dataBaseKeyPrefix + WindowLeftOpenSufix; + string windowSizeKey = dataBaseKeyPrefix + WindowSizeSufix; + string positionKey = dataBaseKeyPrefix + PositionSufix; + + UserSettings.Instance.Fields.SetBool(windowLeftOpenKey, poppedOut); + + UserSettings.Instance.set(windowSizeKey, string.Format("{0},{1}", width, height)); + UserSettings.Instance.set(positionKey, string.Format("{0},{1}", positionX, positionY)); + } + public void ShowContentInWindow() { if (PopedOutSystemWindow == null) diff --git a/CustomWidgets/PopOutTextTab.cs b/CustomWidgets/PopOutTextTab.cs index 60f6b904a..65de2f337 100644 --- a/CustomWidgets/PopOutTextTab.cs +++ b/CustomWidgets/PopOutTextTab.cs @@ -92,7 +92,6 @@ namespace MatterHackers.Agg.UI tabTitle.AutoExpandBoundsToText = true; leftToRight.AddChild(tabTitle); -#if true ImageBuffer popOutImageClick = StaticData.Instance.LoadIcon(Path.Combine("icon_pop_out_32x32.png")); if (ActiveTheme.Instance.IsDarkTheme) { @@ -117,7 +116,6 @@ namespace MatterHackers.Agg.UI popOut.Margin = new BorderDouble(3, 0); popOut.VAnchor = VAnchor.ParentTop; leftToRight.AddChild(popOut); -#endif widgetState.AddChild(leftToRight); widgetState.SetBoundsToEncloseChildren(); diff --git a/MatterControl.csproj b/MatterControl.csproj index 51469ef89..70aba62e6 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -132,6 +132,7 @@ + @@ -340,6 +341,7 @@ PdfSharp.dll + diff --git a/PrintQueue/QueueDataView.cs b/PrintQueue/QueueDataView.cs index abb923793..0c20d329c 100644 --- a/PrintQueue/QueueDataView.cs +++ b/PrintQueue/QueueDataView.cs @@ -318,7 +318,7 @@ namespace MatterHackers.MatterControl.PrintQueue this.MouseLeaveBounds += new EventHandler(control_MouseLeaveBounds); QueueData.Instance.SelectedIndexChanged.RegisterEvent(SelectedIndexChanged, ref unregisterEvents); - QueueData.Instance.ItemAdded.RegisterEvent(ItemAddedToQueue, ref unregisterEvents); + QueueData.Instance.ItemAdded.RegisterEvent(ItemAddedToQueue, ref unregisterEvents); QueueData.Instance.ItemRemoved.RegisterEvent(ItemRemovedFromToQueue, ref unregisterEvents); QueueData.Instance.OrderChanged.RegisterEvent(QueueOrderChanged, ref unregisterEvents);