コード例 #1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            double cellValue;
            bool   isValid = true;

            if (value is string)
            {
                isValid = double.TryParse(value as string, out cellValue);
            }
            else
            {
                cellValue = System.Convert.ToDouble(value);
            }


            if (cellValue > 0 && isValid)
            {
                return(ResourceDictionaryHelper.GetResource <Color>("PriceUpColor"));
            }
            else if (cellValue < 0 && isValid)
            {
                return(ResourceDictionaryHelper.GetResource <Color>("PriceDownColor"));
            }
            else
            {
                return(ResourceDictionaryHelper.GetResource <Color>("PriceUnchangedColor"));
            }
        }
コード例 #2
0
ファイル: Theme.cs プロジェクト: xiangsxuan/ControlzEx
        public static bool IsThemeDictionary(ResourceDictionary resourceDictionary)
        {
            if (resourceDictionary is null)
            {
                throw new ArgumentNullException(nameof(resourceDictionary));
            }

            var source = resourceDictionary.Source;

            if (!(source is null))
            {
                if (ThemeDictionaryCache.TryGetValue(source, out var existingValue))
                {
                    return(existingValue);
                }
            }

            // We are not allowed to use other methods like GetThemeInstance or GetThemeName here as that would cause an endless-loop
            var result = ResourceDictionaryHelper.ContainsKey(resourceDictionary, ThemeInstanceKey) ||
                         string.IsNullOrEmpty(ResourceDictionaryHelper.GetValueFromKey(resourceDictionary, ThemeNameKey) as string) == false;

            if (!(source is null))
            {
                ThemeDictionaryCache[source] = result;
            }

            return(result);
        }
コード例 #3
0
        protected static void SetCurrentTheme(Theme theme, IThemeColorsBase themeColors, ResourceDictionary themeResources)
        {
            // set the current theme colors that will be referenced by the theme styles
            //CurrentTheme.Instance.ThemeColors = themeColors;
            CurrentTheme.SetTheme(theme, themeColors);

            // merge the XAML based light/dark theme set of styles
            ResourceDictionaryHelper.MergeIntoApplicationResources(themeResources);
        }
コード例 #4
0
ファイル: Theme.cs プロジェクト: xiangsxuan/ControlzEx
        public static bool IsRuntimeGeneratedThemeDictionary(ResourceDictionary resourceDictionary)
        {
            if (IsThemeDictionary(resourceDictionary))
            {
                return((ResourceDictionaryHelper.ContainsKey(resourceDictionary, ThemeInstanceKey) && ((Theme)resourceDictionary[ThemeInstanceKey]).IsRuntimeGenerated) ||
                       (ResourceDictionaryHelper.ContainsKey(resourceDictionary, ThemeIsRuntimeGeneratedKey) && (bool)resourceDictionary[ThemeIsRuntimeGeneratedKey]));
            }

            return(false);
        }
コード例 #5
0
ファイル: Theme.cs プロジェクト: xiangsxuan/ControlzEx
        public static Theme?GetThemeInstance([NotNull] ResourceDictionary resourceDictionary)
        {
            if (resourceDictionary is null)
            {
                throw new ArgumentNullException(nameof(resourceDictionary));
            }

            if (IsThemeDictionary(resourceDictionary) == false)
            {
                return(null);
            }

            return(ResourceDictionaryHelper.GetValueFromKey(resourceDictionary, ThemeInstanceKey) as Theme);
        }
コード例 #6
0
        public static string?GetThemeName(ResourceDictionary resourceDictionary)
        {
            if (resourceDictionary is null)
            {
                throw new ArgumentNullException(nameof(resourceDictionary));
            }

            if (IsThemeDictionary(resourceDictionary) == false)
            {
                return(null);
            }

            return(ResourceDictionaryHelper.GetValueFromKey(resourceDictionary, ThemeNameKey) as string);
        }
コード例 #7
0
        /// <summary>
        /// The on aspect view changed.
        /// </summary>
        public void OnAspectViewChanged()
        {
            // [vw::][.:<Aspect Name>:]<View Name>
            // [vw::]<Object Symbol>:<Aspect Name>[:<View Name>]
            // eg: <PropertyDescription Name="AspectView" Value="$'vw::C3020:Graphic Display2:Main View'" />
            // 'vw::V4402:V4402_SFC:Main View'
            if (!string.IsNullOrEmpty(this.AspectView))
            {
                var matchCollection = Regex.Split(this.AspectView, @"\$'vw::([^:]*):([^:]*):([^']*)'");
                if (matchCollection.Length == 5)
                {
                    var unit   = matchCollection[1].Trim(new[] { ' ' });
                    var aspect = matchCollection[2].Trim(new[] { ' ' });
                    var view   = matchCollection[3].Trim(new[] { ' ' });

                    this._aspectView = aspect; // Keep private copy of the parsed template id
                    var resource = ResourceDictionaryHelper.GetTemplate(aspect);
                    if (resource == null)
                    {
                        // Band-Aid?
                        if (view == "Main View")
                        {
                            var overview = string.Format("{0}_{1}", unit, aspect);
                            overview = overview.Replace(' ', '_');
                            resource = ResourceDictionaryHelper.GetTemplate(overview);
                        }
                    }

                    this.SetValue(AspectViewTemplateProperty, resource);

                    // If no Text parameter specified, or if specified as "", use
                    // the name of view's associated object

                    /*  if (aspect != "Logic_Display")
                     * {
                     *  if (string.IsNullOrEmpty(Text))
                     *  {
                     *      SetValue(TextProperty, unit);
                     *  }
                     * }
                     * */
                    this.OnInstructorGraphicChanged();
                }
                // AspectView valid
            }
            // AspectView specified
        }
コード例 #8
0
 public static bool IsRuntimeGeneratedThemeDictionary(ResourceDictionary resourceDictionary)
 {
     return(Theme.IsRuntimeGeneratedThemeDictionary(resourceDictionary) ||
            (ResourceDictionaryHelper.ContainsKey(resourceDictionary, LibraryThemeInstanceKey) && ((LibraryTheme)resourceDictionary[LibraryThemeInstanceKey]).IsRuntimeGenerated));
 }
コード例 #9
0
 public static bool IsThemeDictionary(ResourceDictionary resourceDictionary)
 {
     return(Theme.IsThemeDictionary(resourceDictionary) ||
            ResourceDictionaryHelper.ContainsKey(resourceDictionary, LibraryThemeInstanceKey));
 }
コード例 #10
0
 public override Color GetAlternatingRowBackgroundColor()
 {
     return(ResourceDictionaryHelper.GetResource <Color>("LightGrayColor_ColumnAlternating"));
 }