public ChromeTab CreatePartTab(PartWorkspace workspace) { var partTab = new ChromeTab( workspace.Name, workspace.Name, tabControl, new PartTabPage(workspace, theme, ""), theme, AggContext.StaticData.LoadIcon("cube.png", 16, 16, theme.InvertIcons)) { Name = "newPart" + tabControl.AllTabs.Count(), MinimumSize = new Vector2(120, theme.TabButtonHeight) }; tabControl.AddTab(partTab); void Tab_CloseClicked(object sender, EventArgs args) { ApplicationController.Instance.Workspaces.Remove(workspace); } void Widget_Closed(object sender, EventArgs args) { partTab.CloseClicked -= Tab_CloseClicked; partTab.Closed -= Widget_Closed; } partTab.CloseClicked += Tab_CloseClicked; partTab.Closed += Widget_Closed; return(partTab); }
public ChromeTab CreatePartTab(PartWorkspace workspace) { var partTab = new ChromeTab( workspace.Name, workspace.Name, tabControl, new PartTabPage(workspace, theme, ""), theme, StaticData.Instance.LoadIcon("cube.png", 16, 16, theme.InvertIcons)) { Name = "newPart" + tabControl.AllTabs.Count(), }; EnableReduceWidth(partTab, theme); tabControl.AddTab(partTab); void Tab_CloseClicked(object sender, EventArgs args) { ApplicationController.Instance.Workspaces.Remove(workspace); } void Widget_Closed(object sender, EventArgs args) { partTab.CloseClicked -= Tab_CloseClicked; partTab.Closed -= Widget_Closed; } partTab.CloseClicked += Tab_CloseClicked; partTab.Closed += Widget_Closed; return(partTab); }
public async Task <ChromeTab> CreatePartTab() { var history = ApplicationController.Instance.Library.PlatingHistory; var workspace = new PartWorkspace() { Name = "New Design".Localize() + (partCount == 0 ? "" : $" ({partCount})"), SceneContext = new BedConfig(history) }; partCount++; await workspace.SceneContext.LoadContent( new EditContext() { ContentStore = ApplicationController.Instance.Library.PlatingHistory, SourceItem = history.NewPlatingItem() }); ApplicationController.Instance.Workspaces.Add(workspace); var newTab = CreatePartTab(workspace); tabControl.ActiveTab = newTab; return(newTab); }
private async void Instance_OpenNewFile(object sender, string filePath) { var history = ApplicationController.Instance.Library.PlatingHistory; var workspace = new PartWorkspace(new BedConfig(history)) { Name = Path.GetFileName(filePath), }; ApplicationController.Instance.Workspaces.Add(workspace); var scene = new Object3D(); scene.Children.Add( new Object3D { MeshPath = filePath, Name = Path.GetFileName(filePath) }); await workspace.SceneContext.LoadContent( new EditContext() { ContentStore = ApplicationController.Instance.Library.PlatingHistory, SourceItem = new InMemoryLibraryItem(scene) }); ApplicationController.Instance.Workspaces.Add(workspace); var newTab = CreatePartTab(workspace); tabControl.ActiveTab = newTab; }
private ChromeTab CreatePrinterTab(PartWorkspace workspace, ThemeConfig theme) { var printer = workspace.Printer; // Printer page is in fixed position var tab1 = tabControl.AllTabs.FirstOrDefault(); var printerTabPage = tab1?.TabContent as PrinterTabPage; if (printerTabPage == null || printerTabPage.printer != printer) { // TODO - call save before remove // printerTabPage.sceneContext.SaveChanges(); if (printerTabPage != null) { tabControl.RemoveTab(tab1); } var printerTab = new ChromeTab( printer.Settings.GetValue(SettingsKey.printer_name), printer.Settings.GetValue(SettingsKey.printer_name), tabControl, new PrinterTabPage(workspace, theme, "unused_tab_title"), theme, tabImageUrl: ApplicationController.Instance.GetFavIconUrl(oemName: printer.Settings.GetValue(SettingsKey.make))) { Name = "3D View Tab", MinimumSize = new Vector2(120, theme.TabButtonHeight) }; printerTab.CloseClicked += (s, e) => { ApplicationController.Instance.ClosePrinter(printer); }; printer.Settings.SettingChanged += Printer_SettingChanged; // Unregister listener on Tab close printerTab.Closed += (s, e) => printer.Settings.SettingChanged -= Printer_SettingChanged; // Add printer tab tabControl.AddTab(printerTab); return(printerTab); } else if (tab1 != null) { tabControl.ActiveTab = tab1; return(tab1 as ChromeTab); } return(null); }
public async Task <ChromeTab> CreatePartTab(PartWorkspace workspace, bool saveLayout) { var partTab = new ChromeTab( workspace.Name, workspace.Name, tabControl, new PartTabPage(workspace, theme, ""), theme, StaticData.Instance.LoadIcon("cube.png", 16, 16).SetToColor(theme.TextColor)) { Name = "newPart" + tabControl.AllTabs.Count(), }; EnableReduceWidth(partTab, theme); tabControl.AddTab(partTab); void Tab_CloseClicked(object sender, EventArgs args) { ApplicationController.Instance.Workspaces.Remove(workspace); } // add a right click menu partTab.Click += (s, e) => { if (e.Button == MouseButtons.Right) { AddRightClickTabMenu(tabControl, partTab, null, workspace, e); } }; void Widget_Closed(object sender, EventArgs args) { partTab.CloseClicked -= Tab_CloseClicked; partTab.Closed -= Widget_Closed; } partTab.CloseClicked += Tab_CloseClicked; partTab.Closed += Widget_Closed; if (saveLayout) { await ApplicationController.Instance.PersistUserTabs(); } return(partTab); }
public ChromeTab CreatePartTab(PartWorkspace workspace) { var partTab = new ChromeTab( workspace.Name, workspace.Name, tabControl, new PartTabPage(workspace, theme, ""), theme, AggContext.StaticData.LoadIcon("cube.png", 16, 16, theme.InvertIcons)) { Name = "newPart" + tabControl.AllTabs.Count(), MinimumSize = new Vector2(120, theme.TabButtonHeight), }; partTab.MaximumSize = new Vector2(partTab.Width, partTab.MaximumSize.Y); partTab.HAnchor = HAnchor.Stretch; var textWidget = partTab.Descendants <TextWidget>().First(); textWidget.HAnchor = HAnchor.Stretch; var tabPill = partTab.Descendants <SimpleTab.TabPill>().First(); partTab.ToolTipText = textWidget.Text; tabPill.HAnchor = HAnchor.Stretch; var tabPillMarign = tabPill.Margin; tabPill.Margin = new BorderDouble(tabPillMarign.Left, tabPillMarign.Bottom, tabPillMarign.Right + 10, tabPillMarign.Top); tabControl.AddTab(partTab); void Tab_CloseClicked(object sender, EventArgs args) { ApplicationController.Instance.Workspaces.Remove(workspace); } void Widget_Closed(object sender, EventArgs args) { partTab.CloseClicked -= Tab_CloseClicked; partTab.Closed -= Widget_Closed; } partTab.CloseClicked += Tab_CloseClicked; partTab.Closed += Widget_Closed; return(partTab); }
public ChromeTab CreatePartTab(PartWorkspace workspace) { var partTab = new ChromeTab( workspace.Name, workspace.Name, tabControl, new PartTabPage(workspace, theme, ""), theme, StaticData.Instance.LoadIcon("cube.png", 16, 16, theme.InvertIcons)) { Name = "newPart" + tabControl.AllTabs.Count(), }; EnableReduceWidth(partTab, theme); tabControl.AddTab(partTab); void Tab_CloseClicked(object sender, EventArgs args) { ApplicationController.Instance.Workspaces.Remove(workspace); } // add a right click menu partTab.Click += (s, e) => { if (e.Button == MouseButtons.Right) { AddRightClickTabMenu(tabControl, partTab, null, workspace, e); } }; void Widget_Closed(object sender, EventArgs args) { partTab.CloseClicked -= Tab_CloseClicked; partTab.Closed -= Widget_Closed; } partTab.CloseClicked += Tab_CloseClicked; partTab.Closed += Widget_Closed; return(partTab); }
public ChromeTab CreatePartTab(PartWorkspace workspace) { var partTab = new ChromeTab( workspace.Name, workspace.Name, tabControl, new PartTabPage(null, workspace.SceneContext, theme, ""), theme, AggContext.StaticData.LoadIcon("cube.png", 16, 16, theme.InvertIcons)) { Name = "newPart" + tabControl.AllTabs.Count(), MinimumSize = new Vector2(120, theme.TabButtonHeight) }; tabControl.AddTab(partTab); partTab.CloseClicked += (s, e) => { ApplicationController.Instance.Workspaces.Remove(workspace); }; return(partTab); }
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 void AddRightClickTabMenu(ChromeTabs tabs, ChromeTab printerTab, PrinterConfig printer, PartWorkspace workspace, MouseEventArgs mouseEvent) { var menuTheme = ApplicationController.Instance.MenuTheme; var popupMenu = new PopupMenu(menuTheme); var renameMenuItem = popupMenu.CreateMenuItem("Rename".Localize()); renameMenuItem.Click += (s, e) => { if (workspace != null) { workspace.LibraryView.ActiveContainer.Rename(workspace.LibraryView.ActiveContainer.Items.FirstOrDefault()); } else if (printer != null) { DialogWindow.Show( new InputBoxPage( "Rename Item".Localize(), "Name".Localize(), printer.Settings.GetValue(SettingsKey.printer_name), "Enter New Name Here".Localize(), "Rename".Localize(), (newName) => { printer.Settings.SetValue(SettingsKey.printer_name, newName); })); } }; var moveButtons = new FlowLayoutWidget(); var textWidget = new TextWidget("Move Tab", pointSize: theme.DefaultFontSize, textColor: theme.TextColor) { Margin = PopupMenu.MenuPadding.Clone(PopupMenu.MenuPadding.Left - 5, right: 5), VAnchor = VAnchor.Center, }; moveButtons.AddChild(textWidget); var buttonSize = 24 * DeviceScale; var moveLeftButton = new IconButton(StaticData.Instance.LoadIcon("fa-angle-right_12.png", 14, 14, theme.InvertIcons).MirrorX(), theme) { Width = buttonSize, Height = buttonSize, Margin = new BorderDouble(3, 0), HoverColor = theme.AccentMimimalOverlay, VAnchor = VAnchor.Center, Enabled = tabs.GetTabIndex(printerTab) > tabs.FirstMovableTab, }; moveLeftButton.Click += (s, e) => { tabs.MoveTabLeft(printerTab); popupMenu.Unfocus(); }; moveButtons.AddChild(moveLeftButton); var moveRightButton = new IconButton(StaticData.Instance.LoadIcon("fa-angle-right_12.png", 14, 14, theme.InvertIcons), theme) { Width = buttonSize, Height = buttonSize, Margin = new BorderDouble(3, 0), HoverColor = theme.AccentMimimalOverlay, VAnchor = VAnchor.Center, Enabled = printerTab.NextTab != null, }; moveRightButton.Click += (s, e) => { tabs.MoveTabRight(printerTab); popupMenu.Unfocus(); }; moveButtons.AddChild(moveRightButton); popupMenu.AddChild(moveButtons); popupMenu.ShowMenu(printerTab, mouseEvent); }
private ChromeTab CreatePrinterTab(PartWorkspace workspace, ThemeConfig theme) { var printer = workspace.Printer; // Printer page is in fixed position var tab1 = tabControl.AllTabs.FirstOrDefault(); var printerTabPage = tab1?.TabContent as PrinterTabPage; if (printerTabPage == null || printerTabPage.Printer != printer) { // TODO - call save before remove // printerTabPage.sceneContext.SaveChanges(); if (printerTabPage != null) { tabControl.CloseTab(tab1); } var printerTab = new ChromeTab( printer.Settings.GetValue(SettingsKey.printer_name), printer.Settings.GetValue(SettingsKey.printer_name), tabControl, new PrinterTabPage(workspace, theme, "unused_tab_title"), theme, tabImageUrl: ApplicationController.Instance.GetFavIconUrl(oemName: printer.Settings.GetValue(SettingsKey.make))) { Name = $"3D View Tab {debugPrinterTabIndex++}", }; // add a right click menu printerTab.Click += (s, e) => { if (e.Button == MouseButtons.Right) { AddRightClickTabMenu(tabControl, printerTab, printer, null, e); } }; EnableReduceWidth(printerTab, theme); void Tab_CloseClicked(object sender, EventArgs args) { ApplicationController.Instance.ClosePrinter(printer); } void Widget_Closed(object sender, EventArgs args) { // Unregister listeners printerTab.CloseClicked -= Tab_CloseClicked; printerTab.Closed -= Widget_Closed; printer.Settings.SettingChanged -= Printer_SettingChanged; } // Register listeners printer.Settings.SettingChanged += Printer_SettingChanged; printerTab.CloseClicked += Tab_CloseClicked; printerTab.Closed += Widget_Closed; // Add printer tab tabControl.AddTab(printerTab); return(printerTab); } else if (tab1 != null) { tabControl.ActiveTab = tab1; return(tab1 as ChromeTab); } return(null); }
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 ViewControls3D(PartWorkspace workspace, ThemeConfig theme, UndoBuffer undoBuffer, bool isPrinterType, bool showPrintButton) : base(theme) { this.theme = theme; this.undoBuffer = undoBuffer; this.ActionArea.Click += (s, e) => { view3DWidget.Object3DControlLayer.Focus(); }; this.OverflowButton.ToolTipText = "Tool Bar Overflow".Localize(); this.OverflowButton.DynamicPopupContent = () => { bool IncludeInMenu(SceneOperation operation) { foreach (var widget in this.ActionArea.Children.Where(c => !c.Visible && !ignoredInMenuTypes.Contains(c.GetType()))) { if (operationButtons.TryGetValue(widget, out SceneOperation buttonOperation) && buttonOperation == operation) { return(true); } } return(false); } return(SceneOperations.GetToolbarOverflowMenu(AppContext.MenuTheme, sceneContext, IncludeInMenu)); }; this.IsPrinterMode = isPrinterType; this.sceneContext = workspace.SceneContext; this.workspace = workspace; string iconPath; this.AddChild(CreateAddButton(sceneContext, theme)); this.AddChild(new ToolbarSeparator(theme.GetBorderColor(50), theme.SeparatorMargin)); bedMenuButton = new PopupMenuButton(StaticData.Instance.LoadIcon("bed.png", 16, 16, theme.InvertIcons), theme) { Name = "Bed Options Menu", ToolTipText = "Bed", Enabled = true, Margin = theme.ButtonSpacing, VAnchor = VAnchor.Center, DrawArrow = true }; this.AddChild(bedMenuButton); this.AddChild(new ToolbarSeparator(theme.GetBorderColor(50), theme.SeparatorMargin)); this.AddChild(CreateOpenButton(theme)); this.AddChild(CreateSaveButton(theme)); this.AddChild(new ToolbarSeparator(theme.GetBorderColor(50), theme.SeparatorMargin)); undoButton = new IconButton(StaticData.Instance.LoadIcon("Undo_grey_16x.png", 16, 16, theme.InvertIcons), theme) { Name = "3D View Undo", ToolTipText = "Undo".Localize(), Enabled = false, Margin = theme.ButtonSpacing, VAnchor = VAnchor.Center }; undoButton.Click += (sender, e) => { sceneContext.Scene.Undo(); view3DWidget.Object3DControlLayer.Focus(); }; this.AddChild(undoButton); redoButton = new IconButton(StaticData.Instance.LoadIcon("Redo_grey_16x.png", 16, 16, theme.InvertIcons), theme) { Name = "3D View Redo", Margin = theme.ButtonSpacing, ToolTipText = "Redo".Localize(), Enabled = false, VAnchor = VAnchor.Center }; redoButton.Click += (sender, e) => { sceneContext.Scene.Redo(); view3DWidget.Object3DControlLayer.Focus(); }; this.AddChild(redoButton); if (showPrintButton) { var printButton = new TextButton("Print", theme) { Name = "Print Button", BackgroundColor = theme.AccentMimimalOverlay }; printButton.Click += (s, e) => { view3DWidget.PushToPrinterAndPrint(); }; this.AddChild(printButton); } this.AddChild(new ToolbarSeparator(theme.GetBorderColor(50), theme.SeparatorMargin)); undoButton.Enabled = undoBuffer.UndoCount > 0; redoButton.Enabled = undoBuffer.RedoCount > 0; var buttonGroupA = new ObservableCollection <GuiWidget>(); if (UserSettings.Instance.IsTouchScreen) { iconPath = Path.Combine("ViewTransformControls", "rotate.png"); rotateButton = new RadioIconButton(StaticData.Instance.LoadIcon(iconPath, 32, 32, theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroupA, ToolTipText = "Rotate (Alt + Left Mouse)".Localize(), Margin = theme.ButtonSpacing }; rotateButton.Click += (s, e) => this.ActiveButton = ViewControls3DButtons.Rotate; buttonGroupA.Add(rotateButton); AddChild(rotateButton); iconPath = Path.Combine("ViewTransformControls", "translate.png"); translateButton = new RadioIconButton(StaticData.Instance.LoadIcon(iconPath, 32, 32, theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroupA, ToolTipText = "Move (Shift + Left Mouse)".Localize(), Margin = theme.ButtonSpacing }; translateButton.Click += (s, e) => this.ActiveButton = ViewControls3DButtons.Translate; buttonGroupA.Add(translateButton); AddChild(translateButton); iconPath = Path.Combine("ViewTransformControls", "scale.png"); scaleButton = new RadioIconButton(StaticData.Instance.LoadIcon(iconPath, 32, 32, theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroupA, ToolTipText = "Zoom (Ctrl + Left Mouse)".Localize(), Margin = theme.ButtonSpacing }; scaleButton.Click += (s, e) => this.ActiveButton = ViewControls3DButtons.Scale; buttonGroupA.Add(scaleButton); AddChild(scaleButton); rotateButton.Checked = true; // Add vertical separator this.AddChild(new ToolbarSeparator(theme.GetBorderColor(50), theme.SeparatorMargin)); iconPath = Path.Combine("ViewTransformControls", "partSelect.png"); partSelectButton = new RadioIconButton(StaticData.Instance.LoadIcon(iconPath, 32, 32, theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroupA, ToolTipText = "Select Part".Localize(), Margin = theme.ButtonSpacing }; partSelectButton.Click += (s, e) => this.ActiveButton = ViewControls3DButtons.PartSelect; buttonGroupA.Add(partSelectButton); AddChild(partSelectButton); } operationButtons = new Dictionary <GuiWidget, SceneOperation>(); // Add Selected IObject3D -> Operations to toolbar foreach (var namedAction in SceneOperations.All) { if (namedAction is SceneSelectionSeparator) { this.AddChild(new ToolbarSeparator(theme.GetBorderColor(50), theme.SeparatorMargin)); continue; } // add the create support before the align if (namedAction is OperationGroup group && group.Id == "Transform") { this.AddChild(CreateSupportButton(theme)); this.AddChild(new ToolbarSeparator(theme.GetBorderColor(50), theme.SeparatorMargin)); } GuiWidget button = null; if (namedAction is OperationGroup operationGroup) { if (operationGroup.Collapse) { var defaultOperation = operationGroup.GetDefaultOperation(); PopupMenuButton groupButton = null; groupButton = theme.CreateSplitButton( new SplitButtonParams() { Icon = defaultOperation.Icon(theme.InvertIcons), DefaultAction = (menuButton) => { defaultOperation.Action.Invoke(sceneContext); }, DefaultActionTooltip = defaultOperation.HelpText ?? defaultOperation.Title, ButtonName = defaultOperation.Title, ExtendPopupMenu = (PopupMenu popupMenu) => { foreach (var operation in operationGroup.Operations) { var operationMenu = popupMenu.CreateMenuItem(operation.Title, operation.Icon?.Invoke(theme.InvertIcons)); operationMenu.Enabled = operation.IsEnabled(sceneContext); operationMenu.ToolTipText = operation.Title; if (!operationMenu.Enabled && !string.IsNullOrEmpty(operation.HelpText)) { operationMenu.ToolTipText += "\n\n" + operation.HelpText; } operationMenu.Click += (s, e) => UiThread.RunOnIdle(() => { if (defaultOperation != operation) { // Update button var iconButton = groupButton.Children.OfType <IconButton>().First(); iconButton.SetIcon(operation.Icon(theme.InvertIcons)); iconButton.ToolTipText = operation.HelpText ?? operation.Title; UserSettings.Instance.set(operationGroup.GroupRecordId, operationGroup.Operations.IndexOf(operation).ToString()); defaultOperation = operation; iconButton.Invalidate(); } operation.Action?.Invoke(sceneContext); }); } } }, operationGroup); button = groupButton; } else { if (!(this.ActionArea.Children.LastOrDefault() is ToolbarSeparator)) { this.AddChild(new ToolbarSeparator(theme.GetBorderColor(50), theme.SeparatorMargin)); } foreach (var operation in operationGroup.Operations) { var operationButton = new OperationIconButton(operation, sceneContext, theme); operationButtons.Add(operationButton, operation); this.AddChild(operationButton); } this.AddChild(new ToolbarSeparator(theme.GetBorderColor(50), theme.SeparatorMargin)); } } else if (namedAction.Icon != null) { button = new IconButton(namedAction.Icon(theme.InvertIcons), theme) { Name = namedAction.Title + " Button", ToolTipText = namedAction.Title, Margin = theme.ButtonSpacing, BackgroundColor = theme.ToolbarButtonBackground, HoverColor = theme.ToolbarButtonHover, MouseDownColor = theme.ToolbarButtonDown, }; } else { button = new TextButton(namedAction.Title, theme) { Name = namedAction.Title + " Button", Margin = theme.ButtonSpacing, BackgroundColor = theme.ToolbarButtonBackground, HoverColor = theme.ToolbarButtonHover, MouseDownColor = theme.ToolbarButtonDown, }; } if (button != null) { operationButtons.Add(button, namedAction); // Only bind Click event if not a SplitButton if (!(button is PopupMenuButton)) { button.Click += (s, e) => UiThread.RunOnIdle(() => { namedAction.Action.Invoke(sceneContext); var partTab = button.Parents <PartTabPage>().FirstOrDefault(); var view3D = partTab.Descendants <View3DWidget>().FirstOrDefault(); view3D.Object3DControlLayer.Focus(); }); } this.AddChild(button); } } // Register listeners undoBuffer.Changed += UndoBuffer_Changed; sceneContext.Scene.SelectionChanged += UpdateToolbarButtons; sceneContext.Scene.ItemsModified += UpdateToolbarButtons; // Run on load UpdateToolbarButtons(null, null); }
public PartTabPage(PartWorkspace workspace, ThemeConfig theme, string tabTitle) : base(tabTitle) { this.sceneContext = workspace.SceneContext; this.theme = theme; this.BackgroundColor = theme.BackgroundColor; this.Padding = 0; this.printer = workspace.Printer; this.workspace = workspace; bool isPrinterType = this is PrinterTabPage; var favoritesBarAndView3DWidget = new FlowLayoutWidget() { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch }; viewControls3D = new ViewControls3D(workspace, theme, sceneContext.Scene.UndoBuffer, isPrinterType, !(this is PrinterTabPage)) { VAnchor = VAnchor.Top | VAnchor.Fit, HAnchor = HAnchor.Left | HAnchor.Stretch, Visible = true, }; theme.ApplyBottomBorder(viewControls3D, shadedBorder: (this is PrinterTabPage)); // Shade border if toolbar is secondary rather than primary viewControls3D.ResetView += (sender, e) => { if (view3DWidget.Visible) { this.view3DWidget.ResetView(); } }; viewControls3D.ExtendOverflowMenu = this.GetViewControls3DOverflowMenu; viewControls3D.OverflowButton.Name = "View3D Overflow Menu"; // The 3D model view view3DWidget = new View3DWidget( printer, sceneContext, viewControls3D, theme, this, editorType: (isPrinterType) ? InteractionLayer.EditorType.Printer : InteractionLayer.EditorType.Part); viewControls3D.SetView3DWidget(view3DWidget); this.AddChild(topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch }); topToBottom.AddChild(leftToRight = new FlowLayoutWidget() { Name = "View3DContainerParent", HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch }); view3DContainer = new GuiWidget() { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch }; var toolbarAndView3DWidget = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch }; toolbarAndView3DWidget.AddChild(viewControls3D); var favoritesBarContext = new LibraryConfig() { ActiveContainer = ApplicationController.Instance.Library.RootLibaryContainer }; var leftBar = new GuiWidget() { VAnchor = VAnchor.Stretch, HAnchor = HAnchor.Fit, Border = new BorderDouble(top: 1, right: 1), BorderColor = theme.BorderColor20, }; favoritesBarAndView3DWidget.AddChild(leftBar); bool expanded = UserSettings.Instance.get(UserSettingsKey.FavoritesBarExpansion) != "0"; favoritesBar = new LibraryListView(favoritesBarContext, theme) { Name = "LibraryView", // Drop containers ContainerFilter = (container) => false, HAnchor = HAnchor.Absolute, VAnchor = VAnchor.Stretch, AllowContextMenu = false, // restore to state for favorites bar size Width = expanded ? 55 : 33, ListContentView = new IconView(theme, expanded ? 48 : 24) { VAnchor = VAnchor.Fit | VAnchor.Top }, }; leftBar.AddChild(favoritesBar); favoritesBar.ScrollArea.VAnchor = VAnchor.Fit; var expandedImage = AggContext.StaticData.LoadIcon("expand.png", 16, 16, theme.InvertIcons); var collapsedImage = AggContext.StaticData.LoadIcon("collapse.png", 16, 16, theme.InvertIcons); var expandBarButton = new IconButton(expanded ? collapsedImage : expandedImage, theme) { HAnchor = HAnchor.Center, VAnchor = VAnchor.Absolute | VAnchor.Bottom, Margin = new BorderDouble(bottom: 3, top: 3), Height = theme.ButtonHeight - 6, Width = theme.ButtonHeight - 6 }; expandBarButton.Click += (s, e) => UiThread.RunOnIdle(() => { expanded = !expanded; UserSettings.Instance.set(UserSettingsKey.FavoritesBarExpansion, expanded ? "1" : "0"); favoritesBar.ListContentView = new IconView(theme, expanded ? 48 : 24); favoritesBar.Width = expanded ? 55 : 33; expandBarButton.SetIcon(expanded ? collapsedImage : expandedImage); expandBarButton.Invalidate(); favoritesBar.Reload().ConfigureAwait(false); }); leftBar.AddChild(expandBarButton); favoritesBar.Margin = new BorderDouble(bottom: expandBarButton.Height + expandBarButton.Margin.Height); favoritesBarAndView3DWidget.AddChild(view3DWidget); toolbarAndView3DWidget.AddChild(favoritesBarAndView3DWidget); view3DContainer.AddChild(toolbarAndView3DWidget); leftToRight.AddChild(view3DContainer); if (sceneContext.World.RotationMatrix == Matrix4X4.Identity) { this.view3DWidget.ResetView(); } this.AnchorAll(); }
public PrinterTabPage(PartWorkspace workspace, ThemeConfig theme, string tabTitle) : base(workspace, theme, tabTitle) { gcodeOptions = sceneContext.RendererOptions; view3DWidget.InteractionLayer.EditorMode = InteractionLayer.EditorType.Printer; viewControls3D.TransformStateChanged += (s, e) => { switch (e.TransformMode) { case ViewControls3DButtons.Translate: if (gcode2DWidget != null) { gcode2DWidget.TransformState = GCode2DWidget.ETransformState.Move; } break; case ViewControls3DButtons.Scale: if (gcode2DWidget != null) { gcode2DWidget.TransformState = GCode2DWidget.ETransformState.Scale; } break; } }; viewControls3D.ResetView += (sender, e) => { if (gcode2DWidget?.Visible == true) { gcode2DWidget.CenterPartInView(); } }; var opaqueTrackColor = theme.ResolveColor(theme.BedBackgroundColor, theme.SlightShade); LayerScrollbar = new SliceLayerSelector(printer, theme) { VAnchor = VAnchor.Stretch, HAnchor = HAnchor.Right | HAnchor.Fit, Margin = new BorderDouble(0, 4, 4, 4), Maximum = sceneContext.LoadedGCode?.LayerCount ?? 1 }; LayerScrollbar.SolidSlider.View.TrackColor = opaqueTrackColor; view3DWidget.InteractionLayer.AddChild(LayerScrollbar); layerRenderRatioSlider = new DoubleSolidSlider(new Vector2(), SliceLayerSelector.SliderWidth, theme); layerRenderRatioSlider.FirstValue = 0; layerRenderRatioSlider.FirstValueChanged += (s, e) => { sceneContext.RenderInfo.FeatureToStartOnRatio0To1 = layerRenderRatioSlider.FirstValue; sceneContext.RenderInfo.FeatureToEndOnRatio0To1 = layerRenderRatioSlider.SecondValue; this.Invalidate(); }; layerRenderRatioSlider.SecondValue = 1; layerRenderRatioSlider.SecondValueChanged += (s, e) => { if (printer?.Bed?.RenderInfo != null) { sceneContext.RenderInfo.FeatureToStartOnRatio0To1 = layerRenderRatioSlider.FirstValue; sceneContext.RenderInfo.FeatureToEndOnRatio0To1 = layerRenderRatioSlider.SecondValue; } this.Invalidate(); }; view3DWidget.InteractionLayer.AddChild(layerRenderRatioSlider); theme.ApplySliderStyle(layerRenderRatioSlider); layerRenderRatioSlider.View.TrackColor = opaqueTrackColor; AddSettingsTabBar(leftToRight, view3DWidget); view3DWidget.InteractionLayer.BoundsChanged += (s, e) => { SetSliderSizes(); }; printerActionsBar = new PrinterActionsBar(printer, this, theme); theme.ApplyBottomBorder(printerActionsBar); printerActionsBar.modelViewButton.Enabled = sceneContext.EditableScene; // Must come after we have an instance of View3DWidget an its undo buffer topToBottom.AddChild(printerActionsBar, 0); var trackball = view3DWidget.InteractionLayer.Children <TrackballTumbleWidget>().FirstOrDefault(); tumbleCubeControl = view3DWidget.InteractionLayer.Children <TumbleCubeControl>().FirstOrDefault(); var position = view3DWidget.InteractionLayer.Children.IndexOf(trackball); gcodePanel = new GCodePanel(this, printer, sceneContext, theme) { Name = "GCode3DWidget", HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, BackgroundColor = theme.InteractionLayerOverlayColor, }; var modelViewSidePanel = view3DWidget.Descendants <VerticalResizeContainer>().FirstOrDefault(); gcodeContainer = new VerticalResizeContainer(theme, GrabBarSide.Left) { Width = printer?.ViewState.SelectedObjectPanelWidth ?? 200, VAnchor = VAnchor.Stretch, HAnchor = HAnchor.Absolute, SplitterBarColor = theme.SplitterBackground, SplitterWidth = theme.SplitterWidth, Visible = false, }; gcodeContainer.AddChild(gcodePanel); gcodeContainer.Resized += (s, e) => { if (printer != null) { printer.ViewState.SelectedObjectPanelWidth = gcodeContainer.Width; } }; modelViewSidePanel.BoundsChanged += (s, e) => { gcodeContainer.Width = modelViewSidePanel.Width; }; gcodeContainer.BoundsChanged += (s, e) => { modelViewSidePanel.Width = gcodeContainer.Width; }; var splitContainer = view3DWidget.FindDescendant("SplitContainer"); splitContainer.AddChild(gcodeContainer); view3DContainer.AddChild(new RunningTasksWidget(theme, printer) { MinimumSize = new Vector2(100, 0), Margin = new BorderDouble(top: printerActionsBar.Height + 1, left: favoritesBar.LocalBounds.Width + favoritesBar.DeviceMarginAndBorder.Width + 1), VAnchor = VAnchor.Top | VAnchor.Fit, HAnchor = HAnchor.Left | HAnchor.Fit, }); // Create and append new widget gcode2DWidget = new GCode2DWidget(printer, theme) { Visible = (printer.ViewState.ViewMode == PartViewMode.Layers2D) }; view3DWidget.InteractionLayer.AddChild(gcode2DWidget, position + 1); SetSliderSizes(); this.SetViewMode(printer.ViewState.ViewMode); this.LayerScrollbar.Margin = LayerScrollbar.Margin.Clone(top: tumbleCubeControl.Height + tumbleCubeControl.Margin.Height + 4); // On load, switch to gcode view if previously editing gcode file. Listeners would normally do this but workspace loads before this UI widget if (this?.printerActionsBar?.modelViewButton is GuiWidget button) { button.Enabled = sceneContext.EditableScene; if (sceneContext.ContentType == "gcode" && this?.printerActionsBar?.layers3DButton is GuiWidget gcodeButton) { gcodeButton.InvokeClick(); } } // Register listeners printer.ViewState.VisibilityChanged += ProcessOptionalTabs; printer.ViewState.ViewModeChanged += ViewState_ViewModeChanged; printer.Bed.RendererOptions.PropertyChanged += RendererOptions_PropertyChanged; // register for communication messages printer.Connection.CommunicationStateChanged += Connection_CommunicationStateChanged; printer.Connection.PauseOnLayer += Connection_PauseOnLayer; printer.Connection.FilamentRunout += Connection_FilamentRunout; ApplicationController.Instance.ApplicationError += ApplicationController_ApplicationError; ApplicationController.Instance.ApplicationEvent += ApplicationController_ApplicationEvent; sceneContext.LoadedGCodeChanged += BedPlate_LoadedGCodeChanged; }
public PartTabPage(PartWorkspace workspace, ThemeConfig theme, string tabTitle) : base(tabTitle) { this.sceneContext = workspace.SceneContext; this.theme = theme; this.BackgroundColor = theme.BackgroundColor; this.Padding = 0; this.Workspace = workspace; bool isPrinterType = this is PrinterTabPage; var favoritesBarAndView3DWidget = new FlowLayoutWidget() { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch }; viewControls3D = new ViewControls3D(workspace, theme, sceneContext.Scene.UndoBuffer, isPrinterType, !(this is PrinterTabPage)) { VAnchor = VAnchor.Top | VAnchor.Fit, HAnchor = HAnchor.Left | HAnchor.Stretch, Visible = true, }; // Shade border if toolbar is secondary rather than primary theme.ApplyBottomBorder(viewControls3D, shadedBorder: this is PrinterTabPage); viewControls3D.ResetView += (sender, e) => { if (view3DWidget.Visible) { this.view3DWidget.ResetView(); } }; viewControls3D.ExtendOverflowMenu = this.GetViewControls3DOverflowMenu; viewControls3D.OverflowButton.Name = "View3D Overflow Menu"; // The 3D model view view3DWidget = new View3DWidget( Printer, sceneContext, viewControls3D, theme, this, editorType: isPrinterType ? Object3DControlsLayer.EditorType.Printer : Object3DControlsLayer.EditorType.Part); viewControls3D.SetView3DWidget(view3DWidget); this.AddChild(topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch }); topToBottom.AddChild(leftToRight = new FlowLayoutWidget() { Name = "View3DContainerParent", HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch }); view3DContainer = new GuiWidget() { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch }; var toolbarAndView3DWidget = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch }; toolbarAndView3DWidget.AddChild(viewControls3D); var favoritesBarContext = new LibraryConfig() { ActiveContainer = ApplicationController.Instance.Library.RootLibaryContainer }; var leftBar = new GuiWidget() { VAnchor = VAnchor.Stretch, HAnchor = HAnchor.Fit, Border = new BorderDouble(top: 1, right: 1), BorderColor = theme.BorderColor20, }; favoritesBarAndView3DWidget.AddChild(leftBar); bool expanded = UserSettings.Instance.get(UserSettingsKey.FavoritesBarExpansion) != "0"; favoritesBar = new LibraryListView(favoritesBarContext, theme) { Name = "LibraryView", // Drop containers ContainerFilter = (container) => false, // HAnchor = HAnchor.Fit, HAnchor = HAnchor.Absolute, VAnchor = VAnchor.Stretch, AllowContextMenu = false, ActiveSort = SortKey.ModifiedDate, Ascending = true, // restore to state for favorites bar size Width = expanded ? 55 * GuiWidget.DeviceScale : 33 * GuiWidget.DeviceScale, ListContentView = new IconView(theme, expanded ? 48 * GuiWidget.DeviceScale : 24 * GuiWidget.DeviceScale) { VAnchor = VAnchor.Fit | VAnchor.Top }, }; // favoritesBar.ScrollArea.HAnchor = HAnchor.Fit; favoritesBar.ListContentView.HAnchor = HAnchor.Fit; leftBar.AddChild(favoritesBar); void UpdateWidth(object s, EventArgs e) { if (s is GuiWidget widget) { favoritesBar.Width = widget.Width; } } favoritesBar.ListContentView.BoundsChanged += UpdateWidth; favoritesBar.ScrollArea.VAnchor = VAnchor.Fit; favoritesBar.VerticalScrollBar.Show = ScrollBar.ShowState.Never; var expandedImage = StaticData.Instance.LoadIcon("expand.png", 16, 16).SetToColor(theme.TextColor); var collapsedImage = StaticData.Instance.LoadIcon("collapse.png", 16, 16).SetToColor(theme.TextColor); var expandBarButton = new IconButton(expanded ? collapsedImage : expandedImage, theme) { HAnchor = HAnchor.Center, VAnchor = VAnchor.Absolute | VAnchor.Bottom, Margin = new BorderDouble(bottom: 3, top: 3), Height = theme.ButtonHeight - 6 * GuiWidget.DeviceScale, Width = theme.ButtonHeight - 6 * GuiWidget.DeviceScale, ToolTipText = expanded ? "Reduced Width".Localize() : "Expand Width".Localize(), }; expandBarButton.Click += (s, e) => UiThread.RunOnIdle(async() => { expanded = !expanded; // remove from the one we are deleting favoritesBar.ListContentView.BoundsChanged -= UpdateWidth; UserSettings.Instance.set(UserSettingsKey.FavoritesBarExpansion, expanded ? "1" : "0"); favoritesBar.ListContentView = new IconView(theme, expanded ? 48 * GuiWidget.DeviceScale : 24 * GuiWidget.DeviceScale); favoritesBar.ListContentView.HAnchor = HAnchor.Fit; // add to the one we created favoritesBar.ListContentView.BoundsChanged += UpdateWidth; expandBarButton.SetIcon(expanded ? collapsedImage : expandedImage); expandBarButton.Invalidate(); expandBarButton.ToolTipText = expanded ? "Reduced Width".Localize() : "Expand Width".Localize(); await favoritesBar.Reload(); UpdateWidth(favoritesBar.ListContentView, null); }); leftBar.AddChild(expandBarButton); favoritesBar.Margin = new BorderDouble(bottom: expandBarButton.Height + expandBarButton.Margin.Height); favoritesBarAndView3DWidget.AddChild(view3DWidget); toolbarAndView3DWidget.AddChild(favoritesBarAndView3DWidget); view3DContainer.AddChild(toolbarAndView3DWidget); leftToRight.AddChild(view3DContainer); if (sceneContext.World.RotationMatrix == Matrix4X4.Identity) { this.view3DWidget.ResetView(); } this.AnchorAll(); }
public ViewToolBarControls(PartWorkspace workspace, ThemeConfig theme, UndoBuffer undoBuffer, bool isPrinterType, bool showPrintButton) { this.undoBuffer = undoBuffer; this.IsPrinterMode = isPrinterType; this.sceneContext = workspace.SceneContext; this.workspace = workspace; this.RowPadding = 0; this.RowBoarder = new BorderDouble(0, 0, 0, 1); this.RowBoarderColor = theme.GetBorderColor(50); var openLibraryButton = CreateOpenLibraryButton(sceneContext, theme); this.AddChild(CreateOpenFileButton(openLibraryButton, theme)); this.AddChild(CreateSaveButton(theme)); this.AddChild(new ToolbarSeparator(theme.GetBorderColor(50), theme.SeparatorMargin)); bedMenuButton = new PopupMenuButton("Bed".Localize(), StaticData.Instance.LoadIcon("bed.png", 16, 16).SetToColor(theme.TextColor), theme) { Name = "Bed Options Menu", Enabled = true, Margin = theme.ButtonSpacing, VAnchor = VAnchor.Center, DrawArrow = true }; this.AddChild(bedMenuButton); this.AddChild(new ToolbarSeparator(theme.GetBorderColor(50), theme.SeparatorMargin)); undoButton = new IconButton(StaticData.Instance.LoadIcon("undo.png", 16, 16).SetToColor(theme.TextColor), theme) { Name = "3D View Undo", ToolTipText = "Undo".Localize(), Enabled = false, Margin = theme.ButtonSpacing, VAnchor = VAnchor.Center }; undoButton.Click += (sender, e) => { sceneContext.Scene.Undo(); view3DWidget.Object3DControlLayer.Focus(); }; this.AddChild(undoButton); redoButton = new IconButton(StaticData.Instance.LoadIcon("redo.png", 16, 16).SetToColor(theme.TextColor), theme) { Name = "3D View Redo", Margin = theme.ButtonSpacing, ToolTipText = "Redo".Localize(), Enabled = false, VAnchor = VAnchor.Center }; redoButton.Click += (sender, e) => { sceneContext.Scene.Redo(); view3DWidget.Object3DControlLayer.Focus(); }; this.AddChild(redoButton); if (showPrintButton) { var printButton = new TextButton("Print", theme) { Name = "Print Button", BackgroundColor = theme.AccentMimimalOverlay }; printButton.Click += (s, e) => { view3DWidget.PushToPrinterAndPrint(); }; this.AddChild(printButton); } this.AddChild(new ToolbarSeparator(theme.GetBorderColor(50), theme.SeparatorMargin)); undoButton.Enabled = undoBuffer.UndoCount > 0; redoButton.Enabled = undoBuffer.RedoCount > 0; operationButtons = new Dictionary <GuiWidget, SceneOperation>(); // Add Selected IObject3D -> Operations to toolbar foreach (var namedAction in SceneOperations.All) { if (namedAction is SceneSelectionSeparator) { this.AddChild(new ToolbarSeparator(theme.GetBorderColor(50), theme.SeparatorMargin)); continue; } // add the create support before the align if (namedAction is OperationGroup group && group.Id == "Transform") { this.AddChild(CreateSupportButton(theme)); this.AddChild(new ToolbarSeparator(theme.GetBorderColor(50), theme.SeparatorMargin)); } if (namedAction is OperationGroup operationGroup) { var expandoSet = new FlowLayoutWidget(); var actionDropDown = CreateActionDropDown(theme, operationGroup); var operationButtonGroup = CreateOperationButtonGroup(theme, operationGroup); void UpdateVisability(object s, EventArgs e) { if (operationGroup.Visible) { if (operationGroup.Collapse) { actionDropDown.Visible = true; operationButtonGroup.Visible = false; DoWrappingLayout(); } else { actionDropDown.Visible = false; operationButtonGroup.Visible = true; DoWrappingLayout(); } } else { actionDropDown.Visible = false; operationButtonGroup.Visible = false; DoWrappingLayout(); } } UserSettings.Instance.SettingChanged += UpdateVisability; operationGroup.CollapseChanged += UpdateVisability; operationGroup.VisibleChanged += UpdateVisability; this.Closed += (s, e) => { UserSettings.Instance.SettingChanged -= UpdateVisability; operationGroup.CollapseChanged -= UpdateVisability; operationGroup.VisibleChanged -= UpdateVisability; }; UpdateVisability(operationGroup, null); expandoSet.AddChild(actionDropDown); expandoSet.AddChild(operationButtonGroup); this.AddChild(expandoSet); } else { GuiWidget button; if (namedAction.Icon != null) { button = new IconButton(namedAction.Icon(theme), theme) { Name = namedAction.Title + " Button", ToolTipText = namedAction.Title, Margin = theme.ButtonSpacing, BackgroundColor = theme.ToolbarButtonBackground, HoverColor = theme.ToolbarButtonHover, MouseDownColor = theme.ToolbarButtonDown, }; } else { button = new TextButton(namedAction.Title, theme) { Name = namedAction.Title + " Button", Margin = theme.ButtonSpacing, BackgroundColor = theme.ToolbarButtonBackground, HoverColor = theme.ToolbarButtonHover, MouseDownColor = theme.ToolbarButtonDown, }; } operationButtons.Add(button, namedAction); button.Click += (s, e) => UiThread.RunOnIdle(() => { namedAction.Action.Invoke(sceneContext); var partTab = button.Parents <PartTabPage>().FirstOrDefault(); var view3D = partTab.Descendants <View3DWidget>().FirstOrDefault(); view3D.Object3DControlLayer.Focus(); }); this.AddChild(button); } } // add the options menu this.AddChild(new HorizontalSpacer()); var overflowIcon = StaticData.Instance.LoadIcon(Path.Combine("ViewTransformControls", "overflow.png"), 32, 32).SetToColor(theme.TextColor); var optionsButton = new PopupMenuButton(overflowIcon, theme) { AlignToRightEdge = true }; this.AddChild(optionsButton); optionsButton.Name = "ToolBar Overflow Menu"; optionsButton.ToolTipText = "Tool Bar Options".Localize(); optionsButton.DynamicPopupContent = () => GenerateToolBarOptionsMenu(theme); // Register listeners undoBuffer.Changed += UndoBuffer_Changed; sceneContext.Scene.SelectionChanged += UpdateToolbarButtons; sceneContext.Scene.ItemsModified += UpdateToolbarButtons; // Run on load UpdateToolbarButtons(null, null); }