public static void LoadUITheme()
        {
            //Load the default theme by index
            if (string.IsNullOrEmpty(UserSettings.Instance.get("ActiveThemeIndex")))
            {
                for (int i = 0; i < ActiveTheme.AvailableThemes.Count; i++)
                {
                    IThemeColors current = ActiveTheme.AvailableThemes[i];
                    if (current.Name == OemSettings.Instance.ThemeColor)
                    {
                        UserSettings.Instance.set("ActiveThemeIndex", i.ToString());
                        break;
                    }
                }
            }

            int themeIndex;

            if (int.TryParse(UserSettings.Instance.get("ActiveThemeIndex"), out themeIndex) && themeIndex < ActiveTheme.AvailableThemes.Count)
            {
                try
                {
                    ActiveTheme.Instance = ActiveTheme.AvailableThemes[themeIndex];
                }
                catch
                {
                    GuiWidget.BreakInDebugger();
                }
            }
        }
Example #2
0
        private Style GetCheckBoxStyle(IThemeColors colors)
        {
            var template = TemplateExtensions.Create <Border>()
                           .TemplateBinding(Control.BackgroundProperty, Control.BackgroundProperty)
                           .TemplateBinding(Control.BorderBrushProperty, Control.BorderThicknessProperty)
                           .TemplateBinding(Control.BorderThicknessProperty, Control.BorderThicknessProperty)
                           .Contains <StackPanel>()
                           .Set(StackPanel.OrientationProperty, Orientation.Horizontal)
                           .Contains(TemplateExtensions.Create <Ellipse>()
                                     .Size(8, 8)
                                     .TemplateBinding(Shape.FillProperty, Control.ForegroundProperty))
                           .Contains(TemplateExtensions.Create <ContentPresenter>()
                                     .Center())
                           .AsControlTemplate <CheckBox>();

            return(StyleExtensions.Create()
                   .Set(Control.ForegroundProperty, colors.Text.Normal)
                   .When(TriggerExtensions.Property(ToggleButton.IsCheckedProperty)
                         .Is(true)
                         .Then(Control.FontWeightProperty, FontWeights.Bold)
                         .Then(Control.ForegroundProperty, colors.Control.Selected))
                   .When(TriggerExtensions.Property(UIElement.IsMouseOverProperty)
                         .Is(true)
                         .Then(Control.BackgroundProperty, colors.Control.Over))
                   .When(TriggerExtensions.Property(FrameworkElement.TagProperty)
                         .Is("test")
                         .Then(ContentControl.ContentProperty, null))
                   .Template(template)
                   .AsStyle <CheckBox>());
        }
Example #3
0
 private Style GetTextBlockStyle(IThemeColors colors)
 {
     return(StyleExtensions.Create()
            .Set(Control.FontSizeProperty, 16d)
            .Set(Control.ForegroundProperty, colors.Text.Normal)
            .AsStyle <TextBlock>());
 }
Example #4
0
        public override IEnumerable <Style> GetDefaultStyles(IThemeColors themeColors)
        {
            yield return(this.GetWindowStyle(themeColors));

            yield return(this.GetButtonStyle(themeColors));

            yield return(this.GetCheckBoxStyle(themeColors));

            yield return(this.GetHeaderContentControlStyle(themeColors));

            yield return(this.GetExpanderStyle(themeColors));

            yield return(this.GetToggleButtonStyle(themeColors));

            yield return(this.GetTabControlStyle(themeColors));

            yield return(this.GetListBoxStyle(themeColors));

            yield return(this.GetTextBlockStyle(themeColors));

            yield return(this.GetListBoxItemStyle(themeColors));

            yield return(this.GetMenuItemStyle(themeColors));

            yield return(this.GetContextMenuStyle(themeColors));
        }
Example #5
0
        private Style GetExpanderStyle(IThemeColors colors)
        {
            if (HambergerMenu == null)
            {
                var hambergerTemplate = TemplateExtensions.Create <StackPanel>()
                                        .Contains(TemplateExtensions.Create <DockPanel>()
                                                  .Set(Control.BackgroundProperty, colors.Control.Normal)
                                                  .Contains(TemplateExtensions.Create <ToggleButton>()
                                                            .Set(ContentControl.ContentProperty, "☰")
                                                            .Set(FrameworkElement.MarginProperty, new Thickness(4))
                                                            .Set(Control.FontFamilyProperty, new FontFamily("Segoe UI Symbol"))
                                                            .Set(DockPanel.DockProperty, Dock.Left)
                                                            .Set(Control.FontSizeProperty, 18d)
                                                            .TemplateBinding(ToggleButton.IsCheckedProperty, Expander.IsExpandedProperty))
                                                  .Contains(TemplateExtensions.Create <ContentPresenter>()
                                                            .Set(FrameworkElement.MarginProperty, new Thickness(4))
                                                            .Set(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center)
                                                            .Set(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Center)
                                                            .Set(ContentPresenter.ContentSourceProperty, "Header")))
                                        .Contains(TemplateExtensions.Create <ContentPresenter>()
                                                  .Set(ContentPresenter.ContentSourceProperty, "Content")
                                                  .TemplateBinding(UIElement.VisibilityProperty, Expander.IsExpandedProperty, new BooleanToVisibilityConverter()))
                                        .AsControlTemplate <Expander>();

                HambergerMenu = StyleExtensions.Create()
                                .Template(hambergerTemplate)
                                .AsStyle <Expander>();
            }
            return(null);
        }
Example #6
0
 private Style GetListBoxStyle(IThemeColors colors)
 {
     return(StyleExtensions.Create()
            .Set(Control.PaddingProperty, new Thickness(0, 4, 0, 0))
            .Set(Control.BackgroundProperty, colors.Control.Normal)
            .Set(Control.BorderBrushProperty, colors.Control.Accent1)
            .Set(Control.BorderThicknessProperty, new Thickness(0, 1, 0, 0))
            .AsStyle <ListBox>());
 }
        private void VerifyThemeColors(Color textColor, IThemeColors expectedTheme)
        {
            var originalLineSource = CreateFormattedLineSource(14d, "Times New Roman", textColor);
            var locViz             = CreateLocationViz(CreateSnapshot(), new Span(0, 1), stepNumber: 99);
            var testSubject        = new IssueLocationAdornment(locViz, originalLineSource);

            testSubject.Background.Should().Be(expectedTheme.BackgroundBrush);
            testSubject.BorderBrush.Should().Be(expectedTheme.BorderBrush);
        }
Example #8
0
        private Style GetTabControlStyle(IThemeColors colors)
        {
            /*var template = TemplateExtensions.Create<ItemsPresenter>()
             * .AsControlTemplate<TabControl>();*/

            return(StyleExtensions.Create()
                   .Set(Control.PaddingProperty, new Thickness(0))
                   .Set(Control.BorderThicknessProperty, new Thickness(0))
                   .Set(Control.BackgroundProperty, colors.Control.Normal)
                   .AsStyle <TabControl>());
        }
Example #9
0
        public void SetThemeColors(IThemeColors theme)
        {
            accentColor.BackgroundColor = theme.PrimaryAccentColor;
            icon1.BackgroundColor       = theme.PrimaryAccentColor;
            icon2.BackgroundColor       = theme.PrimaryAccentColor;
            icon3.BackgroundColor       = theme.PrimaryAccentColor;

            tertiaryBackground.BackgroundColor  = theme.TertiaryBackgroundColor;
            secondaryBackground.BackgroundColor = theme.SecondaryBackgroundColor;

            this.BackgroundColor = theme.PrimaryBackgroundColor;
            this.themeName       = theme.Name;
        }
Example #10
0
        public static void Load(IFluentTheme theme, IThemeColors themeColors)
        {
            if (themes.Contains(theme))
            {
                return;
            }

            ResourceDictionary dictionary = (ResourceDictionary)theme;

            theme.GetDefaultStyles(themeColors)
            .Where(x => x != null)
            .ToList()
            .ForEach(x => dictionary.Add(x.TargetType, x));

            themes.Add(theme);
        }
Example #11
0
        private Style GetToggleButtonStyle(IThemeColors colors)
        {
            var template = TemplateExtensions.Create <Border>()
                           .TemplateBinding(Border.BackgroundProperty, ToggleButton.BackgroundProperty)
                           .Contains(TemplateExtensions.Create <ContentPresenter>())
                           .AsControlTemplate <ToggleButton>();

            return(StyleExtensions.Create()
                   .Set(Control.ForegroundProperty, colors.Text.Normal)
                   .Set(Control.BackgroundProperty, new SolidColorBrush(Colors.Transparent))
                   .When(TriggerExtensions.Property(UIElement.IsMouseOverProperty)
                         .Is(true)
                         .Then(Control.BackgroundProperty, colors.Control.Over))
                   .Template(template)
                   .AsStyle <ToggleButton>());
        }
Example #12
0
        public Button CreateThemeButton(IThemeColors darkTheme, int darkThemeIndex)
        {
            var normal = new GuiWidget(colorSelectSize, colorSelectSize);

            normal.BackgroundColor = darkTheme.SourceColor;

            var hover = new GuiWidget(colorSelectSize, colorSelectSize);

            hover.BackgroundColor = darkTheme.SourceColor;

            var pressed = new GuiWidget(colorSelectSize, colorSelectSize);

            pressed.BackgroundColor = darkTheme.SourceColor;

            var disabled = new GuiWidget(colorSelectSize, colorSelectSize);

            int lightThemeIndex = darkThemeIndex + midPoint;
            var lightTheme      = ActiveTheme.AvailableThemes[lightThemeIndex];

            var colorButton = new Button(0, 0, new ButtonViewStates(normal, hover, pressed, disabled));

            colorButton.Cursor = Cursors.Hand;
            colorButton.Click += (s, e) =>
            {
                // Determine if we should set the dark or light version of the theme
                var activeThemeIndex = ActiveTheme.AvailableThemes.IndexOf(ActiveTheme.Instance);

                bool useLightTheme = activeThemeIndex >= midPoint;

                SetTheme(darkThemeIndex, useLightTheme);
            };

            colorButton.MouseEnterBounds += (s, e) =>
            {
                darkPreviewButton.SetThemeColors(darkTheme);
                lightPreviewButton.SetThemeColors(lightTheme);

                hoveredThemeIndex = darkThemeIndex;
            };

            colorButton.MouseLeaveBounds += (s, e) =>
            {
                // darkPreviewButton.SetThemeColors(ActiveTheme.Instance);
            };

            return(colorButton);
        }
        public Button CreateThemeButton(IThemeColors theme, int index)
        {
            var normal = new GuiWidget(colorSelectSize, colorSelectSize);

            normal.BackgroundColor = theme.PrimaryAccentColor;

            var hover = new GuiWidget(colorSelectSize, colorSelectSize);

            hover.BackgroundColor = theme.SecondaryAccentColor;

            var pressed = new GuiWidget(colorSelectSize, colorSelectSize);

            pressed.BackgroundColor = theme.SecondaryAccentColor;

            var disabled = new GuiWidget(colorSelectSize, colorSelectSize);

            var colorButton = new Button(0, 0, new ButtonViewStates(normal, hover, pressed, disabled))
            {
                Name = index.ToString()
            };

            colorButton.Click += (s, e) =>
            {
                string themeIndexText = ((GuiWidget)s).Name;
                int    themeIndex;

                if (int.TryParse(themeIndexText, out themeIndex) && themeIndex < ActiveTheme.AvailableThemes.Count)
                {
                    ActiveSliceSettings.Instance.SetActiveValue("active_theme_index", themeIndex.ToString());
                    ActiveTheme.Instance = ActiveTheme.AvailableThemes[themeIndex];
                }
            };

            colorButton.MouseEnterBounds += (s, e) =>
            {
                colorToChangeTo.BackgroundColor = theme.PrimaryAccentColor;
            };

            colorButton.MouseLeaveBounds += (s, e) =>
            {
                colorToChangeTo.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor;
            };

            return(colorButton);
        }
Example #14
0
        private Style GetContextMenuStyle(IThemeColors colors)
        {
            var template = TemplateExtensions.Create <Border>()
                           .TemplateBinding(Control.BackgroundProperty, Control.BackgroundProperty)
                           .TemplateBinding(Control.BorderBrushProperty, Control.BorderBrushProperty)
                           .TemplateBinding(Control.BorderThicknessProperty, Control.BorderThicknessProperty)
                           .Contains(TemplateExtensions.Create <StackPanel>()
                                     .Set(Panel.IsItemsHostProperty, true))
                           .AsControlTemplate <ContextMenu>();

            return(StyleExtensions.Create()
                   .Set(Control.ForegroundProperty, colors.Text.Normal)
                   .Set(Control.BackgroundProperty, colors.Control.Accent1)
                   .Set(Control.BorderBrushProperty, colors.Control.Accent1)
                   .Set(Control.BorderThicknessProperty, new Thickness(1))
                   .Template(template)
                   .AsStyle <ContextMenu>());
        }
        public Button CreateThemeButton(IThemeColors theme)
        {
            var normal = new GuiWidget(colorSelectSize, colorSelectSize);

            normal.BackgroundColor = theme.PrimaryAccentColor;

            var hover = new GuiWidget(colorSelectSize, colorSelectSize);

            hover.BackgroundColor = theme.SecondaryAccentColor;

            var pressed = new GuiWidget(colorSelectSize, colorSelectSize);

            pressed.BackgroundColor = theme.SecondaryAccentColor;

            var disabled = new GuiWidget(colorSelectSize, colorSelectSize);

            var colorButton = new Button(0, 0, new ButtonViewStates(normal, hover, pressed, disabled))
            {
                Name = theme.Name,
            };

            colorButton.Click += (s, e) =>
            {
                string themeName = ((GuiWidget)s).Name;

                // save it for this printer
                ActiveSliceSettings.Instance.SetValue(SettingsKey.active_theme_name, themeName);

                UserSettings.Instance.set(UserSettingsKey.ActiveThemeName, themeName);
                ActiveTheme.Instance = ActiveTheme.GetThemeColors(themeName);
            };

            colorButton.MouseEnterBounds += (s, e) =>
            {
                colorToChangeTo.BackgroundColor = theme.PrimaryAccentColor;
            };

            colorButton.MouseLeaveBounds += (s, e) =>
            {
                colorToChangeTo.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor;
            };

            return(colorButton);
        }
Example #16
0
        private Style GetMenuItemStyle(IThemeColors colors)
        {
            var template = TemplateExtensions.Create <Border>()
                           .TemplateBinding(Control.BackgroundProperty, MenuItem.BackgroundProperty)
                           .Contains(TemplateExtensions.Create <ContentPresenter>()
                                     .Set(Control.MarginProperty, new Thickness(8))
                                     .Set(ContentPresenter.ContentSourceProperty, "Header"))
                           .AsControlTemplate <MenuItem>();

            return(StyleExtensions.Create()
                   .Set(Control.ForegroundProperty, colors.Text.Normal)
                   .Set(Control.BackgroundProperty, colors.Control.Normal)
                   .When(TriggerExtensions
                         .Property(Control.IsMouseOverProperty)
                         .Is(true)
                         .Then(Control.BackgroundProperty, colors.Control.Over))
                   .Template(template)
                   .AsStyle <MenuItem>());
        }
Example #17
0
        public void RebuildTheme(IThemeColors colors)
        {
            int size = (int)(16 * GuiWidget.DeviceScale);

            if (AggContext.OperatingSystem == OSType.Android)
            {
                restoreNormal = ColorCircle(size, new Color(200, 0, 0));
            }
            else
            {
                restoreNormal = ColorCircle(size, Color.Transparent);
            }

            restoreHover   = ColorCircle(size, new Color("#DB4437"));
            restorePressed = ColorCircle(size, new Color(255, 0, 0));

            this.Colors = colors;

            this.GeneratingThumbnailIcon = AggContext.StaticData.LoadIcon("building_thumbnail_40x40.png", 40, 40, this.InvertIcons);

            DefaultThumbView.ThumbColor = new Color(colors.PrimaryTextColor, 30);

            this.TabBodyBackground = this.ResolveColor(
                colors.TertiaryBackgroundColor,
                new Color(
                    Color.White,
                    (colors.IsDarkTheme) ? 3 : 25));

            this.ActiveTabColor       = this.TabBodyBackground;
            this.TabBarBackground     = this.ActiveTabColor.AdjustLightness(0.85).ToColor();
            this.ThumbnailBackground  = Color.Transparent;
            this.AccentMimimalOverlay = new Color(this.Colors.PrimaryAccentColor, 50);

            // Active tab color with slight transparency
            this.InteractionLayerOverlayColor = new Color(this.ActiveTabColor, 240);

            float alpha0to1 = (colors.IsDarkTheme ? 20 : 60) / 255.0f;

            this.InactiveTabColor = ResolveColor(colors.PrimaryBackgroundColor, new Color(Color.White, this.SlightShade.alpha));

            this.SplitterBackground = this.ActiveTabColor.AdjustLightness(0.87).ToColor();
        }
Example #18
0
        private Style GetDropDownButtonStyle(IThemeColors colors)
        {
            var template = TemplateExtensions.Create <Border>()
                           .TemplateBinding(Control.BackgroundProperty, Control.BackgroundProperty)
                           .TemplateBinding(Border.PaddingProperty, Button.PaddingProperty)
                           .Contains(TemplateExtensions.Create <ContentPresenter>()
                                     .Set(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Center)
                                     .Set(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center)
                                     .TemplateBinding(ContentPresenter.ContentProperty, ContentControl.ContentProperty))
                           .AsControlTemplate <DropDownButton>();

            return(StyleExtensions.Create()
                   .Set(Control.BackgroundProperty, new SolidColorBrush(Colors.Transparent))
                   .Set(Control.PaddingProperty, new Thickness(8, 4, 8, 4))
                   .When(TriggerExtensions.Property(UIElement.IsMouseOverProperty)
                         .Is(true)
                         .Then(Control.BackgroundProperty, colors.Control.Accent1))
                   .Template(template)
                   .AsStyle <DropDownButton>());
        }
		public Button CreateThemeButton(IThemeColors theme)
		{
			var normal = new GuiWidget(colorSelectSize, colorSelectSize);
			normal.BackgroundColor = theme.PrimaryAccentColor;

			var hover = new GuiWidget(colorSelectSize, colorSelectSize);
			hover.BackgroundColor = theme.SecondaryAccentColor;

			var pressed = new GuiWidget(colorSelectSize, colorSelectSize);
			pressed.BackgroundColor = theme.SecondaryAccentColor;

			var disabled = new GuiWidget(colorSelectSize, colorSelectSize);

			var colorButton = new Button(0, 0, new ButtonViewStates(normal, hover, pressed, disabled))
			{
				Name = theme.Name,
			};
			colorButton.Click += (s, e) =>
			{
				string themeName = ((GuiWidget)s).Name;

				// save it for this printer
				ActiveSliceSettings.Instance.SetValue(SettingsKey.active_theme_name, themeName);

				UserSettings.Instance.set(UserSettingsKey.ActiveThemeName, themeName);
				ActiveTheme.Instance = ActiveTheme.GetThemeColors(themeName);
			};

			colorButton.MouseEnterBounds += (s, e) =>
			{
				colorToChangeTo.BackgroundColor = theme.PrimaryAccentColor;
			};

			colorButton.MouseLeaveBounds += (s, e) =>
			{
				colorToChangeTo.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor;
			};

			return colorButton;
		}
        private Style GetHeaderContentControlStyle(IThemeColors colors)
        {
            var template = TemplateExtensions.Create <DockPanel>()
                           .Contains(TemplateExtensions.Create <Border>()
                                     //.Set(Border.CornerRadiusProperty, new CornerRadius(3, 3, 0, 0))
                                     .Set(Control.BackgroundProperty, colors.Control.Accent1)
                                     //.Set(Border.BorderBrushProperty, colors.Outline.Normal)
                                     //.Set(Border.BorderThicknessProperty, new Thickness(1,1,1,0))
                                     .Set(DockPanel.DockProperty, Dock.Top)
                                     .Contains(TemplateExtensions.Create <ContentPresenter>()
                                               .Set(ContentPresenter.ContentSourceProperty, "Header")
                                               .Set(FrameworkElement.MarginProperty, new Thickness(4))))
                           .Contains(TemplateExtensions.Create <Border>()
                                     .Set(Control.BackgroundProperty, colors.Control.Accent2)
                                     .Set(Border.BorderBrushProperty, colors.Outline.Normal)
                                     .Set(Border.BorderThicknessProperty, new Thickness(1, 1, 1, 1))
                                     .Contains(TemplateExtensions.Create <ContentPresenter>()))
                           .AsControlTemplate <HeaderedContentControl>();

            return(StyleExtensions.Create()
                   .Template(template)
                   .AsStyle <HeaderedContentControl>());
        }
Example #21
0
        private Style GetListBoxItemStyle(IThemeColors colors)
        {
            var template = TemplateExtensions.Create <Border>()
                           .Set(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Stretch)
                           .Contains(TemplateExtensions.Create <ContentPresenter>())
                           .TemplateBinding(Border.BackgroundProperty, ListBoxItem.BackgroundProperty)
                           .AsControlTemplate <ListBoxItem>();

            return(StyleExtensions.Create()
                   .Template(template)
                   .Set(Control.PaddingProperty, new Thickness(0, 4, 0, 0))
                   .Set(Control.BackgroundProperty, colors.Control.Normal)
                   .Set(Control.BorderBrushProperty, colors.Control.Accent1)
                   .Set(Control.BorderThicknessProperty, new Thickness(0, 1, 0, 0))
                   .When(TriggerExtensions
                         .Property(ListBoxItem.IsMouseOverProperty)
                         .Is(true)
                         .Then(ListBoxItem.BackgroundProperty, colors.Control.Over))
                   .When(TriggerExtensions
                         .Property(ListBoxItem.IsSelectedProperty)
                         .Is(true)
                         .Then(ListBoxItem.BackgroundProperty, colors.Control.Selected))
                   .AsStyle <ListBoxItem>());
        }
 public SurfaceElevation(IThemeColors themeColors, ElevationLevel elevation)
 {
     _themeColors = themeColors;
     Elevation    = elevation;
 }
Example #23
0
 public abstract IEnumerable <System.Windows.Style> GetDefaultStyles(IThemeColors themeColors);
Example #24
0
        public static IThemeColors Outline(this IThemeColors themeColors, IColorPack colorPack)
        {
            themeColors.Outline = colorPack;

            return(themeColors);
        }
Example #25
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);
        }
Example #26
0
        public static IThemeColors Text(this IThemeColors themeColors, IColorPack colorPack)
        {
            themeColors.Text = colorPack;

            return(themeColors);
        }
Example #27
0
        public void RebuildTheme(IThemeColors colors)
        {
            int size = (int)(16 * GuiWidget.DeviceScale);

            if (AggContext.OperatingSystem == OSType.Android)
            {
                RestoreNormal = ColorCircle(size, new Color(200, 0, 0));
            }
            else
            {
                RestoreNormal = ColorCircle(size, Color.Transparent);
            }

            RestoreHover   = ColorCircle(size, new Color("#DB4437"));
            restorePressed = ColorCircle(size, new Color(255, 0, 0));

            this.Colors = colors;

            this.GeneratingThumbnailIcon = AggContext.StaticData.LoadIcon("building_thumbnail_40x40.png", 40, 40, this.InvertIcons);

            DefaultThumbView.ThumbColor = new Color(colors.PrimaryTextColor, 30);

            var commonOptions = new ButtonFactoryOptions();

            commonOptions.NormalTextColor   = colors.PrimaryTextColor;
            commonOptions.HoverTextColor    = colors.PrimaryTextColor;
            commonOptions.PressedTextColor  = colors.PrimaryTextColor;
            commonOptions.DisabledTextColor = colors.TertiaryBackgroundColor;
            commonOptions.Margin            = this.TextButtonPadding;
            commonOptions.FontSize          = this.DefaultFontSize;
            commonOptions.ImageSpacing      = 8;
            commonOptions.BorderWidth       = 0;
            commonOptions.FixedHeight       = this.ButtonHeight;

            this.TabBodyBackground = this.ResolveColor(
                colors.TertiaryBackgroundColor,
                new Color(
                    Color.White,
                    (colors.IsDarkTheme) ? 3 : 25));

            this.ActiveTabColor       = this.TabBodyBackground;
            this.TabBarBackground     = this.ActiveTabColor.AdjustLightness(0.85).ToColor();
            this.ThumbnailBackground  = this.MinimalShade;
            this.AccentMimimalOverlay = new Color(this.Colors.PrimaryAccentColor, 50);

            // Active tab color with slight transparency
            this.InteractionLayerOverlayColor = new Color(this.ActiveTabColor, 240);

            float alpha0to1 = (colors.IsDarkTheme ? 20 : 60) / 255.0f;

            this.InactiveTabColor = ResolveColor(colors.PrimaryBackgroundColor, new Color(Color.White, this.SlightShade.alpha));

            this.SplitterBackground = this.ActiveTabColor.AdjustLightness(0.87).ToColor();

            this.ButtonFactory = new TextImageButtonFactory(commonOptions);

            var commonGray = new ButtonFactoryOptions(commonOptions)
            {
                NormalTextColor  = Color.Black,
                NormalFillColor  = Color.LightGray,
                HoverTextColor   = Color.Black,
                PressedTextColor = Color.Black,
                PressedFillColor = Color.LightGray,
            };

            #region PartPreviewWidget

            WhiteButtonFactory = new TextImageButtonFactory(new ButtonFactoryOptions(commonOptions)
            {
                FixedWidth  = sideBarButtonWidth,
                FixedHeight = TabButtonHeight,

                NormalTextColor   = Color.Black,
                NormalFillColor   = Color.White,
                NormalBorderColor = new Color(colors.PrimaryTextColor, 200),

                HoverTextColor   = Color.Black,
                HoverFillColor   = new Color(255, 255, 255, 200),
                HoverBorderColor = new Color(colors.PrimaryTextColor, 200),

                BorderWidth = 1,
            });
            #endregion

            this.LinkButtonFactory = new LinkButtonFactory()
            {
                fontSize  = FontSize11,
                textColor = colors.PrimaryTextColor
            };
        }
Example #28
0
        private static void PopulateSurfaceCaptions(ICollection <SurfaceCaptions> themeItems, IThemeColors themeColors, ElevationLevel elevation)
        {
            var errorCaption = new SurfaceCaption
            {
                Caption            = "Sample Error Text",
                CaptionColor       = themeColors.OnError,
                BackgroundColor    = themeColors.Error,
                ContrastRatio      = ColorHelper.GetContrastRatio(themeColors.OnError, themeColors.Error),
                ContrastRatioColor = themeColors.OnError
            };

            var surfaceElevation = new SurfaceElevation(themeColors, elevation);

            AddSurfaceCaption(themeItems, $"Default Surface at {elevation}", "OnSurface Text", themeColors.OnSurface, surfaceElevation.SurfaceColor, errorCaption);
            AddSurfaceCaption(themeItems, $"Default Surface at {elevation}", "Branded Text", themeColors.Primary, surfaceElevation.SurfaceColor, errorCaption);
            AddSurfaceCaption(themeItems, $"Branded Surface at {elevation}", "OnSurface Text", themeColors.OnSurface, surfaceElevation.BrandedSurfaceColor, errorCaption);
            AddSurfaceCaption(themeItems, $"Branded Surface at {elevation}", "Branded Text", themeColors.Primary, surfaceElevation.BrandedSurfaceColor, errorCaption);
        }
Example #29
0
 private Style GetWindowStyle(IThemeColors colors)
 {
     return(StyleExtensions.Create()
            .Set(Control.BackgroundProperty, colors.Control.Normal)
            .AsStyle <Window>());
 }
Example #30
0
 static Theme()
 {
     ThemeColors = GetColors();
 }
Example #31
0
 public override IEnumerable <Style> GetDefaultStyles(IThemeColors themeColors)
 {
     yield return(GetDropDownButtonStyle(themeColors));
 }