From f204e80fd967ccb230e69a4b3c7558599895ed0f Mon Sep 17 00:00:00 2001 From: John Lewin Date: Thu, 19 Apr 2018 15:53:59 -0700 Subject: [PATCH 1/3] Remove plus tab button, use fixed Start tab --- PartPreviewWindow/NewTabButton.cs | 26 ++++++++++++++ PartPreviewWindow/PartPreviewContent.cs | 28 ++++++++------- PartPreviewWindow/Tabs.cs | 35 +++++-------------- .../View3D/PrinterBar/PrinterActionsBar.cs | 14 -------- 4 files changed, 50 insertions(+), 53 deletions(-) diff --git a/PartPreviewWindow/NewTabButton.cs b/PartPreviewWindow/NewTabButton.cs index c83c2cc1d..c86d1ccf5 100644 --- a/PartPreviewWindow/NewTabButton.cs +++ b/PartPreviewWindow/NewTabButton.cs @@ -34,6 +34,32 @@ using MatterHackers.MatterControl.CustomWidgets; namespace MatterHackers.MatterControl.PartPreviewWindow { + public class TabTrailer : GuiWidget + { + private SimpleTabs parentTabControl; + private ThemeConfig theme; + + public ITab LastTab { get; set; } + + public IconButton IconButton { get; } + + public TabTrailer(SimpleTabs parentTabControl, ThemeConfig theme) + { + this.parentTabControl = parentTabControl; + this.theme = theme; + } + + public override void OnDraw(Graphics2D graphics2D) + { + ChromeTab.DrawTabLowerLeft( + graphics2D, + this.LocalBounds, + (parentTabControl.ActiveTab == this.LastTab) ? theme.ActiveTabColor : theme.InactiveTabColor); + + base.OnDraw(graphics2D); + } + } + public class NewTabButton : GuiWidget { private SimpleTabs parentTabControl; diff --git a/PartPreviewWindow/PartPreviewContent.cs b/PartPreviewWindow/PartPreviewContent.cs index d8d4b8b87..bce12511b 100644 --- a/PartPreviewWindow/PartPreviewContent.cs +++ b/PartPreviewWindow/PartPreviewContent.cs @@ -90,16 +90,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow Color selectedTabColor = ActiveTheme.Instance.TabLabelSelected; - // Add a tab for the current printer - if (ActiveSliceSettings.Instance.PrinterSelected) - { - string tabTitle = ActiveSliceSettings.Instance.GetValue(SettingsKey.printer_name); - this.CreatePrinterTab(printer, theme, tabTitle); - } - else - { - } - // add in the update available button Button updateAvailableButton = theme.LinkButtonFactory.Generate("Update Available"); updateAvailableButton.Name = "Update Available Link"; @@ -139,15 +129,27 @@ namespace MatterHackers.MatterControl.PartPreviewWindow ApplicationController.Instance.NotifyPrintersTabRightElement(extensionArea); // Show start page during initial application startup - if (AppContext.IsLoading) { tabControl.AddTab( - new ChromeTab("New Tab".Localize(), tabControl, tabControl.NewTabPage(), theme) + new ChromeTab("Start".Localize(), tabControl, tabControl.NewTabPage(), theme, hasClose: false) { MinimumSize = new Vector2(0, theme.TabButtonHeight), - Name = "Initial Plus Tab" + Name = "Initial Plus Tab", + Padding = new BorderDouble(15, 0) }); } + + // Add a tab for the current printer + if (ActiveSliceSettings.Instance.PrinterSelected) + { + string tabTitle = ActiveSliceSettings.Instance.GetValue(SettingsKey.printer_name); + this.CreatePrinterTab(printer, theme, tabTitle); + } + else + { + } + + // ************** Restore active tabs..... ****************** } internal ChromeTab CreatePrinterTab(PrinterConfig printer, ThemeConfig theme, string tabTitle) diff --git a/PartPreviewWindow/Tabs.cs b/PartPreviewWindow/Tabs.cs index ec352e611..5ee5e91dc 100644 --- a/PartPreviewWindow/Tabs.cs +++ b/PartPreviewWindow/Tabs.cs @@ -178,7 +178,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public class ChromeTabs : SimpleTabs { - private NewTabButton plusTabButton; + private TabTrailer tabTrailer; public ChromeTabs(GuiWidget rightAnchorItem, ThemeConfig theme) : base(theme, rightAnchorItem) @@ -195,32 +195,20 @@ namespace MatterHackers.MatterControl.PartPreviewWindow ChromeTab.DrawTabLowerRight(e.Graphics2D, leadingTabAdornment.LocalBounds, (firstItem == this.ActiveTab) ? theme.ActiveTabColor : theme.InactiveTabColor); }; this.TabBar.ActionArea.AddChild(leadingTabAdornment); - // TODO: add in the printers and designs that are currently open (or were open last run). - plusTabButton = new NewTabButton( - AggContext.StaticData.LoadIcon("fa-plus_12.png", theme.InvertIcons), - this, - theme) + tabTrailer = new TabTrailer(this, theme) { VAnchor = VAnchor.Bottom, MinimumSize = new Vector2(16, theme.TabButtonHeight), ToolTipText = "Create New".Localize() }; - plusTabButton.IconButton.Click += (s, e) => - { - this.AddTab( - new ChromeTab("New Tab".Localize(), this, this.NewTabPage(), theme) - { - MinimumSize = new Vector2(0, theme.TabButtonHeight) - }); - }; - this.TabBar.ActionArea.AddChild(plusTabButton); + this.TabBar.ActionArea.AddChild(tabTrailer); } public void AddTab(GuiWidget tab) { - var position = this.TabBar.ActionArea.GetChildIndex(plusTabButton); + var position = this.TabBar.ActionArea.GetChildIndex(tabTrailer); if (tab is ChromeTab chromeTab) { @@ -232,7 +220,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow this.AddTab(tab, position); - chromeTab.CloseClicked += ChromeTab_CloseClicked; this.ActiveTab = chromeTab; } } @@ -259,15 +246,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } } - private async void ChromeTab_CloseClicked(object sender, EventArgs e) - { - } - public Func NewTabPage { get; set; } protected override void OnActiveTabChanged() { - plusTabButton.LastTab = this.AllTabs.LastOrDefault(); + tabTrailer.LastTab = this.AllTabs.LastOrDefault(); base.OnActiveTabChanged(); } } @@ -447,13 +430,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public class ChromeTab : SimpleTab { - public ChromeTab(string tabLabel, SimpleTabs parentTabControl, GuiWidget tabContent, ThemeConfig theme, string tabImageUrl = null) - : base(tabLabel, parentTabControl, tabContent, theme, tabImageUrl) + public ChromeTab(string tabLabel, SimpleTabs parentTabControl, GuiWidget tabContent, ThemeConfig theme, string tabImageUrl = null, bool hasClose = true) + : base(tabLabel, parentTabControl, tabContent, theme, tabImageUrl, hasClose) { } - public ChromeTab(string tabLabel, SimpleTabs parentTabControl, GuiWidget tabContent, ThemeConfig theme, ImageBuffer imageBuffer) - : base(tabLabel, parentTabControl, tabContent, theme, iconImage: imageBuffer) + public ChromeTab(string tabLabel, SimpleTabs parentTabControl, GuiWidget tabContent, ThemeConfig theme, ImageBuffer imageBuffer, bool hasClose = true) + : base(tabLabel, parentTabControl, tabContent, theme, iconImage: imageBuffer, hasClose: hasClose) { } diff --git a/PartPreviewWindow/View3D/PrinterBar/PrinterActionsBar.cs b/PartPreviewWindow/View3D/PrinterBar/PrinterActionsBar.cs index 40295d101..6d2b1b973 100644 --- a/PartPreviewWindow/View3D/PrinterBar/PrinterActionsBar.cs +++ b/PartPreviewWindow/View3D/PrinterBar/PrinterActionsBar.cs @@ -155,20 +155,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow buttonGroupB.Add(layers2DButton); this.AddChild(layers2DButton); - //// put in the detail message - //var printerConnectionDetail = new TextWidget("") - //{ - // Margin = new BorderDouble(5, 0), - // TextColor = ActiveTheme.Instance.PrimaryTextColor, - // AutoExpandBoundsToText = true, - // PointSize = 8 - //}; - //printer.Connection.PrintingStateChanged.RegisterEvent((s, e) => - //{ - // printerConnectionDetail.Text = printer.PrinterConnectionStatus; - //}, ref unregisterEvents); - //this.AddChild(printerConnectionDetail); - this.AddChild(new HorizontalSpacer()); bool shareTemp = printer.Settings.GetValue(SettingsKey.extruders_share_temperature); From c844f9b8e937c887e79cc9081bbc427f68f4ba04 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Thu, 19 Apr 2018 15:54:55 -0700 Subject: [PATCH 2/3] Add empty plate actions --- PartPreviewWindow/PlusTab/ExplorerBar.cs | 60 +++++++++++++++--------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/PartPreviewWindow/PlusTab/ExplorerBar.cs b/PartPreviewWindow/PlusTab/ExplorerBar.cs index 8b9c06b2f..4e2e5062c 100644 --- a/PartPreviewWindow/PlusTab/ExplorerBar.cs +++ b/PartPreviewWindow/PlusTab/ExplorerBar.cs @@ -33,6 +33,7 @@ using System.Linq; using MatterHackers.Agg; using MatterHackers.Agg.Platform; using MatterHackers.Agg.UI; +using MatterHackers.DataConverters3D; using MatterHackers.Localizations; using MatterHackers.MatterControl.CustomWidgets; using MatterHackers.MatterControl.DataStorage; @@ -88,7 +89,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab HAnchor = HAnchor.Absolute, Border = 0, MinimumSize = Vector2.Zero, - Width = 200 + Width = 200, + BackgroundColor = theme.MinimalShade }); this.printerInfo = printerInfo; @@ -98,6 +100,25 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab var listView = new ListView(ApplicationController.Instance.Library, theme); + var emptyPlateButton = new ImageWidget(AggContext.StaticData.LoadIcon("empty-workspace.png", 70, 70)) + { + Margin = new BorderDouble(right: 5), + Selectable = true, + BackgroundColor = theme.MinimalShade, + Name = "Open Empty Plate Button" + }; + emptyPlateButton.Click += async (s, e) => + { + await ProfileManager.Instance.LoadPrinterOpenItem(new InMemoryLibraryItem(new Object3D())); + + string tabTitle = ActiveSliceSettings.Instance.GetValue(SettingsKey.printer_name); + + var printer = ApplicationController.Instance.ActivePrinter; + + partPreviewContent.CreatePrinterTab(printer, theme, tabTitle); + }; + toolbar.AddChild(emptyPlateButton); + foreach (var item in recentFiles.Take(10).Select(f => new SceneReplacementFileItem(f.FullName)).ToList()) { var iconButton = new IconViewItem(new ListViewItem(item, listView), 70, 70, theme) @@ -210,27 +231,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab var listView = new ListView(ApplicationController.Instance.Library, theme); - foreach (var item in recentParts.Take(10).Select(f => new SceneReplacementFileItem(f.FullName)).ToList()) + var emptyPlateButton = new ImageWidget(AggContext.StaticData.LoadIcon("empty-workspace.png", 70, 70)) { - toolbar.AddChild(new IconViewItem(new ListViewItem(item, listView), 70, 70, theme) - { - Margin = new BorderDouble(right: 5) - }); - } - - var sideBar = new FlowLayoutWidget() - { - VAnchor = VAnchor.Center | VAnchor.Fit, - HAnchor = HAnchor.Fit + Margin = new BorderDouble(right: 5), + Selectable = true, + BackgroundColor = theme.MinimalShade, + Name = "Create Part" }; - - var createPart = new TextButton("Create Part".Localize(), theme) - { - Name = "Create Part Button", - Margin = theme.ButtonSpacing, - BackgroundColor = theme.MinimalShade - }; - createPart.Click += (s, e) => + emptyPlateButton.Click += async (s, e) => { UiThread.RunOnIdle(() => { @@ -249,9 +257,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab }).ConfigureAwait(false); }); }; - sideBar.AddChild(createPart); + toolbar.AddChild(emptyPlateButton); + + + foreach (var item in recentParts.Take(10).Select(f => new SceneReplacementFileItem(f.FullName)).ToList()) + { + toolbar.AddChild(new IconViewItem(new ListViewItem(item, listView), 70, 70, theme) + { + Margin = new BorderDouble(right: 5) + }); + } - toolbar.SetRightAnchorItem(sideBar); } } } \ No newline at end of file From 5d2e506dcfc12d7a9bbeaa03fb885253acc9f91c Mon Sep 17 00:00:00 2001 From: John Lewin Date: Thu, 19 Apr 2018 15:55:35 -0700 Subject: [PATCH 3/3] Purge StaticData image cache on theme change in debug --- ApplicationView/ApplicationController.cs | 8 ++++++++ StaticData/Icons/empty-workspace.png | Bin 0 -> 4567 bytes Submodules/agg-sharp | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 StaticData/Icons/empty-workspace.png diff --git a/ApplicationView/ApplicationController.cs b/ApplicationView/ApplicationController.cs index c7c9b72b4..a0aaeb9a1 100644 --- a/ApplicationView/ApplicationController.cs +++ b/ApplicationView/ApplicationController.cs @@ -726,6 +726,14 @@ namespace MatterHackers.MatterControl this.MenuTheme.RebuildTheme(clonedColors); this.RebuildSceneOperations(this.Theme); + +#if DEBUG + if (AggContext.StaticData is FileSystemStaticData staticData) + { + staticData.PurgeCache(); + } +#endif + }, ref unregisterEvents); this.Theme.RebuildTheme(ActiveTheme.Instance); diff --git a/StaticData/Icons/empty-workspace.png b/StaticData/Icons/empty-workspace.png new file mode 100644 index 0000000000000000000000000000000000000000..2934e2deb363e36b5f4e4ebc2ee433febdfa7b29 GIT binary patch literal 4567 zcmeAS@N?(olHy`uVBq!ia0y~yU~mIr4mJh`hC;nZEes3{Ea{HEjtmSN`?>!lv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