Пример #1
0
 public ValueEditorBase(PropertyItem item)
 {
     Item = item;
     Margin = new Thickness(2, 0, 2, 0);
     this.DataContext = item.Property;
     this.SetBinding(IsEnabledProperty, "IsEnabled");
 }
Пример #2
0
 public StringValueEditor(PropertyItem item)
     : base(item)
 {
     _textBox.Text = null != item.Value ? item.Value.ToString() : string.Empty;
     _textBox.TextChanged += _textBox_TextChanged;
     _textBox.IsReadOnly = !item.PropertyInfo.CanWrite;
     this.Content = _textBox;
 }
Пример #3
0
 public GridLengthValueEditor(PropertyItem item)
     : base(item)
 {
     _comboBox.ItemsSource = new string[] { "自动", "*" };
     _comboBox.SelectedValue = item.Value;
     _comboBox.SelectionChanged += ComboBox_SelectionChanged;
     this.Content = _comboBox;
 }
Пример #4
0
 public ComboBoxValueEditor(PropertyItem item)
     : base(item)
 {
     _comboBox.DisplayMemberPath = GetDisplayMemberPath();
     _comboBox.SelectedValuePath = GetSelectValuePath();
     _comboBox.ItemsSource = GetItemSource();
     _comboBox.SelectedValue = item.Value;
     _comboBox.SelectionChanged += ComboBox_SelectionChanged;
     this.Content = _comboBox;
 }
Пример #5
0
        public FontFamilyValueEditor(PropertyItem item)
            : base(item)
        {
            _comboBox.ItemsSource = _fontFamilies;

            if (null != item.Value)
            {
                _comboBox.SelectedValue = item.Value;
            }

            _comboBox.SelectionChanged += ComboBox_SelectionChanged;

            this.Content = _comboBox;
        }
Пример #6
0
        public static ValueEditorBase CreateValueEdiorBase(PropertyItem item)
        {
            ImageAttribute imageAttribute = AttributeServices.GetAttribute<ImageAttribute>(item.PropertyInfo);
            if (null != imageAttribute)
            {
                return new ImageValueEditor(item, imageAttribute);
            }
            if (typeof(Boolean).IsAssignableFrom(item.PropertyInfo.PropertyType))
            {
                return new BooleanValueEditor(item);
            }
            if (typeof(Color).IsAssignableFrom(item.PropertyInfo.PropertyType))
            {
                return new ColorValueEditor(item);
            }
            if (typeof(Brush).IsAssignableFrom(item.PropertyInfo.PropertyType))
            {
                return new ColorValueEditor(item);
            }
            if (typeof(Thickness).IsAssignableFrom(item.PropertyInfo.PropertyType))
            {
                return new ThicknessValueEditor(item);
            }
            if (typeof(CornerRadius).IsAssignableFrom(item.PropertyInfo.PropertyType))
            {
                return new CornerRadiusValueEditor(item);
            }
            if (typeof(FontFamily).IsAssignableFrom(item.PropertyInfo.PropertyType))
            {
                return new FontFamilyValueEditor(item);
            }
            if (typeof(FontStyle).IsAssignableFrom(item.PropertyInfo.PropertyType))
            {
                return new FontStyleValueEditor(item);
            }
            if (typeof(FontWeight).IsAssignableFrom(item.PropertyInfo.PropertyType))
            {
                return new FontWeightValueEditor(item);
            }


            // ------------------------------------------------------------------------
            if (typeof(Enum).IsAssignableFrom(item.PropertyInfo.PropertyType) ||
                null != item.Property.Source)
            {
                return new EnumValueEditor(item);
            }
            return new StringValueEditor(item);
        }
Пример #7
0
        public ColorValueEditor(PropertyItem item)
            : base(item)
        {
            this.Content = _colorPicker;

            if (typeof(Brush).IsAssignableFrom(item.PropertyInfo.PropertyType))
            {
                _colorPicker.SelectedBrush = (SolidColorBrush)item.Value;
            }
            else if (typeof(Color).IsAssignableFrom(base.Item.PropertyInfo.PropertyType))
            {
                _colorPicker.SelectedBrush = new SolidColorBrush((Color)item.Value);
            }

            _colorPicker.SelectedBrushChanged += ColorPicker_SelectedBrushChanged;
        }
Пример #8
0
 public ImageValueEditor(PropertyItem item, ImageAttribute imageAttribute)
     : base(item)
 {
     _typeEnum = TypeEnum.Other;
     _imageAttribute = imageAttribute;
     if (null != _imageAttribute)
     {
         if (typeof(string).IsAssignableFrom(item.PropertyInfo.PropertyType))
         {
             _typeEnum = TypeEnum.String;
         }
         else if (typeof(byte[]).IsAssignableFrom(item.PropertyInfo.PropertyType))
         {
             _typeEnum = TypeEnum.ByteArray;
         }
         Layout();
     }
     UpdateValue(item.Value);
 }
Пример #9
0
        public void Browse(object instance, IEnumerable<Property> properties)
        {
            _mainGrid.RowDefinitions.Clear();
            _mainGrid.Children.Clear();
            _categories.Clear();
            _editors.Clear();
            if (null != instance && null != properties)
            {
                Type type = instance.GetType();
                PropertyInfo[] propertyInfos = type.GetProperties();
                Property property;
                foreach (PropertyInfo info in propertyInfos)
                {
                    if (null != 
                        (property = properties
                            .SingleOrDefault(p => p.PropertyName == info.Name)))
                    {
                        PropertyItem item = new PropertyItem(instance, info,property);
                        if (!_categories.ContainsKey(property.Category))
                        {
                            _categories.Add(property.Category, new List<PropertyItem>());
                        }
                        _categories[property.Category].Add(item);
                    }
                }
                CreateItem();

                if (null != _instance)
                {
                    _instance.PropertyChanged -= PropertyGrid_PropertyChanged;
                    _instance = null;
                }

                if (instance is INotifyPropertyChanged)
                {
                    _instance = instance as INotifyPropertyChanged;
                    _instance.PropertyChanged += PropertyGrid_PropertyChanged;
                }
            }
        }
Пример #10
0
 public BooleanValueEditor(PropertyItem item)
     : base(item)
 {
 }
Пример #11
0
 public CutomValueEditor(PropertyItem item, CustomAttribute attribute)
     : base(item)
 {
     _attribute = attribute;
     
 }
Пример #12
0
 public FontStyleValueEditor(PropertyItem item)
     : base(item)
 {
 }
Пример #13
0
 public EnumValueEditor(PropertyItem item)
     : base(item)
 {
 }
Пример #14
0
 public ThicknessValueEditor(PropertyItem item)
     : base(item)
 {
     this.DefaultStyleKey = typeof(ThicknessValueEditor);
 }
Пример #15
0
 public FontWeightValueEditor(PropertyItem item)
     : base(item)
 {
 }
Пример #16
0
 public CornerRadiusValueEditor(PropertyItem item)
     : base(item)
 {
     this.DefaultStyleKey = typeof(CornerRadiusValueEditor);
 }
Пример #17
0
 private PropertyGridLabel CreateLabel(int rowIndex, PropertyItem item)
 {
     PropertyGridLabel label = new PropertyGridLabel() { Text = item.Property.DisplayName };
     Grid.SetColumn(label, 1);
     Grid.SetRow(label, rowIndex);
     return label;
 }