public ValueEditorBase(PropertyItem item) { Item = item; Margin = new Thickness(2, 0, 2, 0); this.DataContext = item.Property; this.SetBinding(IsEnabledProperty, "IsEnabled"); }
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; }
public GridLengthValueEditor(PropertyItem item) : base(item) { _comboBox.ItemsSource = new string[] { "自动", "*" }; _comboBox.SelectedValue = item.Value; _comboBox.SelectionChanged += ComboBox_SelectionChanged; this.Content = _comboBox; }
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; }
public FontFamilyValueEditor(PropertyItem item) : base(item) { _comboBox.ItemsSource = _fontFamilies; if (null != item.Value) { _comboBox.SelectedValue = item.Value; } _comboBox.SelectionChanged += ComboBox_SelectionChanged; this.Content = _comboBox; }
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); }
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; }
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); }
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; } } }
public BooleanValueEditor(PropertyItem item) : base(item) { }
public CutomValueEditor(PropertyItem item, CustomAttribute attribute) : base(item) { _attribute = attribute; }
public FontStyleValueEditor(PropertyItem item) : base(item) { }
public EnumValueEditor(PropertyItem item) : base(item) { }
public ThicknessValueEditor(PropertyItem item) : base(item) { this.DefaultStyleKey = typeof(ThicknessValueEditor); }
public FontWeightValueEditor(PropertyItem item) : base(item) { }
public CornerRadiusValueEditor(PropertyItem item) : base(item) { this.DefaultStyleKey = typeof(CornerRadiusValueEditor); }
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; }