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 PartTabPage(PrinterConfig printer, BedConfig sceneContext, ThemeConfig theme, string tabTitle) : base(tabTitle) { this.sceneContext = sceneContext; this.theme = theme; this.BackgroundColor = theme.ActiveTabColor; this.Padding = 0; this.printer = printer; bool isPrinterType = this is PrinterTabPage; viewControls3D = new ViewControls3D(sceneContext, theme, sceneContext.Scene.UndoBuffer, isPrinterType) { 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) ? MeshViewerWidget.EditorType.Printer : MeshViewerWidget.EditorType.Part); viewControls3D.SetView3DWidget(view3DWidget); // Construct and store dictionary of menu actions accessible at workspace level view3DWidget.WorkspaceActions = viewControls3D.MenuActions.Where(o => !string.IsNullOrEmpty(o.ID)).ToDictionary(o => o.ID, o => o); 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); toolbarAndView3DWidget.AddChild(view3DWidget); view3DContainer.AddChild(toolbarAndView3DWidget); leftToRight.AddChild(view3DContainer); view3DWidget.BackgroundColor = ActiveTheme.Instance.TertiaryBackgroundColor; if (sceneContext.World.RotationMatrix == Matrix4X4.Identity) { this.view3DWidget.ResetView(); } this.AnchorAll(); }
public PrintLibraryWidget(MainViewWidget mainViewWidget, PartWorkspace workspace, ThemeConfig theme, Color libraryBackground, PopupMenuButton popupMenuButton) { this.theme = theme; this.mainViewWidget = mainViewWidget; this.Padding = 0; this.AnchorAll(); var allControls = new FlowLayoutWidget(FlowDirection.TopToBottom); libraryContext = workspace.LibraryView; libraryView = new LibraryListView(libraryContext, theme) { Name = "LibraryView", // Drop containers if ShowContainers != 1 ContainerFilter = (container) => this.ShowContainers, BackgroundColor = libraryBackground, Border = new BorderDouble(top: 1) }; navBar = new OverflowBar(theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, }; allControls.AddChild(navBar); theme.ApplyBottomBorder(navBar); var toolbar = new OverflowBar(StaticData.Instance.LoadIcon("fa-sort_16.png", 32, 32, theme.InvertIcons), theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Name = "Folders Toolbar", }; toolbar.OverflowButton.ToolTipText = "Sorting".Localize(); theme.ApplyBottomBorder(toolbar, shadedBorder: true); toolbar.OverflowButton.Name = "Print Library View Options"; toolbar.Padding = theme.ToolbarPadding; toolbar.ExtendOverflowMenu = (popupMenu) => LibraryWidget.CreateSortingMenu(popupMenu, libraryView); allControls.AddChild(toolbar); toolbar.AddChild(new HorizontalSpacer()); toolbar.AddChild(LibraryWidget.CreateViewOptionsMenuButton(theme, libraryView, (show) => ShowContainers = show, () => ShowContainers)); breadCrumbWidget = new FolderBreadCrumbWidget(workspace.LibraryView, theme); navBar.AddChild(breadCrumbWidget); var searchPanel = new TextEditWithInlineCancel(theme) { Visible = false, Margin = new BorderDouble(10, 0, 5, 0), }; searchPanel.TextEditWidget.ActualTextEditWidget.EnterPressed += (s, e) => { this.PerformSearch(); }; searchPanel.ResetButton.Click += (s, e) => { breadCrumbWidget.Visible = true; searchPanel.Visible = false; searchPanel.TextEditWidget.Text = ""; this.ClearSearch(); }; // Store a reference to the input field this.searchInput = searchPanel.TextEditWidget; navBar.AddChild(searchPanel); searchButton = theme.CreateSearchButton(); searchButton.Enabled = false; searchButton.Name = "Search Library Button"; searchButton.Click += (s, e) => { if (searchPanel.Visible) { PerformSearch(); } else { searchContainer = libraryView.ActiveContainer; breadCrumbWidget.Visible = false; searchPanel.Visible = true; searchInput.Focus(); } }; navBar.AddChild(searchButton); allControls.AddChild(libraryView); buttonPanel = new FlowLayoutWidget() { HAnchor = HAnchor.Stretch, Padding = theme.ToolbarPadding, }; AddLibraryButtonElements(); allControls.AddChild(buttonPanel); allControls.AnchorAll(); this.AddChild(allControls); // Register listeners libraryView.SelectedItems.CollectionChanged += SelectedItems_CollectionChanged; libraryContext.ContainerChanged += Library_ContainerChanged; }
public 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.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(PrinterConfig printer, ThemeConfig theme, string tabTitle) : base(printer, printer.Bed, theme, tabTitle) { gcodeOptions = sceneContext.RendererOptions; view3DWidget.meshViewerWidget.EditorMode = MeshViewerWidget.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(); } }; printer.ViewState.ViewModeChanged += ViewState_ViewModeChanged; LayerScrollbar = new SliceLayerSelector(printer, sceneContext, theme) { VAnchor = VAnchor.Stretch, HAnchor = HAnchor.Right | HAnchor.Fit, Margin = new BorderDouble(0, 4, 4, 4), Maximum = sceneContext.LoadedGCode?.LayerCount ?? 1 }; view3DWidget.InteractionLayer.AddChild(LayerScrollbar); layerRenderRatioSlider = new DoubleSolidSlider(new Vector2(), SliceLayerSelector.SliderWidth); 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); sceneContext.LoadedGCodeChanged += BedPlate_LoadedGCodeChanged; 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(printer, sceneContext, theme) { Name = "GCode3DWidget", HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, BackgroundColor = theme.InteractionLayerOverlayColor, }; var modelViewSidePanel = view3DWidget.Descendants <LeftResizeContainer>().FirstOrDefault(); gcodeContainer = new LeftResizeContainer(theme) { Width = printer?.ViewState.SelectedObjectPanelWidth ?? 200, VAnchor = VAnchor.Stretch, HAnchor = HAnchor.Absolute, SpliterBarColor = 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.FindNamedChildRecursive("SplitContainer"); splitContainer.AddChild(gcodeContainer); view3DContainer.AddChild(new RunningTasksWidget(theme) { MinimumSize = new Vector2(100, 0), Margin = new BorderDouble(top: printerActionsBar.Height), 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); printer.ViewState.ConfigurePrinterChanged += ConfigurePrinter_Changed; printer.Bed.RendererOptions.PropertyChanged += RendererOptions_PropertyChanged; printer.Connection.CommunicationStateChanged.RegisterEvent((s, e) => { this.SetSliderVisibility(); }, ref unregisterEvents); }
public LibraryWidget(MainViewWidget mainViewWidget, ThemeConfig theme) { this.theme = theme; this.mainViewWidget = mainViewWidget; this.Padding = 0; this.AnchorAll(); var allControls = new FlowLayoutWidget(FlowDirection.TopToBottom); libraryContext = ApplicationController.Instance.LibraryTabContext; libraryView = new LibraryListView(libraryContext, theme) { Name = "LibraryView", // Drop containers if ShowContainers != 1 ContainerFilter = (container) => this.ShowContainers, BackgroundColor = theme.BackgroundColor, Border = new BorderDouble(top: 1), DoubleClickAction = LibraryListView.DoubleClickActions.PreviewItem }; navBar = new OverflowBar(theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, }; theme.ApplyBottomBorder(navBar); breadCrumbWidget = new FolderBreadCrumbWidget(libraryContext, theme); navBar.AddChild(breadCrumbWidget); var searchPanel = new TextEditWithInlineCancel(theme) { Visible = false, Margin = new BorderDouble(10, 0, 5, 0), }; searchPanel.TextEditWidget.ActualTextEditWidget.EnterPressed += (s, e) => { this.PerformSearch(); }; searchPanel.ResetButton.Click += (s, e) => { breadCrumbWidget.Visible = true; searchPanel.Visible = false; searchPanel.TextEditWidget.Text = ""; this.ClearSearch(); }; // Store a reference to the input field this.searchInput = searchPanel.TextEditWidget; navBar.AddChild(searchPanel); searchButton = theme.CreateSearchButton(); searchButton.Enabled = false; searchButton.Name = "Search Library Button"; searchButton.Click += (s, e) => { if (searchPanel.Visible) { PerformSearch(); } else { searchContainer = libraryContext.ActiveContainer; breadCrumbWidget.Visible = false; searchPanel.Visible = true; searchInput.Focus(); } }; navBar.AddChild(searchButton); navBar.AddChild(CreateViewOptionsMenuButton(theme, libraryView, (show) => ShowContainers = show, () => ShowContainers)); navBar.AddChild(CreateSortingMenuButton(theme, libraryView)); allControls.AddChild(navBar); var horizontalSplitter = new Splitter() { SplitterDistance = UserSettings.Instance.LibraryViewWidth, SplitterSize = theme.SplitterWidth, SplitterBackground = theme.SplitterBackground }; horizontalSplitter.AnchorAll(); horizontalSplitter.DistanceChanged += (s, e) => { UserSettings.Instance.LibraryViewWidth = horizontalSplitter.SplitterDistance; }; allControls.AddChild(horizontalSplitter); libraryTreeView = new TreeView(theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, Margin = 5 }; libraryTreeView.AfterSelect += async(s, e) => { if (libraryTreeView.SelectedNode is ContainerTreeNode treeNode) { if (!treeNode.ContainerAcquired) { await this.EnsureExpanded(treeNode.Tag as ILibraryItem, treeNode); } if (treeNode.ContainerAcquired) { libraryContext.ActiveContainer = treeNode.Container; } } }; horizontalSplitter.Panel1.AddChild(libraryTreeView); var rootColumn = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit, Margin = new BorderDouble(left: 10) }; libraryTreeView.AddChild(rootColumn); if (AppContext.IsLoading) { ApplicationController.StartupActions.Add(new ApplicationController.StartupAction() { Title = "Initializing Library".Localize(), Priority = 0, Action = () => { this.LoadRootLibraryNodes(rootColumn); } }); } else { this.LoadRootLibraryNodes(rootColumn); } horizontalSplitter.Panel2.AddChild(libraryView); buttonPanel = new FlowLayoutWidget() { HAnchor = HAnchor.Stretch, Padding = theme.ToolbarPadding, }; AddLibraryButtonElements(); allControls.AddChild(buttonPanel); allControls.AnchorAll(); this.AddChild(allControls); // Register listeners libraryView.SelectedItems.CollectionChanged += SelectedItems_CollectionChanged; libraryContext.ContainerChanged += Library_ContainerChanged; }
public 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 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 HardwareTabPage(ThemeConfig theme) : base(FlowDirection.TopToBottom) { this.theme = theme; this.Padding = 0; this.HAnchor = HAnchor.Stretch; this.VAnchor = VAnchor.Stretch; var toolbar = new Toolbar(theme.TabbarPadding, theme.CreateSmallResetButton()) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Padding = theme.ToolbarPadding }; theme.ApplyBottomBorder(toolbar); toolbar.AddChild(new TextButton("Inventory".Localize(), theme) { Padding = new BorderDouble(6, 0), MinimumSize = new Vector2(0, theme.ButtonHeight), Selectable = false }); this.AddChild(toolbar); var horizontalSplitter = new Splitter() { SplitterDistance = UserSettings.Instance.LibraryViewWidth, SplitterSize = theme.SplitterWidth, SplitterBackground = theme.SplitterBackground, HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, }; horizontalSplitter.DistanceChanged += (s, e) => { UserSettings.Instance.LibraryViewWidth = horizontalSplitter.SplitterDistance; }; this.AddChild(horizontalSplitter); var treeView = new HardwareTreeView(theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, Width = 300, Margin = 5 }; treeView.NodeMouseDoubleClick += (s, e) => { if (e is MouseEventArgs mouseEvent && s is GuiWidget clickedWidget && mouseEvent.Button == MouseButtons.Left && mouseEvent.Clicks == 2) { if (treeView?.SelectedNode.Tag is PrinterInfo printerInfo) { ApplicationController.Instance.OpenPrinter(printerInfo); } } }; treeView.NodeMouseClick += (s, e) => { if (e is MouseEventArgs mouseEvent && s is GuiWidget clickedWidget && mouseEvent.Button == MouseButtons.Right) { UiThread.RunOnIdle(() => { var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme); var openMenuItem = popupMenu.CreateMenuItem("Open".Localize()); openMenuItem.Click += (s2, e2) => { if (treeView?.SelectedNode.Tag is PrinterInfo printerInfo) { ApplicationController.Instance.OpenPrinter(printerInfo); } }; popupMenu.CreateSeparator(); var deleteMenuItem = popupMenu.CreateMenuItem("Delete".Localize()); deleteMenuItem.Click += (s2, e2) => { if (treeView.SelectedNode.Tag is PrinterInfo printerInfo) { // Delete printer StyledMessageBox.ShowMessageBox( (deletePrinter) => { if (deletePrinter) { ProfileManager.Instance.DeletePrinter(printerInfo.ID); } }, "Are you sure you want to delete printer '{0}'?".Localize().FormatWith(printerInfo.Name), "Delete Printer?".Localize(), StyledMessageBox.MessageType.YES_NO, "Delete Printer".Localize()); } }; popupMenu.ShowMenu(clickedWidget, mouseEvent); }); } }; treeView.ScrollArea.HAnchor = HAnchor.Stretch; treeView.AfterSelect += (s, e) => { if (treeView.SelectedNode.Tag is PrinterInfo printerInfo) { horizontalSplitter.Panel2.CloseChildren(); horizontalSplitter.Panel2.AddChild(new PrinterDetails(printerInfo, theme, true) { HAnchor = HAnchor.MaxFitOrStretch, VAnchor = VAnchor.Stretch, Padding = theme.DefaultContainerPadding }); } }; horizontalSplitter.Panel1.AddChild(treeView); horizontalSplitter.Panel2.AddChild(new GuiWidget() { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, }); }
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 HardwareTabPage(ThemeConfig theme) : base(FlowDirection.TopToBottom) { this.theme = theme; this.Padding = 0; this.HAnchor = HAnchor.Stretch; this.VAnchor = VAnchor.Stretch; var toolbar = new Toolbar(theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Padding = theme.ToolbarPadding }; theme.ApplyBottomBorder(toolbar); toolbar.AddChild(new TextButton("Inventory".Localize(), theme) { Padding = new BorderDouble(6, 0), MinimumSize = new Vector2(0, theme.ButtonHeight), Selectable = false }); this.AddChild(toolbar); var horizontalSplitter = new Splitter() { SplitterDistance = UserSettings.Instance.LibraryViewWidth, SplitterSize = theme.SplitterWidth, SplitterBackground = theme.SplitterBackground, HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, }; horizontalSplitter.DistanceChanged += (s, e) => { UserSettings.Instance.LibraryViewWidth = horizontalSplitter.SplitterDistance; }; this.AddChild(horizontalSplitter); var treeView = new HardwareTreeView(theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, Width = 300, Margin = 5 }; treeView.NodeMouseDoubleClick += (s, e) => { if (e is MouseEventArgs mouseEvent && s is GuiWidget clickedWidget && mouseEvent.Button == MouseButtons.Left && mouseEvent.Clicks == 2) { if (treeView?.SelectedNode.Tag is PrinterInfo printerInfo) { if (ApplicationController.Instance.ActivePrinters.FirstOrDefault(p => p.Settings.ID == printerInfo.ID) is PrinterConfig printer && ApplicationController.Instance.MainView.TabControl.AllTabs.FirstOrDefault(t => t.TabContent is PrinterTabPage printerTabPage && printerTabPage.printer == printer) is ITab tab) { // Switch to existing printer tab ApplicationController.Instance.MainView.TabControl.ActiveTab = tab; } else { // Open new printer tab ApplicationController.Instance.OpenPrinter(printerInfo.ID).ConfigureAwait(false); } } } }; treeView.NodeMouseClick += (s, e) => { if (e is MouseEventArgs mouseEvent && s is GuiWidget clickedWidget && mouseEvent.Button == MouseButtons.Right) { UiThread.RunOnIdle(() => { var menu = new PopupMenu(ApplicationController.Instance.MenuTheme); var openMenuItem = menu.CreateMenuItem("Open".Localize()); openMenuItem.Click += (s2, e2) => { if (treeView?.SelectedNode.Tag is PrinterInfo printerInfo) { // Open printer ApplicationController.Instance.OpenPrinter(printerInfo.ID).ConfigureAwait(false); } }; menu.CreateSeparator(); var deleteMenuItem = menu.CreateMenuItem("Delete".Localize()); deleteMenuItem.Click += (s2, e2) => { // Delete printer StyledMessageBox.ShowMessageBox( (deletePrinter) => { if (deletePrinter) { if (treeView.SelectedNode.Tag is PrinterInfo printerInfo) { ProfileManager.Instance.DeletePrinter(printerInfo.ID); } } }, "Are you sure you want to delete your currently selected printer?".Localize(), "Delete Printer?".Localize(), StyledMessageBox.MessageType.YES_NO, "Delete Printer".Localize()); }; var systemWindow = this.Parents <SystemWindow>().FirstOrDefault(); systemWindow.ShowPopup( new MatePoint(clickedWidget) { Mate = new MateOptions(MateEdge.Left, MateEdge.Top), AltMate = new MateOptions(MateEdge.Left, MateEdge.Top) }, new MatePoint(menu) { Mate = new MateOptions(MateEdge.Left, MateEdge.Top), AltMate = new MateOptions(MateEdge.Right, MateEdge.Top) }, altBounds: new RectangleDouble(mouseEvent.X + 1, mouseEvent.Y + 1, mouseEvent.X + 1, mouseEvent.Y + 1)); }); } }; treeView.ScrollArea.HAnchor = HAnchor.Stretch; treeView.AfterSelect += async(s, e) => { if (treeView.SelectedNode.Tag is PrinterInfo printerInfo) { horizontalSplitter.Panel2.CloseAllChildren(); horizontalSplitter.Panel2.AddChild(new PrinterDetails(printerInfo, theme) { HAnchor = HAnchor.MaxFitOrStretch, VAnchor = VAnchor.Stretch, Padding = theme.DefaultContainerPadding }); } }; horizontalSplitter.Panel1.AddChild(treeView); horizontalSplitter.Panel2.AddChild(new GuiWidget() { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, }); }