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/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/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 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); diff --git a/StaticData/Icons/empty-workspace.png b/StaticData/Icons/empty-workspace.png new file mode 100644 index 000000000..2934e2deb Binary files /dev/null and b/StaticData/Icons/empty-workspace.png differ diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 5a72ceef8..9c491cffc 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 5a72ceef8b2c7aa1c2c43b97907d61f9c421765f +Subproject commit 9c491cffc88bb8b5733a1c5927c63e7d836859a4