public ButtonEditor(PropertyLabel label, PropertyItem property) : base(property) { var button = new Button { Content = "..." }; button.Click += (sender, e) => MessageBox.Show("Custom dialog comes here..."); this.Content = button; }
protected virtual FrameworkElement GetItemLabel(PropertyLabel label, string category) { return(new Border() { Name = Guid.NewGuid().ToString("N"), Margin = new Thickness(0), BorderBrush = CommonBackground, BorderThickness = new Thickness(0, 0, 1, 1), Child = label, Tag = category }); }
public static EditorBase GetRegisteredEditor(PropertyLabel label, PropertyItem propertyItem) { Type editorType = null; if (!_registeredEditors.TryGetValue(propertyItem.PropertyType, out editorType)) { return(null); } var instance = Activator.CreateInstance(editorType, label, propertyItem); return(instance as EditorBase); }
public PropertyRow(PropertyGridView view, PropertyItem property, PropertyLabel label, EditorBase editor) { Requires.NotNull <PropertyGridView>(view, "view"); Requires.NotNull <PropertyItem>(property, "property"); Requires.NotNull <PropertyLabel>(label, "label"); Requires.NotNull <EditorBase>(editor, "editor"); this.View = view; this.Property = property; this.Label = label; this.Editor = editor; label.Name = "lbl" + property.Name; label.Foreground = property.CanWrite ? Brushes.Black : Brushes.Gray; label.MouseLeftButtonDown += LabelMouseLeftButtonDown; label.MouseLeftButtonUp += LabelMouseLeftButtonUp; editor.GotFocus += EditorGotFocus; editor.LostFocus += EditorLostFocus; }
public PropertyRow(PropertyGridView view, PropertyItem property, PropertyLabel label, EditorBase editor) { Requires.NotNull<PropertyGridView>(view, "view"); Requires.NotNull<PropertyItem>(property, "property"); Requires.NotNull<PropertyLabel>(label, "label"); Requires.NotNull<EditorBase>(editor, "editor"); this.View = view; this.Property = property; this.Label = label; this.Editor = editor; label.Name = "lbl" + property.Name; label.Foreground = property.CanWrite ? Brushes.Black : Brushes.Gray; label.MouseLeftButtonDown += LabelMouseLeftButtonDown; label.MouseLeftButtonUp += LabelMouseLeftButtonUp; editor.GotFocus += EditorGotFocus; editor.LostFocus += EditorLostFocus; }
protected virtual void CreatePropertyRow(PropertyItem property, ref int rowIndex) { #region Create Display Objects PropertyLabel label = CreateLabel(property.DisplayName); EditorBase editor = EditorService.GetEditor(property, label); if (editor == null) { return; } this.rows.Add(new PropertyRow(this, property, label, editor)); #endregion rowIndex++; this.RowDefinitions.Add(new RowDefinition()); //string category = property.Category; string category = property.Name; #region Column 0 - Margin FrameworkElement brd = GetItemMargin(category); this.Children.Add(brd); Grid.SetRow(brd, rowIndex); Grid.SetColumn(brd, 0); #endregion #region Column 1 - Label brd = GetItemLabel(label, category); this.Children.Add(brd); Grid.SetRow(brd, rowIndex); Grid.SetColumn(brd, 1); #endregion #region Column 2 - Editor brd = GetItemEditor(editor, category); this.Children.Add(brd); Grid.SetRow(brd, rowIndex); Grid.SetColumn(brd, 2); #endregion }
public static EditorBase GetEditor(PropertyItem propertyItem, PropertyLabel label) { if (propertyItem == null) { throw new ArgumentNullException("propertyItem"); } EditorAttribute attribute = propertyItem.GetAttribute <EditorAttribute>(); if (attribute != null) { Type editorType = Type.GetType(attribute.EditorTypeName, false); if (editorType != null) { return(Activator.CreateInstance(editorType, label, propertyItem) as EditorBase); } } var registeredEditor = GetRegisteredEditor(label, propertyItem); if (registeredEditor != null) { return(registeredEditor); } Type propertyType = propertyItem.PropertyType; EditorBase editor = GetEditor(propertyType, label, propertyItem); while (editor == null && propertyType.BaseType != null) { propertyType = propertyType.BaseType; editor = GetEditor(propertyType, label, propertyItem); } return(editor); }
public static EditorBase GetEditor(Type propertyType, PropertyLabel label, PropertyItem property) { if (typeof(Boolean).IsAssignableFrom(propertyType)) { return(new BooleanEditor(label, property)); } if (typeof(Enum).IsAssignableFrom(propertyType)) { return(new EnumEditor(label, property)); } if (typeof(DateTime).IsAssignableFrom(propertyType)) { return(new DateTimeEditor(label, property)); } if (typeof(String).IsAssignableFrom(propertyType)) { return(new StringEditor(label, property)); } if (typeof(Brush).IsAssignableFrom(propertyType)) { return(new BrushEditor(label, property)); } if (typeof(ValueType).IsAssignableFrom(propertyType)) { return(new StringEditor(label, property)); } //if (typeof(Object).IsAssignableFrom(propertyType)) // return new PropertyGrid(label, property); return(new StringEditor(label, property)); }
protected virtual FrameworkElement GetItemLabel(PropertyLabel label, string category) { return new Border() { Name = Guid.NewGuid().ToString("N"), Margin = new Thickness(0), BorderBrush = CommonBackground, BorderThickness = new Thickness(0, 0, 1, 1), Child = label, Tag = category }; }