Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
/*
|
2022-07-16 07:46:44 -07:00
|
|
|
|
Copyright (c) 2022, Kevin Pope, John Lewin, Lars Brubaker
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
|
|
|
|
1. Redistributions of source code must retain the above copyright notice, this
|
|
|
|
|
|
list of conditions and the following disclaimer.
|
|
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
|
this list of conditions and the following disclaimer in the documentation
|
|
|
|
|
|
and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
|
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
|
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
|
|
|
|
The views and conclusions contained in the software and documentation are those
|
|
|
|
|
|
of the authors and should not be interpreted as representing official policies,
|
|
|
|
|
|
either expressed or implied, of the FreeBSD Project.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Linq;
|
2018-06-19 15:13:54 -07:00
|
|
|
|
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
using MatterHackers.Agg;
|
2017-08-20 02:34:39 -07:00
|
|
|
|
using MatterHackers.Agg.Platform;
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
using MatterHackers.Agg.UI;
|
2021-05-21 15:23:25 -07:00
|
|
|
|
using MatterHackers.ImageProcessing;
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
using MatterHackers.Localizations;
|
|
|
|
|
|
using MatterHackers.MatterControl.CustomWidgets;
|
|
|
|
|
|
using MatterHackers.MatterControl.PartPreviewWindow;
|
|
|
|
|
|
using MatterHackers.MatterControl.PrintQueue;
|
|
|
|
|
|
|
2022-03-15 17:51:28 -07:00
|
|
|
|
namespace MatterHackers.MatterControl.Library.Widgets
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
2018-10-10 13:33:16 -07:00
|
|
|
|
public class PrintLibraryWidget : GuiWidget, IIgnoredPopupChild
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
|
|
|
|
|
private FlowLayoutWidget buttonPanel;
|
2019-04-10 07:10:18 -07:00
|
|
|
|
private ILibraryContext libraryContext;
|
2018-10-24 21:20:56 -07:00
|
|
|
|
private LibraryListView libraryView;
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
private GuiWidget providerMessageContainer;
|
|
|
|
|
|
private TextWidget providerMessageWidget;
|
|
|
|
|
|
|
2018-10-24 21:10:39 -07:00
|
|
|
|
private List<LibraryAction> menuActions = new List<LibraryAction>();
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
|
2017-08-29 18:13:45 -07:00
|
|
|
|
private FolderBreadCrumbWidget breadCrumbWidget;
|
|
|
|
|
|
private GuiWidget searchInput;
|
|
|
|
|
|
private ILibraryContainer searchContainer;
|
|
|
|
|
|
|
2018-10-30 14:02:50 -07:00
|
|
|
|
private MainViewWidget mainViewWidget;
|
2017-09-29 21:30:51 -07:00
|
|
|
|
private ThemeConfig theme;
|
2018-01-01 11:23:52 -08:00
|
|
|
|
private OverflowBar navBar;
|
2018-01-17 08:02:07 -08:00
|
|
|
|
private GuiWidget searchButton;
|
2017-09-29 21:30:51 -07:00
|
|
|
|
|
2020-08-07 18:14:15 -07:00
|
|
|
|
public bool ShowContainers { get; private set; } = true;
|
|
|
|
|
|
|
2019-04-18 16:32:57 -07:00
|
|
|
|
public PrintLibraryWidget(MainViewWidget mainViewWidget, PartWorkspace workspace, ThemeConfig theme, Color libraryBackground, PopupMenuButton popupMenuButton)
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
2017-09-29 21:30:51 -07:00
|
|
|
|
this.theme = theme;
|
2018-10-30 14:02:50 -07:00
|
|
|
|
this.mainViewWidget = mainViewWidget;
|
2017-08-14 11:53:45 -07:00
|
|
|
|
this.Padding = 0;
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
this.AnchorAll();
|
|
|
|
|
|
|
|
|
|
|
|
var allControls = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
|
|
|
|
|
|
2019-04-10 07:10:18 -07:00
|
|
|
|
libraryContext = workspace.LibraryView;
|
|
|
|
|
|
|
|
|
|
|
|
libraryView = new LibraryListView(libraryContext, theme)
|
2017-06-08 10:14:06 -07:00
|
|
|
|
{
|
2017-12-07 14:54:41 -08:00
|
|
|
|
Name = "LibraryView",
|
2017-11-08 18:22:21 -08:00
|
|
|
|
// Drop containers if ShowContainers != 1
|
2020-08-07 18:14:15 -07:00
|
|
|
|
ContainerFilter = (container) => this.ShowContainers,
|
2019-04-18 16:32:57 -07:00
|
|
|
|
BackgroundColor = libraryBackground,
|
2018-01-16 22:55:28 -08:00
|
|
|
|
Border = new BorderDouble(top: 1)
|
2017-06-08 10:14:06 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
2022-07-16 07:46:44 -07:00
|
|
|
|
navBar = new OverflowBar(theme, "File".Localize())
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
2018-01-01 11:23:52 -08:00
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
VAnchor = VAnchor.Fit,
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
};
|
2017-08-29 18:13:45 -07:00
|
|
|
|
allControls.AddChild(navBar);
|
2018-07-15 10:07:30 -07:00
|
|
|
|
theme.ApplyBottomBorder(navBar);
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
|
2021-05-21 15:23:25 -07:00
|
|
|
|
var toolbar = new OverflowBar(StaticData.Instance.LoadIcon("fa-sort_16.png", 32, 32).SetToColor(theme.TextColor), theme)
|
2018-01-16 22:56:03 -08:00
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Stretch,
|
2018-04-26 07:56:29 -07:00
|
|
|
|
VAnchor = VAnchor.Fit,
|
2020-08-02 07:40:55 -07:00
|
|
|
|
Name = "Folders Toolbar",
|
2018-01-16 22:56:03 -08:00
|
|
|
|
};
|
2018-02-14 09:47:02 -08:00
|
|
|
|
|
2020-08-08 07:13:18 -07:00
|
|
|
|
toolbar.OverflowButton.ToolTipText = "Sorting".Localize();
|
2020-08-02 07:55:50 -07:00
|
|
|
|
|
2018-07-15 10:07:30 -07:00
|
|
|
|
theme.ApplyBottomBorder(toolbar, shadedBorder: true);
|
|
|
|
|
|
|
2018-02-14 09:47:02 -08:00
|
|
|
|
toolbar.OverflowButton.Name = "Print Library View Options";
|
2018-04-26 07:56:29 -07:00
|
|
|
|
toolbar.Padding = theme.ToolbarPadding;
|
|
|
|
|
|
|
2022-07-15 19:13:44 -07:00
|
|
|
|
toolbar.ExtendOverflowMenu = (popupMenu) => LibraryWidget.CreateSortingMenu(popupMenu, theme, libraryView);
|
2018-02-14 09:47:02 -08:00
|
|
|
|
|
2018-01-16 22:56:03 -08:00
|
|
|
|
allControls.AddChild(toolbar);
|
|
|
|
|
|
|
2020-08-02 07:40:55 -07:00
|
|
|
|
toolbar.AddChild(new HorizontalSpacer());
|
|
|
|
|
|
|
2020-08-08 07:13:18 -07:00
|
|
|
|
toolbar.AddChild(LibraryWidget.CreateViewOptionsMenuButton(theme,
|
2020-08-07 18:14:15 -07:00
|
|
|
|
libraryView,
|
|
|
|
|
|
(show) => ShowContainers = show,
|
|
|
|
|
|
() => ShowContainers));
|
2018-02-14 09:47:02 -08:00
|
|
|
|
|
2018-12-12 17:12:06 -08:00
|
|
|
|
breadCrumbWidget = new FolderBreadCrumbWidget(workspace.LibraryView, theme);
|
2017-08-29 18:13:45 -07:00
|
|
|
|
navBar.AddChild(breadCrumbWidget);
|
2017-06-11 14:33:33 -07:00
|
|
|
|
|
2020-07-18 13:48:38 -07:00
|
|
|
|
var searchPanel = new TextEditWithInlineCancel(theme)
|
2017-07-28 06:33:41 -07:00
|
|
|
|
{
|
2017-08-29 18:13:45 -07:00
|
|
|
|
Visible = false,
|
2018-01-17 08:02:07 -08:00
|
|
|
|
Margin = new BorderDouble(10, 0, 5, 0),
|
2017-06-11 14:33:33 -07:00
|
|
|
|
};
|
2020-07-18 13:48:38 -07:00
|
|
|
|
searchPanel.TextEditWidget.ActualTextEditWidget.EnterPressed += (s, e) =>
|
2017-06-11 14:33:33 -07:00
|
|
|
|
{
|
2017-08-29 18:13:45 -07:00
|
|
|
|
this.PerformSearch();
|
2017-07-28 06:33:41 -07:00
|
|
|
|
};
|
2018-01-23 12:35:27 -08:00
|
|
|
|
searchPanel.ResetButton.Click += (s, e) =>
|
2017-07-28 06:33:41 -07:00
|
|
|
|
{
|
2017-08-29 18:13:45 -07:00
|
|
|
|
breadCrumbWidget.Visible = true;
|
|
|
|
|
|
searchPanel.Visible = false;
|
2017-07-28 06:33:41 -07:00
|
|
|
|
|
2020-07-18 13:48:38 -07:00
|
|
|
|
searchPanel.TextEditWidget.Text = "";
|
2017-06-11 16:38:33 -07:00
|
|
|
|
|
2017-08-29 18:13:45 -07:00
|
|
|
|
this.ClearSearch();
|
2017-06-11 14:33:33 -07:00
|
|
|
|
};
|
2017-07-28 06:33:41 -07:00
|
|
|
|
|
2017-08-29 18:13:45 -07:00
|
|
|
|
// Store a reference to the input field
|
2020-07-18 13:48:38 -07:00
|
|
|
|
this.searchInput = searchPanel.TextEditWidget;
|
2017-08-29 18:13:45 -07:00
|
|
|
|
|
|
|
|
|
|
navBar.AddChild(searchPanel);
|
|
|
|
|
|
|
2018-04-07 22:51:10 -07:00
|
|
|
|
searchButton = theme.CreateSearchButton();
|
2018-01-17 08:02:07 -08:00
|
|
|
|
searchButton.Enabled = false;
|
2018-01-10 23:21:46 -08:00
|
|
|
|
searchButton.Name = "Search Library Button";
|
2017-08-29 18:13:45 -07:00
|
|
|
|
searchButton.Click += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (searchPanel.Visible)
|
|
|
|
|
|
{
|
|
|
|
|
|
PerformSearch();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2019-04-10 07:10:18 -07:00
|
|
|
|
searchContainer = libraryView.ActiveContainer;
|
2017-08-29 18:13:45 -07:00
|
|
|
|
|
|
|
|
|
|
breadCrumbWidget.Visible = false;
|
|
|
|
|
|
searchPanel.Visible = true;
|
|
|
|
|
|
searchInput.Focus();
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
navBar.AddChild(searchButton);
|
2017-06-11 14:33:33 -07:00
|
|
|
|
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
allControls.AddChild(libraryView);
|
|
|
|
|
|
|
2017-08-15 20:24:07 -07:00
|
|
|
|
buttonPanel = new FlowLayoutWidget()
|
|
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Stretch,
|
2018-04-07 22:51:10 -07:00
|
|
|
|
Padding = theme.ToolbarPadding,
|
2017-08-15 20:24:07 -07:00
|
|
|
|
};
|
|
|
|
|
|
AddLibraryButtonElements();
|
|
|
|
|
|
allControls.AddChild(buttonPanel);
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
|
|
|
|
|
|
allControls.AnchorAll();
|
|
|
|
|
|
|
|
|
|
|
|
this.AddChild(allControls);
|
2019-04-10 07:10:18 -07:00
|
|
|
|
|
|
|
|
|
|
// Register listeners
|
|
|
|
|
|
libraryView.SelectedItems.CollectionChanged += SelectedItems_CollectionChanged;
|
|
|
|
|
|
libraryContext.ContainerChanged += Library_ContainerChanged;
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-08-29 18:13:45 -07:00
|
|
|
|
private void PerformSearch()
|
|
|
|
|
|
{
|
|
|
|
|
|
UiThread.RunOnIdle(() =>
|
|
|
|
|
|
{
|
2019-04-10 07:10:18 -07:00
|
|
|
|
if (libraryContext.ActiveContainer.CustomSearch is ICustomSearch customSearch)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Do custom search
|
|
|
|
|
|
customSearch.ApplyFilter(searchInput.Text.Trim(), libraryContext);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2018-12-21 18:35:59 -08:00
|
|
|
|
{
|
2019-04-10 07:10:18 -07:00
|
|
|
|
// Do basic filtering
|
|
|
|
|
|
// filter the view with a predicate, applying the active sort
|
|
|
|
|
|
libraryView.ApplyFilter(searchInput.Text.Trim());
|
2018-12-21 18:35:59 -08:00
|
|
|
|
}
|
2017-08-29 18:13:45 -07:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-08-24 13:43:59 -07:00
|
|
|
|
public override void OnMouseDown(MouseEventArgs mouseEvent)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (mouseEvent.Button == MouseButtons.XButton1)
|
|
|
|
|
|
{
|
|
|
|
|
|
// user pressed the back button
|
|
|
|
|
|
breadCrumbWidget.NavigateBack();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
base.OnMouseDown(mouseEvent);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-08-29 18:13:45 -07:00
|
|
|
|
private void ClearSearch()
|
|
|
|
|
|
{
|
2018-01-21 21:07:14 -08:00
|
|
|
|
if (searchContainer == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-08-29 18:13:45 -07:00
|
|
|
|
UiThread.RunOnIdle(() =>
|
|
|
|
|
|
{
|
2019-04-10 07:10:18 -07:00
|
|
|
|
if (libraryContext.ActiveContainer.CustomSearch is ICustomSearch customSearch)
|
2018-12-21 18:35:59 -08:00
|
|
|
|
{
|
2019-04-10 07:10:18 -07:00
|
|
|
|
// Clear custom search
|
2018-12-21 18:35:59 -08:00
|
|
|
|
customSearch.ClearFilter();
|
2017-08-29 18:13:45 -07:00
|
|
|
|
|
2019-04-10 07:10:18 -07:00
|
|
|
|
// Restore the original ActiveContainer before search started - some containers may change context
|
|
|
|
|
|
libraryContext.ActiveContainer = searchContainer;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
// Clear basic filtering
|
|
|
|
|
|
libraryView.ClearFilter();
|
|
|
|
|
|
}
|
2017-08-29 18:13:45 -07:00
|
|
|
|
|
|
|
|
|
|
searchContainer = null;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
private void SelectedItems_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Reset)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var item in libraryView.Items)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.ViewWidget.IsSelected = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (e.OldItems != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var item in e.OldItems.OfType<ListViewItem>())
|
|
|
|
|
|
{
|
|
|
|
|
|
item.ViewWidget.IsSelected = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (e.NewItems != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var item in e.NewItems.OfType<ListViewItem>())
|
|
|
|
|
|
{
|
|
|
|
|
|
item.ViewWidget.IsSelected = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Library_ContainerChanged(object sender, ContainerChangedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Release
|
|
|
|
|
|
if (e.PreviousContainer != null)
|
|
|
|
|
|
{
|
2017-10-09 13:20:56 -07:00
|
|
|
|
e.PreviousContainer.ContentChanged -= UpdateStatus;
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var activeContainer = this.libraryView.ActiveContainer;
|
|
|
|
|
|
|
|
|
|
|
|
bool containerSupportsEdits = activeContainer is ILibraryWritableContainer;
|
|
|
|
|
|
|
2020-08-31 19:10:10 -07:00
|
|
|
|
// searchInput.Text = activeContainer.KeywordFilter;
|
2017-12-24 19:40:14 -08:00
|
|
|
|
breadCrumbWidget.SetContainer(activeContainer);
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
|
2017-10-09 13:20:56 -07:00
|
|
|
|
activeContainer.ContentChanged += UpdateStatus;
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
|
2018-01-17 08:02:07 -08:00
|
|
|
|
searchButton.Enabled = activeContainer.Parent != null;
|
|
|
|
|
|
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
UpdateStatus(null, null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void UpdateStatus(object sender, EventArgs e)
|
|
|
|
|
|
{
|
2021-04-25 13:55:47 -07:00
|
|
|
|
string message = this.libraryView.ActiveContainer?.HeaderMarkdown;
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
if (!string.IsNullOrEmpty(message))
|
|
|
|
|
|
{
|
|
|
|
|
|
providerMessageWidget.Text = message;
|
|
|
|
|
|
providerMessageContainer.Visible = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
providerMessageContainer.Visible = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void AddLibraryButtonElements()
|
|
|
|
|
|
{
|
2021-01-29 16:44:47 -08:00
|
|
|
|
buttonPanel.RemoveChildren();
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
|
|
|
|
|
|
// add in the message widget
|
|
|
|
|
|
providerMessageContainer = new GuiWidget()
|
|
|
|
|
|
{
|
2017-08-07 15:47:27 -07:00
|
|
|
|
VAnchor = VAnchor.Fit | VAnchor.Top,
|
|
|
|
|
|
HAnchor = HAnchor.Stretch,
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
Visible = false,
|
|
|
|
|
|
};
|
|
|
|
|
|
buttonPanel.AddChild(providerMessageContainer, -1);
|
|
|
|
|
|
|
|
|
|
|
|
providerMessageWidget = new TextWidget("")
|
|
|
|
|
|
{
|
|
|
|
|
|
PointSize = 8,
|
2017-08-07 15:47:27 -07:00
|
|
|
|
HAnchor = HAnchor.Right,
|
|
|
|
|
|
VAnchor = VAnchor.Bottom,
|
2018-10-13 17:58:54 -07:00
|
|
|
|
TextColor = theme.LightTextColor,
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
Margin = new BorderDouble(6),
|
|
|
|
|
|
AutoExpandBoundsToText = true,
|
|
|
|
|
|
};
|
|
|
|
|
|
providerMessageContainer.AddChild(providerMessageWidget);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-08-23 16:44:11 -07:00
|
|
|
|
public override void OnClosed(EventArgs e)
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
2019-04-10 07:10:18 -07:00
|
|
|
|
// Unregister listeners
|
|
|
|
|
|
libraryView.SelectedItems.CollectionChanged -= SelectedItems_CollectionChanged;
|
|
|
|
|
|
libraryContext.ContainerChanged -= Library_ContainerChanged;
|
|
|
|
|
|
if (libraryView.ActiveContainer != null)
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
2017-10-09 13:20:56 -07:00
|
|
|
|
libraryView.ActiveContainer.ContentChanged -= UpdateStatus;
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-04-10 07:10:18 -07:00
|
|
|
|
mainViewWidget = null;
|
|
|
|
|
|
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
base.OnClosed(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnMouseMove(MouseEventArgs mouseEvent)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (PositionWithinLocalBounds(mouseEvent.X, mouseEvent.Y)
|
|
|
|
|
|
&& mouseEvent.DragFiles?.Count > 0)
|
|
|
|
|
|
{
|
2017-12-28 17:44:01 -08:00
|
|
|
|
if (libraryView?.ActiveContainer.IsProtected == false)
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
2017-12-28 17:44:01 -08:00
|
|
|
|
// Allow drag-drop if IsLoadable or extension == '.zip'
|
|
|
|
|
|
mouseEvent.AcceptDrop = mouseEvent.DragFiles?.Count > 0
|
|
|
|
|
|
&& mouseEvent.DragFiles.TrueForAll(filePath => ApplicationController.Instance.IsLoadableFile(filePath)
|
|
|
|
|
|
|| (Path.GetExtension(filePath) is string extension
|
2019-01-03 21:43:35 -08:00
|
|
|
|
&& string.Equals(extension, ".zip", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
|| filePath.StartsWith("http", StringComparison.OrdinalIgnoreCase));
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
base.OnMouseMove(mouseEvent);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnMouseUp(MouseEventArgs mouseEvent)
|
|
|
|
|
|
{
|
|
|
|
|
|
// TODO: Does this fire when .AcceptDrop is false? Looks like it should
|
|
|
|
|
|
if (mouseEvent.DragFiles?.Count > 0
|
|
|
|
|
|
&& libraryView?.ActiveContainer.IsProtected == false)
|
|
|
|
|
|
{
|
|
|
|
|
|
var container = libraryView.ActiveContainer as ILibraryWritableContainer;
|
|
|
|
|
|
container?.Add(mouseEvent.DragFiles.Select(f => new FileSystemFileItem(f)));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
base.OnMouseUp(mouseEvent);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnLoad(EventArgs args)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Defer creating menu items until plugins have loaded
|
2019-04-10 07:10:18 -07:00
|
|
|
|
LibraryWidget.CreateMenuActions(libraryView, menuActions, libraryContext, mainViewWidget, theme, allowPrint: true);
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
|
2018-01-21 21:07:14 -08:00
|
|
|
|
navBar.OverflowButton.Name = "Print Library Overflow Menu";
|
|
|
|
|
|
navBar.ExtendOverflowMenu = (popupMenu) =>
|
2017-05-23 10:51:12 -07:00
|
|
|
|
{
|
2018-01-21 21:07:14 -08:00
|
|
|
|
// Create menu items in the DropList for each element in this.menuActions
|
|
|
|
|
|
foreach (var menuAction in menuActions)
|
2017-06-07 08:19:30 -07:00
|
|
|
|
{
|
2018-01-21 21:07:14 -08:00
|
|
|
|
if (menuAction is MenuSeparator)
|
2017-11-10 13:12:02 -08:00
|
|
|
|
{
|
2018-10-24 21:13:10 -07:00
|
|
|
|
popupMenu.CreateSeparator();
|
2018-01-21 21:07:14 -08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2018-04-07 11:07:38 -07:00
|
|
|
|
var menuItem = popupMenu.CreateMenuItem(menuAction.Title, menuAction.Icon);
|
2018-01-21 21:07:14 -08:00
|
|
|
|
menuItem.Name = $"{menuAction.Title} Menu Item";
|
2018-10-07 12:08:43 -07:00
|
|
|
|
menuItem.Enabled = menuAction.Action != null && menuAction.IsEnabled(libraryView.SelectedItems, libraryView);
|
2018-01-21 21:07:14 -08:00
|
|
|
|
menuItem.Click += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
menuAction.Action?.Invoke(libraryView.SelectedItems.Select(i => i.Model), libraryView);
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-12-19 17:08:02 -08:00
|
|
|
|
};
|
2017-05-23 10:51:12 -07:00
|
|
|
|
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
base.OnLoad(args);
|
|
|
|
|
|
}
|
2018-05-09 07:52:05 -07:00
|
|
|
|
|
2018-10-11 15:04:03 -07:00
|
|
|
|
public bool KeepMenuOpen => this.ContainsFocus;
|
2018-10-10 13:33:16 -07:00
|
|
|
|
|
2018-05-09 07:52:05 -07:00
|
|
|
|
public enum ListViewModes
|
|
|
|
|
|
{
|
|
|
|
|
|
RowListView,
|
|
|
|
|
|
IconListView,
|
|
|
|
|
|
IconListView18,
|
|
|
|
|
|
IconListView70,
|
|
|
|
|
|
IconListView256
|
|
|
|
|
|
}
|
2018-01-14 10:36:05 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-07-18 13:48:38 -07:00
|
|
|
|
public class TextEditWithInlineCancel : GuiWidget
|
2018-01-14 10:36:05 -08:00
|
|
|
|
{
|
2022-07-15 17:28:39 -07:00
|
|
|
|
public ThemedTextEditWidget TextEditWidget { get; }
|
2019-05-12 09:25:18 -07:00
|
|
|
|
|
2018-11-21 17:36:20 -08:00
|
|
|
|
public GuiWidget ResetButton { get; }
|
2018-01-14 10:36:05 -08:00
|
|
|
|
|
2020-07-18 13:48:38 -07:00
|
|
|
|
public TextEditWithInlineCancel(ThemeConfig theme, string emptyText = null)
|
2017-08-29 18:13:45 -07:00
|
|
|
|
{
|
2020-07-18 13:48:38 -07:00
|
|
|
|
if (emptyText == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
emptyText = "Search".Localize();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-14 10:36:05 -08:00
|
|
|
|
this.VAnchor = VAnchor.Center | VAnchor.Fit;
|
|
|
|
|
|
this.HAnchor = HAnchor.Stretch;
|
2017-08-29 18:13:45 -07:00
|
|
|
|
|
2022-07-15 17:28:39 -07:00
|
|
|
|
TextEditWidget = new ThemedTextEditWidget("", theme, messageWhenEmptyAndNotSelected: emptyText)
|
2017-08-29 18:13:45 -07:00
|
|
|
|
{
|
2018-01-14 10:36:05 -08:00
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
VAnchor = VAnchor.Center
|
|
|
|
|
|
};
|
2020-07-18 13:48:38 -07:00
|
|
|
|
this.AddChild(TextEditWidget);
|
2018-01-14 10:36:05 -08:00
|
|
|
|
|
2020-07-18 13:48:38 -07:00
|
|
|
|
this.ResetButton = theme.CreateSmallResetButton();
|
|
|
|
|
|
ResetButton.HAnchor |= HAnchor.Right;
|
|
|
|
|
|
ResetButton.VAnchor |= VAnchor.Center;
|
|
|
|
|
|
ResetButton.Name = "Close Search";
|
|
|
|
|
|
ResetButton.ToolTipText = "Clear".Localize();
|
2018-01-23 12:35:27 -08:00
|
|
|
|
|
2020-07-18 13:48:38 -07:00
|
|
|
|
this.AddChild(ResetButton);
|
2017-08-29 18:13:45 -07:00
|
|
|
|
}
|
2018-01-17 23:17:49 -08:00
|
|
|
|
|
2020-08-31 19:10:10 -07:00
|
|
|
|
public override void OnLoad(EventArgs args)
|
|
|
|
|
|
{
|
|
|
|
|
|
TextEditWidget.Focus();
|
|
|
|
|
|
base.OnLoad(args);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-17 23:17:49 -08:00
|
|
|
|
public override string Text
|
|
|
|
|
|
{
|
2020-07-18 13:48:38 -07:00
|
|
|
|
get => TextEditWidget.ActualTextEditWidget.Text;
|
|
|
|
|
|
set => TextEditWidget.ActualTextEditWidget.Text = value;
|
2018-01-17 23:17:49 -08:00
|
|
|
|
}
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|