Beispiel #1
0
        internal ControlContentExtruder(PrinterConfig printer, int extruderIndex, ThemeConfig theme)
            : base(FlowDirection.TopToBottom)
        {
            this.HAnchor = HAnchor.Stretch;
            this.printer = printer;

            GuiWidget macroButtons = null;

            // We do not yet support loading filament into extruders other than 0, fix it when time.
            if (extruderIndex == 0)
            {
                // add in load and unload buttons
                macroButtons = new FlowLayoutWidget()
                {
                    Padding = theme.ToolbarPadding,
                };

                var loadFilament = new GCodeMacro()
                {
                    GCode = AggContext.StaticData.ReadAllText(Path.Combine("SliceSettings", "load_filament.txt"))
                };

                var loadButton = new TextButton("Load".Localize(), theme)
                {
                    BackgroundColor = theme.SlightShade,
                    Margin          = theme.ButtonSpacing,
                    ToolTipText     = "Load filament".Localize()
                };
                loadButton.Name   = "Load Filament Button";
                loadButton.Click += (s, e) => loadFilament.Run(printer.Connection);
                macroButtons.AddChild(loadButton);

                var unloadFilament = new GCodeMacro()
                {
                    GCode = AggContext.StaticData.ReadAllText(Path.Combine("SliceSettings", "unload_filament.txt"))
                };

                var unloadButton = new TextButton("Unload".Localize(), theme)
                {
                    BackgroundColor = theme.SlightShade,
                    Margin          = theme.ButtonSpacing,
                    ToolTipText     = "Unload filament".Localize()
                };
                unloadButton.Click += (s, e) => unloadFilament.Run(printer.Connection);
                macroButtons.AddChild(unloadButton);

                this.AddChild(new SettingsItem("Filament".Localize(), macroButtons, theme, enforceGutter: false));
            }

            // Add the Extrude buttons
            var buttonContainer = new FlowLayoutWidget()
            {
                HAnchor = HAnchor.Fit,
                VAnchor = VAnchor.Fit,
                Padding = theme.ToolbarPadding,
            };

            var retractButton = new TextButton("Retract".Localize(), theme)
            {
                BackgroundColor = theme.SlightShade,
                Margin          = theme.ButtonSpacing,
                ToolTipText     = "Retract filament".Localize()
            };

            retractButton.Click += (s, e) =>
            {
                printer.Connection.MoveExtruderRelative(moveAmount * -1, printer.Settings.EFeedRate(extruderIndex), extruderIndex);
            };
            buttonContainer.AddChild(retractButton);

            int extruderButtonTopMargin = macroButtons == null ? 8 : 0;

            var extrudeButton = new TextButton("Extrude".Localize(), theme)
            {
                BackgroundColor = theme.SlightShade,
                Margin          = theme.ButtonSpacing,
                Name            = "Extrude Button",
                ToolTipText     = "Extrude filament".Localize()
            };

            extrudeButton.Click += (s, e) =>
            {
                printer.Connection.MoveExtruderRelative(moveAmount, printer.Settings.EFeedRate(extruderIndex), extruderIndex);
            };
            buttonContainer.AddChild(extrudeButton);

            this.AddChild(new SettingsItem(
                              macroButtons == null ? "Filament".Localize() : "",   // Don't put the name if we put in a macro button (it has the name)
                              buttonContainer,
                              theme,
                              enforceGutter: false));

            var moveButtonsContainer = new FlowLayoutWidget()
            {
                VAnchor = VAnchor.Fit | VAnchor.Center,
                HAnchor = HAnchor.Fit,
                Padding = theme.ToolbarPadding,
            };

            var oneButton = theme.CreateMicroRadioButton("1");

            oneButton.CheckedStateChanged += (s, e) =>
            {
                if (oneButton.Checked)
                {
                    moveAmount = 1;
                }
            };
            moveButtonsContainer.AddChild(oneButton);

            var tenButton = theme.CreateMicroRadioButton("10");

            tenButton.CheckedStateChanged += (s, e) =>
            {
                if (tenButton.Checked)
                {
                    moveAmount = 10;
                }
            };
            moveButtonsContainer.AddChild(tenButton);

            var oneHundredButton = theme.CreateMicroRadioButton("100");

            oneHundredButton.CheckedStateChanged += (s, e) =>
            {
                if (oneHundredButton.Checked)
                {
                    moveAmount = 100;
                }
            };
            moveButtonsContainer.AddChild(oneHundredButton);

            switch (moveAmount)
            {
            case 1:
                oneButton.Checked = true;
                break;

            case 10:
                tenButton.Checked = true;
                break;

            case 100:
                oneHundredButton.Checked = true;
                break;
            }

            moveButtonsContainer.AddChild(new TextWidget("mm", textColor: theme.Colors.PrimaryTextColor, pointSize: 8)
            {
                VAnchor = VAnchor.Center,
                Margin  = new BorderDouble(3, 0)
            });

            this.AddChild(new SettingsItem("Distance".Localize(), moveButtonsContainer, theme, enforceGutter: false));
        }
        internal ControlContentExtruder(PrinterConfig printer, int extruderIndex, ThemeConfig theme)
            : base(FlowDirection.TopToBottom)
        {
            this.HAnchor = HAnchor.Stretch;
            this.printer = printer;

            GuiWidget loadUnloadButtonRow = null;

            // We do not yet support loading filament into extruders other than 0 & 1, fix it when needed.
            if (extruderIndex < 2)
            {
                // add in load and unload buttons
                loadUnloadButtonRow = new FlowLayoutWidget()
                {
                    Padding = theme.ToolbarPadding,
                };

                var loadButton = theme.CreateDialogButton("Load".Localize());
                loadButton.ToolTipText = "Load filament".Localize();
                loadButton.Name        = "Load Filament Button";
                loadButton.Click      += (s, e) => UiThread.RunOnIdle(() =>
                {
                    DialogWindow.Show(
                        new LoadFilamentWizard(printer, extruderIndex, showAlreadyLoadedButton: false));
                });

                loadUnloadButtonRow.AddChild(loadButton);

                var unloadButton = theme.CreateDialogButton("Unload".Localize());
                unloadButton.ToolTipText = "Unload filament".Localize();
                unloadButton.Click      += (s, e) => UiThread.RunOnIdle(() =>
                {
                    DialogWindow.Show(new UnloadFilamentWizard(printer, extruderIndex));
                });
                loadUnloadButtonRow.AddChild(unloadButton);

                this.AddChild(new SettingsItem("Filament".Localize(), loadUnloadButtonRow, theme, enforceGutter: false));
            }

            // Add the Extrude buttons
            var extrudeRetractButtonRow = new FlowLayoutWidget()
            {
                HAnchor = HAnchor.Fit,
                VAnchor = VAnchor.Fit,
                Padding = theme.ToolbarPadding,
            };

            int extruderButtonTopMargin = loadUnloadButtonRow == null ? 8 : 0;

            var extrudeButton = theme.CreateDialogButton("Extrude".Localize());

            extrudeButton.Name        = "Extrude Button";
            extrudeButton.ToolTipText = "Extrude filament".Localize();
            extrudeButton.Click      += (s, e) =>
            {
                printer.Connection.MoveExtruderRelative(moveAmount, printer.Settings.EFeedRate(extruderIndex), extruderIndex);
            };
            extrudeRetractButtonRow.AddChild(extrudeButton);

            var retractButton = theme.CreateDialogButton("Retract".Localize());

            retractButton.ToolTipText = "Retract filament".Localize();
            retractButton.Click      += (s, e) =>
            {
                printer.Connection.MoveExtruderRelative(moveAmount * -1, printer.Settings.EFeedRate(extruderIndex), extruderIndex);
            };
            extrudeRetractButtonRow.AddChild(retractButton);

            this.AddChild(new SettingsItem(
                              loadUnloadButtonRow == null ? "Filament".Localize() : "",   // Don't put the name if we put in a load and unload button (it has the name)
                              extrudeRetractButtonRow,
                              theme,
                              enforceGutter: false));

            var moveButtonsContainer = new FlowLayoutWidget()
            {
                VAnchor = VAnchor.Fit | VAnchor.Center,
                HAnchor = HAnchor.Fit,
                Padding = theme.ToolbarPadding,
            };

            var oneButton = theme.CreateMicroRadioButton("1");

            oneButton.CheckedStateChanged += (s, e) =>
            {
                if (oneButton.Checked)
                {
                    moveAmount = 1;
                }
            };
            moveButtonsContainer.AddChild(oneButton);

            var tenButton = theme.CreateMicroRadioButton("10");

            tenButton.CheckedStateChanged += (s, e) =>
            {
                if (tenButton.Checked)
                {
                    moveAmount = 10;
                }
            };
            moveButtonsContainer.AddChild(tenButton);

            var oneHundredButton = theme.CreateMicroRadioButton("100");

            oneHundredButton.CheckedStateChanged += (s, e) =>
            {
                if (oneHundredButton.Checked)
                {
                    moveAmount = 100;
                }
            };
            moveButtonsContainer.AddChild(oneHundredButton);

            switch (moveAmount)
            {
            case 1:
                oneButton.Checked = true;
                break;

            case 10:
                tenButton.Checked = true;
                break;

            case 100:
                oneHundredButton.Checked = true;
                break;
            }

            moveButtonsContainer.AddChild(new TextWidget("mm", textColor: theme.TextColor, pointSize: 8)
            {
                VAnchor = VAnchor.Center,
                Margin  = new BorderDouble(3, 0)
            });

            this.AddChild(new SettingsItem("Distance".Localize(), moveButtonsContainer, theme, enforceGutter: false));
        }