private void ClearSearch() { if (searchContainer == null) { return; } UiThread.RunOnIdle(() => { if (libraryContext.ActiveContainer.CustomSearch is ICustomSearch customSearch) { // Clear custom search customSearch.ClearFilter(); // Restore the original ActiveContainer before search started - some containers may change context libraryContext.ActiveContainer = searchContainer; } else { // Clear basic filtering libraryView.ClearFilter(); } searchContainer = null; }); }
private TreeNode CreateTreeNode(ILibraryItem containerItem, ILibraryContainer parentContainer) { var treeNode = new ContainerTreeNode(theme, parentContainer) { Text = containerItem.Name, Tag = containerItem, AlwaysExpandable = true }; ApplicationController.Instance.Library.LoadItemThumbnail( (icon) => { treeNode.Image = icon.SetPreMultiply(); }, null, containerItem, null, 20, 20, theme).ConfigureAwait(false); treeNode.ExpandedChanged += (s, e) => { this.EnsureExpanded(containerItem, treeNode).ConfigureAwait(false); }; return(treeNode); }
public static IEnumerable <ILibraryContainer> AncestorsAndSelf(this ILibraryContainer item) { var container = item; while (container != null) { yield return(container); container = container.Parent; } }
public static IEnumerable <ILibraryContainer> Ancestors(this ILibraryContainer item) { var context = item.Parent; while (context != null) { yield return(context); context = context.Parent; } }
public PrintItemWrapper(PrintItem printItem, ILibraryContainer sourceLibraryProviderLocator = null) { this.PrintItem = printItem; if (FileLocation != null) { this.fileType = Path.GetExtension(FileLocation).ToUpper(); } SourceLibraryProviderLocator = sourceLibraryProviderLocator; }
private void ClearSearch() { if (searchContainer == null) { return; } UiThread.RunOnIdle(() => { searchContainer.KeywordFilter = ""; // Restore the original ActiveContainer before search started - some containers may change context ApplicationController.Instance.Library.ActiveContainer = searchContainer; searchContainer = null; }); }
public static void Rename(this ILibraryContainer libraryContainer, ILibraryItem libraryItem) { if (libraryItem == null) { return; } var contentProvider = ApplicationController.Instance.Library.GetContentProvider(libraryItem) as ISceneContentProvider; DialogWindow.Show( new InputBoxPage( "Rename Item".Localize(), "Name".Localize(), libraryItem.Name, "Enter New Name Here".Localize(), "Rename".Localize(), (newName) => { if (libraryContainer is ILibraryWritableContainer writableContainer) { writableContainer.Rename(libraryItem, newName); } })); }
private void OnContainerChanged(ILibraryContainer container) { ContentChanged?.Invoke(this, new ContainerChangedEventArgs(container, null)); }
public void SetContainer(ILibraryContainer currentContainer) { this.CloseChildren(); var backButton = new IconButton(StaticData.Instance.LoadIcon(Path.Combine("Library", "back.png"), 20, 20).SetToColor(theme.TextColor), theme) { VAnchor = VAnchor.Fit | VAnchor.Center, Enabled = currentContainer.Parent != null, Name = "Library Up Button", ToolTipText = "Click to go back".Localize(), Margin = theme.ButtonSpacing, MinimumSize = new Vector2(theme.ButtonHeight, theme.ButtonHeight) }; backButton.Click += (s, e) => { NavigateBack(); }; this.AddChild(backButton); bool firstItem = true; if (this.Width < 250) { var containerButton = new LinkLabel((libraryContext.ActiveContainer.Name == null ? "?" : libraryContext.ActiveContainer.Name), theme) { Name = "Bread Crumb Button " + libraryContext.ActiveContainer.Name, VAnchor = VAnchor.Center, Margin = theme.ButtonSpacing, TextColor = theme.TextColor }; this.AddChild(containerButton); } else { var extraSpacing = (theme.ButtonSpacing).Clone(left: theme.ButtonSpacing.Right * .4); foreach (var container in currentContainer.AncestorsAndSelf().Reverse()) { if (!firstItem) { // Add path separator this.AddChild(new TextWidget("/", pointSize: theme.DefaultFontSize + 1, textColor: theme.TextColor) { VAnchor = VAnchor.Center, Margin = extraSpacing.Clone(top: 2) }); } // Create a button for each container var containerButton = new LinkLabel(container.Name, theme) { Name = "Bread Crumb Button " + container.Name, VAnchor = VAnchor.Center, Margin = theme.ButtonSpacing.Clone(top: 1), TextColor = theme.TextColor }; containerButton.Click += (s, e) => { UiThread.RunOnIdle(() => libraryContext.ActiveContainer = container); }; this.AddChild(containerButton); firstItem = false; } var childrenWidth = this.GetChildrenBoundsIncludingMargins().Width; // while all the buttons don't fit in the control if (this.Parent != null && this.Width > 0 && this.Children.Count > 4 && childrenWidth > (this.Width - 20)) { // lets take out the > and put in a ... var removedWidth = this.RemoveChild(1).Width; var separator = new TextWidget("...", textColor: theme.TextColor) { VAnchor = VAnchor.Center, Margin = new BorderDouble(right: 5) }; removedWidth -= this.AddChild(separator, 1).Width; while (childrenWidth - removedWidth > this.Width - 20 && this.Children.Count > 4) { removedWidth += this.RemoveChild(3).Width; removedWidth += this.RemoveChild(2).Width; } UiThread.RunOnIdle(() => this.Width = this.Width + 1); } } }
public async Task LoadItemThumbnail() { ILibraryItem libraryItem = listViewItem.Model; ILibraryContainer libraryContainer = listViewItem.Container; // Load from cache via LibraryID var thumbnail = ApplicationController.Instance.Thumbnails.LoadCachedImage(libraryItem, thumbWidth, thumbHeight); if (thumbnail != null) { this.SetItemThumbnail(thumbnail); return; } if (thumbnail == null) { // Ask the container - allows the container to provide its own interpretation of the item thumbnail thumbnail = await libraryContainer.GetThumbnail(libraryItem, thumbWidth, thumbHeight); } if (thumbnail == null && libraryItem is IThumbnail) { // If the item provides its own thumbnail, try to collect it thumbnail = await(libraryItem as IThumbnail).GetThumbnail(thumbWidth, thumbHeight); } if (thumbnail == null) { // Ask content provider - allows type specific thumbnail creation var contentProvider = ApplicationController.Instance.Library.GetContentProvider(libraryItem); if (contentProvider != null) { // Before we have a thumbnail set to the content specific thumbnail thumbnail = contentProvider.DefaultImage; if (contentProvider is MeshContentProvider meshContentProvider) { // Store meshContentProvider reference this.meshContentProvider = meshContentProvider; // Schedule work this.ScheduleRaytraceOperation(); } else { // Show processing image this.SetItemThumbnail(theme.GeneratingThumbnailIcon); // Ask the provider for a content specific thumbnail thumbnail = await contentProvider.GetThumbnail(libraryItem, thumbWidth, thumbHeight); } } } if (thumbnail == null) { // Use the listview defaults thumbnail = ((libraryItem is ILibraryContainerLink) ? defaultFolderIcon : defaultItemIcon).AlphaToPrimaryAccent(); } this.SetItemThumbnail(thumbnail); }
public PrintLibraryWidget(MainViewWidget mainViewWidget, PartWorkspace workspace, ThemeConfig theme, Color libraryBackground, PopupMenuButton popupMenuButton) { this.theme = theme; this.mainViewWidget = mainViewWidget; this.Padding = 0; this.AnchorAll(); var allControls = new FlowLayoutWidget(FlowDirection.TopToBottom); libraryContext = workspace.LibraryView; libraryView = new LibraryListView(libraryContext, theme) { Name = "LibraryView", // Drop containers if ShowContainers != 1 ContainerFilter = (container) => this.ShowContainers, BackgroundColor = libraryBackground, Border = new BorderDouble(top: 1) }; navBar = new OverflowBar(theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, }; allControls.AddChild(navBar); theme.ApplyBottomBorder(navBar); var toolbar = new OverflowBar(StaticData.Instance.LoadIcon("fa-sort_16.png", 32, 32, theme.InvertIcons), theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Name = "Folders Toolbar", }; toolbar.OverflowButton.ToolTipText = "Sorting".Localize(); theme.ApplyBottomBorder(toolbar, shadedBorder: true); toolbar.OverflowButton.Name = "Print Library View Options"; toolbar.Padding = theme.ToolbarPadding; toolbar.ExtendOverflowMenu = (popupMenu) => LibraryWidget.CreateSortingMenu(popupMenu, libraryView); allControls.AddChild(toolbar); toolbar.AddChild(new HorizontalSpacer()); toolbar.AddChild(LibraryWidget.CreateViewOptionsMenuButton(theme, libraryView, (show) => ShowContainers = show, () => ShowContainers)); breadCrumbWidget = new FolderBreadCrumbWidget(workspace.LibraryView, theme); navBar.AddChild(breadCrumbWidget); var searchPanel = new TextEditWithInlineCancel(theme) { Visible = false, Margin = new BorderDouble(10, 0, 5, 0), }; searchPanel.TextEditWidget.ActualTextEditWidget.EnterPressed += (s, e) => { this.PerformSearch(); }; searchPanel.ResetButton.Click += (s, e) => { breadCrumbWidget.Visible = true; searchPanel.Visible = false; searchPanel.TextEditWidget.Text = ""; this.ClearSearch(); }; // Store a reference to the input field this.searchInput = searchPanel.TextEditWidget; navBar.AddChild(searchPanel); searchButton = theme.CreateSearchButton(); searchButton.Enabled = false; searchButton.Name = "Search Library Button"; searchButton.Click += (s, e) => { if (searchPanel.Visible) { PerformSearch(); } else { searchContainer = libraryView.ActiveContainer; breadCrumbWidget.Visible = false; searchPanel.Visible = true; searchInput.Focus(); } }; navBar.AddChild(searchButton); allControls.AddChild(libraryView); buttonPanel = new FlowLayoutWidget() { HAnchor = HAnchor.Stretch, Padding = theme.ToolbarPadding, }; AddLibraryButtonElements(); allControls.AddChild(buttonPanel); allControls.AnchorAll(); this.AddChild(allControls); // Register listeners libraryView.SelectedItems.CollectionChanged += SelectedItems_CollectionChanged; libraryContext.ContainerChanged += Library_ContainerChanged; }
public LibraryWidget(MainViewWidget mainViewWidget, ThemeConfig theme) { this.theme = theme; this.mainViewWidget = mainViewWidget; this.Padding = 0; this.AnchorAll(); var allControls = new FlowLayoutWidget(FlowDirection.TopToBottom); libraryContext = ApplicationController.Instance.LibraryTabContext; libraryView = new LibraryListView(libraryContext, theme) { Name = "LibraryView", // Drop containers if ShowContainers != 1 ContainerFilter = (container) => UserSettings.Instance.ShowContainers, BackgroundColor = theme.BackgroundColor, Border = new BorderDouble(top: 1), DoubleClickAction = LibraryListView.DoubleClickActions.PreviewItem }; navBar = new OverflowBar(theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, }; allControls.AddChild(navBar); theme.ApplyBottomBorder(navBar); breadCrumbWidget = new FolderBreadCrumbWidget(libraryContext, theme); navBar.AddChild(breadCrumbWidget); var searchPanel = new SearchInputBox(theme) { Visible = false, Margin = new BorderDouble(10, 0, 5, 0), }; searchPanel.searchInput.ActualTextEditWidget.EnterPressed += (s, e) => { this.PerformSearch(); }; searchPanel.ResetButton.Click += (s, e) => { breadCrumbWidget.Visible = true; searchPanel.Visible = false; searchPanel.searchInput.Text = ""; this.ClearSearch(); }; // Store a reference to the input field this.searchInput = searchPanel.searchInput; navBar.AddChild(searchPanel); searchButton = theme.CreateSearchButton(); searchButton.Enabled = false; searchButton.Name = "Search Library Button"; searchButton.Click += (s, e) => { if (searchPanel.Visible) { PerformSearch(); } else { searchContainer = libraryContext.ActiveContainer; breadCrumbWidget.Visible = false; searchPanel.Visible = true; searchInput.Focus(); } }; navBar.AddChild(searchButton); PopupMenuButton viewOptionsButton; navBar.AddChild( viewOptionsButton = new PopupMenuButton( new ImageWidget(AggContext.StaticData.LoadIcon("fa-sort_16.png", 32, 32, theme.InvertIcons)) { //VAnchor = VAnchor.Center }, theme) { AlignToRightEdge = true, Name = "Print Library View Options" }); viewOptionsButton.DynamicPopupContent = () => { var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme); var siblingList = new List <GuiWidget>(); popupMenu.CreateBoolMenuItem( "Date Created".Localize(), () => libraryView.ActiveSort.HasFlag(SortKey.CreatedDate), (v) => libraryView.ActiveSort = SortKey.CreatedDate, useRadioStyle: true, siblingRadioButtonList: siblingList); popupMenu.CreateBoolMenuItem( "Date Modified".Localize(), () => libraryView.ActiveSort.HasFlag(SortKey.ModifiedDate), (v) => libraryView.ActiveSort = SortKey.ModifiedDate, useRadioStyle: true, siblingRadioButtonList: siblingList); popupMenu.CreateBoolMenuItem( "Name".Localize(), () => libraryView.ActiveSort.HasFlag(SortKey.Name), (v) => libraryView.ActiveSort = SortKey.Name, useRadioStyle: true, siblingRadioButtonList: siblingList); popupMenu.CreateSeparator(); siblingList = new List <GuiWidget>(); popupMenu.CreateBoolMenuItem( "Ascending".Localize(), () => libraryView.Ascending, (v) => libraryView.Ascending = true, useRadioStyle: true, siblingRadioButtonList: siblingList); popupMenu.CreateBoolMenuItem( "Descending".Localize(), () => !libraryView.Ascending, (v) => libraryView.Ascending = false, useRadioStyle: true, siblingRadioButtonList: siblingList); return(popupMenu); }; PopupMenuButton viewMenuButton; navBar.AddChild( viewMenuButton = new PopupMenuButton( new ImageWidget(AggContext.StaticData.LoadIcon("mi-view-list_10.png", 32, 32, theme.InvertIcons)) { //VAnchor = VAnchor.Center }, theme) { AlignToRightEdge = true }); viewMenuButton.DynamicPopupContent = () => { var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme); var listView = this.libraryView; var siblingList = new List <GuiWidget>(); popupMenu.CreateBoolMenuItem( "View List".Localize(), () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.RowListView, (isChecked) => { ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.RowListView; listView.ListContentView = new RowListView(theme); listView.Reload().ConfigureAwait(false); }, useRadioStyle: true, siblingRadioButtonList: siblingList); #if DEBUG popupMenu.CreateBoolMenuItem( "View XSmall Icons".Localize(), () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView18, (isChecked) => { ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView18; listView.ListContentView = new IconListView(theme, 18); listView.Reload().ConfigureAwait(false); }, useRadioStyle: true, siblingRadioButtonList: siblingList); popupMenu.CreateBoolMenuItem( "View Small Icons".Localize(), () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView70, (isChecked) => { ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView70; listView.ListContentView = new IconListView(theme, 70); listView.Reload().ConfigureAwait(false); }, useRadioStyle: true, siblingRadioButtonList: siblingList); #endif popupMenu.CreateBoolMenuItem( "View Icons".Localize(), () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView, (isChecked) => { ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView; listView.ListContentView = new IconListView(theme); listView.Reload().ConfigureAwait(false); }, useRadioStyle: true, siblingRadioButtonList: siblingList); popupMenu.CreateBoolMenuItem( "View Large Icons".Localize(), () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView256, (isChecked) => { ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView256; listView.ListContentView = new IconListView(theme, 256); listView.Reload().ConfigureAwait(false); }, useRadioStyle: true, siblingRadioButtonList: siblingList); return(popupMenu); }; var horizontalSplitter = new Splitter() { SplitterDistance = UserSettings.Instance.LibraryViewWidth, SplitterSize = theme.SplitterWidth, SplitterBackground = theme.SplitterBackground }; horizontalSplitter.AnchorAll(); horizontalSplitter.DistanceChanged += (s, e) => { UserSettings.Instance.LibraryViewWidth = horizontalSplitter.SplitterDistance; }; allControls.AddChild(horizontalSplitter); libraryTreeView = new TreeView(theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, Margin = 5 }; libraryTreeView.AfterSelect += async(s, e) => { if (libraryTreeView.SelectedNode is ContainerTreeNode treeNode) { if (!treeNode.ContainerAcquired) { await this.EnsureExpanded(treeNode.Tag as ILibraryItem, treeNode); } if (treeNode.ContainerAcquired) { libraryContext.ActiveContainer = treeNode.Container; } } }; horizontalSplitter.Panel1.AddChild(libraryTreeView); var rootColumn = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit, Margin = new BorderDouble(left: 10) }; libraryTreeView.AddChild(rootColumn); if (AppContext.IsLoading) { ApplicationController.StartupActions.Add(new ApplicationController.StartupAction() { Title = "Initializing Library".Localize(), Priority = 0, Action = () => { this.LoadRootLibraryNodes(rootColumn); } }); } else { this.LoadRootLibraryNodes(rootColumn); } horizontalSplitter.Panel2.AddChild(libraryView); buttonPanel = new FlowLayoutWidget() { HAnchor = HAnchor.Stretch, Padding = theme.ToolbarPadding, }; AddLibraryButtonElements(); allControls.AddChild(buttonPanel); allControls.AnchorAll(); this.AddChild(allControls); // Register listeners libraryView.SelectedItems.CollectionChanged += SelectedItems_CollectionChanged; libraryContext.ContainerChanged += Library_ContainerChanged; }
public PrintLibraryWidget(PartPreviewContent partPreviewContent, ThemeConfig theme) { this.theme = theme; this.partPreviewContent = partPreviewContent; this.Padding = 0; this.AnchorAll(); var allControls = new FlowLayoutWidget(FlowDirection.TopToBottom); libraryView = new ListView(ApplicationController.Instance.Library, theme) { Name = "LibraryView", // Drop containers if ShowContainers != 1 ContainerFilter = (container) => UserSettings.Instance.ShowContainers, BackgroundColor = theme.ActiveTabColor, Border = new BorderDouble(top: 1) }; libraryView.SelectedItems.CollectionChanged += SelectedItems_CollectionChanged; ApplicationController.Instance.Library.ContainerChanged += Library_ContainerChanged; navBar = new OverflowBar(theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, }; allControls.AddChild(navBar); theme.ApplyBottomBorder(navBar); var toolbar = new OverflowBar(AggContext.StaticData.LoadIcon("fa-sort_16.png", 32, 32, theme.InvertIcons), theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Name = "Folders Toolbar" }; theme.ApplyBottomBorder(toolbar, shadedBorder: true); toolbar.OverflowButton.Name = "Print Library View Options"; toolbar.Padding = theme.ToolbarPadding; toolbar.ExtendOverflowMenu = (popupMenu) => { var siblingList = new List <GuiWidget>(); popupMenu.CreateBoolMenuItem( "Date Created".Localize(), () => libraryView.ActiveSort == ListView.SortKey.CreatedDate, (v) => libraryView.ActiveSort = ListView.SortKey.CreatedDate, useRadioStyle: true, siblingRadioButtonList: siblingList); popupMenu.CreateBoolMenuItem( "Date Modified".Localize(), () => libraryView.ActiveSort == ListView.SortKey.ModifiedDate, (v) => libraryView.ActiveSort = ListView.SortKey.ModifiedDate, useRadioStyle: true, siblingRadioButtonList: siblingList); popupMenu.CreateBoolMenuItem( "Name".Localize(), () => libraryView.ActiveSort == ListView.SortKey.Name, (v) => libraryView.ActiveSort = ListView.SortKey.Name, useRadioStyle: true, siblingRadioButtonList: siblingList); popupMenu.CreateHorizontalLine(); siblingList = new List <GuiWidget>(); popupMenu.CreateBoolMenuItem( "Ascending".Localize(), () => libraryView.Ascending, (v) => libraryView.Ascending = true, useRadioStyle: true, siblingRadioButtonList: siblingList); popupMenu.CreateBoolMenuItem( "Descending".Localize(), () => !libraryView.Ascending, (v) => libraryView.Ascending = false, useRadioStyle: true, siblingRadioButtonList: siblingList); }; allControls.AddChild(toolbar); var showFolders = new ExpandCheckboxButton("Folders".Localize(), theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit | VAnchor.Center, Margin = theme.ButtonSpacing, Name = "Show Folders Toggle", Checked = UserSettings.Instance.ShowContainers, }; showFolders.SetIconMargin(theme.ButtonSpacing); showFolders.CheckedStateChanged += async(s, e) => { UserSettings.Instance.set(UserSettingsKey.ShowContainers, showFolders.Checked ? "1" : "0"); await libraryView.Reload(); }; toolbar.AddChild(showFolders); var openButton = new TextButton("Open", theme) { Margin = theme.ButtonSpacing, }; openButton.Click += (s, e) => { var extensionsWithoutPeriod = new HashSet <string>(ApplicationSettings.OpenDesignFileParams.Split('|').First().Split(',').Select(t => t.Trim().Trim('.'))); foreach (var extension in ApplicationController.Instance.Library.ContentProviders.Keys) { extensionsWithoutPeriod.Add(extension.ToUpper()); } var extensionsArray = extensionsWithoutPeriod.OrderBy(t => t).ToArray(); string filter = string.Format( "{0}|{1}", string.Join(",", extensionsArray), string.Join("", extensionsArray.Select(t => $"*.{t.ToLower()};").ToArray())); UiThread.RunOnIdle(() => { AggContext.FileDialogs.OpenFileDialog( new OpenFileDialogParams(filter, multiSelect: true), (openParams) => { ViewControls3D.LoadAndAddPartsToPlate(this, openParams.FileNames, ApplicationController.Instance.DragDropData.SceneContext); }); }); }; toolbar.AddChild(openButton); PopupMenuButton viewMenuButton; toolbar.AddChild( viewMenuButton = new PopupMenuButton( new ImageWidget(AggContext.StaticData.LoadIcon("mi-view-list_10.png", 32, 32, theme.InvertIcons)) { //VAnchor = VAnchor.Center }, theme) { AlignToRightEdge = true }); viewMenuButton.DynamicPopupContent = () => { var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme); var listView = this.libraryView; var siblingList = new List <GuiWidget>(); popupMenu.CreateBoolMenuItem( "View List".Localize(), () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.RowListView, (isChecked) => { ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.RowListView; listView.ListContentView = new RowListView(theme); listView.Reload().ConfigureAwait(false); }, useRadioStyle: true, siblingRadioButtonList: siblingList); #if DEBUG popupMenu.CreateBoolMenuItem( "View XSmall Icons".Localize(), () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView18, (isChecked) => { ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView18; listView.ListContentView = new IconListView(theme, 18); listView.Reload().ConfigureAwait(false); }, useRadioStyle: true, siblingRadioButtonList: siblingList); popupMenu.CreateBoolMenuItem( "View Small Icons".Localize(), () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView70, (isChecked) => { ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView70; listView.ListContentView = new IconListView(theme, 70); listView.Reload().ConfigureAwait(false); }, useRadioStyle: true, siblingRadioButtonList: siblingList); #endif popupMenu.CreateBoolMenuItem( "View Icons".Localize(), () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView, (isChecked) => { ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView; listView.ListContentView = new IconListView(theme); listView.Reload().ConfigureAwait(false); }, useRadioStyle: true, siblingRadioButtonList: siblingList); popupMenu.CreateBoolMenuItem( "View Large Icons".Localize(), () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView256, (isChecked) => { ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView256; listView.ListContentView = new IconListView(theme, 256); listView.Reload().ConfigureAwait(false); }, useRadioStyle: true, siblingRadioButtonList: siblingList); return(popupMenu); }; breadCrumbWidget = new FolderBreadCrumbWidget(libraryView, theme); navBar.AddChild(breadCrumbWidget); var searchPanel = new SearchInputBox(theme) { Visible = false, Margin = new BorderDouble(10, 0, 5, 0), }; searchPanel.searchInput.ActualTextEditWidget.EnterPressed += (s, e) => { this.PerformSearch(); }; searchPanel.ResetButton.Click += (s, e) => { breadCrumbWidget.Visible = true; searchPanel.Visible = false; searchPanel.searchInput.Text = ""; this.ClearSearch(); }; // Store a reference to the input field this.searchInput = searchPanel.searchInput; navBar.AddChild(searchPanel); searchButton = theme.CreateSearchButton(); searchButton.Enabled = false; searchButton.Name = "Search Library Button"; searchButton.Click += (s, e) => { if (searchPanel.Visible) { PerformSearch(); } else { searchContainer = ApplicationController.Instance.Library.ActiveContainer; breadCrumbWidget.Visible = false; searchPanel.Visible = true; searchInput.Focus(); } }; navBar.AddChild(searchButton); allControls.AddChild(libraryView); buttonPanel = new FlowLayoutWidget() { HAnchor = HAnchor.Stretch, Padding = theme.ToolbarPadding, }; AddLibraryButtonElements(); allControls.AddChild(buttonPanel); allControls.AnchorAll(); this.AddChild(allControls); }
public void SetContainer(ILibraryContainer currentContainer) { var linkButtonFactory = ApplicationController.Instance.Theme.LinkButtonFactory; var theme = ApplicationController.Instance.Theme; this.CloseAllChildren(); var upbutton = new IconButton(AggContext.StaticData.LoadIcon(Path.Combine("FileDialog", "up_folder_20.png"), theme.InvertIcons), theme) { VAnchor = VAnchor.Fit | VAnchor.Center, Enabled = currentContainer.Parent != null, Name = "Library Up Button", Margin = theme.ButtonSpacing, MinimumSize = new Vector2(theme.ButtonHeight, theme.ButtonHeight) }; upbutton.Click += (s, e) => { if (listView.ActiveContainer.Parent != null) { UiThread.RunOnIdle(() => listView.SetActiveContainer(listView.ActiveContainer.Parent)); } }; this.AddChild(upbutton); bool firstItem = true; if (this.Width < 250) { Button containerButton = linkButtonFactory.Generate(listView.ActiveContainer.Name == null ? "?" : listView.ActiveContainer.Name); containerButton.Name = "Bread Crumb Button " + listView.ActiveContainer.Name; containerButton.VAnchor = VAnchor.Center; containerButton.Margin = theme.ButtonSpacing; this.AddChild(containerButton); } else { var extraSpacing = (theme.ButtonSpacing).Clone(left: theme.ButtonSpacing.Right * .4); foreach (var container in currentContainer.AncestorsAndSelf().Reverse()) { if (!firstItem) { // Add path separator var textContainer = new GuiWidget() // HACK: Workaround for VAlign.Center failure in this specific case. Remove wrapper(with padding) once fixed and directly add TextWidget child { HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit | VAnchor.Center, Padding = new BorderDouble(top: 4), Margin = extraSpacing, }; textContainer.AddChild(new TextWidget("/", pointSize: theme.DefaultFontSize + 2, textColor: ActiveTheme.Instance.PrimaryTextColor)); this.AddChild(textContainer); } // Create a button for each container Button containerButton = linkButtonFactory.Generate(container.Name); containerButton.Name = "Bread Crumb Button " + container.Name; containerButton.VAnchor = VAnchor.Center; containerButton.Margin = theme.ButtonSpacing; containerButton.Click += (s, e) => { UiThread.RunOnIdle(() => listView.SetActiveContainer(container)); }; this.AddChild(containerButton); firstItem = false; } // while all the buttons don't fit in the control if (this.Parent != null && this.Width > 0 && this.Children.Count > 4 && this.GetChildrenBoundsIncludingMargins().Width > (this.Width - 20)) { // lets take out the > and put in a ... this.RemoveChild(1); var separator = new TextWidget("...", textColor: ActiveTheme.Instance.PrimaryTextColor) { VAnchor = VAnchor.Center, Margin = new BorderDouble(right: 5) }; this.AddChild(separator, 1); while (this.GetChildrenBoundsIncludingMargins().Width > this.Width - 20 && this.Children.Count > 4) { this.RemoveChild(3); this.RemoveChild(2); } } } }
public async Task LoadItemThumbnail(Action <ImageBuffer> thumbnailListener, Action <MeshContentProvider> buildThumbnail, ILibraryItem libraryItem, ILibraryContainer libraryContainer, int thumbWidth, int thumbHeight, ThemeConfig theme) { void setItemThumbnail(ImageBuffer icon) { if (icon != null) { icon = this.EnsureCorrectThumbnailSizing(icon, thumbWidth, thumbHeight); thumbnailListener?.Invoke(icon); } } // Load from cache via LibraryID var thumbnail = ApplicationController.Instance.Thumbnails.LoadCachedImage(libraryItem, thumbWidth, thumbHeight); if (thumbnail != null) { setItemThumbnail(thumbnail); return; } if (thumbnail == null && libraryContainer != null) { // Ask the container - allows the container to provide its own interpretation of the item thumbnail thumbnail = await libraryContainer.GetThumbnail(libraryItem, thumbWidth, thumbHeight); } if (thumbnail == null && libraryItem is IThumbnail) { // If the item provides its own thumbnail, try to collect it thumbnail = await(libraryItem as IThumbnail).GetThumbnail(thumbWidth, thumbHeight); } if (thumbnail == null) { // Ask content provider - allows type specific thumbnail creation var contentProvider = ApplicationController.Instance.Library.GetContentProvider(libraryItem); if (contentProvider != null) { // Before we have a thumbnail set to the content specific thumbnail thumbnail = contentProvider.DefaultImage; if (contentProvider is MeshContentProvider meshContentProvider) { buildThumbnail?.Invoke(meshContentProvider); } else { // Show processing image setItemThumbnail(theme.GeneratingThumbnailIcon); // Ask the provider for a content specific thumbnail thumbnail = await contentProvider.GetThumbnail(libraryItem, thumbWidth, thumbHeight); } } } if (thumbnail == null) { // Use the listview defaults if (thumbHeight < 24 && thumbWidth < 24) { thumbnail = ((libraryItem is ILibraryContainerLink) ? defaultFolderIconx20 : defaultItemIconx20);; //if (!theme.InvertIcons) //{ // thumbnail = thumbnail.InvertLightness(); //} thumbnail = thumbnail.MultiplyWithPrimaryAccent(); } else { thumbnail = ((libraryItem is ILibraryContainerLink) ? defaultFolderIcon : defaultItemIcon).AlphaToPrimaryAccent(); } } // TODO: Resolve and implement // Allow the container to draw an overlay - use signal interface or add method to interface? //var iconWithOverlay = ActiveContainer.DrawOverlay() setItemThumbnail(thumbnail); }
public ContainerChangedEventArgs(ILibraryContainer activeContainer, ILibraryContainer previousContainer) { this.ActiveContainer = activeContainer; this.PreviousContainer = previousContainer; }
public ListViewItem(ILibraryItem libraryItem, ILibraryContainer container, LibraryListView listView = null) { this.Container = container; this.ListView = listView; this.Model = libraryItem; }
public LibraryPresenter() { container = new LibraryContainer(); container.Initialize(); }
public LibraryWidget(MainViewWidget mainViewWidget, ThemeConfig theme) { this.theme = theme; this.mainViewWidget = mainViewWidget; this.Padding = 0; this.AnchorAll(); var allControls = new FlowLayoutWidget(FlowDirection.TopToBottom); libraryContext = ApplicationController.Instance.LibraryTabContext; libraryView = new LibraryListView(libraryContext, theme) { Name = "LibraryView", // Drop containers if ShowContainers != 1 ContainerFilter = (container) => this.ShowContainers, BackgroundColor = theme.BackgroundColor, Border = new BorderDouble(top: 1), DoubleClickAction = LibraryListView.DoubleClickActions.PreviewItem }; navBar = new OverflowBar(theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, }; theme.ApplyBottomBorder(navBar); breadCrumbWidget = new FolderBreadCrumbWidget(libraryContext, theme); navBar.AddChild(breadCrumbWidget); var searchPanel = new TextEditWithInlineCancel(theme) { Visible = false, Margin = new BorderDouble(10, 0, 5, 0), }; searchPanel.TextEditWidget.ActualTextEditWidget.EnterPressed += (s, e) => { this.PerformSearch(); }; searchPanel.ResetButton.Click += (s, e) => { breadCrumbWidget.Visible = true; searchPanel.Visible = false; searchPanel.TextEditWidget.Text = ""; this.ClearSearch(); }; // Store a reference to the input field this.searchInput = searchPanel.TextEditWidget; navBar.AddChild(searchPanel); searchButton = theme.CreateSearchButton(); searchButton.Enabled = false; searchButton.Name = "Search Library Button"; searchButton.Click += (s, e) => { if (searchPanel.Visible) { PerformSearch(); } else { searchContainer = libraryContext.ActiveContainer; breadCrumbWidget.Visible = false; searchPanel.Visible = true; searchInput.Focus(); } }; navBar.AddChild(searchButton); navBar.AddChild(CreateViewOptionsMenuButton(theme, libraryView, (show) => ShowContainers = show, () => ShowContainers)); navBar.AddChild(CreateSortingMenuButton(theme, libraryView)); allControls.AddChild(navBar); var horizontalSplitter = new Splitter() { SplitterDistance = UserSettings.Instance.LibraryViewWidth, SplitterSize = theme.SplitterWidth, SplitterBackground = theme.SplitterBackground }; horizontalSplitter.AnchorAll(); horizontalSplitter.DistanceChanged += (s, e) => { UserSettings.Instance.LibraryViewWidth = horizontalSplitter.SplitterDistance; }; allControls.AddChild(horizontalSplitter); libraryTreeView = new TreeView(theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, Margin = 5 }; libraryTreeView.AfterSelect += async(s, e) => { if (libraryTreeView.SelectedNode is ContainerTreeNode treeNode) { if (!treeNode.ContainerAcquired) { await this.EnsureExpanded(treeNode.Tag as ILibraryItem, treeNode); } if (treeNode.ContainerAcquired) { libraryContext.ActiveContainer = treeNode.Container; } } }; horizontalSplitter.Panel1.AddChild(libraryTreeView); var rootColumn = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit, Margin = new BorderDouble(left: 10) }; libraryTreeView.AddChild(rootColumn); if (AppContext.IsLoading) { ApplicationController.StartupActions.Add(new ApplicationController.StartupAction() { Title = "Initializing Library".Localize(), Priority = 0, Action = () => { this.LoadRootLibraryNodes(rootColumn); } }); } else { this.LoadRootLibraryNodes(rootColumn); } horizontalSplitter.Panel2.AddChild(libraryView); buttonPanel = new FlowLayoutWidget() { HAnchor = HAnchor.Stretch, Padding = theme.ToolbarPadding, }; AddLibraryButtonElements(); allControls.AddChild(buttonPanel); allControls.AnchorAll(); this.AddChild(allControls); // Register listeners libraryView.SelectedItems.CollectionChanged += SelectedItems_CollectionChanged; libraryContext.ContainerChanged += Library_ContainerChanged; }
public PrintLibraryWidget(MainViewWidget mainViewWidget, PartWorkspace workspace, ThemeConfig theme, PopupMenuButton popupMenuButton) { this.theme = theme; this.mainViewWidget = mainViewWidget; this.Padding = 0; this.AnchorAll(); var allControls = new FlowLayoutWidget(FlowDirection.TopToBottom); libraryContext = workspace.LibraryView; libraryView = new LibraryListView(libraryContext, theme) { Name = "LibraryView", // Drop containers if ShowContainers != 1 ContainerFilter = (container) => UserSettings.Instance.ShowContainers, BackgroundColor = theme.BackgroundColor, Border = new BorderDouble(top: 1) }; navBar = new OverflowBar(theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, }; allControls.AddChild(navBar); theme.ApplyBottomBorder(navBar); var toolbar = new OverflowBar(AggContext.StaticData.LoadIcon("fa-sort_16.png", 32, 32, theme.InvertIcons), theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Name = "Folders Toolbar" }; theme.ApplyBottomBorder(toolbar, shadedBorder: true); toolbar.OverflowButton.Name = "Print Library View Options"; toolbar.Padding = theme.ToolbarPadding; toolbar.ExtendOverflowMenu = (popupMenu) => { var siblingList = new List <GuiWidget>(); popupMenu.CreateBoolMenuItem( "Date Created".Localize(), () => libraryView.ActiveSort == LibraryListView.SortKey.CreatedDate, (v) => libraryView.ActiveSort = LibraryListView.SortKey.CreatedDate, useRadioStyle: true, siblingRadioButtonList: siblingList); popupMenu.CreateBoolMenuItem( "Date Modified".Localize(), () => libraryView.ActiveSort == LibraryListView.SortKey.ModifiedDate, (v) => libraryView.ActiveSort = LibraryListView.SortKey.ModifiedDate, useRadioStyle: true, siblingRadioButtonList: siblingList); popupMenu.CreateBoolMenuItem( "Name".Localize(), () => libraryView.ActiveSort == LibraryListView.SortKey.Name, (v) => libraryView.ActiveSort = LibraryListView.SortKey.Name, useRadioStyle: true, siblingRadioButtonList: siblingList); popupMenu.CreateSeparator(); siblingList = new List <GuiWidget>(); popupMenu.CreateBoolMenuItem( "Ascending".Localize(), () => libraryView.Ascending, (v) => libraryView.Ascending = true, useRadioStyle: true, siblingRadioButtonList: siblingList); popupMenu.CreateBoolMenuItem( "Descending".Localize(), () => !libraryView.Ascending, (v) => libraryView.Ascending = false, useRadioStyle: true, siblingRadioButtonList: siblingList); }; allControls.AddChild(toolbar); var showFolders = new ExpandCheckboxButton("Folders".Localize(), theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit | VAnchor.Center, Margin = theme.ButtonSpacing, Name = "Show Folders Toggle", Checked = UserSettings.Instance.ShowContainers, }; showFolders.SetIconMargin(theme.ButtonSpacing); showFolders.CheckedStateChanged += async(s, e) => { UserSettings.Instance.set(UserSettingsKey.ShowContainers, showFolders.Checked ? "1" : "0"); await libraryView.Reload(); }; toolbar.AddChild(showFolders); PopupMenuButton viewMenuButton; toolbar.AddChild( viewMenuButton = new PopupMenuButton( new ImageWidget(AggContext.StaticData.LoadIcon("mi-view-list_10.png", 32, 32, theme.InvertIcons)) { //VAnchor = VAnchor.Center }, theme) { AlignToRightEdge = true }); viewMenuButton.DynamicPopupContent = () => { var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme); var listView = this.libraryView; var siblingList = new List <GuiWidget>(); popupMenu.CreateBoolMenuItem( "View List".Localize(), () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.RowListView, (isChecked) => { ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.RowListView; listView.ListContentView = new RowListView(theme); listView.Reload().ConfigureAwait(false); }, useRadioStyle: true, siblingRadioButtonList: siblingList); #if DEBUG popupMenu.CreateBoolMenuItem( "View XSmall Icons".Localize(), () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView18, (isChecked) => { ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView18; listView.ListContentView = new IconListView(theme, 18); listView.Reload().ConfigureAwait(false); }, useRadioStyle: true, siblingRadioButtonList: siblingList); popupMenu.CreateBoolMenuItem( "View Small Icons".Localize(), () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView70, (isChecked) => { ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView70; listView.ListContentView = new IconListView(theme, 70); listView.Reload().ConfigureAwait(false); }, useRadioStyle: true, siblingRadioButtonList: siblingList); #endif popupMenu.CreateBoolMenuItem( "View Icons".Localize(), () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView, (isChecked) => { ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView; listView.ListContentView = new IconListView(theme); listView.Reload().ConfigureAwait(false); }, useRadioStyle: true, siblingRadioButtonList: siblingList); popupMenu.CreateBoolMenuItem( "View Large Icons".Localize(), () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView256, (isChecked) => { ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView256; listView.ListContentView = new IconListView(theme, 256); listView.Reload().ConfigureAwait(false); }, useRadioStyle: true, siblingRadioButtonList: siblingList); return(popupMenu); }; breadCrumbWidget = new FolderBreadCrumbWidget(workspace.LibraryView, theme); navBar.AddChild(breadCrumbWidget); var searchPanel = new SearchInputBox(theme) { Visible = false, Margin = new BorderDouble(10, 0, 5, 0), }; searchPanel.searchInput.ActualTextEditWidget.EnterPressed += (s, e) => { this.PerformSearch(); }; searchPanel.ResetButton.Click += (s, e) => { breadCrumbWidget.Visible = true; searchPanel.Visible = false; searchPanel.searchInput.Text = ""; this.ClearSearch(); }; // Store a reference to the input field this.searchInput = searchPanel.searchInput; navBar.AddChild(searchPanel); searchButton = theme.CreateSearchButton(); searchButton.Enabled = false; searchButton.Name = "Search Library Button"; searchButton.Click += (s, e) => { if (searchPanel.Visible) { PerformSearch(); } else { searchContainer = libraryView.ActiveContainer; breadCrumbWidget.Visible = false; searchPanel.Visible = true; searchInput.Focus(); } }; navBar.AddChild(searchButton); allControls.AddChild(libraryView); buttonPanel = new FlowLayoutWidget() { HAnchor = HAnchor.Stretch, Padding = theme.ToolbarPadding, }; AddLibraryButtonElements(); allControls.AddChild(buttonPanel); allControls.AnchorAll(); this.AddChild(allControls); // Register listeners libraryView.SelectedItems.CollectionChanged += SelectedItems_CollectionChanged; libraryContext.ContainerChanged += Library_ContainerChanged; }
public WrappedLibraryContainer(ILibraryContainer libraryContainer) { _libraryContainer = libraryContainer; }
public void SetContainer(ILibraryContainer currentContainer) { this.CloseAllChildren(); var upbutton = new IconButton(AggContext.StaticData.LoadIcon(Path.Combine("Library", "upfolder_20.png"), theme.InvertIcons), theme) { VAnchor = VAnchor.Fit | VAnchor.Center, Enabled = currentContainer.Parent != null, Name = "Library Up Button", ToolTipText = "Up one folder".Localize(), Margin = theme.ButtonSpacing, MinimumSize = new Vector2(theme.ButtonHeight, theme.ButtonHeight) }; upbutton.Click += (s, e) => { if (listView.ActiveContainer.Parent != null) { UiThread.RunOnIdle(() => listView.SetActiveContainer(listView.ActiveContainer.Parent)); } }; this.AddChild(upbutton); bool firstItem = true; if (this.Width < 250) { var containerButton = new LinkLabel((listView.ActiveContainer.Name == null ? "?" : listView.ActiveContainer.Name), theme) { Name = "Bread Crumb Button " + listView.ActiveContainer.Name, VAnchor = VAnchor.Center, Margin = theme.ButtonSpacing, TextColor = theme.Colors.PrimaryTextColor }; this.AddChild(containerButton); } else { var extraSpacing = (theme.ButtonSpacing).Clone(left: theme.ButtonSpacing.Right * .4); foreach (var container in currentContainer.AncestorsAndSelf().Reverse()) { if (!firstItem) { // Add path separator this.AddChild(new TextWidget("/", pointSize: theme.DefaultFontSize + 1, textColor: ActiveTheme.Instance.PrimaryTextColor) { VAnchor = VAnchor.Center, Margin = extraSpacing.Clone(top: 2) }); } // Create a button for each container var containerButton = new LinkLabel(container.Name, theme) { Name = "Bread Crumb Button " + container.Name, VAnchor = VAnchor.Center, Margin = theme.ButtonSpacing.Clone(top: 1), TextColor = theme.Colors.PrimaryTextColor }; containerButton.Click += (s, e) => { UiThread.RunOnIdle(() => listView.SetActiveContainer(container)); }; this.AddChild(containerButton); firstItem = false; } // while all the buttons don't fit in the control if (this.Parent != null && this.Width > 0 && this.Children.Count > 4 && this.GetChildrenBoundsIncludingMargins().Width > (this.Width - 20)) { // lets take out the > and put in a ... this.RemoveChild(1); var separator = new TextWidget("...", textColor: ActiveTheme.Instance.PrimaryTextColor) { VAnchor = VAnchor.Center, Margin = new BorderDouble(right: 5) }; this.AddChild(separator, 1); while (this.GetChildrenBoundsIncludingMargins().Width > this.Width - 20 && this.Children.Count > 4) { this.RemoveChild(3); this.RemoveChild(2); } } } }
public ContainerTreeNode(ThemeConfig theme, ILibraryContainer parentContainer) : base(theme, true) { this.ParentContainer = parentContainer; }