Exemplo n.º 1
0
        public ThemePreviewButton(ThemeConfig theme, ThemeColorPanel themeColorPanel)
        {
            this.theme  = theme;
            activeColor = theme.Colors.SourceColor;

            var primaryAccentColor = theme.Colors.PrimaryAccentColor;

            this.Padding         = 8;
            this.BackgroundColor = theme.ActiveTabColor;
            this.Cursor          = Cursors.Hand;

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

            accentColor = new GuiWidget()
            {
                HAnchor         = HAnchor.Stretch,
                VAnchor         = VAnchor.Absolute | VAnchor.Top,
                Height          = 6,
                Margin          = new BorderDouble(left: 25),
                BackgroundColor = 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 = 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 = 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 = 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.SlightShade,
            };
            this.AddChild(tertiaryBackground);

            this.AddChild(activeIcon = new ImageWidget(themeColorPanel.CheckMark)
            {
                HAnchor = HAnchor.Absolute,
                VAnchor = VAnchor.Absolute,
                OriginRelativeParent = new Vector2(45, 20),
                Visible = false
            });

            var overlay = new GuiWidget
            {
                VAnchor = VAnchor.Stretch,
                HAnchor = HAnchor.Stretch,
                Cursor  = Cursors.Hand
            };

            overlay.Click += (s, e) =>
            {
                UserSettings.Instance.set(UserSettingsKey.ThemeMode, this.Mode);

                // Activate the theme
                themeColorPanel.SetThemeColor(activeColor, this.Mode);
            };

            this.AddChild(overlay);
        }
Exemplo n.º 2
0
        public ThemePreviewButton(ThemeSet themeSet, ThemeColorPanel themeColorPanel)
        {
            this.ThemeSet = themeSet;

            var theme = themeSet.Theme;

            var primaryAccentColor = theme.PrimaryAccentColor;

            this.Padding         = 8;
            this.BackgroundColor = theme.BackgroundColor;
            this.Cursor          = Cursors.Hand;

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

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

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

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

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

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

            var overlay = new GuiWidget
            {
                VAnchor = VAnchor.Stretch,
                HAnchor = HAnchor.Stretch,
                Cursor  = Cursors.Hand
            };

            overlay.Click += (s, e) =>
            {
                // Activate the theme
                themeColorPanel.SetThemeColor(this.ThemeSet, primaryAccentColor, this.Mode);

                // Disable further theme clicks until reload completes
                themeColorPanel.Enabled = false;
            };

            this.AddChild(overlay);
        }