Ejemplo n.º 1
0
        public ItemMaterialButton(PrinterConfig printer, ThemeConfig theme, int initialMaterialIndex)
        {
            this.currentIndex = initialMaterialIndex;
            this.ToolTipText  = "Material".Localize();
            var scaledButtonSize = 24 * GuiWidget.DeviceScale;

            Width  = 30 * GuiWidget.DeviceScale;
            Height = 30 * GuiWidget.DeviceScale;

            var menuTheme = AppContext.MenuTheme;

            this.Name = "ItemMaterialButton";

            this.DynamicPopupContent = () =>
            {
                var materialControl = new MaterialControls(printer, menuTheme, currentIndex)
                {
                    Padding         = theme.DefaultContainerPadding,
                    BackgroundColor = menuTheme.BackgroundColor,
                    HAnchor         = HAnchor.Fit,
                    VAnchor         = VAnchor.Fit,
                };

                materialControl.IndexChanged += (s, e) =>
                {
                    currentIndex = e;
                    MaterialChanged?.Invoke(this, e);
                    materialColorButton.BackgroundColor = MaterialRendering.Color(printer, currentIndex, theme.BorderColor);
                };

                return(materialControl);
            };

            materialColorButton = new ColorButton(MaterialRendering.Color(printer, currentIndex, theme.BorderColor))
            {
                Width                  = scaledButtonSize,
                Height                 = scaledButtonSize,
                BackgroundRadius       = scaledButtonSize / 2,
                BackgroundOutlineWidth = 1,
                HAnchor                = HAnchor.Center,
                VAnchor                = VAnchor.Center,
                DisabledColor          = theme.MinimalShade,
                BorderColor            = theme.TextColor,
                Selectable             = false,
            };

            this.AddChild(materialColorButton);
        }
Ejemplo n.º 2
0
        public ItemMaterialButton(ThemeConfig theme, int initialMaterialIndex)
        {
            this.ToolTipText = "Material".Localize();
            var scaledButtonSize = 14 * GuiWidget.DeviceScale;

            Width  = 30 * GuiWidget.DeviceScale;
            Height = 30 * GuiWidget.DeviceScale;

            this.DynamicPopupContent = () =>
            {
                var materialControl = new MaterialControls(theme, initialMaterialIndex)
                {
                    Padding         = theme.DefaultContainerPadding,
                    BackgroundColor = this.HoverColor,
                    HAnchor         = HAnchor.Fit,
                    VAnchor         = VAnchor.Fit,
                };

                materialControl.IndexChanged += (s, e) =>
                {
                    MaterialChanged?.Invoke(this, e);
                };

                return(materialControl);
            };

            materialColorButton = new ColorButton(MaterialRendering.Color(initialMaterialIndex, theme.BorderColor))
            {
                Width         = scaledButtonSize,
                Height        = scaledButtonSize,
                HAnchor       = HAnchor.Center,
                VAnchor       = VAnchor.Center,
                DrawGrid      = true,
                DisabledColor = theme.MinimalShade,
                Selectable    = false,
            };

            this.AddChild(materialColorButton);
        }