Ejemplo n.º 1
0
        public ThemePreviewButton(IThemeColors theme, bool isActive)
        {
            this.Padding         = 8;
            this.BackgroundColor = theme.PrimaryBackgroundColor;
            this.Cursor          = Cursors.Hand;

            secondaryBackground = new GuiWidget()
            {
                HAnchor         = HAnchor.Absolute | HAnchor.Left,
                VAnchor         = VAnchor.Stretch,
                Margin          = new BorderDouble(0),
                Width           = 20,
                BackgroundColor = theme.SecondaryBackgroundColor,
            };
            this.AddChild(secondaryBackground);

            accentColor = new GuiWidget()
            {
                HAnchor         = HAnchor.Stretch,
                VAnchor         = VAnchor.Absolute | VAnchor.Top,
                Height          = 6,
                Margin          = new BorderDouble(left: 25),
                BackgroundColor = theme.PrimaryAccentColor,
            };
            this.AddChild(accentColor);

            icon1 = new GuiWidget()
            {
                HAnchor         = HAnchor.Absolute | HAnchor.Left,
                VAnchor         = VAnchor.Absolute | VAnchor.Top,
                Height          = 8,
                Width           = 8,
                Margin          = new BorderDouble(left: 6, top: 6),
                BackgroundColor = theme.PrimaryAccentColor,
            };
            this.AddChild(icon1);

            icon2 = new GuiWidget()
            {
                HAnchor         = HAnchor.Absolute | HAnchor.Left,
                VAnchor         = VAnchor.Absolute | VAnchor.Top,
                Height          = 8,
                Width           = 8,
                Margin          = new BorderDouble(left: 6, top: 20),
                BackgroundColor = theme.PrimaryAccentColor,
            };
            this.AddChild(icon2);

            icon3 = new GuiWidget()
            {
                HAnchor         = HAnchor.Absolute | HAnchor.Left,
                VAnchor         = VAnchor.Absolute | VAnchor.Top,
                Height          = 8,
                Width           = 8,
                Margin          = new BorderDouble(left: 6, top: 34),
                BackgroundColor = theme.PrimaryAccentColor,
            };
            this.AddChild(icon3);

            tertiaryBackground = new GuiWidget()
            {
                HAnchor         = HAnchor.Stretch,
                VAnchor         = VAnchor.Absolute | VAnchor.Top,
                Height          = 37,
                Margin          = new BorderDouble(left: 25, top: 12),
                BackgroundColor = theme.TertiaryBackgroundColor,
            };
            this.AddChild(tertiaryBackground);

            if (isActive)
            {
                this.AddChild(new ImageWidget(AggContext.StaticData.LoadIcon("426.png", 16, 16, invertImage: true))
                {
                    HAnchor = HAnchor.Absolute,
                    VAnchor = VAnchor.Absolute,
                    OriginRelativeParent = new Vector2(45, 20)
                });
            }

            var overlay = new GuiWidget();

            overlay.AnchorAll();
            overlay.Cursor = Cursors.Hand;
            overlay.Click += (s, e) =>
            {
                ThemeColorSelectorWidget.SetTheme(this.themeName);
            };

            this.AddChild(overlay);
        }
Ejemplo n.º 2
0
 public override void OnClick(MouseEventArgs mouseEvent)
 {
     ThemeColorSelectorWidget.SetTheme(this.themeName);
     base.OnClick(mouseEvent);
 }