TabControl CreateNewAdvancedControlsTab(SliceSettingsWidget.UiState sliceSettingsUiState) { advancedControls = new TabControl(); advancedControls.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor; advancedControls.TabBar.BorderColor = RGBA_Bytes.White; advancedControls.TabBar.Margin = new BorderDouble(0, 0); advancedControls.TabBar.Padding = new BorderDouble(0, 2); advancedControlsButtonFactory.invertImageLocation = false; Button advancedControlsLinkButton = advancedControlsButtonFactory.Generate("Print\nQueue", "icon_arrow_left_32x32.png"); advancedControlsLinkButton.Margin = new BorderDouble(right: 3); advancedControlsLinkButton.VAnchor = VAnchor.ParentBottom; advancedControlsLinkButton.Cursor = Cursors.Hand; advancedControlsLinkButton.Click += new ButtonBase.ButtonEventHandler(AdvancedControlsButton_Click); advancedControlsLinkButton.MouseEnterBounds += new EventHandler(onMouseEnterBoundsPrintQueueLink); advancedControlsLinkButton.MouseLeaveBounds += new EventHandler(onMouseLeaveBoundsPrintQueueLink); //advancedControls.TabBar.AddChild(advancedControlsLinkButton); GuiWidget manualPrinterControls = new ManualPrinterControls(); ScrollableWidget manualPrinterControlsScrollArea = new ScrollableWidget(true); manualPrinterControlsScrollArea.ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; manualPrinterControlsScrollArea.AnchorAll(); manualPrinterControlsScrollArea.AddChild(manualPrinterControls); advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(manualPrinterControlsScrollArea, "Printer Controls"), 18, ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); sliceSettingsWidget = new SliceSettingsWidget(sliceSettingsUiState); advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(sliceSettingsWidget, "Slice Settings"), 18, ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); return(advancedControls); }
public LicenseAgreementPage() : base("Cancel") { string eulaText = StaticData.Instance.ReadAllText("MatterControl EULA.txt").Replace("\r\n", "\n"); var scrollable = new ScrollableWidget(true); scrollable.AnchorAll(); scrollable.ScrollArea.HAnchor = HAnchor.ParentLeftRight; contentRow.AddChild(scrollable); var textBox = new WrappedTextWidget(eulaText, 200, textColor: ActiveTheme.Instance.PrimaryTextColor); scrollable.AddChild(textBox); var acceptButton = textImageButtonFactory.Generate("Accept".Localize()); acceptButton.Click += (s, e) => { UserSettings.Instance.set("SoftwareLicenseAccepted", "true"); UiThread.RunOnIdle(WizardWindow.Close); }; acceptButton.Visible = true; cancelButton.Visible = true; cancelButton.Click += (s, e) => UiThread.RunOnIdle(WizardWindow.Close); //Add buttons to buttonContainer footerRow.AddChild(acceptButton); footerRow.AddChild(new HorizontalSpacer()); footerRow.AddChild(cancelButton); footerRow.Visible = true; }
public LicenseAgreementPage(Action acceptAction) { this.WindowTitle = "Software License Agreement".Localize(); this.HeaderText = "Software License Agreement".Localize(); string eulaText = AggContext.StaticData.ReadAllText("MatterControl EULA.txt").Replace("\r\n", "\n"); var scrollable = new ScrollableWidget(true); scrollable.AnchorAll(); scrollable.ScrollArea.HAnchor = HAnchor.Stretch; contentRow.AddChild(scrollable); scrollable.ScrollArea.Margin = new BorderDouble(0, 0, 15, 0); scrollable.AddChild(new WrappedTextWidget(eulaText, textColor: theme.TextColor, doubleBufferText: false) { DrawFromHintedCache = true, Name = "LicenseAgreementPage", }); var acceptButton = theme.CreateDialogButton("Accept".Localize()); acceptButton.Click += (s, e) => { UserSettings.Instance.set(UserSettingsKey.SoftwareLicenseAccepted, "true"); this.Close(); acceptAction?.Invoke(); }; acceptButton.Visible = true; this.AddPageAction(acceptButton); }
public PluginsPage() { this.AnchorAll(); this.HeaderText = this.WindowTitle = "MatterControl Plugins".Localize(); var contentScroll = new ScrollableWidget(true); contentScroll.ScrollArea.HAnchor |= HAnchor.Stretch; contentScroll.ScrollArea.VAnchor = VAnchor.Fit; contentScroll.AnchorAll(); var formContainer = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch }; // TODO: Move to instance var plugins = ApplicationController.Plugins; foreach (var plugin in plugins.KnownPlugins) { // Touch Screen Mode formContainer.AddChild( new SettingsItem( plugin.Name, theme, new SettingsItem.ToggleSwitchConfig() { Checked = !plugins.Disabled.Contains(plugin.TypeName), ToggleAction = (itemChecked) => { if (itemChecked) { plugins.Enable(plugin.TypeName); } else { plugins.Disable(plugin.TypeName); } } }, enforceGutter: false)); } contentScroll.AddChild(formContainer); contentRow.AddChild(contentScroll); var saveButton = theme.CreateDialogButton("Save".Localize()); saveButton.Click += (s, e) => { ApplicationController.Plugins.Save(); this.DialogWindow.CloseOnIdle(); }; this.AddPageAction(saveButton); }
public GCodePanel(PrinterConfig printer, BedConfig sceneContext, ThemeConfig theme) : base(FlowDirection.TopToBottom) { this.sceneContext = sceneContext; this.theme = theme; this.printer = printer; SectionWidget sectionWidget; this.AddChild( sectionWidget = new SectionWidget( "Options".Localize(), new GCodeOptionsPanel(sceneContext, printer, theme), theme, ApplicationController.Instance.GetViewOptionButtons(sceneContext, printer, theme)) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Padding = 0 }); sectionWidget.ContentPanel.Descendants <SettingsRow>().First().Border = 0; var scrollable = new ScrollableWidget(true) { Name = "editorPanel", HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, }; scrollable.ScrollArea.HAnchor = HAnchor.Stretch; scrollable.AddChild(loadedGCodeSection = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit }); this.AddChild(scrollable); this.RefreshGCodeDetails(printer); this.EnsureSectionWidgetStyling(this.Children <SectionWidget>()); ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) => { if (e is StringEventArgs stringEvent) { if (stringEvent.Data == "extruder_offset") { printer.Bed.GCodeRenderer?.Clear3DGCode(); } } }, ref unregisterEvents); printer.Bed.LoadedGCodeChanged += Bed_LoadedGCodeChanged; printer.Bed.RendererOptions.PropertyChanged += RendererOptions_PropertyChanged; }
public GCodePanel(PrinterTabPage printerTabPage, PrinterConfig printer, ISceneContext sceneContext, ThemeConfig theme) : base(FlowDirection.TopToBottom) { this.sceneContext = sceneContext; this.theme = theme; this.printer = printer; this.printerTabPage = printerTabPage; SectionWidget sectionWidget; this.AddChild( sectionWidget = new SectionWidget( "Options".Localize(), new GCodeOptionsPanel(sceneContext, printer, theme), theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Padding = 0 }); sectionWidget.ContentPanel.Descendants <SettingsRow>().First().Border = 0; var scrollable = new ScrollableWidget(true) { Name = "editorPanel", HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, }; scrollable.ScrollArea.HAnchor = HAnchor.Stretch; scrollable.AddChild(loadedGCodeSection = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit }); this.AddChild(scrollable); this.RefreshGCodeDetails(printer); this.EnsureSectionWidgetStyling(this.Children <SectionWidget>()); var firstSection = this.Children <SectionWidget>().First(); firstSection.BorderColor = Color.Transparent; // Disable top border on first item to produce a more flat, dark top edge // Register listeners printer.Bed.LoadedGCodeChanged += Bed_LoadedGCodeChanged; printer.Bed.RendererOptions.PropertyChanged += RendererOptions_PropertyChanged; }
void CreateNewAdvancedControlsTab(SliceSettingsWidget.UiState sliceSettingsUiState) { advancedControlsTabControl = new TabControl(); advancedControlsTabControl.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; advancedControlsTabControl.TabBar.BorderColor = ActiveTheme.Instance.SecondaryTextColor; advancedControlsTabControl.TabBar.Margin = new BorderDouble(0, 0); advancedControlsTabControl.TabBar.Padding = new BorderDouble(0, 2); advancedControlsButtonFactory.invertImageLocation = false; Button advancedControlsLinkButton = advancedControlsButtonFactory.Generate(LocalizedString.Get("Print\nQueue"), "icon_arrow_left_32x32.png"); advancedControlsLinkButton.Margin = new BorderDouble(right: 3); advancedControlsLinkButton.VAnchor = VAnchor.ParentBottom; advancedControlsLinkButton.Cursor = Cursors.Hand; advancedControlsLinkButton.Click += new ButtonBase.ButtonEventHandler(AdvancedControlsButton_Click); advancedControlsLinkButton.MouseEnterBounds += new EventHandler(onMouseEnterBoundsPrintQueueLink); advancedControlsLinkButton.MouseLeaveBounds += new EventHandler(onMouseLeaveBoundsPrintQueueLink); advancedControlsTabControl.TabBar.AddChild(advancedControlsLinkButton); GuiWidget hSpacer = new GuiWidget(); hSpacer.HAnchor = HAnchor.ParentLeftRight; advancedControlsTabControl.TabBar.AddChild(hSpacer); GuiWidget manualPrinterControls = new ManualPrinterControls(); ScrollableWidget manualPrinterControlsScrollArea = new ScrollableWidget(true); manualPrinterControlsScrollArea.ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; manualPrinterControlsScrollArea.AnchorAll(); manualPrinterControlsScrollArea.AddChild(manualPrinterControls); //Add the tab contents for 'Advanced Controls' string printerControlsLabel = LocalizedString.Get("Controls").ToUpper(); advancedControlsTabControl.AddTab(new SimpleTextTabWidget(new TabPage(manualPrinterControlsScrollArea, printerControlsLabel), 14, ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); string sliceSettingsLabel = LocalizedString.Get("Slice Settings").ToUpper(); sliceSettingsWidget = new SliceSettingsWidget(sliceSettingsUiState); advancedControlsTabControl.AddTab(new SimpleTextTabWidget(new TabPage(sliceSettingsWidget, sliceSettingsLabel), 14, ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); string configurationLabel = LocalizedString.Get("Configuration").ToUpper(); ScrollableWidget configurationControls = new ConfigurationPage(); advancedControlsTabControl.AddTab(new SimpleTextTabWidget(new TabPage(configurationControls, configurationLabel), 14, ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); }
public ApplicationSettingsPage() : base("Close".Localize()) { this.AlwaysOnTopOfMain = true; this.WindowTitle = this.HeaderText = "MatterControl " + "Settings".Localize(); this.WindowSize = new Vector2(700 * GuiWidget.DeviceScale, 600 * GuiWidget.DeviceScale); contentRow.Padding = theme.DefaultContainerPadding; contentRow.Padding = 0; contentRow.BackgroundColor = Color.Transparent; GuiWidget settingsColumn; { var settingsAreaScrollBox = new ScrollableWidget(true); settingsAreaScrollBox.ScrollArea.HAnchor |= HAnchor.Stretch; settingsAreaScrollBox.AnchorAll(); settingsAreaScrollBox.BackgroundColor = theme.MinimalShade; contentRow.AddChild(settingsAreaScrollBox); settingsColumn = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.MaxFitOrStretch }; settingsAreaScrollBox.AddChild(settingsColumn); } AddGeneralPannel(settingsColumn); AddUsserOptionsPannel(settingsColumn); AddAdvancedPannel(settingsColumn); // Enforce consistent SectionWidget spacing and last child borders foreach (var section in settingsColumn.Children <SectionWidget>()) { section.Margin = new BorderDouble(0, 10, 0, 0); if (section.ContentPanel.Children.LastOrDefault() is SettingsItem lastRow) { // If we're in a contentPanel that has SettingsItems... // Clear the last items bottom border lastRow.Border = lastRow.Border.Clone(bottom: 0); // Set a common margin on the parent container section.ContentPanel.Margin = new BorderDouble(2, 0); } } }
private void AddAllContent() { contentRow.CloseChildren(); GuiWidget settingsColumn; var settingsAreaScrollBox = new ScrollableWidget(true); settingsAreaScrollBox.ScrollArea.HAnchor |= HAnchor.Stretch; settingsAreaScrollBox.AnchorAll(); settingsAreaScrollBox.BackgroundColor = theme.MinimalShade; contentRow.AddChild(settingsAreaScrollBox); settingsColumn = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.MaxFitOrStretch }; settingsAreaScrollBox.AddChild(settingsColumn); if (ProfileManager.GetOemSettingsNeedingUpdate(printer).Any()) { AddUpgradeInfoPannel(settingsColumn); } else { settingsColumn.AddChild(new WrappedTextWidget("No setting currently need to be updated.".Localize(), pointSize: 11) { Margin = new BorderDouble(5), TextColor = theme.TextColor }); } // Enforce consistent SectionWidget spacing and last child borders foreach (var section in settingsColumn.Children <SectionWidget>()) { section.Margin = new BorderDouble(0, 10, 0, 0); if (section.ContentPanel.Children.LastOrDefault() is SettingsItem lastRow) { // If we're in a contentPanel that has SettingsItems... // Clear the last items bottom border lastRow.Border = lastRow.Border.Clone(bottom: 0); // Set a common margin on the parent container section.ContentPanel.Margin = new BorderDouble(2, 0); } } }
public PrinterProfileHistoryPage(PrinterConfig printer) { this.WindowTitle = "Restore Settings".Localize(); this.HeaderText = "Restore Settings".Localize(); this.printer = printer; scrollWindow = new ScrollableWidget() { AutoScroll = true, HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, }; scrollWindow.ScrollArea.HAnchor = HAnchor.Stretch; contentRow.FlowDirection = FlowDirection.TopToBottom; contentRow.AddChild(scrollWindow); var revertButton = theme.CreateDialogButton("Restore".Localize()); revertButton.Click += async(s, e) => { int index = radioButtonList.IndexOf(radioButtonList.Where(r => r.Checked).FirstOrDefault()); if (index != -1) { string profileToken = printerProfileData[orderedProfiles[index]]; var profile = ProfileManager.Instance[printer.Settings.ID]; // Download the specified json profile PrinterSettings printerSettings = null; if (Application.EnableNetworkTraffic) { await ApplicationController.GetPrinterProfileAsync(profile, profileToken); } if (printerSettings != null) { // Persist downloaded profile printerSettings.Save(); // Update/switch printer instance to new settings printer.SwapToSettings(printerSettings); } UiThread.RunOnIdle(DialogWindow.Close); } }; this.AddPageAction(revertButton); LoadHistoryItems(); }
private TabControl CreateExtraSettingsSideTabsAndPages(int minSettingNameWidth, TabControl categoryTabs, out int count) { count = 0; TabControl sideTabs = new TabControl(Orientation.Vertical); sideTabs.Margin = new BorderDouble(0, 0, 0, 5); sideTabs.TabBar.BorderColor = RGBA_Bytes.White; { TabPage groupTabPage = new TabPage("Extra Settings"); SimpleTextTabWidget groupTabWidget = new SimpleTextTabWidget(groupTabPage, 14, ActiveTheme.Instance.TabLabelSelected, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes()); sideTabs.AddTab(groupTabWidget); FlowLayoutWidget subGroupLayoutTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); subGroupLayoutTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; subGroupLayoutTopToBottom.VAnchor = VAnchor.FitToChildren; FlowLayoutWidget topToBottomSettings = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottomSettings.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; foreach (KeyValuePair <string, DataStorage.SliceSetting> item in ActiveSliceSettings.Instance.DefaultSettings) { if (!SliceSettingsOrganizer.Instance.Contains(UserLevel, item.Key)) { OrganizerSettingsData settingInfo = new OrganizerSettingsData(item.Key, item.Key, OrganizerSettingsData.DataEditTypes.STRING); GuiWidget controlsForThisSetting = CreateSettingInfoUIControls(settingInfo, minSettingNameWidth); topToBottomSettings.AddChild(controlsForThisSetting); count++; } } GroupBox groupBox = new GroupBox(new LocalizedString("Extra").Translated); groupBox.TextColor = ActiveTheme.Instance.PrimaryTextColor; groupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor; groupBox.AddChild(topToBottomSettings); groupBox.VAnchor = VAnchor.FitToChildren; groupBox.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; subGroupLayoutTopToBottom.AddChild(groupBox); ScrollableWidget scrollOnGroupTab = new ScrollableWidget(true); scrollOnGroupTab.AnchorAll(); scrollOnGroupTab.AddChild(subGroupLayoutTopToBottom); groupTabPage.AddChild(scrollOnGroupTab); } return(sideTabs); }
public PrinterProfileHistoryPage() : base(unlocalizedTextForTitle: "Restore Settings") { scrollWindow = new ScrollableWidget() { AutoScroll = true, HAnchor = HAnchor.ParentLeftRight, VAnchor = VAnchor.ParentBottomTop, }; scrollWindow.ScrollArea.HAnchor = HAnchor.ParentLeftRight; contentRow.FlowDirection = FlowDirection.TopToBottom; contentRow.AddChild(scrollWindow); var revertButton = textImageButtonFactory.Generate("Restore".Localize()); footerRow.AddChild(revertButton); footerRow.AddChild(new HorizontalSpacer()); footerRow.AddChild(cancelButton); revertButton.Click += async(s, e) => { int index = radioButtonList.IndexOf(radioButtonList.Where(r => r.Checked).FirstOrDefault()); if (index != -1) { string profileToken = printerProfileData[orderedProfiles[index]]; var activeProfile = ProfileManager.Instance.ActiveProfile; // Download the specified json profile var jsonProfile = await ApplicationController.GetPrinterProfileAsync(activeProfile, profileToken); if (jsonProfile != null) { // Persist downloaded profile jsonProfile.Save(); // Update active instance without calling ReloadAll ActiveSliceSettings.RefreshActiveInstance(jsonProfile); } UiThread.RunOnIdle(WizardWindow.Close); } }; LoadHistoryItems(); }
public void LimitScrolToContetsTests() { GuiWidget containerControl = new GuiWidget(200, 200); containerControl.DoubleBuffer = true; containerControl.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); containerControl.OnDraw(containerControl.NewGraphics2D()); ScrollableWidget containerTest = new ScrollableWidget(200, 200); containerTest.DoubleBuffer = true; containerTest.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); containerTest.OnDraw(containerTest.NewGraphics2D()); OutputImages(containerControl, containerTest); Assert.IsTrue(containerControl.BackBuffer != null, "When we set a guiWidget to DoubleBuffer it needs to create one."); Assert.IsTrue(containerControl.BackBuffer == containerTest.BackBuffer, "The Anchored widget should be in the correct place."); }
TabControl CreateNewAdvancedControlsTab(SliceSettingsWidget.UiState sliceSettingsUiState) { StoreUiState(); advancedControls = new TabControl(); advancedControls.AnchorAll(); advancedControls.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; advancedControls.TabBar.BorderColor = ActiveTheme.Instance.SecondaryTextColor; advancedControls.TabBar.Margin = new BorderDouble(0, 0); advancedControls.TabBar.Padding = new BorderDouble(0, 2); advancedControlsButtonFactory.invertImageLocation = false; GuiWidget manualPrinterControls = new ManualPrinterControls(); ScrollableWidget manualPrinterControlsScrollArea = new ScrollableWidget(true); manualPrinterControlsScrollArea.ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; manualPrinterControlsScrollArea.AnchorAll(); manualPrinterControlsScrollArea.AddChild(manualPrinterControls); //Add the tab contents for 'Advanced Controls' string printerControlsLabel = LocalizedString.Get("Controls").ToUpper(); advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(manualPrinterControlsScrollArea, printerControlsLabel), 16, ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); string sliceSettingsLabel = LocalizedString.Get("Slice Settings").ToUpper(); sliceSettingsWidget = new SliceSettingsWidget(sliceSettingsUiState); advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(sliceSettingsWidget, sliceSettingsLabel), 16, ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); string configurationLabel = LocalizedString.Get("Configuration").ToUpper(); ScrollableWidget configurationControls = new ConfigurationPage(); advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(configurationControls, configurationLabel), 16, ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); RestoreUiState(); return(advancedControls); }
public LicenseAgreementPage() { string eulaText = StaticData.Instance.ReadAllText("MatterControl EULA.txt").Replace("\r\n", "\n"); var scrollable = new ScrollableWidget(true); scrollable.AnchorAll(); scrollable.ScrollArea.HAnchor = HAnchor.ParentLeftRight; contentRow.AddChild(scrollable); var textBox = new WrappedTextWidget(eulaText, textColor: ActiveTheme.Instance.PrimaryTextColor, doubleBufferText: false) { DrawFromHintedCache = true, Name = "LicenseAgreementPage", }; scrollable.ScrollArea.Margin = new BorderDouble(0, 0, 15, 0); scrollable.AddChild(textBox); var acceptButton = textImageButtonFactory.Generate("Accept".Localize()); acceptButton.Click += (s, e) => { UserSettings.Instance.set("SoftwareLicenseAccepted", "true"); UiThread.RunOnIdle(WizardWindow.Close); }; acceptButton.Visible = true; cancelButton.Visible = true; // Exit if EULA is not accepted cancelButton.Click += (s, e) => UiThread.RunOnIdle(MatterControlApplication.Instance.Close); //Add buttons to buttonContainer footerRow.AddChild(acceptButton); footerRow.AddChild(new HorizontalSpacer()); footerRow.AddChild(cancelButton); footerRow.Visible = true; UiThread.RunOnIdle(MakeFrontWindow, .2); }
public ScrollableWidgetTestPage() : base("Scroll Widget") { ScrollableWidget scrollWidgetLeft = new ScrollableWidget(); scrollWidgetLeft.AutoScroll = true; scrollWidgetLeft.LocalBounds = new RectangleDouble(0, 0, 300, 400); //scrollWidgetLeft.DebugShowBounds = true; scrollWidgetLeft.OriginRelativeParent = new Vector2(30, 30); scrollWidgetLeft.AddChild(new RandomFillWidget(new Point2D(300, 600))); scrollWidgetLeft.AddChild(new Button("button1", 100, 100)); scrollWidgetLeft.Margin = new BorderDouble(10); //scrollWidgetLeft.DebugShowBounds = true; AddChild(scrollWidgetLeft); ScrollableWidget scrollWidgetRight = new ScrollableWidget(); scrollWidgetRight.LocalBounds = new RectangleDouble(0, 0, 250, 400); //scrollWidgetRight.DebugShowBounds = true; scrollWidgetRight.OriginRelativeParent = new Vector2(340, 30); AddChild(scrollWidgetRight); }
public AboutPage() : base("Close".Localize()) { this.WindowTitle = "About".Localize() + " " + ApplicationController.Instance.ProductName; this.MinimumSize = new Vector2(480 * GuiWidget.DeviceScale, 520 * GuiWidget.DeviceScale); this.WindowSize = new Vector2(500 * GuiWidget.DeviceScale, 550 * GuiWidget.DeviceScale); contentRow.BackgroundColor = Color.Transparent; headerRow.Visible = false; var altHeadingRow = new GuiWidget() { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Absolute, Height = 100, }; contentRow.AddChild(altHeadingRow); var productInfo = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Center | HAnchor.Fit, VAnchor = VAnchor.Center | VAnchor.Fit }; var productTitle = new FlowLayoutWidget() { HAnchor = HAnchor.Center | HAnchor.Fit }; productTitle.AddChild(new TextWidget("MatterControl".Localize(), textColor: theme.TextColor, pointSize: 20) { Margin = new BorderDouble(right: 3) }); productTitle.AddChild(new TextWidget("TM".Localize(), textColor: theme.TextColor, pointSize: 7) { VAnchor = VAnchor.Top }); altHeadingRow.AddChild(productInfo); productInfo.AddChild(productTitle); var spinnerPanel = new GuiWidget() { HAnchor = HAnchor.Absolute | HAnchor.Left, VAnchor = VAnchor.Absolute, Height = 100, Width = 100, }; altHeadingRow.AddChild(spinnerPanel); var accentColor = theme.PrimaryAccentColor; var spinner = new LogoSpinner(spinnerPanel, 4, 0.2, 0, rotateX: 0) { /* * MeshColor = new Color(175, 175, 175, 255), * AmbientColor = new float[] * { * accentColor.Red0To1, * accentColor.Green0To1, * accentColor.Blue0To1, * 0 * }*/ }; productInfo.AddChild( new TextWidget("Version".Localize() + " " + VersionInfo.Instance.BuildVersion, textColor: theme.TextColor, pointSize: theme.DefaultFontSize) { HAnchor = HAnchor.Center }); productInfo.AddChild( new TextWidget("Developed By".Localize() + ": " + "MatterHackers", textColor: theme.TextColor, pointSize: theme.DefaultFontSize) { HAnchor = HAnchor.Center }); contentRow.AddChild( new WrappedTextWidget( "MatterControl is made possible by the team at MatterHackers and other open source software".Localize() + ":", pointSize: theme.DefaultFontSize, textColor: theme.TextColor) { HAnchor = HAnchor.Stretch, Margin = new BorderDouble(0, 15) }); var licensePanel = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Margin = new BorderDouble(bottom: 15) }; var data = JsonConvert.DeserializeObject <List <LibraryLicense> >(AggContext.StaticData.ReadAllText(Path.Combine("License", "license.json"))); var linkIcon = AggContext.StaticData.LoadIcon("fa-link_16.png", 16, 16, theme.InvertIcons); SectionWidget section = null; foreach (var item in data.OrderBy(i => i.Name)) { var linkButton = new IconButton(linkIcon, theme); linkButton.Click += (s, e) => UiThread.RunOnIdle(() => { ApplicationController.Instance.LaunchBrowser(item.Url); }); section = new SectionWidget(item.Title ?? item.Name, new LazyLicenseText(item.Name, theme), theme, linkButton, expanded: false) { HAnchor = HAnchor.Stretch }; licensePanel.AddChild(section); } // Apply a bottom border to the last time for balance if (section != null) { section.Border = section.Border.Clone(bottom: 1); } var scrollable = new ScrollableWidget(autoScroll: true) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, Margin = new BorderDouble(bottom: 10), }; scrollable.ScrollArea.HAnchor = HAnchor.Stretch; scrollable.AddChild(licensePanel); contentRow.AddChild(scrollable); var feedbackButton = new TextButton("Send Feedback", theme) { BackgroundColor = theme.MinimalShade, HAnchor = HAnchor.Absolute, }; feedbackButton.Click += (s, e) => UiThread.RunOnIdle(() => { this.DialogWindow.ChangeToPage <ContactFormPage>(); }); this.AddPageAction(feedbackButton, highlightFirstAction: false); contentRow.AddChild( new TextWidget("Copyright © 2019 MatterHackers, Inc.", textColor: theme.TextColor, pointSize: theme.DefaultFontSize) { HAnchor = HAnchor.Center, }); var siteLink = new LinkLabel("www.matterhackers.com", theme) { HAnchor = HAnchor.Center, TextColor = theme.TextColor }; siteLink.Click += (s, e) => UiThread.RunOnIdle(() => { ApplicationController.Instance.LaunchBrowser("http://www.matterhackers.com"); }); contentRow.AddChild(siteLink); }
public TouchscreenTabView(QueueDataView queueDataView) : base(Orientation.Vertical) { this.queueDataView = queueDataView; this.TabBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; this.TabBar.BorderColor = new RGBA_Bytes(0, 0, 0, 0); this.TabBar.Margin = new BorderDouble(4, 0, 0, 0); this.TabBar.Padding = new BorderDouble(0, 8); this.Margin = new BorderDouble(top: 0); this.TabTextSize = 18; string simpleModeString = UserSettings.Instance.get("IsSimpleMode"); if (simpleModeString == null) { simpleMode = true; UserSettings.Instance.set("IsSimpleMode", "true"); } else { simpleMode = Convert.ToBoolean(simpleModeString); } QueueTabPage = new TabPage(new QueueDataWidget(queueDataView), LocalizedString.Get("Queue").ToUpper()); SimpleTextTabWidget queueTabWidget = new SimpleTextTabWidget(QueueTabPage, "Queue Tab", TabTextSize, ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()); partPreviewContainer = new PartPreviewContent(PrinterConnectionAndCommunication.Instance.ActivePrintItem, View3DWidget.WindowMode.Embeded, View3DWidget.AutoRotate.Enabled, View3DWidget.OpenMode.Viewing); string partPreviewLabel = LocalizedString.Get("Preview").ToUpper(); this.AddTab(new SimpleTextTabWidget(new TabPage(partPreviewContainer, partPreviewLabel), "Part Preview Tab", TabTextSize, ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); string sliceSettingsLabel = LocalizedString.Get("Settings").ToUpper(); sliceSettingsWidget = new SliceSettingsWidget(); sliceTabPage = new TabPage(sliceSettingsWidget, sliceSettingsLabel); this.AddTab(new SimpleTextTabWidget(sliceTabPage, "Slice Settings Tab", TabTextSize, ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); HorizontalLine lineSpacerZero = new HorizontalLine(); lineSpacerZero.Margin = new BorderDouble(4, 10); this.TabBar.AddChild(lineSpacerZero); GuiWidget manualPrinterControls = new ManualControlsWidget(); #if __ANDROID__ //Add the tab contents for 'Advanced Controls' string printerControlsLabel = LocalizedString.Get("Controls").ToUpper(); manualControlsPage = new TabPage(manualPrinterControls, printerControlsLabel); this.AddTab(new SimpleTextTabWidget(manualControlsPage, "Controls Tab", TabTextSize, ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); #else ScrollableWidget manualPrinterControlsScrollArea = new ScrollableWidget(true); manualPrinterControlsScrollArea.ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; manualPrinterControlsScrollArea.AnchorAll(); manualPrinterControlsScrollArea.AddChild(manualPrinterControls); //Add the tab contents for 'Advanced Controls' string printerControlsLabel = LocalizedString.Get("Controls").ToUpper(); manualControlsPage = new TabPage(manualPrinterControlsScrollArea, printerControlsLabel); this.AddTab(new SimpleTextTabWidget(manualControlsPage, "Controls Tab", TabTextSize, ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); #endif HorizontalLine lineSpacerOne = new HorizontalLine(); lineSpacerOne.Margin = new BorderDouble(4, 10); this.TabBar.AddChild(lineSpacerOne); this.AddTab(queueTabWidget); LibraryTabPage = new TabPage(new PrintLibraryWidget(), LocalizedString.Get("Library").ToUpper()); this.AddTab(new SimpleTextTabWidget(LibraryTabPage, "Library Tab", TabTextSize, ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); HistoryTabPage = new TabPage(new PrintHistoryWidget(), LocalizedString.Get("History").ToUpper()); SimpleTextTabWidget historyTabWidget = new SimpleTextTabWidget(HistoryTabPage, "History Tab", TabTextSize, ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()); if (!simpleMode) { this.AddTab(historyTabWidget); } HorizontalLine lineSpacerTwo = new HorizontalLine(); lineSpacerTwo.Margin = new BorderDouble(4, 10); this.TabBar.AddChild(lineSpacerTwo); string configurationLabel = LocalizedString.Get("Options").ToUpper(); PrinterConfigurationScrollWidget printerConfigurationWidget = new PrinterConfigurationScrollWidget(); // Make sure we have the right scroll position when we create this view // This is not working well enough. So, I disabled it until it can be fixed. // Specifically, it has the wronge position on the app restarting. if (false) { UiThread.RunOnIdle(() => { int scrollPosition = UserSettings.Instance.Fields.GetInt(CompactTabView_Options_ScrollPosition, -100000); if (scrollPosition != -100000) { printerConfigurationWidget.ScrollPosition = new Vector2(0, scrollPosition); } }); printerConfigurationWidget.ScrollPositionChanged += (object sender, EventArgs e) => { UserSettings.Instance.Fields.SetInt(CompactTabView_Options_ScrollPosition, (int)printerConfigurationWidget.ScrollPosition.y); }; } optionsPage = new TabPage(printerConfigurationWidget, configurationLabel); this.AddTab(new SimpleTextTabWidget(optionsPage, "Options Tab", TabTextSize, ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); TerminalTabPage = new TabPage(new TerminalWidget(false), LocalizedString.Get("Console").ToUpper()); SimpleTextTabWidget terminalTabWidget = new SimpleTextTabWidget(TerminalTabPage, "Terminal Tab", TabTextSize, ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()); if (!simpleMode) { this.AddTab(terminalTabWidget); } AboutTabPage = new TabPage(new AboutWidget(), LocalizedString.Get("About").ToUpper()); aboutTabWidget = new SimpleTextTabWidget(AboutTabPage, "About Tab", TabTextSize, ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()); this.AddTab(aboutTabWidget); NumQueueItemsChanged(this, null); SetUpdateNotification(this, null); QueueData.Instance.ItemAdded.RegisterEvent(NumQueueItemsChanged, ref unregisterEvents); QueueData.Instance.ItemRemoved.RegisterEvent(NumQueueItemsChanged, ref unregisterEvents); ActiveSliceSettings.ActivePrinterChanged.RegisterEvent((s, e) => ApplicationController.Instance.ReloadAdvancedControlsPanel(), ref unregisterEvents); PrinterConnectionAndCommunication.Instance.ActivePrintItemChanged.RegisterEvent((s, e) => { // ReloadPartPreview UiThread.RunOnIdle(() => { partPreviewContainer.Reload(PrinterConnectionAndCommunication.Instance.ActivePrintItem); }, 1); }, ref unregisterEvents); ApplicationController.Instance.AdvancedControlsPanelReloading.RegisterEvent((s, e) => UiThread.RunOnIdle(ReloadAdvancedControls), ref unregisterEvents); UpdateControlData.Instance.UpdateStatusChanged.RegisterEvent(SetUpdateNotification, ref unregisterEvents); // Make sure we are on the right tab when we create this view { string selectedTab = UserSettings.Instance.get(CompactTabView_CurrentTab); this.SelectTab(selectedTab); TabBar.TabIndexChanged += (object sender, EventArgs e) => { string selectedTabName = TabBar.SelectedTabName; if (!string.IsNullOrEmpty(selectedTabName)) { UserSettings.Instance.set(CompactTabView_CurrentTab, selectedTabName); } }; } }
public SelectedObjectPanel(View3DWidget view3DWidget, BedConfig sceneContext, ThemeConfig theme) : base(FlowDirection.TopToBottom) { this.HAnchor = HAnchor.Stretch; this.VAnchor = VAnchor.Top | VAnchor.Fit; this.Padding = 0; this.view3DWidget = view3DWidget; this.theme = theme; this.sceneContext = sceneContext; this.ContentPanel = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, }; var scrollable = new ScrollableWidget(true) { Name = "editorPanel", HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, }; scrollable.AddChild(this.ContentPanel); scrollable.ScrollArea.HAnchor = HAnchor.Stretch; this.AddChild(scrollable); var toolbar = new LeftClipFlowLayoutWidget() { BackgroundColor = theme.TabBodyBackground, Padding = theme.ToolbarPadding, HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit }; var scene = sceneContext.Scene; // put in a make permanent button var icon = AggContext.StaticData.LoadIcon("fa-check_16.png", 16, 16, theme.InvertIcons).SetPreMultiply(); var applyButton = new IconButton(icon, theme) { Margin = theme.ButtonSpacing, ToolTipText = "Apply operation and make permanent".Localize(), Enabled = scene.SelectedItem?.CanApply == true }; applyButton.Click += (s, e) => { this.item.Apply(view3DWidget.Scene.UndoBuffer); scene.SelectedItem = null; }; scene.SelectionChanged += (s, e) => applyButton.Enabled = scene.SelectedItem?.CanApply == true; toolbar.AddChild(applyButton); // put in a remove button var removeButton = new IconButton(AggContext.StaticData.LoadIcon("close.png", 16, 16, theme.InvertIcons), theme) { Margin = theme.ButtonSpacing, ToolTipText = "Remove operation from parts".Localize() }; removeButton.Click += (s, e) => { var rootSelection = scene.SelectedItemRoot; item.Remove(view3DWidget.Scene.UndoBuffer); scene.SelectedItem = null; if (item != rootSelection) { scene.SelectedItem = rootSelection; } }; toolbar.AddChild(removeButton); var overflowButton = new OverflowBar.OverflowMenuButton(theme); overflowButton.Enabled = scene.SelectedItem != null; scene.SelectionChanged += (s, e) => overflowButton.Enabled = scene.SelectedItem != null; overflowButton.PopupBorderColor = ApplicationController.Instance.MenuTheme.GetBorderColor(120); overflowButton.DynamicPopupContent = () => { return(ApplicationController.Instance.GetActionMenuForSceneItem(item, sceneContext.Scene)); }; toolbar.AddChild(overflowButton); editorPanel = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Name = "editorPanel", Padding = new BorderDouble(right: theme.DefaultContainerPadding + 1) }; // Wrap editorPanel with scrollable container var scrollableWidget = new ScrollableWidget(true) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch }; scrollableWidget.AddChild(editorPanel); scrollableWidget.ScrollArea.HAnchor = HAnchor.Stretch; scrollableWidget.Padding = new BorderDouble(right: theme.DefaultContainerPadding * .8); editorSectionWidget = new ResizableSectionWidget("Editor", sceneContext.ViewState.SelectedObjectEditorHeight, scrollableWidget, theme, serializationKey: UserSettingsKey.EditorPanelExpanded, rightAlignedContent: toolbar, defaultExpansion: true) { VAnchor = VAnchor.Fit, }; editorSectionWidget.Resized += (s, e) => { sceneContext.ViewState.SelectedObjectEditorHeight = editorSectionWidget.ResizeContainer.Height; }; int topBottom = theme.DefaultContainerPadding / 2; editorSectionWidget.ResizeContainer.Padding = new BorderDouble(left: theme.DefaultContainerPadding, top: topBottom, bottom: topBottom + editorSectionWidget.ResizeContainer.SplitterHeight); this.ContentPanel.AddChild(editorSectionWidget); var colorSection = new SectionWidget( "Color".Localize(), new ColorSwatchSelector(scene, theme, buttonSize: 16, buttonSpacing: new BorderDouble(1, 1, 0, 0)) { Margin = new BorderDouble(left: 10) }, theme, serializationKey: UserSettingsKey.ColorPanelExpanded) { Name = "Color Panel", }; this.ContentPanel.AddChild(colorSection); var materialsSection = new SectionWidget("Materials".Localize(), new MaterialControls(scene, theme), theme, serializationKey: UserSettingsKey.MaterialsPanelExpanded) { Name = "Materials Panel", }; this.ContentPanel.AddChild(materialsSection); // Enforce panel padding in sidebar foreach (var sectionWidget in this.ContentPanel.Children <SectionWidget>()) { // Special case for editorResizeWrapper due to ResizeContainer if (sectionWidget is ResizableSectionWidget resizableSectionWidget) { // Apply padding to ResizeContainer not wrapper //resizableSectionWidget.ResizeContainer.Padding = new BorderDouble(10, 10, 10, 0); } else { sectionWidget.ContentPanel.Padding = new BorderDouble(10, 10, 10, 0); sectionWidget.ExpandableWhenDisabled = true; sectionWidget.Enabled = false; } } }
public MessageBoxPage(Action <bool> callback, string message, string caption, MessageType messageType, GuiWidget[] extraWidgetsToAdd, double width, double height, string yesOk, string noCancel, ThemeConfig theme, bool useMarkdown = false) : base((noCancel == "") ? "No".Localize() : noCancel) { this.WindowSize = new Vector2(width * GuiWidget.DeviceScale, height * GuiWidget.DeviceScale); if (yesOk == "") { yesOk = (messageType == MessageType.OK) ? "Ok".Localize() : "Yes".Localize(); } this.HeaderText = caption; // this.IsModal = true; responseCallback = callback; unwrappedMessage = message; if (useMarkdown) { contentRow.AddChild(messageContainer = new MarkdownWidget(theme) { Markdown = message, }); } else { var scrollable = new ScrollableWidget(true); scrollable.AnchorAll(); scrollable.ScrollArea.HAnchor = HAnchor.Stretch; contentRow.AddChild(scrollable); scrollable.AddChild(messageContainer = new TextWidget(message, textColor: theme.TextColor, pointSize: 12) { AutoExpandBoundsToText = true, HAnchor = HAnchor.Left }); } if (extraWidgetsToAdd != null) { foreach (GuiWidget widget in extraWidgetsToAdd) { contentRow.AddChild(widget); } } var affirmativeButton = theme.CreateDialogButton(yesOk); affirmativeButton.Click += (s, e) => { // If applicable, invoke the callback responseCallback?.Invoke(true); haveResponded = true; this.DialogWindow.Close(); }; this.AddPageAction(affirmativeButton, messageType != MessageType.YES_NO_WITHOUT_HIGHLIGHT); switch (messageType) { case MessageType.YES_NO_WITHOUT_HIGHLIGHT: case MessageType.YES_NO: this.WindowTitle = "MatterControl - " + "Please Confirm".Localize(); affirmativeButton.Name = "Yes Button"; this.SetCancelButtonName("No Button"); break; case MessageType.OK: this.WindowTitle = "MatterControl - " + "Alert".Localize(); affirmativeButton.Name = "Ok Button"; this.HideCancelButton(); break; default: throw new NotImplementedException(); } this.AdjustTextWrap(); }
private TabControl CreateNewAdvancedControls(EventHandler AdvancedControlsButton_Click) { TabControl advancedControls = new TabControl(); BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; advancedControls.TabBar.BorderColor = ActiveTheme.Instance.SecondaryTextColor; advancedControls.TabBar.Margin = new BorderDouble(0, 0); advancedControls.TabBar.Padding = new BorderDouble(0, 2); int textSize = 16; if (AdvancedControlsButton_Click != null) { // this means we are in compact view and so we will make the tabs text a bit smaller textSize = 14; TextImageButtonFactory advancedControlsButtonFactory = new TextImageButtonFactory(); advancedControlsButtonFactory.fontSize = 14; advancedControlsButtonFactory.invertImageLocation = false; advancedControlsBackButton = advancedControlsButtonFactory.Generate(LocalizedString.Get("Back"), "icon_arrow_left_32x32.png"); advancedControlsBackButton.ToolTipText = "Switch to Queue, Library and History".Localize(); advancedControlsBackButton.Margin = new BorderDouble(right: 3); advancedControlsBackButton.VAnchor = VAnchor.ParentBottom; advancedControlsBackButton.Cursor = Cursors.Hand; advancedControlsBackButton.Click += new EventHandler(AdvancedControlsButton_Click); advancedControls.TabBar.AddChild(advancedControlsBackButton); } GuiWidget hSpacer = new GuiWidget(); hSpacer.HAnchor = HAnchor.ParentLeftRight; advancedControls.TabBar.AddChild(hSpacer); GuiWidget manualPrinterControls = new ManualPrinterControls(); ScrollableWidget manualPrinterControlsScrollArea = new ScrollableWidget(true); manualPrinterControlsScrollArea.ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; manualPrinterControlsScrollArea.AnchorAll(); manualPrinterControlsScrollArea.AddChild(manualPrinterControls); RGBA_Bytes unselectedTextColor = ActiveTheme.Instance.TabLabelUnselected; //Add the tab contents for 'Advanced Controls' string sliceSettingsLabel = LocalizedString.Get("Settings").ToUpper(); string printerControlsLabel = LocalizedString.Get("Controls").ToUpper(); sliceSettingsWidget = new SliceSettingsWidget(); TabPage sliceSettingsTabPage = new TabPage(sliceSettingsWidget, sliceSettingsLabel); PopOutTextTabWidget sliceSettingPopOut = new PopOutTextTabWidget(sliceSettingsTabPage, SliceSettingsTabName, new Vector2(590, 400), textSize); advancedControls.AddTab(sliceSettingPopOut); TabPage controlsTabPage = new TabPage(manualPrinterControlsScrollArea, printerControlsLabel); PopOutTextTabWidget controlsPopOut = new PopOutTextTabWidget(controlsTabPage, ControlsTabName, new Vector2(400, 300), textSize); advancedControls.AddTab(controlsPopOut); #if !__ANDROID__ MenuOptionSettings.sliceSettingsPopOut = sliceSettingPopOut; MenuOptionSettings.controlsPopOut = controlsPopOut; #endif string optionsLabel = LocalizedString.Get("Options").ToUpper(); ScrollableWidget optionsControls = new PrinterConfigurationScrollWidget(); advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(optionsControls, optionsLabel), "Options Tab", textSize, ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); // Make sure we are on the right tab when we create this view { string selectedTab = UserSettings.Instance.get(ThirdPanelTabView_AdvancedControls_CurrentTab); advancedControls.SelectTab(selectedTab); advancedControls.TabBar.TabIndexChanged += (object sender, EventArgs e) => { UserSettings.Instance.set(ThirdPanelTabView_AdvancedControls_CurrentTab, advancedControls.TabBar.SelectedTabName); }; } return(advancedControls); }
public EePromRepetierWindow() : base(540, 480) { AlwaysOnTopOfMain = true; BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; currentEePromSettings = new EePromRepetierStorage(); FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight; topToBottom.HAnchor = Agg.UI.HAnchor.ParentLeftRight; topToBottom.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; topToBottom.Padding = new BorderDouble(3, 0); FlowLayoutWidget row = new FlowLayoutWidget(); row.HAnchor = Agg.UI.HAnchor.ParentLeftRight; row.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; GuiWidget descriptionWidget = AddDescription(LocalizedString.Get("Description")); descriptionWidget.Margin = new BorderDouble(left: 3); row.AddChild(descriptionWidget); CreateSpacer(row); GuiWidget valueText = new TextWidget(LocalizedString.Get("Value"), textColor: ActiveTheme.Instance.PrimaryTextColor); valueText.VAnchor = Agg.UI.VAnchor.ParentCenter; valueText.Margin = new BorderDouble(left: 5, right: 60); row.AddChild(valueText); topToBottom.AddChild(row); { ScrollableWidget settingsAreaScrollBox = new ScrollableWidget(true); settingsAreaScrollBox.ScrollArea.HAnchor |= HAnchor.ParentLeftRight; settingsAreaScrollBox.AnchorAll(); settingsAreaScrollBox.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; topToBottom.AddChild(settingsAreaScrollBox); settingsColmun = new FlowLayoutWidget(FlowDirection.TopToBottom); settingsColmun.HAnchor = HAnchor.Max_FitToChildren_ParentWidth; settingsAreaScrollBox.AddChild(settingsColmun); } FlowLayoutWidget buttonBar = new FlowLayoutWidget(); buttonBar.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; buttonBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; buttonSave = textImageButtonFactory.Generate(LocalizedString.Get("Save To EEPROM")); buttonSave.Margin = new BorderDouble(0, 3); buttonBar.AddChild(buttonSave); CreateSpacer(buttonBar); buttonCancel = textImageButtonFactory.Generate(LocalizedString.Get("Cancel")); buttonCancel.Margin = new BorderDouble(3); buttonBar.AddChild(buttonCancel); topToBottom.AddChild(buttonBar); #if __ANDROID__ TerminalWidget terminalWidget = new TerminalWidget(true); this.AddChild(new SoftKeyboardContentOffset(topToBottom)); //topToBottom.Closed += (sender, e) => { Close(); }; #else this.AddChild(topToBottom); #endif translate(); ShowAsSystemWindow(); currentEePromSettings.Clear(); PrinterConnectionAndCommunication.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents); currentEePromSettings.eventAdded += NewSettingReadFromPrinter; currentEePromSettings.AskPrinterForSettings(); #if SIMULATE_CONNECTION UiThread.RunOnIdle(AddSimulatedItems); #endif }
public CopyGuestProfilesToUser(Action copyCompleted) : base("Close".Localize()) { this.WindowTitle = "Copy Printers".Localize(); this.HeaderText = "Copy Printers to Account".Localize(); var scrollWindow = new ScrollableWidget() { AutoScroll = true, HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, }; scrollWindow.ScrollArea.HAnchor = HAnchor.Stretch; contentRow.AddChild(scrollWindow); var container = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, }; scrollWindow.AddChild(container); var byCheckbox = new Dictionary <CheckBox, PrinterInfo>(); var guest = ProfileManager.Load("guest"); if (guest?.Profiles.Count > 0) { container.AddChild(new TextWidget("Printers to Copy".Localize() + ":") { TextColor = theme.TextColor, Margin = new BorderDouble(0, 3, 0, 15), }); foreach (var printerInfo in guest.Profiles) { var checkBox = new CheckBox(printerInfo.Name) { TextColor = theme.TextColor, Margin = new BorderDouble(5, 0, 0, 0), HAnchor = HAnchor.Left, Checked = true, }; checkBoxes.Add(checkBox); container.AddChild(checkBox); byCheckbox[checkBox] = printerInfo; } } var skipButton = theme.CreateDialogButton("Skip".Localize()); skipButton.Click += (s, e) => { copyCompleted.Invoke(); }; this.AddPageAction(skipButton, highlightFirstAction: false); var copyButton = theme.CreateDialogButton("Copy".Localize()); copyButton.Name = "CopyProfilesButton"; copyButton.Click += (s, e) => { // do the import foreach (var checkBox in checkBoxes) { if (checkBox.Checked) { // import the printer var printerInfo = byCheckbox[checkBox]; string existingPath = guest.ProfilePath(printerInfo); // PrinterSettings files must actually be copied to the users profile directory if (File.Exists(existingPath)) { File.Copy(existingPath, printerInfo.ProfilePath); // Only add if copy succeeds ProfileManager.Instance.Profiles.Add(printerInfo); } } } guest.Save(); // Close the window and update the PrintersImported flag UiThread.RunOnIdle(() => { ProfileManager.Instance.PrintersImported = true; ProfileManager.Instance.Save(); copyCompleted.Invoke(); }); }; this.AcceptButton = copyButton; this.AddPageAction(copyButton); rememberChoice = new CheckBox("Don't remind me again".Localize(), theme.TextColor) { Name = "Don't remind me again" }; contentRow.AddChild(rememberChoice); copyButton.Visible = true; }
public CopyGuestProfilesToUser() : base("Close", "Copy Printers to Account") { var scrollWindow = new ScrollableWidget() { AutoScroll = true, HAnchor = HAnchor.ParentLeftRight, VAnchor = VAnchor.ParentBottomTop, }; scrollWindow.ScrollArea.HAnchor = HAnchor.ParentLeftRight; contentRow.AddChild(scrollWindow); var container = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.ParentLeftRight, }; scrollWindow.AddChild(container); container.AddChild(new WrappedTextWidget(importMessage, textColor: ActiveTheme.Instance.PrimaryTextColor)); var byCheckbox = new Dictionary <CheckBox, PrinterInfo>(); var guest = ProfileManager.Load("guest"); if (guest?.Profiles.Count > 0) { container.AddChild(new TextWidget("Printers to Copy:".Localize()) { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(0, 3, 0, 15), }); foreach (var printerInfo in guest.Profiles) { var checkBox = new CheckBox(printerInfo.Name) { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(5, 0, 0, 0), HAnchor = HAnchor.ParentLeft, Checked = true, }; checkBoxes.Add(checkBox); container.AddChild(checkBox); byCheckbox[checkBox] = printerInfo; } } var syncButton = textImageButtonFactory.Generate("Copy".Localize()); syncButton.Name = "CopyProfilesButton"; syncButton.Click += (s, e) => { // do the import foreach (var checkBox in checkBoxes) { if (checkBox.Checked) { // import the printer var printerInfo = byCheckbox[checkBox]; string existingPath = guest.ProfilePath(printerInfo); // PrinterSettings files must actually be copied to the users profile directory if (File.Exists(existingPath)) { File.Copy(existingPath, printerInfo.ProfilePath); // Only add if copy succeeds ProfileManager.Instance.Profiles.Add(printerInfo); } } } guest.Save(); // Close the window and update the PrintersImported flag UiThread.RunOnIdle(() => { WizardWindow.Close(); ProfileManager.Instance.PrintersImported = true; ProfileManager.Instance.Save(); }); }; CheckBox rememberChoice = new CheckBox("Don't remind me again".Localize(), ActiveTheme.Instance.PrimaryTextColor); contentRow.AddChild(rememberChoice); syncButton.Visible = true; cancelButton.Visible = true; // Close the window and update the PrintersImported flag cancelButton.Click += (s, e) => UiThread.RunOnIdle(() => { WizardWindow.Close(); if (rememberChoice.Checked) { ProfileManager.Instance.PrintersImported = true; ProfileManager.Instance.Save(); } }); //Add buttons to buttonContainer footerRow.AddChild(syncButton); footerRow.AddChild(new HorizontalSpacer()); footerRow.AddChild(cancelButton); footerRow.Visible = true; }
public MarlinEEPromPage(PrinterConfig printer) : base(printer) { AlwaysOnTopOfMain = true; this.WindowTitle = "Marlin Firmware EEPROM Settings".Localize(); currentEePromSettings = new EePromMarlinSettings(printer.Connection); currentEePromSettings.eventAdded += SetUiToPrinterSettings; // the center content var conterContent = new FlowLayoutWidget(FlowDirection.TopToBottom) { VAnchor = VAnchor.Fit | VAnchor.Top, HAnchor = HAnchor.Stretch }; // add a scroll container var settingsAreaScrollBox = new ScrollableWidget(true); settingsAreaScrollBox.ScrollArea.HAnchor |= HAnchor.Stretch; settingsAreaScrollBox.AnchorAll(); settingsAreaScrollBox.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; contentRow.AddChild(settingsAreaScrollBox); settingsAreaScrollBox.AddChild(conterContent); conterContent.AddChild(Create4FieldSet("Steps per mm".Localize() + ":", "X:", ref stepsPerMmX, "Y:", ref stepsPerMmY, "Z:", ref stepsPerMmZ, "E:", ref stepsPerMmE)); conterContent.AddChild(Create4FieldSet("Maximum feedrates [mm/s]".Localize() + ":", "X:", ref maxFeedrateMmPerSX, "Y:", ref maxFeedrateMmPerSY, "Z:", ref maxFeedrateMmPerSZ, "E:", ref maxFeedrateMmPerSE)); conterContent.AddChild(Create4FieldSet("Maximum Acceleration [mm/s²]".Localize() + ":", "X:", ref maxAccelerationMmPerSSqrdX, "Y:", ref maxAccelerationMmPerSSqrdY, "Z:", ref maxAccelerationMmPerSSqrdZ, "E:", ref maxAccelerationMmPerSSqrdE)); conterContent.AddChild(CreateField("Acceleration Printing".Localize() + ":", ref accelerationPrintingMoves)); conterContent.AddChild(CreateField("Acceleration Travel".Localize() + ":", ref accelerationTravelMoves)); conterContent.AddChild(CreateField("Retract Acceleration".Localize() + ":", ref accelerationRetraction)); conterContent.AddChild(Create3FieldSet("PID Settings".Localize() + ":", "P:", ref pidP, "I:", ref pidI, "D:", ref pidD)); conterContent.AddChild(Create3FieldSet("Bed PID Settings".Localize() + ":", "P:", ref bedPidP, "I:", ref bedPidI, "D:", ref bedPidD)); conterContent.AddChild(Create3FieldSet("Homing Offset".Localize() + ":", "X:", ref homingOffsetX, "Y:", ref homingOffsetY, "Z:", ref homingOffsetZ)); conterContent.AddChild(CreateField("Min feedrate [mm/s]".Localize() + ":", ref minFeedrate)); conterContent.AddChild(CreateField("Min travel feedrate [mm/s]".Localize() + ":", ref minTravelFeedrate)); conterContent.AddChild(CreateField("Minimum segment time [ms]".Localize() + ":", ref minSegmentTime)); conterContent.AddChild(CreateField("Maximum X-Y jerk [mm/s]".Localize() + ":", ref maxXYJerk)); conterContent.AddChild(CreateField("Maximum Z jerk [mm/s]".Localize() + ":", ref maxZJerk)); conterContent.AddChild(CreateField("Maximum E jerk [mm/s]".Localize() + ":", ref maxEJerk)); // the bottom button bar var buttonSave = theme.CreateDialogButton("Save to EEProm".Localize()); buttonSave.Click += (s, e) => UiThread.RunOnIdle(() => { SaveSettingsToActive(); currentEePromSettings.SaveToEeProm(); this.DialogWindow.Close(); }); this.AddPageAction(buttonSave); var exportButton = theme.CreateDialogButton("Export".Localize()); exportButton.Click += (s, e) => { UiThread.RunOnIdle(this.ExportSettings, .1); }; this.AddPageAction(exportButton); printer.Connection.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents); // and ask the printer to send the settings currentEePromSettings.Update(); if (headerRow is OverflowBar overflowBar) { overflowBar.ExtendOverflowMenu = (popupMenu) => { var menuItem = popupMenu.CreateMenuItem("Import".Localize()); menuItem.Name = "Import Menu Item"; menuItem.Click += (s, e) => { UiThread.RunOnIdle(() => { AggContext.FileDialogs.OpenFileDialog( new OpenFileDialogParams("EEPROM Settings|*.ini") { ActionButtonLabel = "Import EEPROM Settings".Localize(), Title = "Import EEPROM".Localize(), }, (openParams) => { if (!string.IsNullOrEmpty(openParams.FileName)) { currentEePromSettings.Import(openParams.FileName); SetUiToPrinterSettings(null, null); } }); }, .1); }; // put in the export button menuItem = popupMenu.CreateMenuItem("Export".Localize()); menuItem.Name = "Export Menu Item"; menuItem.Click += (s, e) => { UiThread.RunOnIdle(this.ExportSettings, .1); }; popupMenu.CreateHorizontalLine(); menuItem = popupMenu.CreateMenuItem("Reset to Factory Defaults".Localize()); menuItem.Click += (s, e) => { currentEePromSettings.SetPrinterToFactorySettings(); currentEePromSettings.Update(); }; }; } foreach (GuiWidget widget in leftStuffToSize) { widget.Width = maxWidthOfLeftStuff; } }
public ImportSettingsPage(string settingsFilePath, PrinterConfig printer) { this.WindowTitle = "Import Wizard"; this.HeaderText = "Select What to Import".Localize(); // TODO: Need to handle load failures for import attempts var settingsToImport = PrinterSettings.LoadFile(settingsFilePath); // if there are no settings to import if (settingsToImport.QualityLayers.Count == 0 && settingsToImport.MaterialLayers.Count == 0) { // Only main setting so don't ask what to merge just do it. UiThread.RunOnIdle(() => { DisplayFailedToImportMessage(settingsFilePath); this.Parents <SystemWindow>().First().Close(); }); } this.settingsFilePath = settingsFilePath; var scrollWindow = new ScrollableWidget() { AutoScroll = true, HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, }; scrollWindow.ScrollArea.HAnchor = HAnchor.Stretch; contentRow.AddChild(scrollWindow); var container = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, }; scrollWindow.AddChild(container); if (settingsToImport.QualityLayers.Count > 0) { container.AddChild(new TextWidget("Quality Presets:") { TextColor = theme.TextColor, Margin = new BorderDouble(0, 3), }); int buttonIndex = 0; foreach (var qualitySetting in settingsToImport.QualityLayers) { var qualityButton = new RadioButton(string.IsNullOrEmpty(qualitySetting.Name) ? "no name" : qualitySetting.Name) { TextColor = theme.TextColor, Margin = new BorderDouble(5, 0, 0, 0), HAnchor = HAnchor.Left, }; container.AddChild(qualityButton); int localButtonIndex = buttonIndex; qualityButton.CheckedStateChanged += (s, e) => { if (qualityButton.Checked) { selectedQuality = localButtonIndex; } else { selectedQuality = -1; } }; buttonIndex++; } } if (settingsToImport.MaterialLayers.Count > 0) { container.AddChild(new TextWidget("Material Presets:") { TextColor = theme.TextColor, Margin = new BorderDouble(0, 3, 0, 15), }); int buttonIndex = 0; foreach (var materialSetting in settingsToImport.MaterialLayers) { var materialButton = new RadioButton(string.IsNullOrEmpty(materialSetting.Name) ? "no name" : materialSetting.Name) { TextColor = theme.TextColor, Margin = new BorderDouble(5, 0), HAnchor = HAnchor.Left, }; container.AddChild(materialButton); int localButtonIndex = buttonIndex; materialButton.CheckedStateChanged += (s, e) => { if (materialButton.Checked) { selectedMaterial = localButtonIndex; } else { selectedMaterial = -1; } }; buttonIndex++; } } var mergeButton = theme.CreateDialogButton("Import".Localize()); mergeButton.Name = "Merge Profile"; mergeButton.Click += (s, e) => UiThread.RunOnIdle(() => { bool copyName = false; PrinterSettingsLayer sourceLayer = null; bool destIsMaterial = true; if (selectedMaterial > -1) { sourceLayer = settingsToImport.MaterialLayers[selectedMaterial]; copyName = true; } else if (selectedQuality > -1) { destIsMaterial = false; sourceLayer = settingsToImport.QualityLayers[selectedQuality]; copyName = true; } List <PrinterSettingsLayer> sourceFilter; if (selectedQuality == -1 && selectedMaterial == -1) { sourceFilter = new List <PrinterSettingsLayer>() { settingsToImport.OemLayer, settingsToImport.UserLayer }; } else { sourceFilter = new List <PrinterSettingsLayer>() { sourceLayer }; } if (File.Exists(settingsFilePath)) { if (Path.GetExtension(settingsFilePath).ToLower() == ProfileManager.ProfileExtension) { var printerSettingsLayer = new PrinterSettingsLayer(); printer.Settings.Merge(printerSettingsLayer, settingsToImport, sourceFilter, copyName); var layerName = (printerSettingsLayer.ContainsKey(SettingsKey.layer_name)) ? printerSettingsLayer[SettingsKey.layer_name] : "none"; string sectionName = destIsMaterial ? "Material".Localize() : "Quality".Localize(); string importSettingSuccessMessage = string.Format("You have successfully imported a new {0} setting. You can find '{1}' in your list of {0} settings.".Localize(), sectionName, layerName); DialogWindow.ChangeToPage( new ImportSucceeded(importSettingSuccessMessage) { DialogWindow = this.DialogWindow, }); if (destIsMaterial) { printer.Settings.MaterialLayers.Add(printerSettingsLayer); } else { printer.Settings.QualityLayers.Add(printerSettingsLayer); } } else { // Inform of unexpected extension type StyledMessageBox.ShowMessageBox( "Oops! Unable to recognize settings file '{0}'.".Localize().FormatWith(Path.GetFileName(settingsFilePath)), "Unable to Import".Localize()); } } }); this.AddPageAction(mergeButton); }
public SelectedObjectPanel(View3DWidget view3DWidget, BedConfig sceneContext, ThemeConfig theme) : base(FlowDirection.TopToBottom) { this.HAnchor = HAnchor.Stretch; this.VAnchor = VAnchor.Top | VAnchor.Fit; this.Padding = 0; this.view3DWidget = view3DWidget; this.theme = theme; this.sceneContext = sceneContext; this.ContentPanel = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, }; var scrollable = new ScrollableWidget(true) { Name = "editorPanel", HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, }; scrollable.AddChild(this.ContentPanel); scrollable.ScrollArea.HAnchor = HAnchor.Stretch; this.AddChild(scrollable); var toolbar = new LeftClipFlowLayoutWidget() { BackgroundColor = theme.TabBodyBackground, Padding = theme.ToolbarPadding, HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit }; var scene = sceneContext.Scene; // put in a make permanent button var icon = AggContext.StaticData.LoadIcon("fa-check_16.png", 16, 16, theme.InvertIcons).SetPreMultiply(); var applyButton = new IconButton(icon, theme) { Margin = theme.ButtonSpacing, ToolTipText = "Apply operation and make permanent".Localize() }; applyButton.Click += (s, e) => { this.item.Apply(view3DWidget.Scene.UndoBuffer); scene.SelectedItem = null; }; scene.SelectionChanged += (s, e) => applyButton.Enabled = scene.SelectedItem?.CanApply == true; toolbar.AddChild(applyButton); // put in a remove button var removeButton = new IconButton(AggContext.StaticData.LoadIcon("close.png", 16, 16, theme.InvertIcons), theme) { Margin = theme.ButtonSpacing, ToolTipText = "Remove operation from parts".Localize() }; removeButton.Click += (s, e) => { item.Remove(view3DWidget.Scene.UndoBuffer); scene.SelectedItem = null; }; scene.SelectionChanged += (s, e) => removeButton.Enabled = scene.SelectedItem?.CanRemove == true; toolbar.AddChild(removeButton); var overflowButton = new OverflowBar.OverflowMenuButton(theme); overflowButton.PopupBorderColor = ApplicationController.Instance.MenuTheme.GetBorderColor(120); overflowButton.DynamicPopupContent = () => { var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme); var menuItem = popupMenu.CreateMenuItem("Rename"); menuItem.Click += (s, e) => { DialogWindow.Show( new InputBoxPage( "Rename Item".Localize(), "Name".Localize(), item.Name, "Enter New Name Here".Localize(), "Rename".Localize(), (newName) => { item.Name = newName; editorSectionWidget.Text = newName; })); }; popupMenu.CreateHorizontalLine(); if (true) //allowOperations) { var selectedItemType = item.GetType(); var selectedItem = item; foreach (var nodeOperation in ApplicationController.Instance.Graph.Operations) { foreach (var type in nodeOperation.MappedTypes) { if (type.IsAssignableFrom(selectedItemType) && (nodeOperation.IsVisible?.Invoke(selectedItem) != false) && nodeOperation.IsEnabled?.Invoke(selectedItem) != false) { var button = popupMenu.CreateMenuItem(nodeOperation.Title, nodeOperation.IconCollector?.Invoke()?.CreateScaledImage(16, 16)); button.Click += (s, e) => { nodeOperation.Operation(selectedItem, sceneContext.Scene).ConfigureAwait(false); }; } } } } return(popupMenu); }; toolbar.AddChild(overflowButton); editorPanel = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Padding = new BorderDouble(top: 10) }; // Wrap editorPanel with scrollable container var scrollableWidget = new ScrollableWidget(true) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch }; scrollableWidget.AddChild(editorPanel); scrollableWidget.ScrollArea.HAnchor = HAnchor.Stretch; editorSectionWidget = new ResizableSectionWidget("Editor", sceneContext.ViewState.SelectedObjectEditorHeight, scrollableWidget, theme, serializationKey: UserSettingsKey.EditorPanelExpanded, rightAlignedContent: toolbar, defaultExpansion: true) { VAnchor = VAnchor.Fit, }; editorSectionWidget.Resized += (s, e) => { sceneContext.ViewState.SelectedObjectEditorHeight = editorSectionWidget.ResizeContainer.Height; }; this.ContentPanel.AddChild(editorSectionWidget); var colorSection = new SectionWidget( "Color".Localize(), new ColorSwatchSelector(scene, theme, buttonSize: 16, buttonSpacing: new BorderDouble(1, 1, 0, 0)) { Margin = new BorderDouble(left: 10) }, theme, serializationKey: UserSettingsKey.ColorPanelExpanded) { Name = "Color Panel", }; this.ContentPanel.AddChild(colorSection); var materialsSection = new SectionWidget("Materials".Localize(), new MaterialControls(scene, theme), theme, serializationKey: UserSettingsKey.MaterialsPanelExpanded) { Name = "Materials Panel", }; this.ContentPanel.AddChild(materialsSection); // Enforce panel padding in sidebar foreach (var sectionWidget in this.ContentPanel.Children <SectionWidget>()) { // Special case for editorResizeWrapper due to ResizeContainer if (sectionWidget is ResizableSectionWidget resizableSectionWidget) { // Apply padding to ResizeContainer not wrapper resizableSectionWidget.ResizeContainer.Padding = new BorderDouble(10, 10, 10, 0); } else { sectionWidget.ContentPanel.Padding = new BorderDouble(10, 10, 10, 0); sectionWidget.ExpandableWhenDisabled = true; sectionWidget.Enabled = false; } } }
public RepetierEEPromPage(PrinterConfig printer) : base(printer) { AlwaysOnTopOfMain = true; this.WindowTitle = "Firmware EEPROM Settings".Localize(); currentEePromSettings = new EePromRepetierStorage(); var topToBottom = contentRow; var row = new FlowLayoutWidget { HAnchor = HAnchor.Stretch, }; GuiWidget descriptionWidget = AddDescription("Description".Localize()); descriptionWidget.Margin = new BorderDouble(left: 3); row.AddChild(descriptionWidget); CreateSpacer(row); row.AddChild(new TextWidget("Value".Localize(), pointSize: theme.FontSize10, textColor: theme.TextColor) { VAnchor = VAnchor.Center, Margin = new BorderDouble(left: 5, right: 60) }); topToBottom.AddChild(row); { var settingsAreaScrollBox = new ScrollableWidget(true); settingsAreaScrollBox.ScrollArea.HAnchor |= HAnchor.Stretch; settingsAreaScrollBox.AnchorAll(); settingsAreaScrollBox.BackgroundColor = theme.MinimalShade; topToBottom.AddChild(settingsAreaScrollBox); settingsColumn = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.MaxFitOrStretch }; settingsAreaScrollBox.AddChild(settingsColumn); } if (headerRow is OverflowBar overflowBar) { overflowBar.ExtendOverflowMenu = (popupMenu) => { var menuItem = popupMenu.CreateMenuItem("Import".Localize()); menuItem.Name = "Import Menu Item"; menuItem.Click += (s, e) => { UiThread.RunOnIdle(() => { AggContext.FileDialogs.OpenFileDialog( new OpenFileDialogParams("EEPROM Settings|*.ini") { ActionButtonLabel = "Import EEPROM Settings".Localize(), Title = "Import EEPROM".Localize(), }, (openParams) => { if (!string.IsNullOrEmpty(openParams.FileName)) { currentEePromSettings.Import(openParams.FileName); RebuildUi(); } }); }, .1); }; menuItem = popupMenu.CreateMenuItem("Export".Localize()); menuItem.Name = "Export Menu Item"; menuItem.Click += (s, e) => { UiThread.RunOnIdle(this.ExportSettings, .1); }; }; } // put in the save button var buttonSave = theme.CreateDialogButton("Save To EEPROM".Localize()); buttonSave.Click += (s, e) => { currentEePromSettings.Save(printer.Connection); currentEePromSettings.Clear(); this.DialogWindow.Close(); }; this.AddPageAction(buttonSave); var exportButton = theme.CreateDialogButton("Export".Localize()); exportButton.Click += (s, e) => { UiThread.RunOnIdle(this.ExportSettings, .1); }; this.AddPageAction(exportButton); currentEePromSettings.Clear(); printer.Connection.LineReceived += currentEePromSettings.Add; currentEePromSettings.SettingAdded += NewSettingReadFromPrinter; currentEePromSettings.AskPrinterForSettings(printer.Connection); #if SIMULATE_CONNECTION UiThread.RunOnIdle(AddSimulatedItems); #endif }
public SelectedObjectPanel(View3DWidget view3DWidget, BedConfig sceneContext, ThemeConfig theme) : base(FlowDirection.TopToBottom) { this.HAnchor = HAnchor.Stretch; this.VAnchor = VAnchor.Top | VAnchor.Fit; this.Padding = 0; this.view3DWidget = view3DWidget; this.theme = theme; this.sceneContext = sceneContext; var toolbar = new LeftClipFlowLayoutWidget() { BackgroundColor = theme.ActiveTabColor, Padding = theme.ToolbarPadding, HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit }; var scene = sceneContext.Scene; // put in a make permanent button var icon = AggContext.StaticData.LoadIcon("noun_766157.png", 16, 16, theme.InvertIcons).SetPreMultiply(); var flattenButton = new IconButton(icon, theme) { Margin = theme.ButtonSpacing, ToolTipText = "Flatten".Localize(), Enabled = scene.SelectedItem?.CanFlatten == true }; flattenButton.Click += (s, e) => { this.item.Flatten(view3DWidget.Scene.UndoBuffer); scene.SelectedItem = null; }; toolbar.AddChild(flattenButton); // put in a remove button var removeButton = new IconButton(AggContext.StaticData.LoadIcon("remove.png", 16, 16, theme.InvertIcons), theme) { Margin = theme.ButtonSpacing, ToolTipText = "Delete".Localize(), Enabled = scene.SelectedItem != null }; removeButton.Click += (s, e) => { var rootSelection = scene.SelectedItemRoot; var removeItem = item; removeItem.Remove(view3DWidget.Scene.UndoBuffer); scene.SelectedItem = null; // Only restore the root selection if it wasn't the item removed if (removeItem != rootSelection) { scene.SelectedItem = rootSelection; } }; toolbar.AddChild(removeButton); var overflowButton = new OverflowBar.OverflowMenuButton(theme) { Enabled = scene.SelectedItem != null, PopupBorderColor = ApplicationController.Instance.MenuTheme.GetBorderColor(120) }; overflowButton.DynamicPopupContent = () => { return(ApplicationController.Instance.GetActionMenuForSceneItem(item, sceneContext.Scene, false)); }; toolbar.AddChild(overflowButton); editorPanel = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Name = "editorPanel", Padding = new BorderDouble(right: theme.DefaultContainerPadding + 1) }; // Wrap editorPanel with scrollable container var scrollableWidget = new ScrollableWidget(true) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch }; scrollableWidget.AddChild(editorPanel); scrollableWidget.ScrollArea.HAnchor = HAnchor.Stretch; editorSectionWidget = new SectionWidget("Editor", scrollableWidget, theme, toolbar, expandingContent: false, defaultExpansion: true, setContentVAnchor: false) { VAnchor = VAnchor.Stretch }; this.AddChild(editorSectionWidget); this.ContentPanel = editorPanel; editorPanel.Padding = new BorderDouble(theme.DefaultContainerPadding, 0); scene.SelectionChanged += (s, e) => { if (editorPanel.Children.FirstOrDefault()?.DescendantsAndSelf <SectionWidget>().FirstOrDefault() is SectionWidget firstSectionWidget) { firstSectionWidget.Margin = firstSectionWidget.Margin.Clone(top: 0); } var selectedItem = scene.SelectedItem; flattenButton.Enabled = selectedItem?.CanFlatten == true; removeButton.Enabled = selectedItem != null; overflowButton.Enabled = selectedItem != null; }; }
private TabControl CreateNewAdvancedControls(EventHandler AdvancedControlsButton_Click, EventHandler onMouseEnterBoundsPrintQueueLink, EventHandler onMouseLeaveBoundsPrintQueueLink) { TabControl advancedControls = new TabControl(); BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; advancedControls.TabBar.BorderColor = ActiveTheme.Instance.SecondaryTextColor; advancedControls.TabBar.Margin = new BorderDouble(0, 0); advancedControls.TabBar.Padding = new BorderDouble(0, 2); int textSize = 16; if (AdvancedControlsButton_Click != null) { // this means we are in compact view and so we will make the tabs text a bit smaller textSize = 14; TextImageButtonFactory advancedControlsButtonFactory = new TextImageButtonFactory(); advancedControlsButtonFactory.invertImageLocation = false; advancedControlsLinkButton = advancedControlsButtonFactory.Generate(LocalizedString.Get("Print\nQueue"), "icon_arrow_left_32x32.png"); advancedControlsLinkButton.Margin = new BorderDouble(right: 3); advancedControlsLinkButton.VAnchor = VAnchor.ParentBottom; advancedControlsLinkButton.Cursor = Cursors.Hand; advancedControlsLinkButton.Click += new EventHandler(AdvancedControlsButton_Click); advancedControlsLinkButton.MouseEnterBounds += new EventHandler(onMouseEnterBoundsPrintQueueLink); advancedControlsLinkButton.MouseLeaveBounds += new EventHandler(onMouseLeaveBoundsPrintQueueLink); advancedControls.TabBar.AddChild(advancedControlsLinkButton); } GuiWidget hSpacer = new GuiWidget(); hSpacer.HAnchor = HAnchor.ParentLeftRight; advancedControls.TabBar.AddChild(hSpacer); GuiWidget manualPrinterControls = new ManualPrinterControls(); ScrollableWidget manualPrinterControlsScrollArea = new ScrollableWidget(true); manualPrinterControlsScrollArea.ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; manualPrinterControlsScrollArea.AnchorAll(); manualPrinterControlsScrollArea.AddChild(manualPrinterControls); RGBA_Bytes unselectedTextColor = ActiveTheme.Instance.TabLabelUnselected; //Add the tab contents for 'Advanced Controls' string printerControlsLabel = LocalizedString.Get("Controls").ToUpper(); advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(manualPrinterControlsScrollArea, printerControlsLabel), "Controls Tab", textSize, ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); string sliceSettingsLabel = LocalizedString.Get("Slice Settings").ToUpper(); sliceSettingsWidget = new SliceSettingsWidget(sliceSettingsUiState); advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(sliceSettingsWidget, sliceSettingsLabel), "Slice Settings Tab", textSize, ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); string configurationLabel = LocalizedString.Get("Configuration").ToUpper(); ScrollableWidget configurationControls = new PrinterConfigurationScrollWidget(); advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(configurationControls, configurationLabel), "Configuration Tab", textSize, ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); advancedControls.SelectedTabIndex = lastAdvanceControlsIndex; return(advancedControls); }