internal OpenMenuContents(ObservableCollection<MenuItem> MenuItems, GuiWidget widgetRelativeTo, Vector2 openOffset, Direction direction, RGBA_Bytes backgroundColor, RGBA_Bytes borderColor, int borderWidth, double maxHeight, bool alignToRightEdge) { this.MenuItems = new List<MenuItem>(); this.MenuItems.AddRange(MenuItems); this.alignToRightEdge = alignToRightEdge; this.openOffset = openOffset; this.borderWidth = borderWidth; this.borderColor = borderColor; this.BackgroundColor = backgroundColor; this.direction = direction; this.widgetRelativeTo = widgetRelativeTo; scrollingWindow = new ScrollableWidget(true); { FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); foreach (MenuItem menu in MenuItems) { menu.ClearRemovedFlag(); topToBottom.AddChild(menu); menu.DoClickFunction = AllowClickingItems; } topToBottom.HAnchor = UI.HAnchor.ParentLeft | UI.HAnchor.FitToChildren; topToBottom.VAnchor = UI.VAnchor.ParentBottom; Width = topToBottom.Width; Height = topToBottom.Height; scrollingWindow.AddChild(topToBottom); } scrollingWindow.HAnchor = HAnchor.ParentLeftRight; scrollingWindow.VAnchor = VAnchor.ParentBottomTop; if (maxHeight > 0 && Height > maxHeight) { MakeMenuHaveScroll(maxHeight); } AddChild(scrollingWindow); LostFocus += new EventHandler(DropListItems_LostFocus); GuiWidget topParent = widgetRelativeTo.Parent; while (topParent.Parent != null) { // Regretably we don't know who it is that is the window that will actually think it is moving relative to its parent // but we need to know anytime our widgetRelativeTo has been moved by any change, so we hook them all. if (!widgetRefList.Contains(topParent)) { widgetRefList.Add(topParent); topParent.PositionChanged += new EventHandler(widgetRelativeTo_PositionChanged); topParent.BoundsChanged += new EventHandler(widgetRelativeTo_PositionChanged); } topParent = topParent.Parent; } topParent.AddChild(this); widgetRelativeTo_PositionChanged(widgetRelativeTo, null); widgetRelativeTo.Closed += widgetRelativeTo_Closed; }
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 PopupWidget(GuiWidget contentWidget, IPopupLayoutEngine layoutEngine, bool makeScrollable) { this.contentWidget = contentWidget; this.layoutEngine = layoutEngine; ignoredWidgets = contentWidget.Children.Where(c => c is IIgnoredPopupChild).ToList(); if (contentWidget is IIgnoredPopupChild) { ignoredWidgets.Add(contentWidget); } if (makeScrollable) { scrollingWindow = new ScrollableWidget(true); { contentWidget.ClearRemovedFlag(); scrollingWindow.AddChild(contentWidget); contentWidget.HAnchor = UI.HAnchor.Left | UI.HAnchor.Fit; contentWidget.VAnchor |= UI.VAnchor.Bottom; // we may have fit or absolute so or it in Width = contentWidget.Width; Height = contentWidget.Height; } scrollingWindow.HAnchor = HAnchor.Stretch; scrollingWindow.VAnchor = VAnchor.Stretch; if (layoutEngine.MaxHeight > 0 && Height > layoutEngine.MaxHeight) { MakeMenuHaveScroll(layoutEngine.MaxHeight); } this.AddChild(scrollingWindow); } else { this.AddChild(contentWidget); Width = contentWidget.Width; // Clamp height to MaxHeight if specified, otherwise content height Height = layoutEngine.MaxHeight > 0 ? Math.Min(layoutEngine.MaxHeight, contentWidget.Height) : contentWidget.Height; } layoutEngine.ShowPopup(this); }
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, 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); }
private void topLevelWindow_MouseMove(object sender, MouseEventArgs mouseEvent) { count++; if (count == 20) { RemoveAllChildren(); ScrollableWidget allContainer = new ScrollableWidget(true); topToBottomTotal = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottomTotal.SuspendLayout(); GuiWidget.DefaultEnforceIntegerBounds = true; AddInfoRecursive(topLevelWindow, topToBottomTotal); GuiWidget.DefaultEnforceIntegerBounds = false; topToBottomTotal.ResumeLayout(); topToBottomTotal.PerformLayout(); allContainer.AddChild(topToBottomTotal); AddChild(allContainer); allContainer.AnchorAll(); } }
public EePromRepetierWidget() : base(540, 480) { 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 |= Agg.UI.HAnchor.ParentLeftRight; settingsAreaScrollBox.AnchorAll(); settingsAreaScrollBox.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; topToBottom.AddChild(settingsAreaScrollBox); settingsColmun = new FlowLayoutWidget(FlowDirection.TopToBottom); settingsColmun.HAnchor = Agg.UI.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); this.AddChild(topToBottom); translate(); //MatterControlApplication.Instance.LanguageChanged += translate; ShowAsSystemWindow(); currentEePromSettings.Clear(); PrinterConnectionAndCommunication.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents); currentEePromSettings.eventAdded += NewSettingReadFromPrinter; currentEePromSettings.AskPrinterForSettings(); #if SIMULATE_CONNECTION UiThread.RunOnIdle(AddSimulatedItems); #endif }
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 configurationControls = new PrinterConfigurationScrollWidget(); advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(configurationControls, optionsLabel), "Configuration 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; }
private TabControl CreateSideTabsAndPages(int minSettingNameWidth, OrganizerCategory category, UiState uiState) { TabControl groupTabs = new TabControl(Orientation.Vertical); groupTabs.Margin = new BorderDouble(0, 0, 0, 5); groupTabs.TabBar.BorderColor = RGBA_Bytes.White; foreach (OrganizerGroup group in category.GroupsList) { tabIndexForItem = 0; string groupTabLbl = new LocalizedString (group.Name).Translated; TabPage groupTabPage = new TabPage(groupTabLbl); SimpleTextTabWidget groupTabWidget = new SimpleTextTabWidget(groupTabPage, 14, ActiveTheme.Instance.TabLabelSelected, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes()); FlowLayoutWidget subGroupLayoutTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); subGroupLayoutTopToBottom.AnchorAll(); bool needToAddSubGroup = false; foreach (OrganizerSubGroup subGroup in group.SubGroupsList) { bool addedSettingToSubGroup = false; FlowLayoutWidget topToBottomSettings = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottomSettings.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; foreach (OrganizerSettingsData settingInfo in subGroup.SettingDataList) { if (ActivePrinterProfile.Instance.ActiveSliceEngine.MapContains(settingInfo.SlicerConfigName)) { addedSettingToSubGroup = true; GuiWidget controlsForThisSetting = CreateSettingInfoUIControls(settingInfo, minSettingNameWidth); topToBottomSettings.AddChild(controlsForThisSetting); if (showHelpBox.Checked) { AddInHelpText(topToBottomSettings, settingInfo); } } } if (addedSettingToSubGroup) { needToAddSubGroup = true; string groupBoxLbl = new LocalizedString (subGroup.Name).Translated; GroupBox groupBox = new GroupBox (groupBoxLbl); groupBox.TextColor = ActiveTheme.Instance.PrimaryTextColor; groupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor; groupBox.AddChild(topToBottomSettings); groupBox.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; subGroupLayoutTopToBottom.AddChild(groupBox); } } if (needToAddSubGroup) { ScrollableWidget scrollOnGroupTab = new ScrollableWidget(true); scrollOnGroupTab.AnchorAll(); subGroupLayoutTopToBottom.HAnchor = HAnchor.Max_FitToChildren_ParentWidth; subGroupLayoutTopToBottom.VAnchor = VAnchor.FitToChildren; //subGroupLayoutTopToBottom.DebugShowBounds = true; //scrollOnGroupTab.DebugShowBounds = true; scrollOnGroupTab.AddChild(subGroupLayoutTopToBottom); groupTabPage.AddChild(scrollOnGroupTab); groupTabs.AddTab(groupTabWidget); } } if (!groupTabs.SelectTab(uiState.selectedGroup.name)) { groupTabs.SelectTab(uiState.selectedGroup.index); } return groupTabs; }
public CompactTabView(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) => UiThread.RunOnIdle(ReloadPartPreview, null, 1), ref unregisterEvents); ApplicationController.Instance.ReloadAdvancedControlsPanelTrigger.RegisterEvent((s, e) => UiThread.RunOnIdle(LoadAdvancedControls), 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) => { UserSettings.Instance.set(CompactTabView_CurrentTab, TabBar.SelectedTabName); }; } }
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; }
private TabControl CreateAdvancedControlsTab() { 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; // 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; backButton = advancedControlsButtonFactory.Generate(LocalizedString.Get("Back"), StaticData.Instance.LoadIcon("icon_arrow_left_32x32.png", 32,32)); backButton.ToolTipText = "Switch to Queue, Library and History".Localize(); backButton.Margin = new BorderDouble(right: 3); backButton.VAnchor = VAnchor.ParentBottom; backButton.Cursor = Cursors.Hand; backButton.Click += (s, e) => BackClicked?.Invoke(this, null); advancedControls.TabBar.AddChild(backButton); advancedControls.TabBar.AddChild(new HorizontalSpacer()); GuiWidget manualPrinterControls = new ManualPrinterControls(); ScrollableWidget manualPrinterControlsScrollArea = new ScrollableWidget(true); manualPrinterControlsScrollArea.ScrollArea.HAnchor |= HAnchor.ParentLeftRight; manualPrinterControlsScrollArea.AnchorAll(); manualPrinterControlsScrollArea.AddChild(manualPrinterControls); RGBA_Bytes unselectedTextColor = ActiveTheme.Instance.TabLabelUnselected; if (ActiveSliceSettings.Instance.PrinterSelected) { sliceSettingsWidget = new SliceSettingsWidget(); } else { sliceSettingsWidget = new NoSettingsWidget(); } var sliceSettingsTabPage = new TabPage(sliceSettingsWidget, "Settings".Localize().ToUpper()); var sliceSettingPopOut = new PopOutTextTabWidget(sliceSettingsTabPage, SliceSettingsTabName, new Vector2(590, 400), textSize); advancedControls.AddTab(sliceSettingPopOut); var controlsTabPage = new TabPage(manualPrinterControlsScrollArea, "Controls".Localize().ToUpper()); var controlsPopOut = new PopOutTextTabWidget(controlsTabPage, ControlsTabName, new Vector2(400, 300), textSize); advancedControls.AddTab(controlsPopOut); #if !__ANDROID__ MenuOptionSettings.sliceSettingsPopOut = sliceSettingPopOut; MenuOptionSettings.controlsPopOut = controlsPopOut; #endif var optionsControls = new PrinterConfigurationScrollWidget(); advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(optionsControls, "Options".Localize().ToUpper()), "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 += (sender, e) => { string selectedTabName = advancedControls.TabBar.SelectedTabName; if (!string.IsNullOrEmpty(selectedTabName)) { UserSettings.Instance.set(ThirdPanelTabView_AdvancedControls_CurrentTab, selectedTabName); } }; } return advancedControls; }
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; }
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 ChooseConnectionWidget(ConnectionWindow windowController, SystemWindow container, bool editMode = false) : base(windowController, container) { { this.editMode = editMode; textImageButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.borderWidth = 0; editButtonFactory.normalTextColor = ActiveTheme.Instance.SecondaryAccentColor; editButtonFactory.hoverTextColor = RGBA_Bytes.White; editButtonFactory.disabledTextColor = ActiveTheme.Instance.SecondaryAccentColor; editButtonFactory.pressedTextColor = RGBA_Bytes.White; editButtonFactory.borderWidth = 0; editButtonFactory.FixedWidth = 60 * TextWidget.GlobalPointSizeScaleRatio; this.AnchorAll(); this.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; this.Padding = new BorderDouble(0); //To be re-enabled once native borders are turned off GuiWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); mainContainer.AnchorAll(); mainContainer.Padding = new BorderDouble(3, 0, 3, 5); mainContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight); headerRow.HAnchor = HAnchor.ParentLeftRight; headerRow.Margin = new BorderDouble(0, 3, 0, 0); headerRow.Padding = new BorderDouble(0, 3, 0, 0); { string chooseThreeDPrinterConfigLabel = LocalizedString.Get("Choose a 3D Printer Configuration"); string chooseThreeDPrinterConfigFull = string.Format("{0}:", chooseThreeDPrinterConfigLabel); TextWidget elementHeader = new TextWidget(string.Format(chooseThreeDPrinterConfigFull), pointSize: 14); elementHeader.TextColor = this.defaultTextColor; elementHeader.HAnchor = HAnchor.ParentLeftRight; elementHeader.VAnchor = Agg.UI.VAnchor.ParentCenter; headerRow.AddChild(elementHeader); } FlowLayoutWidget editButtonRow = new FlowLayoutWidget(FlowDirection.LeftToRight); editButtonRow.BackgroundColor = ActiveTheme.Instance.TransparentDarkOverlay; editButtonRow.HAnchor = HAnchor.ParentLeftRight; editButtonRow.Margin = new BorderDouble(0, 3, 0, 0); editButtonRow.Padding = new BorderDouble(0, 3, 0, 0); Button enterLeaveEditModeButton; if (!this.editMode) { enterLeaveEditModeButton = editButtonFactory.Generate(LocalizedString.Get("Edit"), centerText: true); enterLeaveEditModeButton.Click += EditModeOnLink_Click; } else { enterLeaveEditModeButton = editButtonFactory.Generate(LocalizedString.Get("Done"), centerText: true); enterLeaveEditModeButton.Click += EditModeOffLink_Click; } editButtonRow.AddChild(enterLeaveEditModeButton); //To do - replace with scrollable widget FlowLayoutWidget printerListContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); //ListBox printerListContainer = new ListBox(); { printerListContainer.HAnchor = HAnchor.ParentLeftRight; printerListContainer.VAnchor = VAnchor.FitToChildren; printerListContainer.Padding = new BorderDouble(3); printerListContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; //Get a list of printer records and add them to radio button list foreach (Printer printer in GetAllPrinters()) { PrinterListItem printerListItem; if (this.editMode) { printerListItem = new PrinterListItemEdit(printer, this.windowController); } else { printerListItem = new PrinterListItemView(printer, this.windowController); } printerListContainer.AddChild(printerListItem); } } FlowLayoutWidget buttonContainer = new FlowLayoutWidget(FlowDirection.LeftToRight); buttonContainer.HAnchor = HAnchor.ParentLeft | HAnchor.ParentRight; buttonContainer.Margin = new BorderDouble(0, 3); { closeButton = textImageButtonFactory.Generate(LocalizedString.Get("Close")); Button addPrinterButton = textImageButtonFactory.Generate(LocalizedString.Get("Add"), "icon_circle_plus.png"); addPrinterButton.ToolTipText = "Add a new Printer Profile".Localize(); addPrinterButton.Click += new EventHandler(AddConnectionLink_Click); Button refreshListButton = textImageButtonFactory.Generate(LocalizedString.Get("Refresh")); refreshListButton.Click += new EventHandler(EditModeOffLink_Click); GuiWidget spacer = new GuiWidget(); spacer.HAnchor = HAnchor.ParentLeftRight; //Add buttons to ButtonContainer buttonContainer.AddChild(addPrinterButton); if (!this.editMode) { buttonContainer.AddChild(refreshListButton); } buttonContainer.AddChild(spacer); buttonContainer.AddChild(closeButton); } ScrollableWidget printerListScrollArea = new ScrollableWidget(true); printerListScrollArea.ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; printerListScrollArea.AnchorAll(); printerListScrollArea.AddChild(printerListContainer); FlowLayoutWidget printerListScrollContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); printerListScrollContainer.HAnchor = HAnchor.ParentLeftRight; printerListScrollContainer.VAnchor = VAnchor.ParentBottomTop; printerListScrollContainer.Padding = new BorderDouble(3); printerListScrollContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; mainContainer.AddChild(headerRow); mainContainer.AddChild(editButtonRow); mainContainer.AddChild(printerListScrollContainer); printerListScrollContainer.AddChild(printerListScrollArea); mainContainer.AddChild(buttonContainer); this.AddChild(mainContainer); BindCloseButtonClick(); } }
internal OpenMenuContents(ObservableCollection <MenuItem> MenuItems, GuiWidget widgetRelativeTo, Vector2 openOffset, Direction direction, RGBA_Bytes backgroundColor, RGBA_Bytes borderColor, int borderWidth, double maxHeight, bool alignToRightEdge) { this.MenuItems = new List <MenuItem>(); this.MenuItems.AddRange(MenuItems); this.alignToRightEdge = alignToRightEdge; this.openOffset = openOffset; this.borderWidth = borderWidth; this.borderColor = borderColor; this.BackgroundColor = backgroundColor; this.direction = direction; this.widgetRelativeTo = widgetRelativeTo; scrollingWindow = new ScrollableWidget(true); { FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); foreach (MenuItem menu in MenuItems) { topToBottom.AddChild(menu); menu.DoClickFunction = AllowClickingItems; } topToBottom.HAnchor = UI.HAnchor.ParentLeft | UI.HAnchor.FitToChildren; topToBottom.VAnchor = UI.VAnchor.ParentBottom; Width = topToBottom.Width; Height = topToBottom.Height; scrollingWindow.AddChild(topToBottom); } scrollingWindow.HAnchor = HAnchor.ParentLeftRight; scrollingWindow.VAnchor = VAnchor.ParentBottomTop; if (maxHeight > 0 && Height > maxHeight) { scrollingWindow.VAnchor = UI.VAnchor.None; scrollingWindow.Height = maxHeight; scrollingWindow.MinimumSize = new Vector2(Width + 15, 0); Width = scrollingWindow.Width; Height = maxHeight; scrollingWindow.ScrollArea.VAnchor = UI.VAnchor.FitToChildren; } AddChild(scrollingWindow); LostFocus += new EventHandler(DropListItems_LostFocus); GuiWidget topParent = widgetRelativeTo.Parent; while (topParent.Parent != null) { // Regretably we don't know who it is that is the window that will actually think it is moving relative to its parent // but we need to know anytime our widgetRelativeTo has been moved by any change, so we hook them all. if (!widgetRefList.Contains(topParent)) { widgetRefList.Add(topParent); topParent.PositionChanged += new EventHandler(widgetRelativeTo_PositionChanged); topParent.BoundsChanged += new EventHandler(widgetRelativeTo_PositionChanged); } topParent = topParent.Parent; } topParent.AddChild(this); widgetRelativeTo_PositionChanged(widgetRelativeTo, null); widgetRelativeTo.Closed += widgetRelativeTo_Closed; }
public EePromRepetierWindow() : base(650 * GuiWidget.DeviceScale, 480 * GuiWidget.DeviceScale) { AlwaysOnTopOfMain = true; BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; currentEePromSettings = new EePromRepetierStorage(); FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.VAnchor = Agg.UI.VAnchor.ParentBottomTop; 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; // put in the save button { Button buttonSave = textImageButtonFactory.Generate("Save To EEPROM".Localize()); buttonSave.Margin = new BorderDouble(0, 3); buttonSave.Click += (sender, e) => { UiThread.RunOnIdle(() => { currentEePromSettings.Save(); currentEePromSettings.Clear(); currentEePromSettings.eventAdded -= NewSettingReadFromPrinter; Close(); }); }; buttonBar.AddChild(buttonSave); } CreateSpacer(buttonBar); // put in the import button { Button buttonImport = textImageButtonFactory.Generate("Import".Localize() + "..."); buttonImport.Margin = new BorderDouble(0, 3); buttonImport.Click += (sender, e) => { UiThread.RunOnIdle(() => { FileDialog.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(); } }); }); }; buttonBar.AddChild(buttonImport); } // put in the export button { Button buttonExport = textImageButtonFactory.Generate("Export".Localize() + "..."); buttonExport.Margin = new BorderDouble(0, 3); buttonExport.Click += (sender, e) => { UiThread.RunOnIdle(() => { FileDialog.SaveFileDialog( new SaveFileDialogParams("EEPROM Settings|*.ini") { ActionButtonLabel = "Export EEPROM Settings".Localize(), Title = "Export EEPROM".Localize(), FileName = "eeprom_settings.ini" }, (saveParams) => { if (!string.IsNullOrEmpty(saveParams.FileName)) { currentEePromSettings.Export(saveParams.FileName); } }); }); }; buttonBar.AddChild(buttonExport); } // put in the cancel button { Button buttonCancel = textImageButtonFactory.Generate("Close".Localize()); buttonCancel.Margin = new BorderDouble(10, 3, 0, 3); buttonCancel.Click += (sender, e) => { UiThread.RunOnIdle(() => { currentEePromSettings.Clear(); currentEePromSettings.eventAdded -= NewSettingReadFromPrinter; Close(); }); }; buttonBar.AddChild(buttonCancel); } topToBottom.AddChild(buttonBar); this.AddChild(topToBottom); Title = LocalizedString.Get("Firmware EEPROM Settings"); ShowAsSystemWindow(); currentEePromSettings.Clear(); PrinterConnectionAndCommunication.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents); currentEePromSettings.eventAdded += NewSettingReadFromPrinter; currentEePromSettings.AskPrinterForSettings(); #if SIMULATE_CONNECTION UiThread.RunOnIdle(AddSimulatedItems); #endif }
public SelectPartsOfPrinterToImport(string settingsFilePath, PrinterSettingsLayer destinationLayer, string sectionName = null) : base(unlocalizedTextForTitle: "Import Wizard") { this.isMergeIntoUserLayer = destinationLayer == ActiveSliceSettings.Instance.UserLayer; this.destinationLayer = destinationLayer; this.sectionName = sectionName; // TODO: Need to handle load failures for import attempts settingsToImport = PrinterSettings.LoadFile(settingsFilePath); this.headerLabel.Text = "Select What to Import".Localize(); this.settingsFilePath = settingsFilePath; 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); if (isMergeIntoUserLayer) { container.AddChild(new WrappedTextWidget(importMessage, textColor: ActiveTheme.Instance.PrimaryTextColor)); } // add in the check boxes to select what to import container.AddChild(new TextWidget("Main Settings:") { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(0, 3, 0, isMergeIntoUserLayer ? 10 : 0), }); var mainProfileRadioButton = new RadioButton("Printer Profile") { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(5, 0), HAnchor = HAnchor.ParentLeft, Checked = true, }; container.AddChild(mainProfileRadioButton); if (settingsToImport.QualityLayers.Count > 0) { container.AddChild(new TextWidget("Quality Presets:") { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(0, 3, 0, 15), }); int buttonIndex = 0; foreach (var qualitySetting in settingsToImport.QualityLayers) { RadioButton qualityButton = new RadioButton(qualitySetting.Name) { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(5, 0, 0, 0), HAnchor = HAnchor.ParentLeft, }; 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 = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(0, 3, 0, 15), }); int buttonIndex = 0; foreach (var materialSetting in settingsToImport.MaterialLayers) { RadioButton materialButton = new RadioButton(materialSetting.Name) { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(5, 0), HAnchor = HAnchor.ParentLeft, }; container.AddChild(materialButton); int localButtonIndex = buttonIndex; materialButton.CheckedStateChanged += (s, e) => { if (materialButton.Checked) { selectedMaterial = localButtonIndex; } else { selectedMaterial = -1; } }; buttonIndex++; } } var mergeButtonTitle = this.isMergeIntoUserLayer ? "Merge".Localize() : "Import".Localize(); var mergeButton = textImageButtonFactory.Generate(mergeButtonTitle); mergeButton.Name = "Merge Profile"; mergeButton.Click += (s, e) => UiThread.RunOnIdle(() => { bool copyName = false; PrinterSettingsLayer sourceLayer = null; if (selectedMaterial > -1) { sourceLayer = settingsToImport.MaterialLayers[selectedMaterial]; copyName = true; } else if (selectedQuality > -1) { 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 }; } ActiveSliceSettings.Instance.Merge(destinationLayer, settingsToImport, sourceFilter, copyName); this.Parents<SystemWindow>().FirstOrDefault()?.CloseOnIdle(); }); footerRow.AddChild(mergeButton); footerRow.AddChild(new HorizontalSpacer()); footerRow.AddChild(cancelButton); if (settingsToImport.QualityLayers.Count == 0 && settingsToImport.MaterialLayers.Count == 0) { // Only main setting so don't ask what to merge just do it. UiThread.RunOnIdle(() => { var sourceFilter = new List<PrinterSettingsLayer>() { settingsToImport.OemLayer ?? new PrinterSettingsLayer(), settingsToImport.UserLayer ?? new PrinterSettingsLayer() }; ActiveSliceSettings.Instance.Merge(destinationLayer, settingsToImport, sourceFilter, false); UiThread.RunOnIdle(ApplicationController.Instance.ReloadAdvancedControlsPanel); string successMessage = importPrinterSuccessMessage.FormatWith(Path.GetFileNameWithoutExtension(settingsFilePath)); if (!isMergeIntoUserLayer) { string sourceName = isMergeIntoUserLayer ? Path.GetFileNameWithoutExtension(settingsFilePath) : destinationLayer[SettingsKey.layer_name]; successMessage = ImportSettingsPage.importSettingSuccessMessage.FormatWith(sourceName, sectionName); } WizardWindow.ChangeToPage(new ImportSucceeded(successMessage) { WizardWindow = this.WizardWindow, }); }); } }
private TabControl CreateNewAdvancedControls(ButtonBase.ButtonEventHandler 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 ButtonBase.ButtonEventHandler(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 PrinterConfigurationPage(); 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; }