public void UpdateSelection(OptionValueChangedEventArgs e) { if (e == null) { return; } if (inUpdate) { return; } // if (!optionItem.IsAlive) { // return; // } // IOptionItem oi = (IOptionItem)optionItem.Target; object value = e.NewValue; if (value == OptionItem.VALUE_UNDEFINED) { //no change return; } try { inUpdate = true; //lock selection for the duration of our update selection.BeginValueUpdate(); ICollection <IPropertyItemDescriptor <T> > descriptors; descriptors = selection.Selection; bool hasChanged = false; foreach (IPropertyItemDescriptor <T> descriptor in descriptors) { //get the propertyItem from the current lookup IPropertyMap map = descriptor.Properties; if (map == null) { continue; } //get value from current selection item IPropertyItem item = map.GetEntry(virtualPropertyName); IValueSetter setter = item != null ? item.Setter : null; if (setter == null || !setter.CanSet()) { continue; } setter.SetValue(value); hasChanged = true; } if (hasChanged) { selection.UpdateSelectedItems(); } } finally { selection.EndValueUpdate(); inUpdate = false; } }
public void Add(IPropertyItem editor) { Control control = editor as Control; if (control == null) { return; } _items.Add(editor); control.Padding = new Padding(control.Padding.Left + GroupPropertyPadding, control.Padding.Top, control.Padding.Right, control.Padding.Bottom); AddSecondaryControl(control); }
public void Add(IPropertyItem editor) { var control = editor as Control; if (control == null) { return; } _items.Add(editor); AddSecondaryControl(control); }
public override System.Windows.DataTemplate SelectTemplate(object item, System.Windows.DependencyObject container) { DataTemplate template = null; IPropertyItem propertyItem = item as IPropertyItem; if (propertyItem != null) { FrameworkElement element = container as FrameworkElement; if (element != null) { var value = propertyItem.Value; if (value is String) { template = element.FindResource("dtStringValue") as DataTemplate; } else if (value is Int32) { template = element.FindResource("dtIntegerValue") as DataTemplate; }
/// <summary> /// Gets the property item by path. /// </summary> /// <param name="pi">The pi.</param> /// <param name="configPath">The config path.</param> /// <returns>The property item</returns> public static PropertyItem GetPropertyItemByPath(IPropertyItem pi, String configPath) { if (pi == null) { throw new ArgumentNullException("pi"); } if (string.IsNullOrEmpty(configPath)) { throw new ArgumentNullException("configPath"); } List <String> keys = new List <String>(); keys.AddRange(configPath.Split(new string[] { "/" }, StringSplitOptions.None)); PropertyItem result = FindPropertyItemByKey(pi, keys); keys.Clear(); return(result); }
private static PropertyItem FindPropertyItemByKey(IPropertyItem pi, List <String> keys) { PropertyItem result = null; if (pi.PropertyItems.ContainsKey(keys[0])) { PropertyItem item = pi.PropertyItems[keys[0]]; if (keys.Count == 1) { result = item; } else { keys.RemoveAt(0); result = FindPropertyItemByKey(item, keys); } } return(result); }
///<inheritdoc/> public virtual OptionItemValidities CheckValidity(ISelectionProvider <T> selection) { if (selection.Selection.Count == 0) { return(OptionItemValidities.Invalid); } OptionItemValidities retval = OptionItemValidities.ReadWrite; foreach (IPropertyItemDescriptor <T> descriptor in selection.Selection) { IPropertyMap map = descriptor.Properties; if (map == null) { return(OptionItemValidities.Invalid); } IPropertyItem item = map.GetEntry(virtualPropertyName); if (item != null) { IValueGetter getter = item.Getter; IValueSetter setter = item.Setter; if (getter != null && getter.CanGet()) { if (setter == null || !setter.CanSet()) { //readonly item... retval = OptionItemValidities.ReadOnly; } } else { //we can't even get the values :-( return(OptionItemValidities.Invalid); } } else { return(OptionItemValidities.Invalid); } } return(retval); }
public PropertyItemViewModel(IPropertyItem item) { Model = item as INotifyPropertyChanged; }
public void UpdateOptionItem(IOptionItem oi) { if (inUpdate) { return; } // if (!optionItem.IsAlive) { // return; // } // // IOptionItem oi = (IOptionItem)optionItem.Target; //lock... inUpdate = true; ICollection <IPropertyItemDescriptor <T> > descriptors; descriptors = selection.Selection; if (descriptors.Count == 0) { SetUndefinedValue(oi); inUpdate = false; return; } bool filled = false; object accumulatedValue = null; foreach (IPropertyItemDescriptor <T> descriptor in descriptors) { //get the propertyItem from the current lookup IPropertyMap map = descriptor.Properties; if (map == null) { continue; } IPropertyItem item = map.GetEntry(virtualPropertyName); if (item == null) { continue; } //get value from current selection item IValueGetter getter = item.Getter; if (getter == null || !getter.CanGet()) { continue; } object value = getter.GetValue(); if (!filled) { //first value accumulatedValue = value; filled = true; } else { //check if value is different? IEqualityComparer comparer = item.EqualityComparer; if (comparer != null) { if (!comparer.Equals(accumulatedValue, value)) { SetUndefinedValue(oi); inUpdate = false; return; } } else { if (accumulatedValue != null && !accumulatedValue.Equals(value)) { SetUndefinedValue(oi); inUpdate = false; return; } else if (accumulatedValue == null && value != null) { SetUndefinedValue(oi); inUpdate = false; return; } } } } if (accumulatedValue == null) { if ((bool)oi.Attributes[OptionItem.SupportNullValueAttribute]) { oi.Value = accumulatedValue; } } else { oi.Value = accumulatedValue; } inUpdate = false; }
public PropertyItemController(IPropertyItem propertyItem) { _propertyItem = propertyItem; }
void OnPropertySelectionChanged(PropertyItemViewModel payload) { if (_selectedItem != null) { _selectedItem.PropertyChanged -= _selectedItem_PropertyChanged; } var pItem = _appModel.CurrentFile.Properties.FirstOrDefault(p => p.Name == payload.Name); _selectedItem = pItem; if (pItem != null) { _selectedItem.PropertyChanged += _selectedItem_PropertyChanged; SelectedPropertyName = pItem.Name; Value = pItem.Value.ToString(); } }