コード例 #1
0
        public void RelayMethod(object obj)
        {
            string command = obj.ToString();

            //  Do:应用
            if (command == "Loaded")
            {
                ResourceDictionary resource = this.GetThemeDictionary();

                foreach (var item in resource.Keys)
                {
                    object current = resource[item.ToString()];

                    if (current is SolidColorBrush)
                    {
                        //  Message:查找到了想要的资源
                        ItemNotifyClass itemClass = new ItemNotifyClass();
                        SolidColorBrush brush     = current as SolidColorBrush;
                        itemClass.Color = brush;
                        itemClass.Name  = item.ToString();
                        itemClass.Value = current.ToString();

                        if (ThemeService.Current.KeyToMarkDictionary.ContainsKey(itemClass.Name))
                        {
                            itemClass.Mark = ThemeService.Current.KeyToMarkDictionary[itemClass.Name];
                        }

                        this.Collection.Add(itemClass);
                    }
                }
            }
            //  Do:取消
            else if (command == "Cancel")
            {
            }
        }
コード例 #2
0
        public void RelayMethod(object obj)
        {
            string command = obj.ToString();

            //  Do:应用
            if (command == "Loaded")
            {
                //var value= System.Windows.SystemColors

                foreach (var item in typeof(SystemColors).GetProperties())
                {
                    var value = item.GetValue(null, null);

                    if (item.PropertyType == typeof(SolidColorBrush))
                    {
                        ItemNotifyClass itemClass = new ItemNotifyClass();
                        SolidColorBrush brush     = value as SolidColorBrush;
                        itemClass.Color = brush;
                        itemClass.Name  = item.Name.ToString();
                        itemClass.Value = value.ToString();

                        this.Collection.Add(itemClass);
                    }

                    //else if(item.PropertyType==typeof(Color))
                    //{
                    //    ItemNotifyClass itemClass = new ItemNotifyClass();
                    //    Color brush = (Color)value;
                    //    itemClass.Color = new SolidColorBrush(brush);
                    //    itemClass.Name = item.Name.ToString();
                    //    itemClass.Value = value.ToString();

                    //    this.Collection.Add(itemClass);
                    //}
                }


                //foreach (var item in typeof(SystemFonts).GetProperties())
                //{
                //    var value = item.GetValue(null, null);

                //    if (item.PropertyType == typeof(SolidColorBrush))
                //    {
                //        ItemNotifyClass itemClass = new ItemNotifyClass();
                //        SolidColorBrush brush = value as SolidColorBrush;
                //        itemClass.Color = brush;
                //        itemClass.Name = item.Name.ToString();
                //        itemClass.Value = value.ToString();

                //        this.Collection.Add(itemClass);

                //    }
                //    //else if(item.PropertyType==typeof(Color))
                //    //{
                //    //    ItemNotifyClass itemClass = new ItemNotifyClass();
                //    //    Color brush = (Color)value;
                //    //    itemClass.Color = new SolidColorBrush(brush);
                //    //    itemClass.Name = item.Name.ToString();
                //    //    itemClass.Value = value.ToString();

                //    //    this.Collection.Add(itemClass);
                //    //}
                //}


                //foreach (var item in resource.Keys)
                //{

                //    object current = resource[item.ToString()];

                //    if (current is SolidColorBrush)
                //    {
                //        //  Message:查找到了想要的资源
                //        ItemNotifyClass itemClass = new ItemNotifyClass();
                //        SolidColorBrush brush = current as SolidColorBrush;
                //        itemClass.Color = brush;
                //        itemClass.Name = item.ToString();
                //        itemClass.Value = current.ToString();

                //        this.Collection.Add(itemClass);

                //    }
                //}
            }
            //  Do:取消
            else if (command == "Cancel")
            {
            }
        }