Example #1
0
        private FlowLayoutWidget GetMacroButtonContainer()
        {
            FlowLayoutWidget macroButtonContainer = new FlowLayoutWidget();

            macroButtonContainer.Margin  = new BorderDouble(3, 0);
            macroButtonContainer.Padding = new BorderDouble(3);

            if (ActiveSliceSettings.Instance?.Macros == null)
            {
                return(macroButtonContainer);
            }

            int buttonCount = 0;

            foreach (GCodeMacro macro in ActiveSliceSettings.Instance.Macros)
            {
                buttonCount++;

                Button macroButton = textImageButtonFactory.Generate(MacroControls.FixMacroName(macro.Name));
                macroButton.Text   = macro.GCode;
                macroButton.Margin = new BorderDouble(right: 5);
                macroButton.Click += (s, e) => SendCommandToPrinter(macroButton.Text);

                macroButtonContainer.AddChild(macroButton);
            }

            if (buttonCount == 0)
            {
                TextWidget noMacrosFound = new TextWidget(LocalizedString.Get("No macros are currently set up for this printer."), pointSize: 10);
                noMacrosFound.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                macroButtonContainer.AddChild(noMacrosFound);
            }

            return(macroButtonContainer);
        }
        public static SectionWidget CreateSection(PrinterConfig printer, ThemeConfig theme)
        {
            var widget = new MacroControls(printer, theme);

            var editButton = new IconButton(AggContext.StaticData.LoadIcon("icon_edit.png", 16, 16, theme.InvertIcons), theme);

            editButton.Click += (s, e) =>
            {
                DialogWindow.Show(new MacroListPage(printer.Settings));
            };

            return(new SectionWidget(
                       "Macros".Localize(),
                       widget,
                       theme,
                       editButton));
        }