public PopupMenuButton CreateSplitButton(SplitButtonParams buttonParams, OperationGroup operationGroup = null) { PopupMenuButton menuButton = null; var innerButton = new IconButton(buttonParams.Icon, this) { Name = buttonParams.ButtonName + " Inner SplitButton", ToolTipText = buttonParams.DefaultActionTooltip, }; innerButton.Click += (s, e) => { buttonParams.DefaultAction.Invoke(menuButton); }; // Remove right Padding for drop style innerButton.Padding = innerButton.Padding.Clone(right: 0); if (operationGroup == null) { menuButton = new PopupMenuButton(innerButton, this); } else { menuButton = new OperationGroupButton(operationGroup, innerButton, this); } menuButton.DynamicPopupContent = () => { var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme); buttonParams.ExtendPopupMenu?.Invoke(popupMenu); return(popupMenu); }; menuButton.Name = buttonParams.ButtonName + " Menu SplitButton"; menuButton.BackgroundColor = this.ToolbarButtonBackground; menuButton.HoverColor = this.ToolbarButtonHover; menuButton.MouseDownColor = this.ToolbarButtonDown; menuButton.DrawArrow = true; menuButton.Margin = this.ButtonSpacing; menuButton.DistinctPopupButton = true; innerButton.Selectable = true; return(menuButton); }
public static GuiWidget CreateSortingMenuButton(ThemeConfig theme, LibraryListView libraryView) { var viewOptionsButton = new PopupMenuButton( new ImageWidget(StaticData.Instance.LoadIcon("fa-sort_16.png", 32, 32, theme.InvertIcons)), theme) { AlignToRightEdge = true, Name = "Print Library View Options", ToolTipText = "Sorting".Localize() }; viewOptionsButton.DynamicPopupContent = () => { var popupMenu = new PopupMenu(theme); CreateSortingMenu(popupMenu, libraryView); return(popupMenu); }; return(viewOptionsButton); }
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 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; }
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 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 PopupMenuButton CreateSplitButton(SplitButtonParams buttonParams, OperationGroup operationGroup = null) { PopupMenuButton menuButton = null; GuiWidget innerButton; if (buttonParams.ButtonText == null) { innerButton = new IconButton(buttonParams.Icon, this) { Name = buttonParams.ButtonName + " Inner SplitButton", Enabled = buttonParams.ButtonEnabled, ToolTipText = buttonParams.ButtonTooltip, }; // Remove right Padding for drop style innerButton.Padding = innerButton.Padding.Clone(right: 0); } else { if (buttonParams.Icon == null) { innerButton = new TextButton(buttonParams.ButtonText, this) { Name = buttonParams.ButtonName, Enabled = buttonParams.ButtonEnabled, ToolTipText = buttonParams.ButtonTooltip, }; } else { innerButton = new TextIconButton(buttonParams.ButtonText, buttonParams.Icon, this) { Name = buttonParams.ButtonName, Enabled = buttonParams.ButtonEnabled, ToolTipText = buttonParams.ButtonTooltip, }; } } innerButton.Click += (s, e) => { buttonParams.ButtonAction.Invoke(menuButton); }; if (operationGroup == null) { menuButton = new PopupMenuButton(innerButton, this); } else { menuButton = new OperationGroupButton(operationGroup, innerButton, this); } var theme = ApplicationController.Instance.MenuTheme; menuButton.DynamicPopupContent = () => { var popupMenu = new PopupMenu(theme); buttonParams.ExtendPopupMenu?.Invoke(popupMenu); return(popupMenu); }; menuButton.Name = buttonParams.ButtonName + " Menu SplitButton"; if (buttonParams.ButtonText == null) { menuButton.BackgroundColor = this.ToolbarButtonBackground; } else { menuButton.BackgroundColor = this.MinimalShade; } menuButton.HoverColor = this.ToolbarButtonHover; menuButton.MouseDownColor = this.ToolbarButtonDown; menuButton.DrawArrow = true; menuButton.Margin = this.ButtonSpacing; menuButton.DistinctPopupButton = true; menuButton.BackgroundRadius = new RadiusCorners(theme.ButtonRadius, theme.ButtonRadius, 0, 0); innerButton.Selectable = true; return(menuButton); }
public static GuiWidget CreateDefaultOptions(GuiWidget textField, ThemeConfig theme, Action selectionChanged) { var selectString = "- " + "What went wrong?".Localize() + " -"; var menuButton = new PopupMenuButton(selectString, theme); var menuButtonText = menuButton.Descendants<TextWidget>().First(); menuButtonText.AutoExpandBoundsToText = true; void AddSelection(PopupMenu menu, string text, string helpUrl = "", bool other = false) { var menuItem = menu.CreateMenuItem(text); menuItem.Click += (s, e) => { textField.Name = helpUrl; var markdownWidget = textField.Parents<SystemWindow>().First().Descendants<MarkdownWidget>().LastOrDefault(); if (markdownWidget != null) { markdownWidget.Markdown = textField.Name; markdownWidget.Visible = !string.IsNullOrEmpty(markdownWidget.Markdown); } if (other) { textField.Text = ""; textField.Visible = true; UiThread.RunOnIdle(textField.Focus); menuButtonText.Text = "Other".Localize() + "..."; } else { textField.Text = text; textField.Visible = false; menuButtonText.Text = textField.Text; } selectionChanged?.Invoke(); }; } string TroubleShooting(string type, int issue) { return $"For help with {type} and other issues, please read MatterHackers [Troubleshooting Guide](https://www.matterhackers.com/articles/3d-printer-troubleshooting-guide#Issue{issue})"; } menuButton.DynamicPopupContent = () => { var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme); popupMenu.CreateSubMenu("First Layer".Localize(), theme, (menu) => { AddSelection(menu, "First Layer Bad Quality".Localize(), TroubleShooting("the first layer", 1)); AddSelection(menu, "Initial Z Height Incorrect".Localize(), TroubleShooting("initial Z height", 1)); }); popupMenu.CreateSubMenu("Quality".Localize(), theme, (menu) => { AddSelection(menu, "General Quality".Localize(), TroubleShooting("general quality", 100)); AddSelection(menu, "Rough Overhangs".Localize()); AddSelection(menu, "Skipped Layers".Localize()); AddSelection(menu, "Some Parts Lifted".Localize(), TroubleShooting("lifting", 6)); AddSelection(menu, "Stringing / Poor retractions".Localize(), TroubleShooting("stringing", 9)); AddSelection(menu, "Warping".Localize(), TroubleShooting("warping", 6)); AddSelection(menu, "Dislodged From Bed".Localize(), TroubleShooting("adhesion", 2)); AddSelection(menu, "Layer Shift".Localize(), TroubleShooting("layer shifting", 8)); }); popupMenu.CreateSubMenu("Mechanical".Localize(), theme, (menu) => { AddSelection(menu, "Bed Dislodged".Localize()); AddSelection(menu, "Bowden Tube Popped Out".Localize()); AddSelection(menu, "Extruder Slipping".Localize(), TroubleShooting("the extruder", 13)); AddSelection(menu, "Flooded Hot End".Localize()); AddSelection(menu, "Power Outage".Localize()); }); popupMenu.CreateSubMenu("Computer / MatterControl ".Localize(), theme, (menu) => { AddSelection(menu, "Computer Crashed".Localize()); AddSelection(menu, "Computer Slow / Lagging".Localize()); AddSelection(menu, "Couldn't Resume".Localize()); AddSelection(menu, "Wouldn’t Slice Correctly".Localize()); }); popupMenu.CreateSubMenu("Filament".Localize(), theme, (menu) => { AddSelection(menu, "Filament Jam".Localize()); AddSelection(menu, "Filament Runout".Localize()); AddSelection(menu, "Filament Snapped".Localize()); }); popupMenu.CreateSubMenu("Heating".Localize(), theme, (menu) => { AddSelection(menu, "Thermal Runaway - Bed".Localize()); AddSelection(menu, "Thermal Runaway - Hot End".Localize()); AddSelection(menu, "Heating".Localize()); AddSelection(menu, "Took Too Long To Heat".Localize()); AddSelection(menu, "Bad Thermistor".Localize()); AddSelection(menu, "Bad Thermistor".Localize()); }); AddSelection(popupMenu, "Test Print".Localize()); AddSelection(popupMenu, "User Error".Localize()); AddSelection(popupMenu, "Other".Localize(), "", true); return popupMenu; }; textField.Visible = false; menuButton.VAnchor = VAnchor.Fit; return menuButton; }
public static GuiWidget CreateDefaultOptions(GuiWidget textField, ThemeConfig theme, Action selectionChanged) { var selectString = "- " + "What went wrong?".Localize() + " -"; var menuButton = new PopupMenuButton(selectString, theme); var menuButtonText = menuButton.Descendants <TextWidget>().First(); menuButtonText.AutoExpandBoundsToText = true; void AddSelection(PopupMenu menu, string text, bool other = false) { var menuItem = menu.CreateMenuItem(text); menuItem.Click += (s, e) => { if (other) { textField.Text = ""; textField.Visible = true; UiThread.RunOnIdle(textField.Focus); menuButtonText.Text = "Other".Localize() + "..."; } else { textField.Text = text; textField.Visible = false; menuButtonText.Text = textField.Text; } selectionChanged?.Invoke(); }; } menuButton.DynamicPopupContent = () => { var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme); popupMenu.CreateSubMenu("First Layer".Localize(), theme, (menu) => { AddSelection(menu, "First Layer Bad Quality".Localize()); AddSelection(menu, "Initial Z Height Incorrect".Localize()); }); popupMenu.CreateSubMenu("Quality".Localize(), theme, (menu) => { AddSelection(menu, "General Quality".Localize()); AddSelection(menu, "Rough Overhangs".Localize()); AddSelection(menu, "Skipped Layers".Localize()); AddSelection(menu, "Some Parts Lifted".Localize()); AddSelection(menu, "Stringing / Poor retractions".Localize()); AddSelection(menu, "Warping".Localize()); AddSelection(menu, "Dislodged From Bed".Localize()); AddSelection(menu, "Layer Shift".Localize()); }); popupMenu.CreateSubMenu("Mechanical".Localize(), theme, (menu) => { AddSelection(menu, "Bed Dislodged".Localize()); AddSelection(menu, "Bowden Tube Popped Out".Localize()); AddSelection(menu, "Extruder Slipping".Localize()); AddSelection(menu, "Flooded Hot End".Localize()); AddSelection(menu, "Power Outage".Localize()); }); popupMenu.CreateSubMenu("Computer / MatterControl ".Localize(), theme, (menu) => { AddSelection(menu, "Computer Crashed".Localize()); AddSelection(menu, "Computer Slow / Lagging".Localize()); AddSelection(menu, "Couldn't Resume".Localize()); AddSelection(menu, "Wouldn’t Slice Correctly".Localize()); }); popupMenu.CreateSubMenu("Filament".Localize(), theme, (menu) => { AddSelection(menu, "Filament Jam".Localize()); AddSelection(menu, "Filament Runout".Localize()); AddSelection(menu, "Filament Snapped".Localize()); }); popupMenu.CreateSubMenu("Heating".Localize(), theme, (menu) => { AddSelection(menu, "Thermal Runaway - Bed".Localize()); AddSelection(menu, "Thermal Runaway - Hot End".Localize()); AddSelection(menu, "Heating".Localize()); AddSelection(menu, "Took Too Long To Heat".Localize()); AddSelection(menu, "Bad Thermistor".Localize()); AddSelection(menu, "Bad Thermistor".Localize()); }); AddSelection(popupMenu, "Test Print".Localize()); AddSelection(popupMenu, "User Error".Localize()); AddSelection(popupMenu, "Other".Localize(), true); return(popupMenu); }; textField.Visible = false; menuButton.VAnchor = VAnchor.Fit; return(menuButton); }