public override void SyncColors()
    {
        string colorTypeString = colorType.ToString();

        if (colorCustomTypes == null)
        {
            colorCustomTypes = new UIColorCustomType();
        }

        if (colorCustomTypes.ContainsKey(colorTypeString))
        {
            colorKey = colorCustomTypes.Get <string>(colorType.ToString());

            if (!string.IsNullOrEmpty(colorKey))
            {
                AppColor appColor = AppColors.Instance.GetById(colorKey);

                if (appColor != null)
                {
                    Color colorTo = appColor.GetColor();
                    colorTo.a = colorAlpha;
                    UIColors.ColorTo(
                        gameObject, colorTo);

                    foreach (Transform t in gameObject.transform)
                    {
                        UIColors.ColorTo(
                            t.gameObject, colorTo);
                    }
                }
            }
        }
    }
        public static AppColor GetColor <T>(this T e)
        {
            AppColor description = AppColor.Black;

            if (e is Enum)
            {
                Type  type   = e.GetType();
                Array values = Enum.GetValues(type);

                foreach (int val in values)
                {
                    if (val == ((IConvertible)e).ToInt32(CultureInfo.InvariantCulture))
                    {
                        var memInfo    = type.GetMember(type.GetEnumName(val));
                        var attributes = memInfo[0].GetCustomAttributes(typeof(StateColorAttribute), false);
                        if (attributes.Length > 0)
                        {
                            // we're only getting the first description we find
                            // others will be ignored
                            description = ((StateColorAttribute)attributes[0]).Color;
                        }

                        break;
                    }
                }
            }

            return(description);
        }
Beispiel #3
0
        public void Should_load_any_app_color(
            [ValueSource(nameof(AppColorNames))] AppColor colorName,
            [ValueSource(nameof(TestColorValues))] Color color)
        {
            var         mockFileReader     = CreateMockFileReader(GetThemeContent(colorName, color));
            var         mockCssUrlResolver = Substitute.For <IThemeCssUrlResolver>();
            ThemeLoader loader             = new(mockCssUrlResolver, mockFileReader);

            var theme = LoadTheme(loader);

            theme.GetColor(colorName).ToArgb().Should().Be(color.ToArgb());
        }
Beispiel #4
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                value = "#ffffff";
            }

            string   colorCode = (string)value;
            AppColor appColor  = ColorUtility.FindAppColor(colorCode);

            return(appColor.Name);
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string colorcode = (string)value;

            if (string.IsNullOrEmpty(colorcode))
            {
                colorcode = "#ffffff";
            }

            AppColor appColor = ColorUtility.FindAppColor(colorcode);

            return(appColor.FriendlyName);
        }
Beispiel #6
0
        public void Should_apply_colorblind_overrides_to_app_colors(
            [ValueSource(nameof(AppColorNames))] AppColor colorName)
        {
            var         regularColor       = Color.Red;
            var         colorblindColor    = Color.Blue;
            var         mockFileReader     = CreateMockFileReader(GetThemeContent(colorName, regularColor, colorblindColor));
            var         mockCssUrlResolver = Substitute.For <IThemeCssUrlResolver>();
            ThemeLoader loader             = new(mockCssUrlResolver, mockFileReader);

            var regularTheme = LoadTheme(loader);

            regularTheme.GetColor(colorName).ToArgb().Should().Be(regularColor.ToArgb());

            var colorblindTheme = LoadTheme(loader, ThemeVariations.Colorblind);

            colorblindTheme.GetColor(colorName).ToArgb().Should().Be(colorblindColor.ToArgb());
        }
 public override Color GetColor(AppColor name) =>
 AppColorDefaults.GetBy(name);
Beispiel #8
0
 public override Color GetColor(AppColor name) =>
 _appColors.TryGetValue(name, out var result)
         ? result
         : Color.Empty;
Beispiel #9
0
 /// <summary>
 /// Get GitExtensions app-specific color value as defined by this instance
 /// </summary>
 public abstract Color GetColor(AppColor name);
Beispiel #10
0
 public StateColorAttribute(AppColor color)
 {
     Color = color;
 }
Beispiel #11
0
 /// <summary>
 /// Get GitExtensions app-specific color value as defined by this instance. If not defined,
 /// returns <see cref="Color.Empty"/>.
 /// </summary>
 public Color GetColor(AppColor name) =>
 AppColorValues.TryGetValue(name, out var result)
         ? result
         : Color.Empty;
Beispiel #12
0
        public static MvcHtmlString AppGridAddButton(this HtmlHelper htmlHelper, string text, string href, AppColor color = AppColor.none, object htmlAttributes = null)
        {
            var control = new RenderActionLink();

            control.Text  = text;
            control.Name  = text;
            control.Color = color;
            control.Href  = href;
            control.ID    = "a" + text;
            control.Class = "btn-sm add-row";

            HtmlAttributes(control, htmlAttributes);
            return(MvcHtmlString.Create(control.ToString()));
        }
Beispiel #13
0
 private void ResetInternal(AppColor name) =>
 AppSettings.SetColor(name, _defaultTheme.GetColor(name));
Beispiel #14
0
 /// <summary>
 /// Define color value for GitExtensions app-specific color
 /// </summary>
 public void SetColor(AppColor name, Color color)
 {
     AppSettings.SetColor(name, color);
     ColorChanged?.Invoke();
 }
Beispiel #15
0
 /// <summary>
 /// <inheritdoc cref="Theme"/>
 /// </summary>
 public override Color GetColor(AppColor name) =>
 AppSettings.GetColor(name);
Beispiel #16
0
 /// <summary>
 /// Reset GitExtensions app-specific color to <see cref="AppColorDefaults"/>
 /// </summary>
 public void ResetColor(AppColor name)
 {
     ResetInternal(name);
     ColorChanged?.Invoke();
 }
Beispiel #17
0
        public static MvcHtmlString AppButton(this HtmlHelper htmlHelper, string text, AppButtonType type, AppColor color = AppColor.none, object htmlAttributes = null)
        {
            var control = new RenderButton();

            control.Text  = text;
            control.Type  = type;
            control.Color = color;
            HtmlAttributes(control, htmlAttributes);
            return(MvcHtmlString.Create(control.ToString()));
        }
Beispiel #18
0
        public static MvcHtmlString AppButtonModal(this HtmlHelper htmlHelper, string text, string modalname, AppColor color = AppColor.none, object htmlAttributes = null)
        {
            var control = new RenderActionLink();

            control.Text     = text;
            control.Color    = color;
            control.IsModal  = true;
            control.ForModal = "#" + modalname;
            control.Href     = "#" + modalname;
            control.ID       = "btn-" + modalname;

            HtmlAttributes(control, htmlAttributes);
            return(MvcHtmlString.Create(control.ToString()));
        }
Beispiel #19
0
 public static Color GetBy(AppColor name)
 {
     return(Values.TryGetValue(name, out var result)
         ? result
         : FallbackColor);
 }
Beispiel #20
0
 public static Color GetThemeColor(this AppColor name) =>
 ThemeModule.Settings.Theme.GetColor(name);