Пример #1
0
        public GCodeDebugView(PrinterTabPage printerTabPage, GCodeFile gCodeFile, ISceneContext sceneContext, ThemeConfig theme)
            : base(theme)
        {
            this.gCodeFile      = gCodeFile;
            this.printerTabPage = printerTabPage;
            this.sceneContext   = sceneContext;

            gCodeMemoryFile = gCodeFile as GCodeMemoryFile;
            if (gCodeMemoryFile != null)
            {
                rawLine = this.AddSetting("G-Code Line".Localize(), "");
            }

            startPointWidget = this.AddSetting("Start".Localize(), "");
            endPointWidget   = this.AddSetting("End".Localize(), "");
            lengthWidget     = this.AddSetting("Length".Localize(), "");
            //slopeWidget = this.AddSetting("Slope".Localize(), "");
            //yInterceptWidget = this.AddSetting("Y Intercept".Localize(), "");
            //xInterceptWidget = this.AddSetting("X Intercept".Localize(), "");
            if (gCodeMemoryFile != null)
            {
                timeToToolChange = this.AddSetting("Time to Tool Change".Localize(), "");
            }

            // Register listeners
            printerTabPage.LayerFeaturesScrollbar.SecondValueChanged += this.LayerFeaturesScrollbar_SecondValueChanged;
        }
Пример #2
0
        public GCodePanel(PrinterTabPage printerTabPage, PrinterConfig printer, ISceneContext sceneContext, ThemeConfig theme)
            : base(FlowDirection.TopToBottom)
        {
            this.sceneContext   = sceneContext;
            this.theme          = theme;
            this.printer        = printer;
            this.printerTabPage = printerTabPage;

            SectionWidget sectionWidget;

            this.AddChild(
                sectionWidget = new SectionWidget(
                    "Options".Localize(),
                    new GCodeOptionsPanel(sceneContext, printer, theme),
                    theme)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Fit,
                Padding = 0
            });

            sectionWidget.ContentPanel.Descendants <SettingsRow>().First().Border = 0;

            var scrollable = new ScrollableWidget(true)
            {
                Name    = "editorPanel",
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch,
            };

            scrollable.ScrollArea.HAnchor = HAnchor.Stretch;

            scrollable.AddChild(loadedGCodeSection = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Fit
            });

            this.AddChild(scrollable);

            this.RefreshGCodeDetails(printer);

            this.EnsureSectionWidgetStyling(this.Children <SectionWidget>());

            var firstSection = this.Children <SectionWidget>().First();

            firstSection.BorderColor = Color.Transparent;             // Disable top border on first item to produce a more flat, dark top edge

            // Register listeners
            printer.Bed.LoadedGCodeChanged += Bed_LoadedGCodeChanged;
            printer.Bed.RendererOptions.PropertyChanged += RendererOptions_PropertyChanged;
        }
Пример #3
0
        public SliceButton(PrinterConfig printer, PrinterTabPage printerTabPage, ThemeConfig theme)
            : base("Slice".Localize(), theme)
        {
            this.printer        = printer;
            this.printerTabPage = printerTabPage;

            this.BackgroundColor = theme.ToolbarButtonBackground;
            this.HoverColor      = theme.ToolbarButtonHover;
            this.MouseDownColor  = theme.ToolbarButtonDown;

            // Register listeners
            printer.Connection.CommunicationStateChanged += Connection_CommunicationStateChanged;

            SetButtonStates();
        }
Пример #4
0
        public GCodeDebugView(PrinterTabPage printerTabPage, GCodeFile gCodeMemoryFile, ISceneContext sceneContext, ThemeConfig theme)
            : base(theme)
        {
            this.printerTabPage = printerTabPage;
            this.sceneContext   = sceneContext;

            startPointWidget = this.AddSetting("Start".Localize(), "");
            endPointWidget   = this.AddSetting("End".Localize(), "");
            lengthWidget     = this.AddSetting("Length".Localize(), "");
            slopeWidget      = this.AddSetting("Slope".Localize(), "");
            yInterceptWidget = this.AddSetting("Y Intercept".Localize(), "");
            xInterceptWidget = this.AddSetting("X Intercept".Localize(), "");

            // Register listeners
            printerTabPage.LayerFeaturesScrollbar.SecondValueChanged += this.LayerFeaturesScrollbar_SecondValueChanged;
        }
Пример #5
0
        public SliceButton(PrinterConfig printer, PrinterTabPage printerTabPage, ThemeConfig theme)
            : base("Slice".Localize(), theme)
        {
            this.printer        = printer;
            this.printerTabPage = printerTabPage;

            this.BackgroundColor = theme.ToolbarButtonBackground;
            this.HoverColor      = theme.ToolbarButtonHover;
            this.MouseDownColor  = theme.ToolbarButtonDown;

            printer.Connection.CommunicationStateChanged.RegisterEvent((s, e) =>
            {
                UiThread.RunOnIdle(SetButtonStates);
            }, ref unregisterEvents);

            SetButtonStates();
        }
Пример #6
0
        public PrinterActionsBar(PrinterConfig printer, PrinterTabPage printerTabPage, ThemeConfig theme)
            : base(theme)
        {
            this.printer        = printer;
            this.printerTabPage = printerTabPage;

            this.HAnchor = HAnchor.Stretch;
            this.VAnchor = VAnchor.Fit;

            var defaultMargin = theme.ButtonSpacing;

            // add the reset button first (if there is one)
            if (printer.Settings.GetValue <bool>(SettingsKey.show_reset_connection))
            {
                var resetConnectionButton = new TextIconButton(
                    "Reset".Localize(),
                    AggContext.StaticData.LoadIcon("e_stop.png", 14, 14, theme.InvertIcons),
                    theme)
                {
                    ToolTipText = "Reboots the firmware on the controller".Localize(),
                    Margin      = defaultMargin
                };
                resetConnectionButton.Click += (s, e) =>
                {
                    UiThread.RunOnIdle(printer.Connection.RebootBoard);
                };
                this.AddChild(resetConnectionButton);
            }

            this.AddChild(new PrinterConnectButton(printer, theme));

            // add the start print button
            GuiWidget startPrintButton;

            this.AddChild(startPrintButton = new PrintPopupMenu(printer, theme)
            {
                Margin = theme.ButtonSpacing
            });

            void SetPrintButtonStyle(object s, EventArgs e)
            {
                switch (printer.Connection.CommunicationState)
                {
                case CommunicationStates.FinishedPrint:
                case CommunicationStates.Connected:
                    theme.ApplyPrimaryActionStyle(startPrintButton);
                    break;

                default:
                    theme.RemovePrimaryActionStyle(startPrintButton);
                    break;
                }
            }

            // make sure the buttons state is set correctly
            printer.Connection.CommunicationStateChanged += SetPrintButtonStyle;
            startPrintButton.Closed += (s, e) => printer.Connection.CommunicationStateChanged -= SetPrintButtonStyle;

            // and set the style right now
            SetPrintButtonStyle(this, null);

            this.AddChild(new SliceButton(printer, printerTabPage, theme)
            {
                Name   = "Generate Gcode Button",
                Margin = theme.ButtonSpacing,
            });

            // Add vertical separator
            this.AddChild(new ToolbarSeparator(theme)
            {
                VAnchor = VAnchor.Absolute,
                Height  = theme.ButtonHeight,
            });

            var buttonGroupB = new ObservableCollection <GuiWidget>();

            var iconPath = Path.Combine("ViewTransformControls", "model.png");

            modelViewButton = new RadioIconButton(AggContext.StaticData.LoadIcon(iconPath, 16, 16, theme.InvertIcons), theme)
            {
                SiblingRadioButtonList = buttonGroupB,
                Name        = "Model View Button",
                Checked     = printer?.ViewState.ViewMode == PartViewMode.Model || printer == null,
                ToolTipText = "Model View".Localize(),
                Margin      = theme.ButtonSpacing
            };
            modelViewButton.Click += SwitchModes_Click;
            buttonGroupB.Add(modelViewButton);
            AddChild(modelViewButton);

            viewModes.Add(PartViewMode.Model, modelViewButton);

            iconPath       = Path.Combine("ViewTransformControls", "gcode_3d.png");
            layers3DButton = new RadioIconButton(AggContext.StaticData.LoadIcon(iconPath, 16, 16, theme.InvertIcons), theme)
            {
                SiblingRadioButtonList = buttonGroupB,
                Name        = "Layers3D Button",
                Checked     = printer?.ViewState.ViewMode == PartViewMode.Layers3D,
                ToolTipText = "3D Layer View".Localize(),
                Margin      = theme.ButtonSpacing
            };
            layers3DButton.Click += SwitchModes_Click;
            buttonGroupB.Add(layers3DButton);

            viewModes.Add(PartViewMode.Layers3D, layers3DButton);

            if (!UserSettings.Instance.IsTouchScreen)
            {
                this.AddChild(layers3DButton);
            }

            iconPath       = Path.Combine("ViewTransformControls", "gcode_2d.png");
            layers2DButton = new RadioIconButton(AggContext.StaticData.LoadIcon(iconPath, 16, 16, theme.InvertIcons), theme)
            {
                SiblingRadioButtonList = buttonGroupB,
                Name        = "Layers2D Button",
                Checked     = printer?.ViewState.ViewMode == PartViewMode.Layers2D,
                ToolTipText = "2D Layer View".Localize(),
                Margin      = theme.ButtonSpacing,
            };
            layers2DButton.Click += SwitchModes_Click;
            buttonGroupB.Add(layers2DButton);
            this.AddChild(layers2DButton);

            viewModes.Add(PartViewMode.Layers2D, layers2DButton);

            this.AddChild(new HorizontalSpacer());

            int hotendCount = printer.Settings.Helpers.HotendCount();

            if (!printer.Settings.GetValue <bool>(SettingsKey.sla_printer))
            {
                for (int extruderIndex = 0; extruderIndex < hotendCount; extruderIndex++)
                {
                    this.AddChild(new TemperatureWidgetHotend(printer, extruderIndex, theme, hotendCount)
                    {
                        Margin = new BorderDouble(right: 10)
                    });
                }
            }

            if (printer.Settings.GetValue <bool>(SettingsKey.has_heated_bed))
            {
                this.AddChild(new TemperatureWidgetBed(printer, theme));
            }

            this.OverflowButton.Name = "Printer Overflow Menu";
            this.ExtendOverflowMenu  = (popupMenu) =>
            {
                this.GeneratePrinterOverflowMenu(popupMenu, ApplicationController.Instance.MenuTheme);
            };

            printer.ViewState.ViewModeChanged += (s, e) =>
            {
                if (viewModes[e.ViewMode] is RadioIconButton activeButton &&
                    viewModes[e.PreviousMode] is RadioIconButton previousButton &&
                    !buttonIsBeingClicked)
                {
                    // Show slide to animation from previous to current, on completion update view to current by setting active.Checked
                    previousButton.SlideToNewState(
                        activeButton,
                        this,
                        () =>
                    {
                        activeButton.Checked = true;
                    },
                        theme);
                }
            };

            // Register listeners
            printer.Connection.ConnectionSucceeded += CheckForPrintRecovery;

            // if we are already connected than check if there is a print recovery right now
            if (printer.Connection.CommunicationState == CommunicationStates.Connected)
            {
                CheckForPrintRecovery(null, null);
            }
        }
Пример #7
0
        public PrinterActionsBar(PrinterConfig printer, PrinterTabPage printerTabPage, ThemeConfig theme)
            : base(theme)
        {
            this.printer        = printer;
            this.printerTabPage = printerTabPage;

            this.HAnchor = HAnchor.Stretch;
            this.VAnchor = VAnchor.Fit;

            var defaultMargin = theme.ButtonSpacing;

            // add the reset button first (if there is one)
            if (printer.Settings.GetValue <bool>(SettingsKey.show_reset_connection))
            {
                var resetConnectionButton = new TextIconButton(
                    "Reset".Localize(),
                    AggContext.StaticData.LoadIcon("e_stop.png", 14, 14, theme.InvertIcons),
                    theme)
                {
                    ToolTipText = "Reboots the firmware on the controller".Localize(),
                    Margin      = defaultMargin
                };
                resetConnectionButton.Click += (s, e) =>
                {
                    UiThread.RunOnIdle(printer.Connection.RebootBoard);
                };
                this.AddChild(resetConnectionButton);
            }

            this.AddChild(new PrinterConnectButton(printer, theme));
            this.AddChild(new PrintButton(printer, theme));

            this.AddChild(new SliceButton(printer, printerTabPage, theme)
            {
                Name   = "Generate Gcode Button",
                Margin = theme.ButtonSpacing,
            });

            // Add vertical separator
            this.AddChild(new ToolbarSeparator(theme)
            {
                VAnchor = VAnchor.Absolute,
                Height  = theme.ButtonHeight,
            });

            var buttonGroupB = new ObservableCollection <GuiWidget>();

            var iconPath = Path.Combine("ViewTransformControls", "model.png");

            modelViewButton = new RadioIconButton(AggContext.StaticData.LoadIcon(iconPath, 16, 16, theme.InvertIcons), theme)
            {
                SiblingRadioButtonList = buttonGroupB,
                Name        = "Model View Button",
                Checked     = printer?.ViewState.ViewMode == PartViewMode.Model || printer == null,
                ToolTipText = "Model View".Localize(),
                Margin      = theme.ButtonSpacing
            };
            modelViewButton.Click += SwitchModes_Click;
            buttonGroupB.Add(modelViewButton);
            AddChild(modelViewButton);

            iconPath       = Path.Combine("ViewTransformControls", "gcode_3d.png");
            layers3DButton = new RadioIconButton(AggContext.StaticData.LoadIcon(iconPath, 16, 16, theme.InvertIcons), theme)
            {
                SiblingRadioButtonList = buttonGroupB,
                Name        = "Layers3D Button",
                Checked     = printer?.ViewState.ViewMode == PartViewMode.Layers3D,
                ToolTipText = "3D Layer View".Localize(),
                Margin      = theme.ButtonSpacing
            };
            layers3DButton.Click += SwitchModes_Click;
            buttonGroupB.Add(layers3DButton);

            if (!UserSettings.Instance.IsTouchScreen)
            {
                this.AddChild(layers3DButton);
            }

            iconPath       = Path.Combine("ViewTransformControls", "gcode_2d.png");
            layers2DButton = new RadioIconButton(AggContext.StaticData.LoadIcon(iconPath, 16, 16, theme.InvertIcons), theme)
            {
                SiblingRadioButtonList = buttonGroupB,
                Name        = "Layers2D Button",
                Checked     = printer?.ViewState.ViewMode == PartViewMode.Layers2D,
                ToolTipText = "2D Layer View".Localize(),
                Margin      = theme.ButtonSpacing,
            };
            layers2DButton.Click += SwitchModes_Click;
            buttonGroupB.Add(layers2DButton);
            this.AddChild(layers2DButton);

            this.AddChild(new HorizontalSpacer());

            bool shareTemp     = printer.Settings.GetValue <bool>(SettingsKey.extruders_share_temperature);
            int  extruderCount = shareTemp ? 1 : printer.Settings.GetValue <int>(SettingsKey.extruder_count);

            if (!printer.Settings.GetValue <bool>(SettingsKey.sla_printer))
            {
                for (int extruderIndex = 0; extruderIndex < extruderCount; extruderIndex++)
                {
                    this.AddChild(new TemperatureWidgetHotend(printer, extruderIndex, theme)
                    {
                        Margin = new BorderDouble(right: 10)
                    });
                }
            }

            if (printer.Settings.GetValue <bool>(SettingsKey.has_heated_bed))
            {
                this.AddChild(new TemperatureWidgetBed(printer, theme));
            }

            this.OverflowButton.Name = "Printer Overflow Menu";
            this.ExtendOverflowMenu  = (popupMenu) =>
            {
                this.GeneratePrinterOverflowMenu(popupMenu, ApplicationController.Instance.MenuTheme);
            };

            printer.ViewState.ViewModeChanged += (s, e) =>
            {
                RadioIconButton activeButton = null;
                if (e.ViewMode == PartViewMode.Layers2D)
                {
                    activeButton = layers2DButton;
                }
                else if (e.ViewMode == PartViewMode.Layers3D)
                {
                    activeButton = layers3DButton;
                }
                else
                {
                    activeButton = modelViewButton;
                }

                if (activeButton != null)
                {
                    activeButton.Checked = true;

                    if (!buttonIsBeingClicked)
                    {
                        activeButton.FlashBackground(theme.Colors.PrimaryAccentColor.WithContrast(theme.Colors.PrimaryTextColor, 6).ToColor());
                    }
                }
            };

            printer.Connection.ConnectionSucceeded.RegisterEvent((s, e) =>
            {
                UiThread.RunOnIdle(() =>
                {
                    PrintRecovery.CheckIfNeedToRecoverPrint(printer);
                });
            }, ref unregisterEvents);
        }