Beispiel #1
0
        void configureEePromButton_Click(object sender, EventArgs mouseEvent)
        {
            UiThread.RunOnIdle((state) =>
            {
#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 (PrinterConnectionAndCommunication.Instance.FirmwareType)
                {
                case PrinterConnectionAndCommunication.FirmwareTypes.Repetier:
                    if (openEePromRepetierWidget != null)
                    {
                        openEePromRepetierWidget.BringToFront();
                    }
                    else
                    {
                        openEePromRepetierWidget         = new EePromRepetierWidget();
                        openEePromRepetierWidget.Closed += (RepetierWidget, RepetierEvent) =>
                        {
                            openEePromRepetierWidget = null;
                        };
                    }
                    break;

                case PrinterConnectionAndCommunication.FirmwareTypes.Marlin:
                    if (openEePromMarlinWidget != null)
                    {
                        openEePromMarlinWidget.BringToFront();
                    }
                    else
                    {
                        openEePromMarlinWidget         = new EePromMarlinWidget();
                        openEePromMarlinWidget.Closed += (marlinWidget, marlinEvent) =>
                        {
                            openEePromMarlinWidget = null;
                        };
                    }
                    break;

                default:
                    StyledMessageBox.ShowMessageBox(null, noEepromMappingMessage, noEepromMappingTitle, StyledMessageBox.MessageType.OK);
                    break;
                }
#endif
            });
        }
        private void AddEePromControls(FlowLayoutWidget controlsTopToBottomLayout)
        {
            AltGroupBox eePromControlsGroupBox = new AltGroupBox(groupBoxTitle);

            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 (PrinterConnectionAndCommunication.Instance.FirmwareType)
                        {
                        case PrinterConnectionAndCommunication.FirmwareTypes.Repetier:
                            if (openEePromRepetierWidget != null)
                            {
                                openEePromRepetierWidget.BringToFront();
                            }
                            else
                            {
                                openEePromRepetierWidget         = new EePromRepetierWidget();
                                openEePromRepetierWidget.Closed += (RepetierWidget, RepetierEvent) =>
                                {
                                    openEePromRepetierWidget = null;
                                };
                            }
                            break;

                        case PrinterConnectionAndCommunication.FirmwareTypes.Marlin:
                            if (openEePromMarlinWidget != null)
                            {
                                openEePromMarlinWidget.BringToFront();
                            }
                            else
                            {
                                openEePromMarlinWidget         = new EePromMarlinWidget();
                                openEePromMarlinWidget.Closed += (marlinWidget, marlinEvent) =>
                                {
                                    openEePromMarlinWidget = null;
                                };
                            }
                            break;

                        default:
                            UiThread.RunOnIdle((state) =>
                            {
                                StyledMessageBox.ShowMessageBox(null, noEepromMappingMessage, noEepromMappingTitle, StyledMessageBox.MessageType.OK);
                            }
                                               );
                            break;
                        }
#endif
                    };
                    //eePromControlsLayout.AddChild(eePromIcon);
                    eePromControlsLayout.AddChild(openEePromWindow);
                }

                eePromControlsGroupBox.AddChild(eePromControlsLayout);
            }

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

            controlsTopToBottomLayout.AddChild(eePromControlsContainer);
        }