public void ShouldReturnParentValue() { PropertyItemValue value = new PropertyItemValue(new PropertyItemMock()); PropertyItem property = new PropertyItemMock(value); Assert.AreEqual(value, property.ParentValue); }
public override void ShowDialog(PropertyItemValue propertyValue, IInputElement commandSource) { if (propertyValue == null) { return; } if (propertyValue.ParentProperty.IsReadOnly) { return; } var ofd = new OpenFileDialog(); ofd.Multiselect = false; var property = propertyValue.ParentProperty; if (property != null) { var optionsAttribute = (OpenFileDialogOptionsAttribute)property.Attributes[typeof(OpenFileDialogOptionsAttribute)]; if (optionsAttribute != null) { optionsAttribute.ConfigureDialog(ofd); } } if (ofd.ShowDialog() == true) { propertyValue.StringValue = ofd.FileName; } }
public override void ClearValue(PropertyItemValue propertyValue, IInputElement commandSource) { if (propertyValue == null || propertyValue.IsReadOnly) { return; } propertyValue.StringValue = string.Empty; }
/// <summary> /// Initializes a new instance of the <see cref="ValueExceptionEventArgs"/> class. /// </summary> /// <param name="message">The message.</param> /// <param name="value">The value.</param> /// <param name="source">The source.</param> /// <param name="exception">The exception.</param> public ValueExceptionEventArgs(string message, PropertyItemValue value, ValueExceptionSource source, Exception exception) { if (message == null) throw new ArgumentNullException("message"); if (value == null) throw new ArgumentNullException("value"); if (exception == null) throw new ArgumentNullException("exception"); _message = message; _value = value; _source = source; _exception = exception; }
public override void ShowDialog(PropertyItemValue propertyValue, IInputElement commandSource) { if (propertyValue == null) { return; } if (!propertyValue.IsCollection) { return; } MessageBox.Show("Collection!"); }
private void WrapEventHandlers(PropertyItemValue target) { if (target == null) { return; } if (_wrappedEvents) { return; } target.PropertyChanged += ValuePropertyChanged; _wrappedEvents = true; }
private void UnwrapEventHandlers(PropertyItemValue target) { if (target == null) { return; } if (!_wrappedEvents) { return; } target.PropertyChanged -= ValuePropertyChanged; _wrappedEvents = false; }
public CollectionItemValue(PropertyItemValue propertyItemValue, int index) { _propertyItemValue = propertyItemValue; _index = index; var expandable = PropertyGridUtils.GetAttributes <ExpandableObjectAttribute>(Value); if (expandable.Any()) { var descriptors = MetadataRepository.GetProperties(Value).Select(prop => prop.Descriptor); if (descriptors.Any()) { object objectValue; if (Value is ICloneable valueToClone) { objectValue = valueToClone.Clone(); } else { objectValue = Value; } HasSubProperties = true; var properties = new GridEntryCollection <PropertyItem>(); foreach (PropertyDescriptor d in descriptors) { var item = new PropertyItem(_propertyItemValue.ParentProperty.Owner, objectValue, d); item.IsBrowsable = ShouldDisplayProperty(d); item.ValueChanged += ItemOnValueChanged; properties.Add(item); } if (_propertyItemValue.ParentProperty.Owner.PropertyComparer != null) { properties.Sort(_propertyItemValue.ParentProperty.Owner.PropertyComparer); } SubProperties = properties; } MetadataRepository.Remove(Value); } }
/// <summary> /// Initializes a new instance of the <see cref="ValueExceptionEventArgs"/> class. /// </summary> /// <param name="message">The message.</param> /// <param name="value">The value.</param> /// <param name="source">The source.</param> /// <param name="exception">The exception.</param> public ValueExceptionEventArgs(string message, PropertyItemValue value, ValueExceptionSource source, Exception exception) { if (message == null) { throw new ArgumentNullException("message"); } if (value == null) { throw new ArgumentNullException("value"); } if (exception == null) { throw new ArgumentNullException("exception"); } _message = message; _value = value; _source = source; _exception = exception; }
public override void ShowDialog(PropertyItemValue propertyValue, IInputElement commandSource) { if (propertyValue == null) { return; } if (propertyValue.ParentProperty.IsReadOnly) { return; } OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.AllowMultiple = false; openFileDialog.Filters = new List <FileDialogFilter> { new FileDialogFilter() { Name = "Image Files (*.jpg, *.png, *.bmp)" , Extensions = new List <string>() { "jpg", "png", "bmp" } } }; var mainWindow = ApplicationExtension.GetMainWindow(); openFileDialog.ShowAsync(mainWindow).ContinueWith(x => { if (x.IsFaulted == false) { string result = x.Result.FirstOrDefault(); if (string.IsNullOrEmpty(result) == false) { propertyValue.StringValue = result; } } }, TaskScheduler.FromCurrentSynchronizationContext()); }
public override void ShowDialog(PropertyItemValue propertyValue, IInputElement commandSource) { PropertyGrid propGrid = commandSource as PropertyGrid; string lastPath = propertyValue.StringValue; if (propGrid == null) { return; } OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "All files (*.*)|*.*"; openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); openFileDialog.ShowDialog(); propertyValue.StringValue = openFileDialog.FileName != String.Empty ? openFileDialog.FileName : lastPath; // change this string and compile, the ui does not see this change propGrid.DoReload(); propGrid.RaiseEvent(new PropertyValueChangedEventArgs(PropertyGrid.PropertyValueChangedEvent, propertyValue.ParentProperty, "")); }
public override void ShowDialog(PropertyItemValue propertyValue, IInputElement commandSource) { if (propertyValue == null) { return; } if (propertyValue.ParentProperty.IsReadOnly) { return; } OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.AllowMultiple = false; var property = propertyValue.ParentProperty; if (property != null) { var optionsAttribute = (OpenFileDialogOptionsAttribute)property.Attributes[typeof(OpenFileDialogOptionsAttribute)]; if (optionsAttribute != null) { optionsAttribute.ConfigureDialog(openFileDialog); } } var mainWindow = ApplicationExtension.GetMainWindow(); openFileDialog.ShowAsync(mainWindow).ContinueWith(x => { if (x.IsFaulted == false) { string result = x.Result.FirstOrDefault(); if (string.IsNullOrEmpty(result) == false) { propertyValue.StringValue = result; } } }, TaskScheduler.FromCurrentSynchronizationContext()); }
public override void ShowDialog(PropertyItemValue propertyValue, IInputElement commandSource) { if (propertyValue == null) { return; } if (propertyValue.ParentProperty.IsReadOnly) { return; } OpenFileDialog ofd = new OpenFileDialog { Filter = "Image Files (*.jpg, *.png, *.bmp)|*.jpg;*.png;*.bmp", Multiselect = false }; if (ofd.ShowDialog() == true) { propertyValue.StringValue = ofd.FileName; } }
private void OnShowDialogEditor(object sender, ExecutedRoutedEventArgs e) { PropertyItemValue parameter = e.Parameter as PropertyItemValue; parameter?.ParentProperty?.Editor?.ShowDialog(parameter, this); }
/// <summary> /// Initializes a new instance of the <see cref="PropertyItem"/> class. /// </summary> /// <param name="parentValue">The parent value.</param> protected PropertyItem(PropertyItemValue parentValue) { _parentValue = parentValue; }
private void UnwrapEventHandlers(PropertyItemValue target) { if (target == null) return; if (!wrappedEvents) return; target.PropertyChanged -= ValuePropertyChanged; wrappedEvents = false; }
private void WrapEventHandlers(PropertyItemValue target) { if (target == null) return; if (wrappedEvents) return; target.PropertyChanged += ValuePropertyChanged; wrappedEvents = true; }
public PropertyItemMock(PropertyItemValue value) : base(value) { }
/// <summary> /// Shows the dialog for editing property value. /// </summary> /// <param name="propertyValue">The property value.</param> /// <param name="commandSource">The command source.</param> public virtual void ShowDialog(PropertyItemValue propertyValue, IInputElement commandSource) { }
public CollectionItemValue(PropertyItemValue propertyItemValue, int index) { _propertyItemValue = propertyItemValue; _index = index; }