public static PopupMenu CreateSortingMenu(PopupMenu popupMenu, LibraryListView libraryView) { 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); }
public FlowLayoutWidget CreateMenuItems(PopupMenu popupMenu, IEnumerable <NamedAction> menuActions, bool emptyMenu = true) { // Retain past behavior, where menu is cleared each call. More recent callers many pass in a newly populated menu and // not require the clear if (emptyMenu) { popupMenu.CloseAllChildren(); } // Create menu items in the DropList for each element in this.menuActions foreach (var menuAction in menuActions) { if (menuAction is ActionSeparator) { popupMenu.CreateSeparator(); } else { PopupMenu.MenuItem menuItem; if (menuAction is NamedBoolAction boolAction) { menuItem = popupMenu.CreateBoolMenuItem(menuAction.Title, boolAction.GetIsActive, boolAction.SetIsActive); } else { menuItem = popupMenu.CreateMenuItem(menuAction.Title, menuAction.Icon, menuAction.Shortcut); } menuItem.Name = $"{menuAction.Title} Menu Item"; menuItem.Enabled = menuAction.Action != null && menuAction.IsEnabled?.Invoke() != false; menuItem.ClearRemovedFlag(); if (menuItem.Enabled) { menuItem.Click += (s, e) => { menuAction.Action(); }; } } } return(popupMenu); }
public FlowLayoutWidget CreateMenuItems(PopupMenu popupMenu, IEnumerable <NamedAction> menuActions) { // Create menu items in the DropList for each element in this.menuActions popupMenu.CloseAllChildren(); foreach (var menuAction in menuActions) { if (menuAction.Title == "----") { popupMenu.CreateHorizontalLine(); } else { PopupMenu.MenuItem menuItem; if (menuAction is NamedBoolAction boolAction) { menuItem = popupMenu.CreateBoolMenuItem(menuAction.Title, boolAction.GetIsActive, boolAction.SetIsActive); } else { menuItem = popupMenu.CreateMenuItem(menuAction.Title, menuAction.Icon, menuAction.Shortcut); } menuItem.Name = $"{menuAction.Title} Menu Item"; menuItem.Enabled = menuAction.Action != null && menuAction.IsEnabled?.Invoke() != false; menuItem.ClearRemovedFlag(); if (menuItem.Enabled) { menuItem.Click += (s, e) => { menuAction.Action(); }; } } } return(popupMenu); }
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; }
private GuiWidget CreateVisibilityOptions(ThemeConfig theme) { var visibilityOptionsButton = new PopupMenuButton("Visibility Options", theme) { VAnchor = VAnchor.Center }; var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme); visibilityOptionsButton.PopupContent = popupMenu; // put in options for filtering various output popupMenu.CreateBoolMenuItem( "Line Checksums".Localize(), () => UserSettings.Instance.Fields.GetBool(UserSettingsKey.TerminalShowChecksum, true), (isChecked) => { UserSettings.Instance.Fields.SetBool(UserSettingsKey.TerminalShowChecksum, isChecked); textScrollWidget.RebuildFilteredList(); }); popupMenu.CreateBoolMenuItem( "In / Out Indicators".Localize(), () => UserSettings.Instance.Fields.GetBool(UserSettingsKey.TerminalShowInputOutputMarks, true), (isChecked) => { UserSettings.Instance.Fields.SetBool(UserSettingsKey.TerminalShowInputOutputMarks, isChecked); textScrollWidget.RebuildFilteredList(); }); // request section popupMenu.CreateSeparator(); popupMenu.CreateBoolMenuItem( "Temperature Requests".Localize(), () => UserSettings.Instance.Fields.GetBool(UserSettingsKey.TerminalShowTempRequests, true), (isChecked) => { UserSettings.Instance.Fields.SetBool(UserSettingsKey.TerminalShowTempRequests, isChecked); textScrollWidget.RebuildFilteredList(); }); popupMenu.CreateBoolMenuItem( "Movement Requests".Localize(), () => UserSettings.Instance.Fields.GetBool(UserSettingsKey.TerminalShowMovementRequests, true), (isChecked) => { UserSettings.Instance.Fields.SetBool(UserSettingsKey.TerminalShowMovementRequests, isChecked); textScrollWidget.RebuildFilteredList(); }); // response section popupMenu.CreateSeparator(); popupMenu.CreateBoolMenuItem( "Temperature Responses".Localize(), () => UserSettings.Instance.Fields.GetBool(UserSettingsKey.TerminalShowTempResponse, true), (isChecked) => { UserSettings.Instance.Fields.SetBool(UserSettingsKey.TerminalShowTempResponse, isChecked); textScrollWidget.RebuildFilteredList(); }); popupMenu.CreateBoolMenuItem( "'Ok' Responses".Localize(), () => UserSettings.Instance.Fields.GetBool(UserSettingsKey.TerminalShowOks, true), (isChecked) => { UserSettings.Instance.Fields.SetBool(UserSettingsKey.TerminalShowOks, isChecked); textScrollWidget.RebuildFilteredList(); }); popupMenu.CreateBoolMenuItem( "'Wait' Responses".Localize(), () => UserSettings.Instance.Fields.GetBool(UserSettingsKey.TerminalShowWaitResponse, false), (isChecked) => { UserSettings.Instance.Fields.SetBool(UserSettingsKey.TerminalShowWaitResponse, isChecked); textScrollWidget.RebuildFilteredList(); }); return(visibilityOptionsButton); }
public static GuiWidget CreateViewOptionsMenuButton(ThemeConfig theme, LibraryListView libraryView, Action <bool> showContainers, Func <bool> containersShown) { var viewMenuButton = new PopupMenuButton( new ImageWidget(StaticData.Instance.LoadIcon("mi-view-list_10.png", 32, 32, theme.InvertIcons)) { // VAnchor = VAnchor.Center }, theme) { AlignToRightEdge = true, ToolTipText = "View Settings".Localize() }; viewMenuButton.DynamicPopupContent = () => { var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme); var listView = libraryView; var siblingList = new List <GuiWidget>(); popupMenu.CreateBoolMenuItem( "Show Folders".Localize(), () => containersShown(), (isChecked) => { showContainers(isChecked); listView.Reload().ConfigureAwait(false); }); popupMenu.CreateSeparator(); 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); }; return(viewMenuButton); }
public FlowLayoutWidget CreateMenuItems(PopupMenu popupMenu, IEnumerable <NamedAction> menuActions) { // Create menu items in the DropList for each element in this.menuActions foreach (var menuAction in menuActions) { if (menuAction is ActionSeparator) { popupMenu.CreateSeparator(); } else { if (menuAction is NamedActionGroup namedActionButtons) { var content = new FlowLayoutWidget() { HAnchor = HAnchor.Fit | HAnchor.Stretch }; var textWidget = new TextWidget(menuAction.Title, pointSize: this.DefaultFontSize, textColor: this.TextColor) { // Padding = MenuPadding, VAnchor = VAnchor.Center }; content.AddChild(textWidget); content.AddChild(new HorizontalSpacer()); foreach (var actionButton in namedActionButtons.Group) { var button = new TextButton(actionButton.Title, this) { Border = new BorderDouble(1, 0, 0, 0), BorderColor = this.MinimalShade, HoverColor = this.AccentMimimalOverlay, Enabled = actionButton.IsEnabled() }; content.AddChild(button); if (actionButton.IsEnabled()) { button.Click += (s, e) => { actionButton.Action(); popupMenu.Unfocus(); }; } } var menuItem = new PopupMenu.MenuItem(content, this) { HAnchor = HAnchor.Fit | HAnchor.Stretch, VAnchor = VAnchor.Fit, HoverColor = Color.Transparent, }; popupMenu.AddChild(menuItem); menuItem.Padding = new BorderDouble(menuItem.Padding.Left, menuItem.Padding.Bottom, 0, menuItem.Padding.Top); } else { PopupMenu.MenuItem menuItem; if (menuAction is NamedBoolAction boolAction) { menuItem = popupMenu.CreateBoolMenuItem(menuAction.Title, boolAction.GetIsActive, boolAction.SetIsActive); } else { menuItem = popupMenu.CreateMenuItem(menuAction.Title, menuAction.Icon, menuAction.Shortcut); } menuItem.Name = $"{menuAction.Title} Menu Item"; menuItem.Enabled = menuAction is NamedActionGroup || (menuAction.Action != null && menuAction.IsEnabled?.Invoke() != false); menuItem.ClearRemovedFlag(); if (menuItem.Enabled) { menuItem.Click += (s, e) => { menuAction.Action(); }; } } } } return(popupMenu); }
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 GuiWidget Create(IObject3D item, UndoBuffer undoBuffer, ThemeConfig theme) { this.injectedItem = item as SvgObject3D; if (this.injectedItem == null) { return(null); } var column = new FlowLayoutWidget(FlowDirection.TopToBottom) { VAnchor = VAnchor.Fit, HAnchor = HAnchor.Absolute, Width = 210, Padding = new BorderDouble(12), }; column.Closed += (s, e) => { //unregisterEvents?.Invoke(this, null); }; var rightPanel = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch }; var label = new TextWidget("All Paths", textColor: AppContext.Theme.TextColor) { HAnchor = HAnchor.Left, Margin = new BorderDouble(0, 0, 0, 15) }; column.AddChild(label); var row = new FlowLayoutWidget() { }; column.AddChild(row); var editButton = new TextButton("Edit".Localize(), theme) { Enabled = false, }; editButton.Click += async(s, e) => { ApplicationController.Instance.OpenIntoNewTab(new[] { new InMemoryLibraryItem(new VertexStorageObject3D(lastDPath)) }); }; int pathCount = 1; var droplist = new PopupMenu(theme) { BackgroundColor = theme.InactiveTabColor }; row.AddChild(droplist); row.AddChild(editButton); var allPaths = SvgParser.GetPaths(this.injectedItem.SvgPath); selectedItems = new HashSet <SvgParser.SvgNodeInfo>(allPaths); foreach (var pathItem in allPaths) { bool itemChecked = true; PopupMenu.MenuItem menuItem = null; menuItem = droplist.CreateBoolMenuItem( $"Path {pathCount++}", () => itemChecked, (isChecked) => { lastDPath = (pathItem as SvgParser.SvgPathInfo)?.DString; editButton.Enabled = true; if (isChecked) { selectedItems.Add(pathItem); } else { selectedItems.Remove(pathItem); } this.Rebuild(); }); } this.Rebuild(); return(column); }