示例#1
0
        public void GroupBoxResizeThenLayoutBeforeMatchChildren()
        {
            bool integerBounds = GuiWidget.DefaultEnforceIntegerBounds;

            GuiWidget.DefaultEnforceIntegerBounds = true;
            GroupBox groupBox = new GroupBox("group box");

            groupBox.Name = "groupBox";
            GuiWidget contents = new GuiWidget(30, 20);

            contents.Name        = "contents";
            contents.MinimumSize = new VectorMath.Vector2(0, 0);

            // make sure the client area will get smaller when the contents get smaller
            groupBox.ClientArea.VAnchor = Agg.UI.VAnchor.FitToChildren;
            groupBox.ClientArea.Name    = "groupBox.ClientArea";

            groupBox.AddChild(contents);

            Assert.IsTrue(contents.Height == 20);
            Assert.IsTrue(groupBox.ClientArea.Height == 20);
            Assert.IsTrue(groupBox.Height == 50);
            TextWidget groupBoxLabel = groupBox.Children[0] as TextWidget;

            groupBoxLabel.Name = "groupBoxLabel";
            Assert.IsTrue(groupBoxLabel.BoundsRelativeToParent.Top == groupBox.LocalBounds.Top);
            contents.Height = 10;
            Assert.IsTrue(groupBoxLabel.BoundsRelativeToParent.Top == groupBox.LocalBounds.Top);
            Assert.IsTrue(contents.Height == 10);
            Assert.IsTrue(groupBox.ClientArea.Height == 10);
            Assert.IsTrue(groupBox.Height == 40);

            GuiWidget.DefaultEnforceIntegerBounds = integerBounds;
        }
        private void PutInFanControls(FlowLayoutWidget controlsTopToBottomLayout)
        {
            GroupBox fanControlsGroupBox = new GroupBox(new LocalizedString("Fan Controls").Translated);

            fanControlsGroupBox.Margin      = new BorderDouble(0);
            fanControlsGroupBox.TextColor   = ActiveTheme.Instance.PrimaryTextColor;
            fanControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            fanControlsGroupBox.HAnchor    |= Agg.UI.HAnchor.ParentLeftRight;
            fanControlsGroupBox.VAnchor     = Agg.UI.VAnchor.FitToChildren;

            {
                FlowLayoutWidget fanControlsLayout = new FlowLayoutWidget(FlowDirection.TopToBottom);
                fanControlsLayout.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
                fanControlsLayout.VAnchor = Agg.UI.VAnchor.FitToChildren;
                fanControlsLayout.Padding = new BorderDouble(3, 5, 3, 0);
                {
                    fanControlsLayout.AddChild(CreateFanControls());
                }

                fanControlsGroupBox.AddChild(fanControlsLayout);
            }

            fanControlsContainer = new DisablablableWidget();
            fanControlsContainer.AddChild(fanControlsGroupBox);

            if (PrinterCommunication.Instance.ActivePrinter == null ||
                PrinterCommunication.Instance.ActivePrinter.GetFeatures().HasFan())
            {
                controlsTopToBottomLayout.AddChild(fanControlsContainer);
            }
        }
示例#3
0
        public WindowPage()
            : base("Window")
        {
            WindowWidget widow = new WindowWidget(new RectangleDouble(20, 20, 400, 400));

            AddChild(widow);

            GroupBox groupBox = new GroupBox("Radio Group");

            groupBox.LocalBounds          = new RectangleDouble(0, 0, 300, 100);
            groupBox.OriginRelativeParent = new Vector2(0, 0);
            groupBox.AddChild(new RadioButton(0, 40, "Simple Radio Button 1"));
            groupBox.AddChild(new RadioButton(0, 20, "Simple Radio Button 2"));
            groupBox.AddChild(new RadioButton(0, 0, "Simple Radio Button 3"));
            widow.AddChild(groupBox);
        }
        private GuiWidget CreateSdCardManagerContainer()
        {
            GroupBox terminalControlsContainer;

            terminalControlsContainer = new GroupBox("SD Card Printing");

            terminalControlsContainer.Margin      = new BorderDouble(top: 10);
            terminalControlsContainer.TextColor   = ActiveTheme.Instance.PrimaryTextColor;
            terminalControlsContainer.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            terminalControlsContainer.HAnchor     = Agg.UI.HAnchor.ParentLeftRight;
            terminalControlsContainer.Height      = 68;

            {
                FlowLayoutWidget buttonBar = new FlowLayoutWidget();
                buttonBar.HAnchor |= HAnchor.ParentLeftRight;
                buttonBar.VAnchor |= Agg.UI.VAnchor.ParentCenter;
                buttonBar.Margin   = new BorderDouble(3, 0, 3, 6);
                buttonBar.Padding  = new BorderDouble(0);

                this.textImageButtonFactory.FixedHeight = TallButtonHeight;

                Button showSDPrintingPannel = textImageButtonFactory.Generate("SD CARD MANAGER");
                showSDPrintingPannel.Margin = new BorderDouble(left: 10);
                showSDPrintingPannel.Click += (sender, e) =>
                {
                    SDCardManager.Show();
                };
                buttonBar.AddChild(showSDPrintingPannel);

                terminalControlsContainer.AddChild(buttonBar);
            }

            return(terminalControlsContainer);
        }
        private GuiWidget CreateTerminalControlsContainer()
        {
            GroupBox terminalControlsContainer;

            terminalControlsContainer = new GroupBox(new LocalizedString("Printer Communications").Translated);

            terminalControlsContainer.Margin      = new BorderDouble(top: 10);
            terminalControlsContainer.TextColor   = ActiveTheme.Instance.PrimaryTextColor;
            terminalControlsContainer.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            terminalControlsContainer.HAnchor     = Agg.UI.HAnchor.ParentLeftRight;
            terminalControlsContainer.Height      = 68;

            {
                FlowLayoutWidget buttonBar = new FlowLayoutWidget();
                buttonBar.HAnchor |= HAnchor.ParentLeftRight;
                buttonBar.VAnchor |= Agg.UI.VAnchor.ParentCenter;
                buttonBar.Margin   = new BorderDouble(3, 0, 3, 6);
                buttonBar.Padding  = new BorderDouble(0);

                this.textImageButtonFactory.FixedHeight = TallButtonHeight;

                Button showTerminal = textImageButtonFactory.Generate(new LocalizedString("SHOW TERMINAL").Translated);
                showTerminal.Margin = new BorderDouble(0);
                showTerminal.Click += (sender, e) =>
                {
                    OutputScrollWindow.Show();
                };
                buttonBar.AddChild(showTerminal);

                terminalControlsContainer.AddChild(buttonBar);
            }

            return(terminalControlsContainer);
        }
        public ButtonsPage()
            : base("Radio and Check Buttons")
        {
            FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

            topToBottom.AddChild(new CheckBox("Simple Check Box"));

            CheckBoxViewStates fourStates = new CheckBoxViewStates(new TextWidget("normal"), new TextWidget("normal"),
                                                                   new TextWidget("switch n->p"),
                                                                   new TextWidget("pressed"), new TextWidget("pressed"),
                                                                   new TextWidget("switch p->n"),
                                                                   new TextWidget("disabled"));

            topToBottom.AddChild(new CheckBox(fourStates));

            GuiWidget normalPressed = new TextWidget("0 4state");

            normalPressed.BackgroundColor = RGBA_Bytes.Gray;
            GuiWidget downPressed = new TextWidget("1 4state");

            downPressed.BackgroundColor = RGBA_Bytes.Gray;

            GuiWidget normalHover = new TextWidget("0 4state");

            normalHover.BackgroundColor = RGBA_Bytes.Yellow;
            GuiWidget downHover = new TextWidget("1 4state");

            downHover.BackgroundColor = RGBA_Bytes.Yellow;

            CheckBoxViewStates fourStates2 = new CheckBoxViewStates(new TextWidget("0 4state"), normalHover, normalPressed, new TextWidget("1 4state"), downHover, downPressed, new TextWidget("disabled"));

            topToBottom.AddChild(new CheckBox(fourStates2));

            topToBottom.AddChild(new RadioButton("Simple Radio Button 1"));
            topToBottom.AddChild(new RadioButton("Simple Radio Button 2"));
            topToBottom.AddChild(new RadioButton(new RadioButtonViewText("Simple Radio Button 3")));
            topToBottom.AddChild(new RadioButton(new RadioButtonViewStates(new TextWidget("O - unchecked"), new TextWidget("O - unchecked hover"), new TextWidget("O - checking"), new TextWidget("X - checked"), new TextWidget("disabled"))));

            groupBox = new GroupBox("Radio Group");
            //groupBox.LocalBounds = new RectangleDouble(0, 0, 300, 150);
            groupBox.OriginRelativeParent = new Vector2(200, 350);
            FlowLayoutWidget topToBottomRadios = new FlowLayoutWidget(FlowDirection.TopToBottom);

            topToBottomRadios.AnchorAll();
            topToBottomRadios.AddChild(new RadioButton("Simple Radio Button 1"));
            topToBottomRadios.AddChild(new RadioButton("Simple Radio Button 2"));
            topToBottomRadios.AddChild(new RadioButton("Simple Radio Button 3"));
            topToBottomRadios.SetBoundsToEncloseChildren();
            groupBox.AddChild(topToBottomRadios);
            topToBottom.AddChild(groupBox);

            AddChild(topToBottom);

            topToBottom.VAnchor = UI.VAnchor.ParentTop;
        }
        private GuiWidget CreatePrintLevelingControlsContainer()
        {
            GroupBox printLevelingControlsContainer;

            printLevelingControlsContainer = new GroupBox(new LocalizedString("Automatic Calibration").Translated);

            printLevelingControlsContainer.Margin      = new BorderDouble(0);
            printLevelingControlsContainer.TextColor   = ActiveTheme.Instance.PrimaryTextColor;
            printLevelingControlsContainer.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            printLevelingControlsContainer.HAnchor     = Agg.UI.HAnchor.ParentLeftRight;
            printLevelingControlsContainer.Height      = 68;

            {
                FlowLayoutWidget buttonBar = new FlowLayoutWidget();
                buttonBar.HAnchor |= HAnchor.ParentLeftRight;
                buttonBar.VAnchor |= Agg.UI.VAnchor.ParentCenter;
                buttonBar.Margin   = new BorderDouble(0, 0, 0, 0);
                buttonBar.Padding  = new BorderDouble(0);

                this.textImageButtonFactory.FixedHeight = TallButtonHeight;

                Button runPrintLevelingButton = textImageButtonFactory.Generate(new LocalizedString("CONFIGURE").Translated);
                runPrintLevelingButton.Margin  = new BorderDouble(left: 6);
                runPrintLevelingButton.VAnchor = VAnchor.ParentCenter;
                runPrintLevelingButton.Click  += new ButtonBase.ButtonEventHandler(runPrintLeveling_Click);

                CheckBox doLevelingCheckBox = new CheckBox(new LocalizedString("Enable Automatic Print Leveling").Translated);
                doLevelingCheckBox.Margin    = new BorderDouble(left: 3);
                doLevelingCheckBox.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                doLevelingCheckBox.VAnchor   = VAnchor.ParentCenter;
                doLevelingCheckBox.Checked   = PrinterCommunication.Instance.DoPrintLeveling;

                buttonBar.AddChild(doLevelingCheckBox);
                buttonBar.AddChild(runPrintLevelingButton);
                doLevelingCheckBox.CheckedStateChanged += (sender, e) =>
                {
                    PrinterCommunication.Instance.DoPrintLeveling = doLevelingCheckBox.Checked;
                };
                PrinterCommunication.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) =>
                {
                    doLevelingCheckBox.Checked = PrinterCommunication.Instance.DoPrintLeveling;
                    if (doLevelingCheckBox.Checked && PrinterCommunication.Instance.ActivePrinter.PrintLevelingProbePositions == null)
                    {
                        //OpenPrintLevelWizard();
                    }
                }, ref unregisterEvents);

                printLevelingControlsContainer.AddChild(buttonBar);
            }

            return(printLevelingControlsContainer);
        }
示例#8
0
        public void AddReleaseOptions(FlowLayoutWidget controlsTopToBottom)
        {
            GroupBox releaseOptionsGroupBox = new GroupBox(LocalizedString.Get("Update Feed"));

            releaseOptionsGroupBox.Margin      = new BorderDouble(0);
            releaseOptionsGroupBox.TextColor   = ActiveTheme.Instance.PrimaryTextColor;
            releaseOptionsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            releaseOptionsGroupBox.HAnchor     = Agg.UI.HAnchor.ParentLeftRight;
            releaseOptionsGroupBox.Height      = 68;

            FlowLayoutWidget controlsContainer = new FlowLayoutWidget();

            controlsContainer.HAnchor |= HAnchor.ParentCenter;

            AnchoredDropDownList releaseOptionsDropList = new AnchoredDropDownList("Development");

            releaseOptionsDropList.Margin = new BorderDouble(0, 3);

            MenuItem releaseOptionsDropDownItem = releaseOptionsDropList.AddItem("Release", "release");

            releaseOptionsDropDownItem.Selected += new EventHandler(FixTabDot);

            MenuItem preReleaseDropDownItem = releaseOptionsDropList.AddItem("Pre-Release", "pre-release");

            preReleaseDropDownItem.Selected += new EventHandler(FixTabDot);

            MenuItem developmentDropDownItem = releaseOptionsDropList.AddItem("Development", "development");

            developmentDropDownItem.Selected += new EventHandler(FixTabDot);

            releaseOptionsDropList.MinimumSize = new Vector2(releaseOptionsDropList.LocalBounds.Width, releaseOptionsDropList.LocalBounds.Height);

            List <string> acceptableUpdateFeedTypeValues = new List <string> ()
            {
                "release", "pre-release", "development"
            };
            string currentUpdateFeedType = UserSettings.Instance.get("UpdateFeedType");

            if (acceptableUpdateFeedTypeValues.IndexOf(currentUpdateFeedType) == -1)
            {
                UserSettings.Instance.set("UpdateFeedType", "release");
            }

            releaseOptionsDropList.SelectedValue = UserSettings.Instance.get("UpdateFeedType");

            releaseOptionsDropList.SelectionChanged += new EventHandler(ReleaseOptionsDropList_SelectionChanged);

            controlsContainer.AddChild(releaseOptionsDropList);
            releaseOptionsGroupBox.AddChild(controlsContainer);
            controlsTopToBottom.AddChild(releaseOptionsGroupBox);
        }
        private void AddMovementControls(FlowLayoutWidget controlsTopToBottomLayout)
        {
            Button   editButton;
            GroupBox movementControlsGroupBox = new GroupBox(textImageButtonFactory.GenerateGroupBoxLableWithEdit(new LocalizedString("Movement Controls").Translated, out editButton));

            editButton.Click += (sender, e) =>
            {
                if (editSettingsWindow == null)
                {
                    editSettingsWindow         = new EditManualMovementSpeedsWindow("Movement Speeds", GetMovementSpeedsString(), SetMovementSpeeds);
                    editSettingsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { editSettingsWindow = null; };
                }
                else
                {
                    editSettingsWindow.BringToFront();
                }
            };

            movementControlsGroupBox.Margin      = new BorderDouble(0);
            movementControlsGroupBox.TextColor   = ActiveTheme.Instance.PrimaryTextColor;
            movementControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            movementControlsGroupBox.HAnchor    |= Agg.UI.HAnchor.ParentLeftRight;
            movementControlsGroupBox.VAnchor     = Agg.UI.VAnchor.FitToChildren;

            {
                FlowLayoutWidget manualControlsLayout = new FlowLayoutWidget(FlowDirection.TopToBottom);
                manualControlsLayout.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
                manualControlsLayout.VAnchor = Agg.UI.VAnchor.FitToChildren;
                manualControlsLayout.Padding = new BorderDouble(3, 5, 3, 0);
                {
                    manualControlsLayout.AddChild(GetHomeButtonBar());

                    manualControlsLayout.AddChild(CreateSeparatorLine());

                    manualControlsLayout.AddChild(new JogControls(new XYZColors()));

                    manualControlsLayout.AddChild(CreateSeparatorLine());

                    //manualControlsLayout.AddChild(GetManualMoveBar());
                }

                movementControlsGroupBox.AddChild(manualControlsLayout);
            }

            movementControlsContainer = new DisablablableWidget();
            movementControlsContainer.AddChild(movementControlsGroupBox);
            controlsTopToBottomLayout.AddChild(movementControlsContainer);
        }
示例#10
0
        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(LocalizedString.Get("Extra"));
                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);

                SliceSettingListControl scrollOnGroupTab = new SliceSettingListControl();
                scrollOnGroupTab.AnchorAll();
                scrollOnGroupTab.AddChild(subGroupLayoutTopToBottom);
                groupTabPage.AddChild(scrollOnGroupTab);
            }
            return(sideTabs);
        }
示例#11
0
        private void AddTerminalControls(FlowLayoutWidget controlsTopToBottomLayout)
        {
            GroupBox terminalControlsContainer;

            terminalControlsContainer = new GroupBox(LocalizedString.Get("Communications"));

            terminalControlsContainer.Margin      = new BorderDouble(0);
            terminalControlsContainer.TextColor   = ActiveTheme.Instance.PrimaryTextColor;
            terminalControlsContainer.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            terminalControlsContainer.HAnchor     = Agg.UI.HAnchor.ParentLeftRight;
            terminalControlsContainer.Height      = 68;

            OutputScrollWindow.HookupPrinterOutput();

            {
                FlowLayoutWidget buttonBar = new FlowLayoutWidget();
                buttonBar.HAnchor |= HAnchor.ParentCenter;
                buttonBar.VAnchor |= Agg.UI.VAnchor.ParentCenter;
                buttonBar.Margin   = new BorderDouble(3, 0, 3, 6);
                buttonBar.Padding  = new BorderDouble(0);

                this.textImageButtonFactory.FixedHeight = TallButtonHeight;

                Agg.Image.ImageBuffer terminalImage = new Agg.Image.ImageBuffer();
                ImageIO.LoadImageData(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "Icons", "PrintStatusControls", "terminal-24x24.png"), terminalImage);
                ImageWidget terminalIcon = new ImageWidget(terminalImage);
                terminalIcon.Margin = new BorderDouble(right: 6);

                Button showTerminal = textImageButtonFactory.Generate("Show Terminal".Localize().ToUpper());
                showTerminal.Margin = new BorderDouble(0);
                showTerminal.Click += (sender, e) =>
                {
                    OutputScrollWindow.Show();
                };

                //buttonBar.AddChild(terminalIcon);
                buttonBar.AddChild(showTerminal);

                terminalControlsContainer.AddChild(buttonBar);
            }

            terminalCommunicationsContainer = new DisableableWidget();
            terminalCommunicationsContainer.AddChild(terminalControlsContainer);

            controlsTopToBottomLayout.AddChild(terminalCommunicationsContainer);
        }
示例#12
0
        private void AddLanguageControls(FlowLayoutWidget controlsTopToBottomLayout)
        {
            DisableableWidget container = new DisableableWidget();

            GroupBox languageControlsGroupBox = new GroupBox(LocalizedString.Get("Language Settings"));

            languageControlsGroupBox.TextColor   = ActiveTheme.Instance.PrimaryTextColor;
            languageControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            languageControlsGroupBox.HAnchor     = Agg.UI.HAnchor.ParentLeftRight;
            languageControlsGroupBox.VAnchor     = Agg.UI.VAnchor.FitToChildren;
            languageControlsGroupBox.Height      = 78;

            FlowLayoutWidget controlsContainer = new FlowLayoutWidget();

            controlsContainer.HAnchor = HAnchor.ParentLeftRight;

            LanguageSelector languageSelector = new LanguageSelector();

            languageSelector.Margin            = new BorderDouble(0);
            languageSelector.SelectionChanged += new EventHandler(LanguageDropList_SelectionChanged);

            TextWidget experimentalWidget = new TextWidget("Experimental", pointSize: 10);

            experimentalWidget.VAnchor   = Agg.UI.VAnchor.ParentCenter;
            experimentalWidget.Margin    = new BorderDouble(left: 4);
            experimentalWidget.TextColor = ActiveTheme.Instance.SecondaryAccentColor;

            restartButton         = textImageButtonFactory.Generate("Restart");
            restartButton.VAnchor = Agg.UI.VAnchor.ParentCenter;
            restartButton.Visible = false;
            restartButton.Click  += (sender, e) =>
            {
                RestartApplication();
            };

            controlsContainer.AddChild(languageSelector);
            controlsContainer.AddChild(experimentalWidget);
            controlsContainer.AddChild(new HorizontalSpacer());
            controlsContainer.AddChild(restartButton);

            languageControlsGroupBox.AddChild(controlsContainer);

            container.AddChild(languageControlsGroupBox);

            controlsTopToBottomLayout.AddChild(container);
        }
示例#13
0
        private void AddThemeControls(FlowLayoutWidget controlsTopToBottomLayout)
        {
            DisableableWidget container = new DisableableWidget();

            GroupBox themeControlsGroupBox = new GroupBox(LocalizedString.Get("Theme Settings"));

            themeControlsGroupBox.TextColor   = ActiveTheme.Instance.PrimaryTextColor;
            themeControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            themeControlsGroupBox.HAnchor     = Agg.UI.HAnchor.ParentLeftRight;
            themeControlsGroupBox.VAnchor     = Agg.UI.VAnchor.FitToChildren;
            themeControlsGroupBox.Height      = 78;

            FlowLayoutWidget colorSelectorContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);

            colorSelectorContainer.HAnchor = HAnchor.ParentLeftRight;


            ThemeColorSelectorWidget themeSelector = new ThemeColorSelectorWidget();

            themeSelector.Margin = new BorderDouble(right: 5);

            GuiWidget currentColorThemeBorder = new GuiWidget();

            currentColorThemeBorder.HAnchor         = Agg.UI.HAnchor.ParentLeftRight;
            currentColorThemeBorder.VAnchor         = VAnchor.ParentBottomTop;
            currentColorThemeBorder.Margin          = new BorderDouble(top: 2, bottom: 2);
            currentColorThemeBorder.Padding         = new BorderDouble(4);
            currentColorThemeBorder.BackgroundColor = RGBA_Bytes.White;

            GuiWidget currentColorTheme = new GuiWidget();

            currentColorTheme.HAnchor         = HAnchor.ParentLeftRight;
            currentColorTheme.VAnchor         = VAnchor.ParentBottomTop;
            currentColorTheme.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor;


            themeControlsGroupBox.AddChild(colorSelectorContainer);
            colorSelectorContainer.AddChild(themeSelector);
            colorSelectorContainer.AddChild(currentColorThemeBorder);
            currentColorThemeBorder.AddChild(currentColorTheme);
            container.AddChild(themeControlsGroupBox);
            controlsTopToBottomLayout.AddChild(container);
        }
示例#14
0
        void AddChildElements()
        {
            Button   editButton;
            GroupBox groupBox = new GroupBox(textImageButtonFactory.GenerateGroupBoxLableWithEdit(new LocalizedString("Macros").Translated, out editButton));

            editButton.Click += (sender, e) =>
            {
                if (editSettingsWindow == null)
                {
                    editSettingsWindow         = new EditMacrosWindow(GetMacros(), ReloadMacros);
                    editSettingsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { editSettingsWindow = null; };
                }
                else
                {
                    editSettingsWindow.BringToFront();
                }
            };

            groupBox.TextColor   = ActiveTheme.Instance.PrimaryTextColor;
            groupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            groupBox.HAnchor    |= Agg.UI.HAnchor.ParentLeftRight;
            // make sure the client area will get smaller when the contents get smaller
            groupBox.ClientArea.VAnchor = Agg.UI.VAnchor.FitToChildren;

            FlowLayoutWidget controlRow = new FlowLayoutWidget(Agg.UI.FlowDirection.TopToBottom);

            controlRow.Margin   = new BorderDouble(top: 5);
            controlRow.HAnchor |= HAnchor.ParentLeftRight;
            {
                {
                    this.presetButtonsContainer = GetMacroButtonContainer();
                    controlRow.AddChild(this.presetButtonsContainer);
                }
            }

            groupBox.AddChild(controlRow);
            this.AddChild(groupBox);
        }
示例#15
0
        private void AddEePromControls(FlowLayoutWidget controlsTopToBottomLayout)
        {
            GroupBox eePromControlsGroupBox = new GroupBox(LocalizedString.Get("EEProm Settings"));

            eePromControlsGroupBox.Margin      = new BorderDouble(0);
            eePromControlsGroupBox.TextColor   = ActiveTheme.Instance.PrimaryTextColor;
            eePromControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            eePromControlsGroupBox.HAnchor     = Agg.UI.HAnchor.ParentLeftRight;
            eePromControlsGroupBox.VAnchor     = Agg.UI.VAnchor.FitToChildren;
            eePromControlsGroupBox.Height      = 68;
            {
                FlowLayoutWidget eePromControlsLayout = new FlowLayoutWidget();
                eePromControlsLayout.HAnchor |= HAnchor.ParentCenter;
                eePromControlsLayout.VAnchor |= Agg.UI.VAnchor.ParentCenter;
                eePromControlsLayout.Margin   = new BorderDouble(3, 0, 3, 6);
                eePromControlsLayout.Padding  = new BorderDouble(0);
                {
                    Agg.Image.ImageBuffer eePromImage = new Agg.Image.ImageBuffer();
                    ImageIO.LoadImageData(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "Icons", "PrintStatusControls", "leveling-24x24.png"), eePromImage);
                    ImageWidget eePromIcon = new ImageWidget(eePromImage);
                    eePromIcon.Margin = new BorderDouble(right: 6);

                    Button openEePromWindow = textImageButtonFactory.Generate("Configure".Localize().ToUpper());
                    openEePromWindow.Click += (sender, e) =>
                    {
#if false // This is to force the creation of the repetier window for testing when we don't have repetier firmware.
                        new MatterHackers.MatterControl.EeProm.EePromRepetierWidget();
#else
                        switch (PrinterCommunication.Instance.FirmwareType)
                        {
                        case PrinterCommunication.FirmwareTypes.Repetier:
                            new MatterHackers.MatterControl.EeProm.EePromRepetierWidget();
                            break;

                        case PrinterCommunication.FirmwareTypes.Marlin:
                            new MatterHackers.MatterControl.EeProm.EePromMarlinWidget();
                            break;

                        default:
                            UiThread.RunOnIdle((state) =>
                            {
                                string message = LocalizedString.Get("Oops! There is no eeprom mapping for your printer's firmware.");
                                StyledMessageBox.ShowMessageBox(message, "Warning no eeprom mapping", StyledMessageBox.MessageType.OK);
                            }
                                               );
                            break;
                        }
#endif
                    };
                    //eePromControlsLayout.AddChild(eePromIcon);
                    eePromControlsLayout.AddChild(openEePromWindow);
                }

                eePromControlsGroupBox.AddChild(eePromControlsLayout);
            }

            eePromControlsContainer = new DisableableWidget();
            eePromControlsContainer.AddChild(eePromControlsGroupBox);

            controlsTopToBottomLayout.AddChild(eePromControlsContainer);
        }
示例#16
0
        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 = ActiveTheme.Instance.PrimaryTextColor;
            foreach (OrganizerGroup group in category.GroupsList)
            {
                tabIndexForItem = 0;
                string  groupTabLabel = LocalizedString.Get(group.Name);
                TabPage groupTabPage  = new TabPage(groupTabLabel);
                groupTabPage.HAnchor = HAnchor.ParentLeftRight;

                SimpleTextTabWidget groupTabWidget = new SimpleTextTabWidget(groupTabPage, 14,
                                                                             ActiveTheme.Instance.TabLabelSelected, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes());
                groupTabWidget.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

                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.ParentLeftRight;

                    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   groupBoxLabel = LocalizedString.Get(subGroup.Name);
                        GroupBox groupBox      = new GroupBox(groupBoxLabel);
                        groupBox.TextColor   = ActiveTheme.Instance.PrimaryTextColor;
                        groupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
                        groupBox.AddChild(topToBottomSettings);
                        groupBox.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

                        subGroupLayoutTopToBottom.AddChild(groupBox);
                    }
                }

                if (needToAddSubGroup)
                {
                    SliceSettingListControl scrollOnGroupTab = new SliceSettingListControl();

                    subGroupLayoutTopToBottom.VAnchor = VAnchor.FitToChildren;
                    subGroupLayoutTopToBottom.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

                    //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);
        }
示例#17
0
        public ContainerTest(ControlBase parent) : base(parent)
        {
            GroupBox gb = new GroupBox(parent);

            gb.Text   = "group box";
            gb.Width  = 120;
            gb.Height = 120;
            gb.AddChild(new Button(null)
            {
                Text = "Button"
            });

            Panel panel = new Panel(parent)
            {
                Children =
                {
                    new FlowLayout(null)
                    {
                        Children =
                        {
                            new Label(null)
                            {
                                Text = "A label in a panel"
                            },
                            new Button(null)
                            {
                                Text = "A button in a panel",
                            }
                        },
                        Dock = Dock.Fill
                    }
                },
            };

            panel.SetBounds(130, 130, 150, 150);
            ScrollControl sc = new ScrollControl(parent)
            {
                Children =
                {
                    new Label(null)
                    {
                        Text = "Scroll control"
                    },
                    new Button(null)
                    {
                        X    = 180,
                        Y    = 180,
                        Text = "Scroll to me"
                    },
                    new Button(null)
                    {
                        X    = 180,
                        Y    = 380,
                        Text = "No, scroll to me."
                    },
                }
            };

            sc.SetBounds(0, 300, 200, 200);
            VerticalScrollBar vs = new VerticalScrollBar(sc);

            vs.NudgeAmount         = 30;
            vs.ViewableContentSize = 10;
            vs.ContentSize         = 120;
            vs.Disable();
            vs.Height = 100;
            vs.Y     += 20;
        }
示例#18
0
        private GuiWidget CreatePrintLevelingControlsContainer()
        {
            Button   editButton;
            GroupBox printLevelingControlsContainer = new GroupBox(textImageButtonFactory.GenerateGroupBoxLabelWithEdit(LocalizedString.Get("Automatic Calibration"), out editButton));

            editButton.Click += (sender, e) =>
            {
                if (editLevelingSettingsWindow == null)
                {
                    editLevelingSettingsWindow         = new EditLevelingSettingsWindow();
                    editLevelingSettingsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { editLevelingSettingsWindow = null; };
                }
                else
                {
                    editLevelingSettingsWindow.BringToFront();
                }
            };

            printLevelingControlsContainer.Margin      = new BorderDouble(0);
            printLevelingControlsContainer.TextColor   = ActiveTheme.Instance.PrimaryTextColor;
            printLevelingControlsContainer.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            printLevelingControlsContainer.HAnchor     = Agg.UI.HAnchor.ParentLeftRight;
            printLevelingControlsContainer.Height      = 68;

            {
                FlowLayoutWidget buttonBar = new FlowLayoutWidget();
                buttonBar.HAnchor |= HAnchor.ParentLeftRight;
                buttonBar.VAnchor |= Agg.UI.VAnchor.ParentCenter;
                buttonBar.Margin   = new BorderDouble(0, 0, 0, 0);
                buttonBar.Padding  = new BorderDouble(0);

                this.textImageButtonFactory.FixedHeight = TallButtonHeight;

                Button runPrintLevelingButton = textImageButtonFactory.Generate("Configure".Localize().ToUpper());
                runPrintLevelingButton.Margin  = new BorderDouble(left: 6);
                runPrintLevelingButton.VAnchor = VAnchor.ParentCenter;
                runPrintLevelingButton.Click  += new ButtonBase.ButtonEventHandler(runPrintLeveling_Click);

                Agg.Image.ImageBuffer levelingImage = new Agg.Image.ImageBuffer();
                ImageIO.LoadImageData(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "Icons", "PrintStatusControls", "leveling-24x24.png"), levelingImage);
                if (!ActiveTheme.Instance.IsDarkTheme)
                {
                    InvertLightness.DoInvertLightness(levelingImage);
                }

                ImageWidget levelingIcon = new ImageWidget(levelingImage);
                levelingIcon.Margin = new BorderDouble(right: 6);

                enablePrintLevelingButton         = textImageButtonFactory.Generate("Enable".Localize().ToUpper());
                enablePrintLevelingButton.Margin  = new BorderDouble(left: 6);
                enablePrintLevelingButton.VAnchor = VAnchor.ParentCenter;
                enablePrintLevelingButton.Click  += new ButtonBase.ButtonEventHandler(enablePrintLeveling_Click);

                disablePrintLevelingButton         = textImageButtonFactory.Generate("Disable".Localize().ToUpper());
                disablePrintLevelingButton.Margin  = new BorderDouble(left: 6);
                disablePrintLevelingButton.VAnchor = VAnchor.ParentCenter;
                disablePrintLevelingButton.Click  += new ButtonBase.ButtonEventHandler(disablePrintLeveling_Click);

                CheckBox doLevelingCheckBox = new CheckBox(LocalizedString.Get("Enable Automatic Print Leveling"));
                doLevelingCheckBox.Margin    = new BorderDouble(left: 3);
                doLevelingCheckBox.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                doLevelingCheckBox.VAnchor   = VAnchor.ParentCenter;
                doLevelingCheckBox.Checked   = ActivePrinterProfile.Instance.DoPrintLeveling;

                printLevelingStatusLabel = new TextWidget("");
                printLevelingStatusLabel.AutoExpandBoundsToText = true;
                printLevelingStatusLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                printLevelingStatusLabel.VAnchor   = VAnchor.ParentCenter;

                GuiWidget hSpacer = new GuiWidget();
                hSpacer.HAnchor = HAnchor.ParentLeftRight;

                buttonBar.AddChild(levelingIcon);
                //buttonBar.AddChild(doLevelingCheckBox);
                buttonBar.AddChild(printLevelingStatusLabel);
                buttonBar.AddChild(hSpacer);
                buttonBar.AddChild(enablePrintLevelingButton);
                buttonBar.AddChild(disablePrintLevelingButton);
                buttonBar.AddChild(runPrintLevelingButton);
                doLevelingCheckBox.CheckedStateChanged += (sender, e) =>
                {
                    ActivePrinterProfile.Instance.DoPrintLeveling = doLevelingCheckBox.Checked;
                };
                ActivePrinterProfile.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) =>
                {
                    SetPrintLevelButtonVisiblity();
                }, ref unregisterEvents);

                printLevelingControlsContainer.AddChild(buttonBar);
            }
            SetPrintLevelButtonVisiblity();
            return(printLevelingControlsContainer);
        }
示例#19
0
        public SliceSettingsWidget(UiState uiState)
        {
            int minSettingNameWidth = 220;

            buttonFactory.FixedHeight     = 20;
            buttonFactory.fontSize        = 10;
            buttonFactory.normalFillColor = RGBA_Bytes.White;
            buttonFactory.normalTextColor = RGBA_Bytes.DarkGray;

            showHelpBox         = new CheckBox(0, 0, LocalizedString.Get("Show Help"), textSize: 10);
            showHelpBox.Checked = UserSettings.Instance.get(SliceSettingsShowHelpEntry) == "true";

            showAllDetails         = new CheckBox(0, 0, LocalizedString.Get("Show All Settings"), textSize: 10);
            showAllDetails.Checked = UserSettings.Instance.get(SliceSettingsLevelEntry) == "Advanced";

            FlowLayoutWidget pageTopToBottomLayout = new FlowLayoutWidget(FlowDirection.TopToBottom, vAnchor: Agg.UI.VAnchor.ParentTop);

            pageTopToBottomLayout.AnchorAll();
            pageTopToBottomLayout.Padding = new BorderDouble(3, 0);
            this.AddChild(pageTopToBottomLayout);

            settingsControlBar = new SettingsControlBar();
            pageTopToBottomLayout.AddChild(settingsControlBar);

            noConnectionMessageContainer             = new GroupBox(LocalizedString.Get("No Printer Selected"));
            noConnectionMessageContainer.Margin      = new BorderDouble(top: 10);
            noConnectionMessageContainer.TextColor   = ActiveTheme.Instance.PrimaryTextColor;
            noConnectionMessageContainer.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            noConnectionMessageContainer.HAnchor     = Agg.UI.HAnchor.ParentLeftRight;
            noConnectionMessageContainer.Height      = 80;

            TextWidget noConnectionMessage = new TextWidget(LocalizedString.Get("No printer is currently selected. Select printer to edit slice settings."));

            noConnectionMessage.Margin    = new BorderDouble(5);
            noConnectionMessage.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            noConnectionMessage.VAnchor   = VAnchor.ParentCenter;

            noConnectionMessageContainer.AddChild(noConnectionMessage);
            pageTopToBottomLayout.AddChild(noConnectionMessageContainer);

            categoryTabs = new TabControl();
            categoryTabs.TabBar.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            categoryTabs.Margin             = new BorderDouble(top: 8);
            categoryTabs.AnchorAll();
            List <TabBar> sideTabBarsListForLayout = new List <TabBar>();

            for (int categoryIndex = 0; categoryIndex < SliceSettingsOrganizer.Instance.UserLevels[UserLevel].CategoriesList.Count; categoryIndex++)
            {
                OrganizerCategory   category          = SliceSettingsOrganizer.Instance.UserLevels[UserLevel].CategoriesList[categoryIndex];
                string              categoryPageLabel = LocalizedString.Get(category.Name);
                TabPage             categoryPage      = new TabPage(categoryPageLabel);
                SimpleTextTabWidget textTabWidget     = new SimpleTextTabWidget(categoryPage, 16,
                                                                                ActiveTheme.Instance.TabLabelSelected, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes());
                categoryPage.AnchorAll();
                categoryTabs.AddTab(textTabWidget);

                TabControl sideTabs = CreateSideTabsAndPages(minSettingNameWidth, category, uiState);
                sideTabBarsListForLayout.Add(sideTabs.TabBar);

                categoryPage.AddChild(sideTabs);
            }

            if (showAllDetails.Checked && ActivePrinterProfile.Instance.ActiveSliceEngineType == ActivePrinterProfile.SlicingEngineTypes.Slic3r)
            {
                TabPage             extraSettingsPage          = new TabPage("Other");
                SimpleTextTabWidget extraSettingsTextTabWidget = new SimpleTextTabWidget(extraSettingsPage, 16,
                                                                                         ActiveTheme.Instance.TabLabelSelected, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes());
                extraSettingsPage.AnchorAll();
                int        count;
                TabControl extraSettingsSideTabs = CreateExtraSettingsSideTabsAndPages(minSettingNameWidth, categoryTabs, out count);
                if (count > 0)
                {
                    categoryTabs.AddTab(extraSettingsTextTabWidget);
                    sideTabBarsListForLayout.Add(extraSettingsSideTabs.TabBar);
                    extraSettingsPage.AddChild(extraSettingsSideTabs);
                }
            }

            double sideTabBarsMinimumWidth = 0;

            foreach (TabBar tabBar in sideTabBarsListForLayout)
            {
                sideTabBarsMinimumWidth = Math.Max(sideTabBarsMinimumWidth, tabBar.Width);
            }
            foreach (TabBar tabBar in sideTabBarsListForLayout)
            {
                tabBar.MinimumSize = new Vector2(sideTabBarsMinimumWidth, tabBar.MinimumSize.y);
            }

            // space before checkboxes (hold the right aligned)
            {
                GuiWidget hSpacer = new GuiWidget();
                hSpacer.HAnchor = HAnchor.ParentLeftRight;

                categoryTabs.TabBar.AddChild(hSpacer);
            }

            // add in the ability to turn on and off all details settings
            {
                showAllDetails.TextColor            = ActiveTheme.Instance.PrimaryTextColor;
                showAllDetails.Margin               = new BorderDouble(right: 8);
                showAllDetails.VAnchor              = VAnchor.ParentCenter;
                showAllDetails.Cursor               = Cursors.Hand;
                showAllDetails.CheckedStateChanged += new CheckBox.CheckedStateChangedEventHandler(RebuildSlicerSettings);

                categoryTabs.TabBar.AddChild(showAllDetails);
            }

            // add in the ability to turn on and off help text
            {
                showHelpBox.TextColor            = ActiveTheme.Instance.PrimaryTextColor;
                showHelpBox.Margin               = new BorderDouble(right: 3);
                showHelpBox.VAnchor              = VAnchor.ParentCenter;
                showHelpBox.Cursor               = Cursors.Hand;
                showHelpBox.CheckedStateChanged += new CheckBox.CheckedStateChangedEventHandler(RebuildSlicerSettings);

                categoryTabs.TabBar.AddChild(showHelpBox);
            }

            pageTopToBottomLayout.AddChild(categoryTabs);
            AddHandlers();
            SetVisibleControls();

            if (!categoryTabs.SelectTab(uiState.selectedCategory.name))
            {
                categoryTabs.SelectTab(uiState.selectedCategory.index);
            }
        }
        private void AddAdjustmentControls(FlowLayoutWidget controlsTopToBottomLayout)
        {
            GroupBox adjustmentControlsGroupBox = new GroupBox(new LocalizedString("Tuning Adjustment (while printing)").Translated);

            adjustmentControlsGroupBox.Margin      = new BorderDouble(0);
            adjustmentControlsGroupBox.TextColor   = ActiveTheme.Instance.PrimaryTextColor;
            adjustmentControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            adjustmentControlsGroupBox.HAnchor     = Agg.UI.HAnchor.ParentLeftRight;
            adjustmentControlsGroupBox.Height      = 93;

            {
                FlowLayoutWidget tuningRatiosLayout = new FlowLayoutWidget(FlowDirection.TopToBottom);
                tuningRatiosLayout.Margin = new BorderDouble(0, 0, 0, 6);
                tuningRatiosLayout.AnchorAll();
                tuningRatiosLayout.Padding = new BorderDouble(3, 5, 3, 0);
                TextWidget feedRateDescription;
                {
                    FlowLayoutWidget feedRateLeftToRight;
                    {
                        feedRateValue = new NumberEdit(1, allowDecimals: true, minValue: minFeedRateRatio, maxValue: maxFeedRateRatio, pixelWidth: 40);

                        feedRateLeftToRight = new FlowLayoutWidget();

                        feedRateDescription           = new TextWidget(new LocalizedString("Speed Multiplier").Translated);
                        feedRateDescription.TextColor = RGBA_Bytes.White;
                        feedRateLeftToRight.AddChild(feedRateDescription);
                        feedRateRatioSlider        = new Slider(new Vector2(), 300, minFeedRateRatio, maxFeedRateRatio);
                        feedRateRatioSlider.Margin = new BorderDouble(5, 0);
                        feedRateRatioSlider.Value  = PrinterCommunication.Instance.FeedRateRatio;
                        feedRateRatioSlider.View.BackgroundColor = new RGBA_Bytes();
                        feedRateRatioSlider.ValueChanged        += (sender, e) =>
                        {
                            PrinterCommunication.Instance.FeedRateRatio = feedRateRatioSlider.Value;
                        };
                        PrinterCommunication.Instance.FeedRateRatioChanged.RegisterEvent(FeedRateRatioChanged_Event, ref unregisterEvents);
                        feedRateValue.EditComplete += (sender, e) =>
                        {
                            feedRateRatioSlider.Value = feedRateValue.Value;
                        };
                        feedRateLeftToRight.AddChild(feedRateRatioSlider);
                        tuningRatiosLayout.AddChild(feedRateLeftToRight);

                        feedRateLeftToRight.AddChild(feedRateValue);
                        feedRateValue.Margin = new BorderDouble(0, 0, 5, 0);
                        textImageButtonFactory.FixedHeight = (int)feedRateValue.Height + 1;
                        feedRateLeftToRight.AddChild(textImageButtonFactory.Generate(new LocalizedString("Set").Translated));
                    }

                    TextWidget extrusionDescription;
                    {
                        extrusionValue = new NumberEdit(1, allowDecimals: true, minValue: minExtrutionRatio, maxValue: maxExtrusionRatio, pixelWidth: 40);

                        FlowLayoutWidget leftToRight = new FlowLayoutWidget();

                        extrusionDescription           = new TextWidget(new LocalizedString("Extrusion Multiplier").Translated);
                        extrusionDescription.TextColor = RGBA_Bytes.White;
                        leftToRight.AddChild(extrusionDescription);
                        extrusionRatioSlider        = new Slider(new Vector2(), 300, minExtrutionRatio, maxExtrusionRatio);
                        extrusionRatioSlider.Margin = new BorderDouble(5, 0);
                        extrusionRatioSlider.Value  = PrinterCommunication.Instance.ExtrusionRatio;
                        extrusionRatioSlider.View.BackgroundColor = new RGBA_Bytes();
                        extrusionRatioSlider.ValueChanged        += (sender, e) =>
                        {
                            PrinterCommunication.Instance.ExtrusionRatio = extrusionRatioSlider.Value;
                        };
                        PrinterCommunication.Instance.ExtrusionRatioChanged.RegisterEvent(ExtrusionRatioChanged_Event, ref unregisterEvents);
                        extrusionValue.EditComplete += (sender, e) =>
                        {
                            extrusionRatioSlider.Value = extrusionValue.Value;
                        };
                        leftToRight.AddChild(extrusionRatioSlider);
                        tuningRatiosLayout.AddChild(leftToRight);
                        leftToRight.AddChild(extrusionValue);
                        extrusionValue.Margin = new BorderDouble(0, 0, 5, 0);
                        textImageButtonFactory.FixedHeight = (int)extrusionValue.Height + 1;
                        leftToRight.AddChild(textImageButtonFactory.Generate(new LocalizedString("Set").Translated));
                    }

                    feedRateDescription.Width       = extrusionDescription.Width;
                    feedRateDescription.MinimumSize = new Vector2(extrusionDescription.Width, feedRateDescription.MinimumSize.y);
                    feedRateLeftToRight.HAnchor     = HAnchor.FitToChildren;
                    feedRateLeftToRight.VAnchor     = VAnchor.FitToChildren;
                }

                adjustmentControlsGroupBox.AddChild(tuningRatiosLayout);
            }

            tuningAdjustmentControlsContainer = new DisablablableWidget();
            tuningAdjustmentControlsContainer.AddChild(adjustmentControlsGroupBox);
            controlsTopToBottomLayout.AddChild(tuningAdjustmentControlsContainer);
        }
示例#21
0
        void AddChildElements()
        {
            Button   editButton;
            GroupBox groupBox = new GroupBox(textImageButtonFactory.GenerateGroupBoxLableWithEdit(label, out editButton));

            editButton.Click += (sender, e) =>
            {
                if (editSettingsWindow == null)
                {
                    editSettingsWindow         = new EditTemperaturePresetsWindow(editWindowLabel, GetTemperaturePresets(), SetTemperaturePresets);
                    editSettingsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { editSettingsWindow = null; };
                }
                else
                {
                    editSettingsWindow.BringToFront();
                }
            };

            groupBox.TextColor   = ActiveTheme.Instance.PrimaryTextColor;
            groupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            groupBox.HAnchor    |= Agg.UI.HAnchor.ParentLeftRight;
            // make sure the client area will get smaller when the contents get smaller
            groupBox.ClientArea.VAnchor = Agg.UI.VAnchor.FitToChildren;

            FlowLayoutWidget controlRow = new FlowLayoutWidget(Agg.UI.FlowDirection.TopToBottom);

            controlRow.Margin   = new BorderDouble(top: 5);
            controlRow.HAnchor |= HAnchor.ParentLeftRight;
            {
                // put in the temperature slider and preset buttons

                tempSliderContainer = new FlowLayoutWidget(Agg.UI.FlowDirection.TopToBottom);

                {
                    GuiWidget sliderLabels = GetSliderLabels();

                    tempSliderContainer.HAnchor = HAnchor.ParentLeftRight;
                    tempSliderContainer.AddChild(sliderLabels);
                    tempSliderContainer.Visible = false;
                }
                GuiWidget spacer = new GuiWidget(0, 10);
                spacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;


                // put in the temperature indicators
                {
                    FlowLayoutWidget temperatureIndicator = new FlowLayoutWidget();
                    temperatureIndicator.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
                    temperatureIndicator.Margin  = new BorderDouble(bottom: 6);
                    temperatureIndicator.Padding = new BorderDouble(0, 3);

                    // put in the actual temperature controls
                    {
                        FlowLayoutWidget extruderActualIndicator = new FlowLayoutWidget(Agg.UI.FlowDirection.LeftToRight);

                        extruderActualIndicator.Margin = new BorderDouble(3, 0);
                        string     extruderActualLabelTxt     = new LocalizedString("Actual").Translated;
                        string     extruderActualLabelTxtFull = string.Format("{0}: ", extruderActualLabelTxt);
                        TextWidget extruderActualLabel        = new TextWidget(extruderActualLabelTxtFull, pointSize: 10);
                        extruderActualLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                        extruderActualLabel.VAnchor   = VAnchor.ParentCenter;

                        actualTempIndicator = new TextWidget(string.Format("{0:0.0}°C", GetActualTemperature()), pointSize: 12);
                        actualTempIndicator.AutoExpandBoundsToText = true;
                        actualTempIndicator.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                        actualTempIndicator.VAnchor   = VAnchor.ParentCenter;

                        extruderActualIndicator.AddChild(extruderActualLabel);
                        extruderActualIndicator.AddChild(actualTempIndicator);

                        string extruderAboutLabelTxt     = new LocalizedString("Target").Translated;
                        string extruderAboutLabelTxtFull = string.Format("{0}: ", extruderAboutLabelTxt);

                        TextWidget extruderTargetLabel = new TextWidget(extruderAboutLabelTxtFull, pointSize: 10);
                        extruderTargetLabel.Margin    = new BorderDouble(left: 10);
                        extruderTargetLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                        extruderTargetLabel.VAnchor   = VAnchor.ParentCenter;

                        extruderActualIndicator.AddChild(extruderTargetLabel);
                        temperatureIndicator.AddChild(extruderActualIndicator);
                    }

                    // put in the target temperature controls
                    temperatureIndicator.AddChild(GetTargetTemperatureDisplay());

                    FlowLayoutWidget helperTextWidget = GetHelpTextWidget();


                    GuiWidget hspacer = new GuiWidget();
                    hspacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

                    LinkButtonFactory linkFactory = new LinkButtonFactory();
                    linkFactory.textColor = ActiveTheme.Instance.PrimaryTextColor;
                    linkFactory.fontSize  = 10;

                    Button helpTextLink = linkFactory.Generate("?");

                    helpTextLink.Click += (sender, e) =>
                    {
                        helperTextWidget.Visible = !helperTextWidget.Visible;
                    };

                    //temperatureIndicator.AddChild(hspacer);
                    //temperatureIndicator.AddChild(helpTextLink);

                    this.presetButtonsContainer = GetPresetsContainer();

                    controlRow.AddChild(temperatureIndicator);
                    //controlRow.AddChild(helperTextWidget);
                    controlRow.AddChild(this.presetButtonsContainer);
                    //controlRow.AddChild(tempSliderContainer);
                }
            }

            groupBox.AddChild(controlRow);

            this.AddChild(groupBox);
        }
示例#22
0
		public void GroupBoxResizeThenLayoutBeforeMatchChildren()
		{
			bool integerBounds = GuiWidget.DefaultEnforceIntegerBounds;
			GuiWidget.DefaultEnforceIntegerBounds = true;
			GroupBox groupBox = new GroupBox("group box");
			groupBox.Name = "groupBox";
			GuiWidget contents = new GuiWidget(30, 20);
			contents.Name = "contents";
			contents.MinimumSize = new VectorMath.Vector2(0, 0);

			// make sure the client area will get smaller when the contents get smaller
			groupBox.ClientArea.VAnchor = Agg.UI.VAnchor.FitToChildren;
			groupBox.ClientArea.Name = "groupBox.ClientArea";

			groupBox.AddChild(contents);

			Assert.IsTrue(contents.Height == 20);
			Assert.IsTrue(groupBox.ClientArea.Height == 20);
			Assert.IsTrue(groupBox.Height == 50);
			TextWidget groupBoxLabel = groupBox.Children[0] as TextWidget;
			groupBoxLabel.Name = "groupBoxLabel";
			Assert.IsTrue(groupBoxLabel.BoundsRelativeToParent.Top == groupBox.LocalBounds.Top);
			contents.Height = 10;
			Assert.IsTrue(groupBoxLabel.BoundsRelativeToParent.Top == groupBox.LocalBounds.Top);
			Assert.IsTrue(contents.Height == 10);
			Assert.IsTrue(groupBox.ClientArea.Height == 10);
			Assert.IsTrue(groupBox.Height == 40);

			GuiWidget.DefaultEnforceIntegerBounds = integerBounds;
		}