diff --git a/ApplicationView/ThemeConfig.cs b/ApplicationView/ThemeConfig.cs index dde9f9c82..abcbf4417 100644 --- a/ApplicationView/ThemeConfig.cs +++ b/ApplicationView/ThemeConfig.cs @@ -68,7 +68,6 @@ namespace MatterHackers.MatterControl public TextImageButtonFactory WhiteButtonFactory; public TextImageButtonFactory ButtonFactory { get; private set; } - public TextImageButtonFactory SmallMarginButtonFactory { get; private set; } public TextImageButtonFactory WizardButtons { get; private set; } /// @@ -180,12 +179,6 @@ namespace MatterHackers.MatterControl this.ButtonFactory = new TextImageButtonFactory(commonOptions); - this.SmallMarginButtonFactory = new TextImageButtonFactory(new ButtonFactoryOptions(commonOptions) - { - Margin = new BorderDouble(8, 0), - ImageSpacing = 6 - }); - this.WizardButtons = new TextImageButtonFactory(new ButtonFactoryOptions(commonOptions) { #if __ANDROID__ diff --git a/Library/Widgets/ListView/PrintItemAction.cs b/Library/Widgets/ListView/PrintItemAction.cs index 3a6d101eb..cb9a2334d 100644 --- a/Library/Widgets/ListView/PrintItemAction.cs +++ b/Library/Widgets/ListView/PrintItemAction.cs @@ -43,7 +43,7 @@ namespace MatterHackers.MatterControl.PrintQueue public Action, ListView> Action { get; set; } public Func, ListView, bool> IsEnabled { get; set; } - + public string ToolTipText { get; internal set; } internal PopupMenu.MenuItem MenuItem { get; set; } } diff --git a/Library/Widgets/PrintLibraryWidget.cs b/Library/Widgets/PrintLibraryWidget.cs index 54976194f..18b8e941d 100644 --- a/Library/Widgets/PrintLibraryWidget.cs +++ b/Library/Widgets/PrintLibraryWidget.cs @@ -46,8 +46,6 @@ namespace MatterHackers.MatterControl.PrintLibrary { public class PrintLibraryWidget : GuiWidget { - private Button addToLibraryButton; - private Button createFolderButton; private FlowLayoutWidget buttonPanel; private ListView libraryView; private GuiWidget providerMessageContainer; @@ -398,13 +396,8 @@ namespace MatterHackers.MatterControl.PrintLibrary var activeContainer = this.libraryView.ActiveContainer; - var writableContainer = activeContainer as ILibraryWritableContainer; - bool containerSupportsEdits = activeContainer is ILibraryWritableContainer; - addToLibraryButton.Enabled = containerSupportsEdits; - createFolderButton.Enabled = containerSupportsEdits && writableContainer?.AllowAction(ContainerActions.AddContainers) == true; - searchInput.Text = activeContainer.KeywordFilter; breadCrumbWidget.SetContainer(activeContainer); @@ -433,60 +426,6 @@ namespace MatterHackers.MatterControl.PrintLibrary { buttonPanel.RemoveAllChildren(); - // the add button - addToLibraryButton = theme.SmallMarginButtonFactory.Generate("Add".Localize(), AggContext.StaticData.LoadIcon("cube.png", IconColor.Theme)); - addToLibraryButton.Enabled = false; // The library selector (the first library selected) is protected so we can't add to it. - addToLibraryButton.ToolTipText = "Add an .stl, .obj, .amf, .gcode or .zip file to the Library".Localize(); - addToLibraryButton.Name = "Library Add Button"; - addToLibraryButton.Margin = new BorderDouble(0, 0, 3, 0); - addToLibraryButton.Click += (sender, e) => UiThread.RunOnIdle(() => - { - AggContext.FileDialogs.OpenFileDialog( - new OpenFileDialogParams(ApplicationSettings.OpenPrintableFileParams, multiSelect: true), - (openParams) => - { - if (openParams.FileNames != null) - { - var writableContainer = this.libraryView.ActiveContainer as ILibraryWritableContainer; - if (writableContainer != null - && openParams.FileNames.Length > 0) - { - writableContainer.Add(openParams.FileNames.Select(f => new FileSystemFileItem(f))); - } - } - }); - }); - buttonPanel.AddChild(addToLibraryButton); - - // the create folder button - createFolderButton = theme.SmallMarginButtonFactory.Generate("Create Folder".Localize()); - createFolderButton.Enabled = false; // Disabled until changed by the ActiveContainer - createFolderButton.Name = "Create Folder From Library Button"; - createFolderButton.Margin = new BorderDouble(0, 0, 3, 0); - createFolderButton.Click += (sender, e) => - { - DialogWindow.Show( - new InputBoxPage( - "Create Folder".Localize(), - "Folder Name".Localize(), - "", - "Enter New Name Here".Localize(), - "Create".Localize(), - (newName) => - { - if (!string.IsNullOrEmpty(newName) - && this.libraryView.ActiveContainer is ILibraryWritableContainer writableContainer) - { - writableContainer.Add(new[] - { - new CreateFolderItem() { Name = newName } - }); - } - })); - - }; - buttonPanel.AddChild(createFolderButton); - // add in the message widget providerMessageContainer = new GuiWidget() { @@ -510,6 +449,70 @@ namespace MatterHackers.MatterControl.PrintLibrary private void CreateMenuActions() { + menuActions.Add(new PrintItemAction() + { + Title = "Add".Localize(), + ToolTipText = "Add an.stl, .obj, .amf, .gcode or.zip file to the Library".Localize(), + Action = (selectedLibraryItems, listView) => + { + /* + AggContext.StaticData.LoadIcon("cube.png", IconColor.Theme) + Name = "Library Add Button"; + */ + + AggContext.FileDialogs.OpenFileDialog( + new OpenFileDialogParams(ApplicationSettings.OpenPrintableFileParams, multiSelect: true), + (openParams) => + { + if (openParams.FileNames != null) + { + var writableContainer = this.libraryView.ActiveContainer as ILibraryWritableContainer; + if (writableContainer != null + && openParams.FileNames.Length > 0) + { + writableContainer.Add(openParams.FileNames.Select(f => new FileSystemFileItem(f))); + } + } + }); + }, + IsEnabled = (s, l) => this.libraryView.ActiveContainer is ILibraryWritableContainer + }); + + menuActions.Add(new PrintItemAction() + { + Title = "Create Folder".Localize(), + Action = (selectedLibraryItems, listView) => + { + /* + Name = "Create Folder From Library Button"; + */ + + DialogWindow.Show( + new InputBoxPage( + "Create Folder".Localize(), + "Folder Name".Localize(), + "", + "Enter New Name Here".Localize(), + "Create".Localize(), + (newName) => + { + if (!string.IsNullOrEmpty(newName) + && this.libraryView.ActiveContainer is ILibraryWritableContainer writableContainer) + { + writableContainer.Add(new[] + { + new CreateFolderItem() { Name = newName } + }); + } + })); + }, + IsEnabled = (s, l) => + { + return this.libraryView.ActiveContainer is ILibraryWritableContainer writableContainer + && writableContainer?.AllowAction(ContainerActions.AddContainers) == true; + } + }); + menuActions.Add(new PrintItemAction() {