public CheckboxMenuItem(GuiWidget widget, ThemeConfig theme) : base(widget, theme) { faChecked = AggContext.StaticData.LoadIcon("fa-check_16.png", 16, 16, theme.InvertIcons); }
public BoundsField(ThemeConfig theme) : base(theme) { labels = new[] { 'L', 'B', 'R', 'T' }; }
public static void CreateMenuActions(ListView libraryView, List <PrintItemAction> menuActions, PartPreviewContent partPreviewContent, ThemeConfig theme, bool allowPrint) { menuActions.Add(new PrintItemAction() { Icon = AggContext.StaticData.LoadIcon("cube.png", 16, 16, ApplicationController.Instance.MenuTheme.InvertIcons), Title = "Add".Localize(), ToolTipText = "Add an.stl, .obj, .amf, .gcode or.zip file to the Library".Localize(), Action = (selectedLibraryItems, listView) => { UiThread.RunOnIdle(() => { AggContext.FileDialogs.OpenFileDialog( new OpenFileDialogParams(ApplicationSettings.OpenPrintableFileParams, multiSelect: true), (openParams) => { if (openParams.FileNames != null) { var writableContainer = libraryView.ActiveContainer as ILibraryWritableContainer; if (writableContainer != null && openParams.FileNames.Length > 0) { writableContainer.Add(openParams.FileNames.Select(f => new FileSystemFileItem(f))); } } }); }); }, IsEnabled = (s, l) => libraryView.ActiveContainer is ILibraryWritableContainer }); menuActions.Add(new PrintItemAction() { Title = "Create Folder".Localize(), Icon = AggContext.StaticData.LoadIcon("fa-folder-new_16.png", 16, 16, ApplicationController.Instance.MenuTheme.InvertIcons), Action = (selectedLibraryItems, listView) => { DialogWindow.Show( new InputBoxPage( "Create Folder".Localize(), "Folder Name".Localize(), "", "Enter New Name Here".Localize(), "Create".Localize(), (newName) => { if (!string.IsNullOrEmpty(newName) && libraryView.ActiveContainer is ILibraryWritableContainer writableContainer) { writableContainer.Add(new[] { new CreateFolderItem() { Name = newName } }); } })); }, IsEnabled = (s, l) => { return(libraryView.ActiveContainer is ILibraryWritableContainer writableContainer && writableContainer?.AllowAction(ContainerActions.AddContainers) == true); } });
private GuiWidget GetPopupContent(ThemeConfig theme) { var widget = new IgnoredPopupWidget() { Width = 300, HAnchor = HAnchor.Absolute, VAnchor = VAnchor.Fit, BackgroundColor = theme.Colors.PrimaryBackgroundColor, Padding = new BorderDouble(12, 0) }; var container = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit | VAnchor.Top, }; widget.AddChild(container); GuiWidget hotendRow; container.AddChild(hotendRow = new SettingsItem( "Heated Bed".Localize(), theme, new SettingsItem.ToggleSwitchConfig() { Checked = false, ToggleAction = (itemChecked) => { var goalTemp = itemChecked ? printer.Settings.GetValue <double>(SettingsKey.bed_temperature) : 0; if (itemChecked) { SetTargetTemperature(goalTemp); } else { SetTargetTemperature(0); } } }, enforceGutter: false)); var toggleWidget = hotendRow.Children.Where(o => o is ICheckbox).FirstOrDefault(); toggleWidget.Name = "Toggle Heater"; heatToggle = toggleWidget as ICheckbox; int tabIndex = 0; var settingsContext = new SettingsContext(printer, null, NamedSettingsLayers.All); var settingsData = SettingsOrganizer.Instance.GetSettingsData(SettingsKey.bed_temperature); var temperatureRow = SliceSettingsTabView.CreateItemRow(settingsData, settingsContext, printer, theme, ref tabIndex); SliceSettingsRow.AddBordersToEditFields(temperatureRow); container.AddChild(temperatureRow); alwaysEnabled.Add(hotendRow); // add in the temp graph var graph = new DataViewGraph() { DynamiclyScaleRange = false, MinValue = 0, ShowGoal = true, GoalColor = ActiveTheme.Instance.PrimaryAccentColor, GoalValue = printer.Settings.GetValue <double>(SettingsKey.bed_temperature), MaxValue = 150, // could come from some profile value in the future Width = widget.Width - 20, Height = 35, // this works better if it is a common multiple of the Width Margin = new BorderDouble(0, 5, 0, 0), }; var runningInterval = UiThread.SetInterval(() => { graph.AddData(this.ActualTemperature); }, 1); this.Closed += (s, e) => runningInterval.Continue = false; var valueField = temperatureRow.Descendants <MHNumberEdit>().FirstOrDefault(); var settingsRow = temperatureRow.DescendantsAndSelf <SliceSettingsRow>().FirstOrDefault(); PrinterSettings.SettingChanged.RegisterEvent((s, e) => { if (e is StringEventArgs stringEvent) { var temp = printer.Settings.GetValue <double>(SettingsKey.bed_temperature); valueField.Value = temp; graph.GoalValue = temp; settingsRow.UpdateStyle(); if (stringEvent.Data == SettingsKey.bed_temperature && heatToggle.Checked) { SetTargetTemperature(temp); } } ; }, ref unregisterEvents); container.AddChild(graph); return(widget); }
public PopupMenuButton(ThemeConfig theme) { this.theme = theme; this.DisabledColor = new Color(theme.Colors.SecondaryTextColor, 50); this.HoverColor = theme.MinimalShade; }
public SliceSettingsWidget(PrinterConfig printer, SettingsContext settingsContext, ThemeConfig theme) : base(FlowDirection.TopToBottom) { this.printer = printer; this.SettingsContext = settingsContext; settingsControlBar = new PresetsToolbar(printer, theme) { HAnchor = HAnchor.Stretch, Padding = new BorderDouble(8, 12, 8, 8) }; using (this.LayoutLock()) { this.AddChild(settingsControlBar); var settingsSection = PrinterSettings.Layout.SlicingSections[0]; switch (UserSettings.Instance.get(UserSettingsKey.SliceSettingsViewDetail)) { case "Simple": settingsSection = PrinterSettings.Layout.SlicingSections[0]; break; case "Intermediate": settingsSection = PrinterSettings.Layout.SlicingSections[1]; break; case "Advanced": settingsSection = PrinterSettings.Layout.SlicingSections[2]; break; } this.AddChild( new SliceSettingsTabView( settingsContext, "SliceSettings", printer, settingsSection, theme, isPrimarySettingsView: true, justMySettingsTitle: "My Modified Settings".Localize(), databaseMRUKey: UserSettingsKey.SliceSettingsWidget_CurrentTab)); } this.AnchorAll(); }
public InlineStringEdit(string stringValue, ThemeConfig theme, string automationName, bool boldFont = false, bool editable = true) : base(theme) { this.Padding = theme.ToolbarPadding; this.HAnchor = HAnchor.Stretch; this.VAnchor = VAnchor.Fit; titleText = new TextWidget(stringValue, textColor: theme.TextColor, pointSize: theme.DefaultFontSize, bold: boldFont) { VAnchor = VAnchor.Center, AutoExpandBoundsToText = true, EllipsisIfClipped = true, Margin = new BorderDouble(left: 5) }; this.AddChild(titleText); this.ActionArea.VAnchor = VAnchor.Stretch; this.ActionArea.MinimumSize = new Vector2(0, titleText.Height); saveButton = new IconButton(AggContext.StaticData.LoadIcon("fa-save_16.png", 16, 16, theme.InvertIcons), theme) { ToolTipText = "Save".Localize(), Visible = false, Name = automationName + " Save", }; searchPanel = new SearchInputBox(theme) { Visible = false, Margin = new BorderDouble(left: 4) }; searchPanel.searchInput.ActualTextEditWidget.EnterPressed += (s, e) => { this.Text = searchPanel.Text; this.SetVisibility(showEditPanel: false); this.ValueChanged?.Invoke(this, null); }; searchPanel.searchInput.Name = automationName + " Field"; searchPanel.ResetButton.Name = "Close Title Edit"; searchPanel.ResetButton.ToolTipText = "Close".Localize(); searchPanel.ResetButton.Click += (s, e) => { this.SetVisibility(showEditPanel: false); }; this.AddChild(searchPanel); rightPanel = new FlowLayoutWidget(); var icon = editable ? AggContext.StaticData.LoadIcon("icon_edit.png", 16, 16, theme.InvertIcons) : new ImageBuffer(16, 16); editButton = new IconButton(icon, theme) { ToolTipText = "Edit".Localize(), Name = automationName + " Edit", Selectable = editable }; editButton.Click += (s, e) => { if (this.EditOverride != null) { this.EditOverride.Invoke(this, null); } else { searchPanel.Text = this.Text; this.SetVisibility(showEditPanel: true); } }; rightPanel.AddChild(editButton); saveButton.Click += (s, e) => { this.Text = searchPanel.Text; this.SetVisibility(showEditPanel: false); }; rightPanel.AddChild(saveButton); this.SetRightAnchorItem(rightPanel); this.ActionArea.Margin = this.ActionArea.Margin.Clone(right: rightPanel.Width + 5); }
private static GuiWidget CreateSourceChildSelector(SelectedChildren childSelector, OperationSourceContainerObject3D sourceCantainer, ThemeConfig theme) { GuiWidget tabContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); var sourceChildren = sourceCantainer.SourceContainer.VisibleMeshes().ToList(); var objectChecks = new Dictionary <ICheckbox, IObject3D>(); var radioSiblings = new List <GuiWidget>(); for (int i = 0; i < sourceChildren.Count; i++) { var itemIndex = i; var child = sourceChildren[itemIndex]; var rowContainer = new FlowLayoutWidget(); GuiWidget selectWidget; if (sourceChildren.Count == 2) { var radioButton = new RadioButton(string.IsNullOrWhiteSpace(child.Name) ? $"{itemIndex}" : $"{child.Name}") { Checked = childSelector.Contains(child.Name), TextColor = theme.TextColor }; radioSiblings.Add(radioButton); radioButton.SiblingRadioButtonList = radioSiblings; selectWidget = radioButton; } else { selectWidget = new CheckBox(string.IsNullOrWhiteSpace(child.Name) ? $"{itemIndex}" : $"{child.Name}") { Checked = childSelector.Contains(child.Name), TextColor = theme.TextColor }; } objectChecks.Add((ICheckbox)selectWidget, child); rowContainer.AddChild(selectWidget); var checkBox = selectWidget as ICheckbox; checkBox.CheckedStateChanged += (s, e) => { if (s is ICheckbox checkbox) { if (checkBox.Checked) { if (!childSelector.Contains(objectChecks[checkbox].Name)) { childSelector.Add(objectChecks[checkbox].Name); } } else { if (childSelector.Contains(objectChecks[checkbox].Name)) { childSelector.Remove(objectChecks[checkbox].Name); } } } }; tabContainer.AddChild(rowContainer); } return(tabContainer); }
private static GuiWidget CreateSelector(SelectedChildren childSelector, IObject3D parent, ThemeConfig theme) { GuiWidget tabContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); void UpdateSelectColors(bool selectionChanged = false) { foreach (var child in parent.Children.ToList()) { using (child.RebuildLock()) { if (selectionChanged) { child.Visible = true; } } } } tabContainer.Closed += (s, e) => UpdateSelectColors(); var children = parent.Children.ToList(); Dictionary <ICheckbox, IObject3D> objectChecks = new Dictionary <ICheckbox, IObject3D>(); List <GuiWidget> radioSiblings = new List <GuiWidget>(); for (int i = 0; i < children.Count; i++) { var itemIndex = i; var child = children[itemIndex]; FlowLayoutWidget rowContainer = new FlowLayoutWidget(); GuiWidget selectWidget; if (children.Count == 2) { var radioButton = new RadioButton(string.IsNullOrWhiteSpace(child.Name) ? $"{itemIndex}" : $"{child.Name}") { Checked = childSelector.Contains(child.ID), TextColor = theme.TextColor }; radioSiblings.Add(radioButton); radioButton.SiblingRadioButtonList = radioSiblings; selectWidget = radioButton; } else { selectWidget = new CheckBox(string.IsNullOrWhiteSpace(child.Name) ? $"{itemIndex}" : $"{child.Name}") { Checked = childSelector.Contains(child.ID), TextColor = theme.TextColor }; } objectChecks.Add((ICheckbox)selectWidget, child); rowContainer.AddChild(selectWidget); ICheckbox checkBox = selectWidget as ICheckbox; checkBox.CheckedStateChanged += (s, e) => { if (s is ICheckbox checkbox) { if (checkBox.Checked) { if (!childSelector.Contains(objectChecks[checkbox].ID)) { childSelector.Add(objectChecks[checkbox].ID); } } else { if (childSelector.Contains(objectChecks[checkbox].ID)) { childSelector.Remove(objectChecks[checkbox].ID); } } if (parent is MeshWrapperObject3D meshWrapper) { using (meshWrapper.RebuildLock()) { meshWrapper.ResetMeshWrapperMeshes(Object3DPropertyFlags.All, CancellationToken.None); } } UpdateSelectColors(true); } }; tabContainer.AddChild(rowContainer); UpdateSelectColors(); } return(tabContainer); }
public static GuiWidget CreatePropertyEditor(EditableProperty property, UndoBuffer undoBuffer, PPEContext context, ThemeConfig theme) { var object3D = property.Item; var propertyGridModifier = property.Item as IPropertyGridModifier; GuiWidget rowContainer = null; // Get reflected property value once, then test for each case below var propertyValue = property.Value; void RegisterValueChanged(UIField field, Func <string, object> valueFromString, Func <object, string> valueToString = null) { field.ValueChanged += (s, e) => { var newValue = field.Value; var oldValue = property.Value.ToString(); if (valueToString != null) { oldValue = valueToString(property.Value); } //field.Content if (undoBuffer != null) { undoBuffer.AddAndDo(new UndoRedoActions(() => { property.SetValue(valueFromString(oldValue)); object3D?.Invalidate(new InvalidateArgs(context.item, InvalidateType.Properties)); propertyGridModifier?.UpdateControls(new PublicPropertyChange(context, property.PropertyInfo.Name)); }, () => { property.SetValue(valueFromString(newValue)); object3D?.Invalidate(new InvalidateArgs(context.item, InvalidateType.Properties)); propertyGridModifier?.UpdateControls(new PublicPropertyChange(context, property.PropertyInfo.Name)); })); } else { property.SetValue(valueFromString(newValue)); object3D?.Invalidate(new InvalidateArgs(context.item, InvalidateType.Properties)); propertyGridModifier?.UpdateControls(new PublicPropertyChange(context, property.PropertyInfo.Name)); } }; } // create a double editor if (propertyValue is double doubleValue) { var field = new DoubleField(theme); field.Initialize(0); field.DoubleValue = doubleValue; RegisterValueChanged(field, (valueString) => { return(double.Parse(valueString)); }); void RefreshField(object s, InvalidateArgs e) { if (e.InvalidateType.HasFlag(InvalidateType.DisplayValues)) { double newValue = (double)property.Value; if (newValue != field.DoubleValue) { field.DoubleValue = newValue; } } } object3D.Invalidated += RefreshField; field.Content.Closed += (s, e) => object3D.Invalidated -= RefreshField; rowContainer = CreateSettingsRow(property, field); } else if (propertyValue is Color color) { var field = new ColorField(theme, object3D.Color); field.Initialize(0); field.ValueChanged += (s, e) => { property.SetValue(field.Color); object3D?.Invalidate(new InvalidateArgs(context.item, InvalidateType.Properties)); propertyGridModifier?.UpdateControls(new PublicPropertyChange(context, property.PropertyInfo.Name)); }; rowContainer = CreateSettingsRow(property, field); } else if (propertyValue is Vector2 vector2) { var field = new Vector2Field(theme); field.Initialize(0); field.Vector2 = vector2; RegisterValueChanged(field, (valueString) => { return(Vector2.Parse(valueString)); }, (value) => { var s = ((Vector2)value).ToString(); return(s.Substring(1, s.Length - 2)); }); rowContainer = CreateSettingsColumn(property, field); } else if (propertyValue is Vector3 vector3) { var field = new Vector3Field(theme); field.Initialize(0); field.Vector3 = vector3; RegisterValueChanged(field, (valueString) => { return(Vector3.Parse(valueString)); }, (value) => { var s = ((Vector3)value).ToString(); return(s.Substring(1, s.Length - 2)); }); rowContainer = CreateSettingsColumn(property, field); } else if (propertyValue is DirectionVector directionVector) { var field = new DirectionVectorField(theme); field.Initialize(0); field.SetValue(directionVector); field.ValueChanged += (s, e) => { property.SetValue(field.DirectionVector); object3D?.Invalidate(new InvalidateArgs(context.item, InvalidateType.Properties)); propertyGridModifier?.UpdateControls(new PublicPropertyChange(context, property.PropertyInfo.Name)); }; rowContainer = CreateSettingsRow(property, field); } else if (propertyValue is DirectionAxis directionAxis) { rowContainer = CreateSettingsColumn(property); var newDirectionVector = new DirectionVector() { Normal = directionAxis.Normal }; var row1 = CreateSettingsRow("Axis".Localize()); var field1 = new DirectionVectorField(theme); field1.Initialize(0); field1.SetValue(newDirectionVector); row1.AddChild(field1.Content); rowContainer.AddChild(row1); // the direction axis // the distance from the center of the part // create a double editor var field2 = new Vector3Field(theme); field2.Initialize(0); field2.Vector3 = directionAxis.Origin - property.Item.Children.First().GetAxisAlignedBoundingBox().Center; var row2 = CreateSettingsColumn("Offset", field2); // update this when changed EventHandler <InvalidateArgs> updateData = (s, e) => { field2.Vector3 = ((DirectionAxis)property.Value).Origin - property.Item.Children.First().GetAxisAlignedBoundingBox().Center; }; property.Item.Invalidated += updateData; field2.Content.Closed += (s, e) => { property.Item.Invalidated -= updateData; }; // update functions field1.ValueChanged += (s, e) => { property.SetValue(new DirectionAxis() { Normal = field1.DirectionVector.Normal, Origin = property.Item.Children.First().GetAxisAlignedBoundingBox().Center + field2.Vector3 }); object3D?.Invalidate(new InvalidateArgs(context.item, InvalidateType.Properties)); propertyGridModifier?.UpdateControls(new PublicPropertyChange(context, property.PropertyInfo.Name)); }; field2.ValueChanged += (s, e) => { property.SetValue(new DirectionAxis() { Normal = field1.DirectionVector.Normal, Origin = property.Item.Children.First().GetAxisAlignedBoundingBox().Center + field2.Vector3 }); object3D?.Invalidate(new InvalidateArgs(context.item, InvalidateType.Properties)); propertyGridModifier?.UpdateControls(new PublicPropertyChange(context, property.PropertyInfo.Name)); }; rowContainer.AddChild(row2); } else if (propertyValue is SelectedChildren childSelector) { var showAsList = property.PropertyInfo.GetCustomAttributes(true).OfType <ShowAsListAttribute>().FirstOrDefault() != null; if (showAsList) { UIField field = new ChildrenSelectorListField(property, theme); field.Initialize(0); RegisterValueChanged(field, (valueString) => { var childrenSelector = new SelectedChildren(); foreach (var child in valueString.Split(',')) { childrenSelector.Add(child); } return(childrenSelector); }); rowContainer = CreateSettingsRow(property, field); } else // show the subtract editor for boolean subtract and subtract and replace { rowContainer = CreateSettingsColumn(property); if (property.Item is OperationSourceContainerObject3D sourceContainer) { rowContainer.AddChild(CreateSourceChildSelector(childSelector, sourceContainer, theme)); } else { rowContainer.AddChild(CreateSelector(childSelector, property.Item, theme)); } } } else if (propertyValue is ImageBuffer imageBuffer) { rowContainer = CreateSettingsColumn(property); rowContainer.AddChild(CreateImageDisplay(imageBuffer, property.Item, theme)); } #if !__ANDROID__ else if (propertyValue is List <string> stringList) { var selectedItem = ApplicationController.Instance.DragDropData.SceneContext.Scene.SelectedItem; var field = new SurfacedEditorsField(theme, selectedItem); field.Initialize(0); field.ListValue = stringList; field.ValueChanged += (s, e) => { property.SetValue(field.ListValue); }; rowContainer = CreateSettingsColumn(property, field); rowContainer.Descendants <HorizontalSpacer>().FirstOrDefault()?.Close(); } #endif // create a int editor else if (propertyValue is int intValue) { var field = new IntField(theme); field.Initialize(0); field.IntValue = intValue; RegisterValueChanged(field, (valueString) => { return(int.Parse(valueString)); }); void RefreshField(object s, InvalidateArgs e) { if (e.InvalidateType.HasFlag(InvalidateType.DisplayValues)) { int newValue = (int)property.Value; if (newValue != field.IntValue) { field.IntValue = newValue; } } } object3D.Invalidated += RefreshField; field.Content.Closed += (s, e) => object3D.Invalidated -= RefreshField; rowContainer = CreateSettingsRow(property, field); } // create a bool editor else if (propertyValue is bool boolValue) { var field = new ToggleboxField(theme); field.Initialize(0); field.Checked = boolValue; RegisterValueChanged(field, (valueString) => { return(valueString == "1"); }, (value) => { return(((bool)(value)) ? "1" : "0"); }); rowContainer = CreateSettingsRow(property, field); } // create a string editor else if (propertyValue is string stringValue) { var field = new TextField(theme); field.Initialize(0); field.SetValue(stringValue, false); field.Content.HAnchor = HAnchor.Stretch; RegisterValueChanged(field, (valueString) => valueString); rowContainer = CreateSettingsRow(property, field); var label = rowContainer.Children.First(); if (field is TextField) { var spacer = rowContainer.Children.OfType <HorizontalSpacer>().FirstOrDefault(); spacer.HAnchor = HAnchor.Absolute; spacer.Width = Math.Max(0, 100 - label.Width); } } // create a char editor else if (propertyValue is char charValue) { var field = new CharField(theme); field.Initialize(0); field.SetValue(charValue.ToString(), false); field.ValueChanged += (s, e) => { property.SetValue(Convert.ToChar(field.Value)); object3D?.Invalidate(new InvalidateArgs(context.item, InvalidateType.Properties)); propertyGridModifier?.UpdateControls(new PublicPropertyChange(context, property.PropertyInfo.Name)); }; rowContainer = CreateSettingsRow(property, field); } // create an enum editor else if (property.PropertyType.IsEnum) { UIField field; var iconsAttribute = property.PropertyInfo.GetCustomAttributes(true).OfType <IconsAttribute>().FirstOrDefault(); if (iconsAttribute != null) { field = new IconEnumField(property, iconsAttribute, theme) { InitialValue = propertyValue.ToString() }; } else { field = new EnumField(property, theme); } field.Initialize(0); RegisterValueChanged(field, (valueString) => { return(Enum.Parse(property.PropertyType, valueString)); }); field.ValueChanged += (s, e) => { property.SetValue(Enum.Parse(property.PropertyType, field.Value)); object3D?.Invalidate(new InvalidateArgs(context.item, InvalidateType.Properties)); propertyGridModifier?.UpdateControls(new PublicPropertyChange(context, property.PropertyInfo.Name)); }; rowContainer = CreateSettingsRow(property, field, theme); } // Use known IObject3D editors else if (propertyValue is IObject3D item && ApplicationController.Instance.Extensions.GetEditorsForType(property.PropertyType)?.FirstOrDefault() is IObject3DEditor iObject3DEditor) { rowContainer = iObject3DEditor.Create(item, undoBuffer, theme); } // remember the row name and widget context.editRows.Add(property.PropertyInfo.Name, rowContainer); return(rowContainer); }
private static GuiWidget CreateImageDisplay(ImageBuffer imageBuffer, IObject3D parent, ThemeConfig theme) { return(new ImageWidget(imageBuffer)); }
public static FlowLayoutWidget CreateSettingsRow(string labelText, string toolTipText = null, ThemeConfig theme = null) { if (theme == null) { theme = AppContext.Theme; } var rowContainer = new FlowLayoutWidget(FlowDirection.LeftToRight) { HAnchor = HAnchor.Stretch, Padding = new BorderDouble(5), ToolTipText = toolTipText }; rowContainer.AddChild(new TextWidget(labelText + ":", pointSize: 11, textColor: theme.TextColor) { Margin = new BorderDouble(0, 0, 3, 0), VAnchor = VAnchor.Center, }); rowContainer.AddChild(new HorizontalSpacer()); return(rowContainer); }
private static FlowLayoutWidget CreateSettingsRow(EditableProperty property, UIField field, ThemeConfig theme = null) { var row = CreateSettingsRow(property.DisplayName.Localize(), property.Description.Localize(), theme); row.AddChild(field.Content); return(row); }
public GuiWidget Create(IObject3D item, UndoBuffer undoBuffer, ThemeConfig theme) { var mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch }; if (item != null) { var context = new PPEContext() { item = item }; // CreateEditor AddUnlockLinkIfRequired(context, mainContainer, theme); GuiWidget scope = mainContainer; // Create a field editor for each editable property detected via reflection foreach (var property in GetEditablePropreties(context.item)) { // Create SectionWidget for SectionStartAttributes if (property.PropertyInfo.GetCustomAttributes(true).OfType <SectionStartAttribute>().FirstOrDefault() is SectionStartAttribute sectionStart) { var column = new FlowLayoutWidget() { FlowDirection = FlowDirection.TopToBottom, Padding = new BorderDouble(theme.DefaultContainerPadding).Clone(top: 0) }; var section = new SectionWidget(sectionStart.Title, column, theme); theme.ApplyBoxStyle(section); mainContainer.AddChild(section); scope = column; } // Create SectionWidget for SectionStartAttributes if (property.PropertyInfo.GetCustomAttributes(true).OfType <SectionEndAttribute>().Any()) { // Push scope back to mainContainer on scope = mainContainer; } var editor = CreatePropertyEditor(property, undoBuffer, context, theme); if (editor != null) { scope.AddChild(editor); } } AddWebPageLinkIfRequired(context, mainContainer, theme); // add in an Update button if applicable var showUpdate = context.item.GetType().GetCustomAttributes(typeof(ShowUpdateButtonAttribute), true).FirstOrDefault() as ShowUpdateButtonAttribute; if (showUpdate != null) { var updateButton = new TextButton("Update".Localize(), theme) { Margin = 5, BackgroundColor = theme.MinimalShade, HAnchor = HAnchor.Right, VAnchor = VAnchor.Absolute }; updateButton.Click += (s, e) => { context.item.Invalidate(new InvalidateArgs(context.item, InvalidateType.Properties)); }; mainContainer.AddChild(updateButton); } // Init with custom 'UpdateControls' hooks (context.item as IPropertyGridModifier)?.UpdateControls(new PublicPropertyChange(context, "Update_Button")); } return(mainContainer); }
public ScaleTopControl(IInteractionVolumeContext context) : base(context) { theme = MatterControl.AppContext.Theme; zValueDisplayInfo = new InlineEditControl() { ForceHide = () => { // if the selection changes if (RootSelection != ActiveSelectedItem) { return(true); } // if another control gets a hover if (InteractionContext.HoveredInteractionVolume != this && InteractionContext.HoveredInteractionVolume != null) { return(true); } // if we clicked on the control if (HadClickOnControl) { return(false); } return(false); } , GetDisplayString = (value) => "{0:0.0}mm".FormatWith(value) }; zValueDisplayInfo.VisibleChanged += (s, e) => { if (!zValueDisplayInfo.Visible) { HadClickOnControl = false; } }; zValueDisplayInfo.EditComplete += (s, e) => { var selectedItem = ActiveSelectedItem; Matrix4X4 startingTransform = selectedItem.Matrix; var originalSelectedBounds = selectedItem.GetAxisAlignedBoundingBox(); Vector3 topPosition = GetTopPosition(selectedItem); Vector3 lockedBottom = new Vector3(topPosition.X, topPosition.Y, originalSelectedBounds.MinXYZ.Z); Vector3 newSize = Vector3.Zero; newSize.Z = zValueDisplayInfo.Value; Vector3 scaleAmount = ScaleCornerControl.GetScalingConsideringShiftKey(originalSelectedBounds, mouseDownSelectedBounds, newSize, InteractionContext.GuiSurface.ModifierKeys); Matrix4X4 scale = Matrix4X4.CreateScale(scaleAmount); selectedItem.Matrix = selectedItem.ApplyAtBoundsCenter(scale); // and keep the locked edge in place AxisAlignedBoundingBox scaledSelectedBounds = selectedItem.GetAxisAlignedBoundingBox(); Vector3 newLockedBottom = new Vector3(topPosition.X, topPosition.Y, scaledSelectedBounds.MinXYZ.Z); selectedItem.Matrix *= Matrix4X4.CreateTranslation(lockedBottom - newLockedBottom); Invalidate(); InteractionContext.Scene.AddTransformSnapshot(startingTransform); }; InteractionContext.GuiSurface.AddChild(zValueDisplayInfo); DrawOnTop = true; topScaleMesh = PlatonicSolids.CreateCube(selectCubeSize, selectCubeSize, selectCubeSize); CollisionVolume = topScaleMesh.CreateBVHData(); InteractionContext.GuiSurface.AfterDraw += InteractionLayer_AfterDraw; }
private void AddUnlockLinkIfRequired(PPEContext context, FlowLayoutWidget editControlsContainer, ThemeConfig theme) { var unlockLink = context.item.GetType().GetCustomAttributes(typeof(UnlockLinkAttribute), true).FirstOrDefault() as UnlockLinkAttribute; if (unlockLink != null && !string.IsNullOrEmpty(unlockLink.UnlockPageLink) && !context.item.Persistable) { FlowLayoutWidget row = GetUnlockRow(theme, unlockLink.UnlockPageLink); editControlsContainer.AddChild(row); } }
public GenerateSupportPanel(ThemeConfig theme, InteractiveScene scene) : base(FlowDirection.TopToBottom) { supportGenerator = new SupportGenerator(scene); this.theme = theme; this.VAnchor = VAnchor.Fit; this.HAnchor = HAnchor.Absolute; this.Width = 300; this.BackgroundColor = theme.BackgroundColor; this.Padding = theme.DefaultContainerPadding; // Add an editor field for the SupportGenerator.SupportType PropertyInfo propertyInfo = typeof(SupportGenerator).GetProperty(nameof(SupportGenerator.SupportType)); var editor = PublicPropertyEditor.CreatePropertyEditor( new EditableProperty(propertyInfo, supportGenerator), null, new PPEContext(), theme); if (editor != null) { this.AddChild(editor); } // put in support pillar size var pillarSizeField = new DoubleField(theme); pillarSizeField.Initialize(0); pillarSizeField.DoubleValue = supportGenerator.PillarSize; pillarSizeField.ValueChanged += (s, e) => { supportGenerator.PillarSize = pillarSizeField.DoubleValue; // in case it was corrected set it back again if (pillarSizeField.DoubleValue != supportGenerator.PillarSize) { pillarSizeField.DoubleValue = supportGenerator.PillarSize; } }; var pillarRow = PublicPropertyEditor.CreateSettingsRow("Pillar Size".Localize(), "The width and depth of the support pillars".Localize(), theme); pillarRow.AddChild(pillarSizeField.Content); this.AddChild(pillarRow); // put in the angle setting var overHangField = new DoubleField(theme); overHangField.Initialize(0); overHangField.DoubleValue = supportGenerator.MaxOverHangAngle; overHangField.ValueChanged += (s, e) => { supportGenerator.MaxOverHangAngle = overHangField.DoubleValue; // in case it was corrected set it back again if (overHangField.DoubleValue != supportGenerator.MaxOverHangAngle) { overHangField.DoubleValue = supportGenerator.MaxOverHangAngle; } }; var overHangRow = PublicPropertyEditor.CreateSettingsRow("Overhang Angle".Localize(), "The angle to generate support for".Localize(), theme); overHangRow.AddChild(overHangField.Content); this.AddChild(overHangRow); // Button Row var buttonRow = new FlowLayoutWidget() { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Margin = new BorderDouble(top: 5) }; this.AddChild(buttonRow); buttonRow.AddChild(new HorizontalSpacer()); // add 'Remove Auto Supports' button var removeButton = theme.CreateDialogButton("Remove".Localize()); removeButton.ToolTipText = "Remove all auto generated supports".Localize(); removeButton.Click += (s, e) => supportGenerator.RemoveExisting(); buttonRow.AddChild(removeButton); // add 'Generate Supports' button var generateButton = theme.CreateDialogButton("Generate".Localize()); generateButton.ToolTipText = "Find and create supports where needed".Localize(); generateButton.Click += (s, e) => Rebuild(); buttonRow.AddChild(generateButton); theme.ApplyPrimaryActionStyle(generateButton); }
private void AddWebPageLinkIfRequired(PPEContext context, FlowLayoutWidget editControlsContainer, ThemeConfig theme) { var unlockLink = context.item.GetType().GetCustomAttributes(typeof(WebPageLinkAttribute), true).FirstOrDefault() as WebPageLinkAttribute; if (unlockLink != null) { var row = CreateSettingsRow("Website".Localize()); var detailsLink = new TextIconButton(unlockLink.Name.Localize(), AggContext.StaticData.LoadIcon("internet.png", 16, 16, theme.InvertIcons), theme) { BackgroundColor = theme.MinimalShade, ToolTipText = unlockLink.Url, }; detailsLink.Click += (s, e) => { ApplicationController.Instance.LaunchBrowser(unlockLink.Url); }; row.AddChild(detailsLink); editControlsContainer.AddChild(row); } }
// Default constructor uses IconListView public LibraryListView(ILibraryContext context, ThemeConfig theme) : this(context, new IconListView(theme), theme) { }
public InventoryTreeView(ThemeConfig theme) : base(theme) { UiThread.RunOnIdle(() => { rootColumn = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit }; this.AddChild(rootColumn); // Printers printersNode = new TreeNode(theme) { Text = "Printers".Localize(), HAnchor = HAnchor.Stretch, AlwaysExpandable = true, Image = AggContext.StaticData.LoadIcon("printer.png", 16, 16, theme.InvertIcons) }; printersNode.TreeView = this; var forcedHeight = 20; var mainRow = printersNode.Children.FirstOrDefault(); mainRow.HAnchor = HAnchor.Stretch; mainRow.AddChild(new HorizontalSpacer()); // add in the create printer button var createPrinter = new IconButton(AggContext.StaticData.LoadIcon("md-add-circle_18.png", 18, 18, theme.InvertIcons), theme) { Name = "Create Printer", VAnchor = VAnchor.Center, Margin = theme.ButtonSpacing.Clone(left: theme.ButtonSpacing.Right), ToolTipText = "Create Printer".Localize(), Height = forcedHeight, Width = forcedHeight }; createPrinter.Click += (s, e) => UiThread.RunOnIdle(() => { if (ApplicationController.Instance.ActivePrinter.Connection.PrinterIsPrinting || ApplicationController.Instance.ActivePrinter.Connection.PrinterIsPaused) { StyledMessageBox.ShowMessageBox("Please wait until the print has finished and try again.".Localize(), "Can't add printers while printing".Localize()); } else { DialogWindow.Show(PrinterSetup.GetBestStartPage(PrinterSetup.StartPageOptions.ShowMakeModel)); } }); mainRow.AddChild(createPrinter); // add in the import printer button var importPrinter = new IconButton(AggContext.StaticData.LoadIcon("md-import_18.png", 18, 18, theme.InvertIcons), theme) { VAnchor = VAnchor.Center, Margin = theme.ButtonSpacing, ToolTipText = "Import Printer".Localize(), Height = forcedHeight, Width = forcedHeight }; importPrinter.Click += (s, e) => UiThread.RunOnIdle(() => { AggContext.FileDialogs.OpenFileDialog( new OpenFileDialogParams( "settings files|*.ini;*.printer;*.slice"), (result) => { if (!string.IsNullOrEmpty(result.FileName) && File.Exists(result.FileName)) { //simpleTabs.RemoveTab(simpleTabs.ActiveTab); if (ProfileManager.ImportFromExisting(result.FileName)) { string importPrinterSuccessMessage = "You have successfully imported a new printer profile. You can find '{0}' in your list of available printers.".Localize(); DialogWindow.Show( new ImportSucceeded( importPrinterSuccessMessage.FormatWith(Path.GetFileNameWithoutExtension(result.FileName)))); } else { StyledMessageBox.ShowMessageBox("Oops! Settings file '{0}' did not contain any settings we could import.".Localize().FormatWith(Path.GetFileName(result.FileName)), "Unable to Import".Localize()); } } }); }); mainRow.AddChild(importPrinter); rootColumn.AddChild(printersNode); InventoryTreeView.RebuildPrintersList(printersNode, theme); this.Invalidate(); // Filament var materialsNode = new TreeNode(theme) { Text = "Materials".Localize(), AlwaysExpandable = true, Image = AggContext.StaticData.LoadIcon("filament.png", 16, 16, theme.InvertIcons) }; materialsNode.TreeView = this; rootColumn.AddChild(materialsNode); }, 1); PrinterSettings.SettingChanged.RegisterEvent((s, e) => { var activePrinter = ApplicationController.Instance.ActivePrinter; string settingsName = (e as StringEventArgs)?.Data; if (settingsName != null && settingsName == SettingsKey.printer_name) { if (ProfileManager.Instance.ActiveProfile != null) { ProfileManager.Instance.ActiveProfile.Name = activePrinter.Settings.GetValue(SettingsKey.printer_name); InventoryTreeView.RebuildPrintersList(printersNode, theme); this.Invalidate(); } } }, ref unregisterEvents); PrinterSettings.SettingChanged.RegisterEvent((s, e) => { string settingsName = (e as StringEventArgs)?.Data; if (settingsName == SettingsKey.printer_name) { InventoryTreeView.RebuildPrintersList(printersNode, theme); this.Invalidate(); } }, ref unregisterEvents); //// Rebuild the droplist any time the ActivePrinter changes //ApplicationController.Instance.ActivePrinterChanged.RegisterEvent((s, e) => //{ // this.Rebuild(); //}, ref unregisterEvents); // Rebuild the droplist any time the Profiles list changes ProfileManager.ProfilesListChanged.RegisterEvent((s, e) => { InventoryTreeView.RebuildPrintersList(printersNode, theme); this.Invalidate(); }, ref unregisterEvents); }
public FloorDrawable(Object3DControlsLayer.EditorType editorType, ISceneContext sceneContext, Color buildVolumeColor, ThemeConfig theme) { this.buildVolumeColor = buildVolumeColor; this.sceneContext = sceneContext; this.editorType = editorType; this.theme = theme; this.printer = sceneContext.Printer; this.EnsureBedTexture(selectedItem: null); // Register listeners if (printer != null) { printer.Settings.SettingChanged += this.Settings_SettingChanged; } }
public OverflowMenuButton(ThemeConfig theme) : base(CreateOverflowIcon(theme), theme) { }
public ListField(ThemeConfig theme) { this.theme = theme; }
public GridWidget(int gridWidth, int gridHeight, double columnWidth = 60, double rowHeight = 14, ThemeConfig theme = null) : base(FlowDirection.TopToBottom) { for (int y = 0; y < gridHeight; y++) { var row = new FlowLayoutWidget(); this.AddChild(row); for (int x = 0; x < gridWidth; x++) { row.AddChild(new GuiWidget() { Width = columnWidth * GuiWidget.DeviceScale, Height = rowHeight * GuiWidget.DeviceScale, Border = 1, BorderColor = theme == null ? Color.LightGray : theme.BorderColor20, }); } } }
public PopupMenuButton(ImageBuffer imageBuffer, ThemeConfig theme) : this(new IconButton(imageBuffer, theme), theme) { }
public static GuiWidget GetQualityWidget(ThemeConfig theme, PrintTask printTask, Action clicked, double buttonFontSize) { var content = new FlowLayoutWidget() { HAnchor = HAnchor.Fit | HAnchor.Stretch }; var siblings = new List<GuiWidget>(); var textWidget = new TextWidget("Print Quality".Localize() + ":", pointSize: theme.DefaultFontSize, textColor: theme.TextColor) { VAnchor = VAnchor.Center }; content.AddChild(textWidget); var size = (int)(buttonFontSize * GuiWidget.DeviceScale); var star = StaticData.Instance.LoadIcon("star.png", size, size).SetToColor(theme.TextColor); var openStar = StaticData.Instance.LoadIcon("open_star.png", size, size).SetToColor(theme.TextColor); var failure = StaticData.Instance.LoadIcon("failure.png", size, size).SetToColor(theme.TextColor); content.AddChild(new GuiWidget(size, 1)); content.MouseLeaveBounds += (s, e) => { SetStarState(theme, siblings, printTask); }; for (int i = 0; i < QualityNames.Length; i++) { var buttonIndex = i; GuiWidget buttonContent; if (i == 0) { buttonContent = new ImageWidget(failure); } else { buttonContent = new GuiWidget() { HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit }; buttonContent.AddChild(new ImageWidget(openStar) { Name = "open" }); buttonContent.AddChild(new ImageWidget(star) { Name = "closed", Visible = false }); } var button = new RadioButton(buttonContent) { Enabled = printTask.PrintComplete, Checked = printTask.QualityWasSet && printTask.PrintQuality == i, ToolTipText = QualityNames[i], Margin = 0, Padding = 5, HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit, }; button.MouseEnterBounds += (s, e) => { // set the correct filled stars for the hover for (int j = 0; j < siblings.Count; j++) { var open = siblings[j].Descendants().Where(d => d.Name == "open").FirstOrDefault(); var closed = siblings[j].Descendants().Where(d => d.Name == "closed").FirstOrDefault(); if (j == 0) { if (buttonIndex == 0) { siblings[j].BackgroundColor = theme.AccentMimimalOverlay; } else { siblings[j].BackgroundColor = Color.Transparent; } } else if (j <= buttonIndex) { siblings[j].BackgroundColor = theme.AccentMimimalOverlay; } else { siblings[j].BackgroundColor = Color.Transparent; } if (j <= buttonIndex) { if (open != null) { open.Visible = false; closed.Visible = true; } } else { if (open != null) { open.Visible = true; closed.Visible = false; } } } }; siblings.Add(button); button.SiblingRadioButtonList = siblings; content.AddChild(button); button.Click += (s, e) => { printTask.PrintQuality = siblings.IndexOf((GuiWidget)s); printTask.QualityWasSet = true; printTask.CommitAndPushToServer(); clicked(); }; } SetStarState(theme, siblings, printTask); return content; }
public TabTrailer(SimpleTabs parentTabControl, ThemeConfig theme) { this.parentTabControl = parentTabControl; this.theme = theme; }
public static GuiWidget CreateDefaultOptions(GuiWidget textField, ThemeConfig theme, Action selectionChanged) { var selectString = "- " + "What went wrong?".Localize() + " -"; var menuButton = new PopupMenuButton(selectString, theme); var menuButtonText = menuButton.Descendants<TextWidget>().First(); menuButtonText.AutoExpandBoundsToText = true; void AddSelection(PopupMenu menu, string text, string helpUrl = "", bool other = false) { var menuItem = menu.CreateMenuItem(text); menuItem.Click += (s, e) => { textField.Name = helpUrl; var markdownWidget = textField.Parents<SystemWindow>().First().Descendants<MarkdownWidget>().LastOrDefault(); if (markdownWidget != null) { markdownWidget.Markdown = textField.Name; markdownWidget.Visible = !string.IsNullOrEmpty(markdownWidget.Markdown); } if (other) { textField.Text = ""; textField.Visible = true; UiThread.RunOnIdle(textField.Focus); menuButtonText.Text = "Other".Localize() + "..."; } else { textField.Text = text; textField.Visible = false; menuButtonText.Text = textField.Text; } selectionChanged?.Invoke(); }; } string TroubleShooting(string type, int issue) { return $"For help with {type} and other issues, please read MatterHackers [Troubleshooting Guide](https://www.matterhackers.com/articles/3d-printer-troubleshooting-guide#Issue{issue})"; } menuButton.DynamicPopupContent = () => { var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme); popupMenu.CreateSubMenu("First Layer".Localize(), theme, (menu) => { AddSelection(menu, "First Layer Bad Quality".Localize(), TroubleShooting("the first layer", 1)); AddSelection(menu, "Initial Z Height Incorrect".Localize(), TroubleShooting("initial Z height", 1)); }); popupMenu.CreateSubMenu("Quality".Localize(), theme, (menu) => { AddSelection(menu, "General Quality".Localize(), TroubleShooting("general quality", 100)); AddSelection(menu, "Rough Overhangs".Localize()); AddSelection(menu, "Skipped Layers".Localize()); AddSelection(menu, "Some Parts Lifted".Localize(), TroubleShooting("lifting", 6)); AddSelection(menu, "Stringing / Poor retractions".Localize(), TroubleShooting("stringing", 9)); AddSelection(menu, "Warping".Localize(), TroubleShooting("warping", 6)); AddSelection(menu, "Dislodged From Bed".Localize(), TroubleShooting("adhesion", 2)); AddSelection(menu, "Layer Shift".Localize(), TroubleShooting("layer shifting", 8)); }); popupMenu.CreateSubMenu("Mechanical".Localize(), theme, (menu) => { AddSelection(menu, "Bed Dislodged".Localize()); AddSelection(menu, "Bowden Tube Popped Out".Localize()); AddSelection(menu, "Extruder Slipping".Localize(), TroubleShooting("the extruder", 13)); AddSelection(menu, "Flooded Hot End".Localize()); AddSelection(menu, "Power Outage".Localize()); }); popupMenu.CreateSubMenu("Computer / MatterControl ".Localize(), theme, (menu) => { AddSelection(menu, "Computer Crashed".Localize()); AddSelection(menu, "Computer Slow / Lagging".Localize()); AddSelection(menu, "Couldn't Resume".Localize()); AddSelection(menu, "Wouldn’t Slice Correctly".Localize()); }); popupMenu.CreateSubMenu("Filament".Localize(), theme, (menu) => { AddSelection(menu, "Filament Jam".Localize()); AddSelection(menu, "Filament Runout".Localize()); AddSelection(menu, "Filament Snapped".Localize()); }); popupMenu.CreateSubMenu("Heating".Localize(), theme, (menu) => { AddSelection(menu, "Thermal Runaway - Bed".Localize()); AddSelection(menu, "Thermal Runaway - Hot End".Localize()); AddSelection(menu, "Heating".Localize()); AddSelection(menu, "Took Too Long To Heat".Localize()); AddSelection(menu, "Bad Thermistor".Localize()); AddSelection(menu, "Bad Thermistor".Localize()); }); AddSelection(popupMenu, "Test Print".Localize()); AddSelection(popupMenu, "User Error".Localize()); AddSelection(popupMenu, "Other".Localize(), "", true); return popupMenu; }; textField.Visible = false; menuButton.VAnchor = VAnchor.Fit; return menuButton; }
public LibraryWidget(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); 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); 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 == 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); 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); treeView = new TreeView(theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, Margin = 5 }; treeView.AfterSelect += async(s, e) => { if (treeView.SelectedNode is ContainerTreeNode treeNode) { if (!treeNode.ContainerAcquired) { await this.EnsureExpanded(treeNode.Tag as ILibraryItem, treeNode); } if (treeNode.ContainerAcquired) { ApplicationController.Instance.Library.ActiveContainer = treeNode.Container; } } }; horizontalSplitter.Panel1.AddChild(treeView); var rootColumn = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit, Margin = new BorderDouble(left: 10) }; treeView.AddChild(rootColumn); UiThread.RunOnIdle(() => { foreach (var item in ApplicationController.Instance.Library.ActiveContainer.ChildContainers) { var rootNode = this.CreateTreeNode(item); rootNode.TreeView = treeView; rootColumn.AddChild(rootNode); } }, 1); horizontalSplitter.Panel2.AddChild(libraryView); buttonPanel = new FlowLayoutWidget() { HAnchor = HAnchor.Stretch, Padding = theme.ToolbarPadding, }; AddLibraryButtonElements(); allControls.AddChild(buttonPanel); allControls.AnchorAll(); this.AddChild(allControls); }
public SubMenuItemButton(GuiWidget content, ThemeConfig theme) : base(content, theme) { }