public BrowseFolderEditor(string title, string value, string propertyName, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { _onChange = onChange; _onActivate = onActivate; _propertyName = propertyName; InitializeComponent(); labelTitle.Text = title; textValue.Text = value; }
public BrowseFolderEditor(string title, string value, string propertyName, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { _onChange = onChange; _onActivate = onActivate; _propertyName = propertyName; InitializeComponent(); labelTitle.Text = title; textValue.Text = value; }
public IntEditor(string title, int value, bool allowTemplates, string propertyName, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { _onChange = onChange; _onActivate = onActivate; _propertyName = propertyName; InitializeComponent(); labelTitle.Text = title; textValue.Text = value.ToString(); }
public Property <T> AddChangedListener(PropertyChangedDelegate <T> listener, bool invoke = false) { Changed += listener; if (invoke) { listener(this, Value, Value); } return(this); }
public CheckBoxEditor(string title, bool value, string propertyName, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { _propertyName = propertyName; _onChange = onChange; _onActivate = onActivate; InitializeComponent(); checkBox.Checked = value; checkBox.Text = title; }
/// <summary>Performs the logical operation "target.PropertyChanged += handler", /// where 'target' is located in another AppDomain, using this helper as an /// intermediary so that the subscription works correctly.</summary> public CrossDomainPropertyChangeHelper(IPropertyChanged target, PropertyChangedDelegate handler) { Debug.Assert(RemotingServices.IsTransparentProxy(target)); _handler = handler; target.PropertyChanged += Intermediary; // Honestly I don't know what I am doing. Tried to figure it out, failed. ((ILease)RemotingServices.GetLifetimeService(this)).Register(this); // register self as sponsor }
/// <summary> /// Initializes a new instance of the <see cref="DependencyProperty"/> class. /// </summary> /// <param name="declaringType">The type which declares the property.</param> /// <param name="ownerType">The type which can own this property.</param> /// <param name="propertyType">The type of the property.</param> /// <param name="name">The name of the property.</param> /// <param name="defaultBindingMode">The default <see cref="BindingMode"/> for this property.</param> /// <param name="isAttachement">Specifies if the property is a attachement.</param> /// <param name="createValueCallback">The default value of the property.</param> /// <param name="coerceValueCallback">The callback for coercing the value.</param> /// <param name="validationCallback">The validation callback of the value.</param> /// <param name="changingCallback">The changing callback of the property.</param> /// <param name="changedCallback">The changed callback of the property.</param> internal DependencyProperty(TypeInfo declaringType, String name, BindingMode defaultBindingMode, Boolean isAttachement, CreateValueDelegate <TOwner, TProperty> createValueCallback, CoerceValueDelegate <TOwner, TProperty> coerceValueCallback, PropertyValidationDelegate <TOwner, TProperty> validationCallback, PropertyChangingDelegate <TOwner, TProperty> changingCallback, PropertyChangedDelegate <TOwner, TProperty> changedCallback) : base(declaringType, Reflection.TypeOf <TOwner> .TypeInfo, name, defaultBindingMode, isAttachement, false) { _CreateValueCallback = createValueCallback; _CoerceValueCallback = coerceValueCallback; _ValidationCallback = validationCallback; _ChangingCallback = changingCallback; _ChangedCallback = changedCallback; }
public CheckBoxEditor(string title, bool value, string propertyName, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { _propertyName = propertyName; _onChange = onChange; _onActivate = onActivate; InitializeComponent(); checkBox.Checked = value; checkBox.Text = title; }
public DateTimeEditor(string title, DateTime value, bool allowTemplates, string propertyName, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { _propertyName = propertyName; _onChange = onChange; _onActivate = onActivate; InitializeComponent(); labelTitle.Text = title; dateTimePicker.Value = value; }
public DateTimeEditor(string title, DateTime value, bool allowTemplates, string propertyName, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { _propertyName = propertyName; _onChange = onChange; _onActivate = onActivate; InitializeComponent(); labelTitle.Text = title; dateTimePicker.Value = value; }
/// <summary>Performs the logical operation "target.PropertyChanged += handler", /// where 'target' is located in another AppDomain, using this helper as an /// intermediary so that the subscription works correctly.</summary> public CrossDomainPropertyChangeHelper(IPropertyChanged target, PropertyChangedDelegate handler) { Debug.Assert(RemotingServices.IsTransparentProxy(target)); _handler = handler; target.PropertyChanged += Intermediary; // Honestly I don't know what I am doing. Tried to figure it out, failed. ((ILease)RemotingServices.GetLifetimeService(this)).Register(this); // register self as sponsor }
public CheckBoxTemplateEditor(string title, object value, string propertyName, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { _propertyName = propertyName; _onChange = onChange; _onActivate = onActivate; InitializeComponent(); Value = value; checkBox.Text = title; AdjustControlState(); }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { var dateTime = (DateTime)value; if (dateTime <= DateTime.MinValue || dateTime >= DateTime.MaxValue) { dateTime = DateTime.Now; } Control control = new Editors.DateTimeEditor(Name, dateTime, AllowTemplates, propertyName, onChange, onActivate); return control; }
/// <summary> /// Initializes a new instance of the <see cref="DependencyProperty"/> class. /// </summary> /// <param name="declaringType">The type which declares the property.</param> /// <param name="ownerType">The type which can own this property.</param> /// <param name="propertyType">The type of the property.</param> /// <param name="name">The name of the property.</param> /// <param name="defaultBindingMode">The default <see cref="BindingMode"/> for this property.</param> /// <param name="isAttachement">Specifies if the property is a attachement.</param> /// <param name="defaultValue">The default value of the property.</param> /// <param name="coerceValueCallback">The callback for coercing the value.</param> /// <param name="validationCallback">The validation callback of the value.</param> /// <param name="changingCallback">The changing callback of the property.</param> /// <param name="changedCallback">The changed callback of the property.</param> internal DependencyProperty(TypeInfo declaringType, String name, BindingMode defaultBindingMode, Boolean isAttachement, TProperty defaultValue, CoerceValueDelegate <TOwner, TProperty> coerceValueCallback, PropertyValidationDelegate <TOwner, TProperty> validationCallback, PropertyChangingDelegate <TOwner, TProperty> changingCallback, PropertyChangedDelegate <TOwner, TProperty> changedCallback, out DependencyPropertyKey <TProperty> key) : base(declaringType, Reflection.TypeOf <TOwner> .TypeInfo, name, defaultBindingMode, isAttachement, false) { _DefaultValue = defaultValue; _CoerceValueCallback = coerceValueCallback; _ValidationCallback = validationCallback; _ChangingCallback = changingCallback; _ChangedCallback = changedCallback; Key = key = new DependencyPropertyKey <TProperty>(this); }
public CheckBoxTemplateEditor(string title, object value, string propertyName, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { _propertyName = propertyName; _onChange = onChange; _onActivate = onActivate; InitializeComponent(); Value = value; checkBox.Text = title; AdjustControlState(); }
public ListEditor(string title, IEnumerable <ComboBoxItem> list, Type listType, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { _onChange = onChange; _onActivate = onActivate; _propertyName = propertyName; _listType = listType; _itemType = _listType.GetProperty("Item").PropertyType; _body = body; InitializeComponent(); labelTitle.Text = title; PopulateList(list); }
public ListEditor(string title, IEnumerable<ComboBoxItem> list, Type listType, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { _onChange = onChange; _onActivate = onActivate; _propertyName = propertyName; _listType = listType; _itemType = _listType.GetProperty("Item").PropertyType; _body = body; InitializeComponent(); labelTitle.Text = title; PopulateList(list); }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { Control control; if (Multiline) { control = new Editors.MultilineTextEditor(Name, (string)value, MaxLength, propertyName, onChange, onActivate); } else { control = new Editors.TextEditor(Name, (string)value, MaxLength, propertyName, onChange, onActivate); } return control; }
public SimpleComboBoxEditor(string title, object list, bool dropDownListOnly, string displayField, string valueField, string propertyName, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { _onChange = onChange; _onActivate = onActivate; _propertyName = propertyName; InitializeComponent(); labelTitle.Text = title; comboBox.DropDownStyle = dropDownListOnly ? ComboBoxStyle.DropDownList : ComboBoxStyle.DropDown; comboBox.ValueMember = valueField; comboBox.DisplayMember = displayField; comboBox.DataSource = list; comboBox.SelectedIndexChanged += new EventHandler(comboBox_SelectedIndexChanged); }
public MultilineTextEditor(string title, string value, int maxLength, string propertyName, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { _propertyName = propertyName; _onChange = onChange; _onActivate = onActivate; InitializeComponent(); labelTitle.Text = title; textValue.Text = value; if (maxLength > 0) { textValue.MaxLength = maxLength; } }
public TextEditor(string title, string value, int maxLength, string propertyName, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { _onChange = onChange; _onActivate = onActivate; _propertyName = propertyName; InitializeComponent(); labelTitle.Text = title; textValue.Text = value; if (maxLength > 0) { textValue.MaxLength = maxLength; } }
public SimpleComboBoxEditor(string title, object list, bool dropDownListOnly, string displayField, string valueField, string propertyName, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { _onChange = onChange; _onActivate = onActivate; _propertyName = propertyName; InitializeComponent(); labelTitle.Text = title; comboBox.DropDownStyle = dropDownListOnly ? ComboBoxStyle.DropDownList : ComboBoxStyle.DropDown; comboBox.ValueMember = valueField; comboBox.DisplayMember = displayField; comboBox.DataSource = list; comboBox.SelectedIndexChanged += new EventHandler(comboBox_SelectedIndexChanged); }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { var fields = ListEnum.GetFields().Where(f => f.FieldType == ListEnum).ToList(); var list = new List<Editors.ComboBoxItem>(); foreach (var f in fields) { var nameAttr = f.GetCustomAttributes(true).OfType<GinNameAttribute>().FirstOrDefault(); list.Add(new Editors.ComboBoxItem { Display = nameAttr != null ? nameAttr.Name : f.Name, Value = f.GetValue(null) }); } Control control = new Editors.ComboBoxEditor(Name, value, true, list, propertyName, onChange, onActivate); return control; }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { Control control; if (AllowTemplates) { control = new Editors.CheckBoxTemplateEditor(Name, value, propertyName, onChange, onActivate); } else { var boolValue = false; if (value is bool) { boolValue = (bool)value; } control = new Editors.CheckBoxEditor(Name, boolValue, propertyName, onChange, onActivate); } return control; }
public ComplexValueEditor(string title, object value, Type valueType, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { if (value == null) { value = GetDefaultValueOrNull(valueType); } _onChange = onChange; _onActivate = onActivate; _propertyName = propertyName; _valueType = valueType; _value = value; _body = body; InitializeComponent(); labelTitle.Text = title; if (value != null) { labelValue.Text = value.ToString(); } }
public ComplexValueEditor(string title, object value, Type valueType, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { if (value == null) { value = GetDefaultValueOrNull(valueType); } _onChange = onChange; _onActivate = onActivate; _propertyName = propertyName; _valueType = valueType; _value = value; _body = body; InitializeComponent(); labelTitle.Text = title; if (value != null) { labelValue.Text = value.ToString(); } }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { Control control = null; var iList = value as IList; if (iList != null) { var list = new List<ComboBoxItem>(); foreach (var item in iList) { list.Add(new ComboBoxItem { Display = item.ToString(), Value = item }); } control = new ListEditor(Name, list, ListType, propertyName, body, onChange, onActivate); } return control; }
public ComboBoxEditor(string title, object value, bool dropDownListOnly, IEnumerable<ComboBoxItem> list, string propertyName, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { _onChange = onChange; _onActivate = onActivate; _propertyName = propertyName; InitializeComponent(); labelTitle.Text = title; comboBox.DropDownStyle = dropDownListOnly ? ComboBoxStyle.DropDownList : ComboBoxStyle.DropDown; comboBox.ValueMember = "Value"; comboBox.DisplayMember = "Display"; comboBox.DataSource = list; foreach (var item in comboBox.Items) { if (((ComboBoxItem)item).Value.ToString() == value.ToString()) { comboBox.SelectedItem = item; break; } } comboBox.SelectedIndexChanged += new EventHandler(comboBox_SelectedIndexChanged); }
public ComboBoxEditor(string title, object value, bool dropDownListOnly, IEnumerable <ComboBoxItem> list, string propertyName, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { _onChange = onChange; _onActivate = onActivate; _propertyName = propertyName; InitializeComponent(); labelTitle.Text = title; comboBox.DropDownStyle = dropDownListOnly ? ComboBoxStyle.DropDownList : ComboBoxStyle.DropDown; comboBox.ValueMember = "Value"; comboBox.DisplayMember = "Display"; comboBox.DataSource = list; foreach (var item in comboBox.Items) { if (((ComboBoxItem)item).Value.ToString() == value.ToString()) { comboBox.SelectedItem = item; break; } } comboBox.SelectedIndexChanged += new EventHandler(comboBox_SelectedIndexChanged); }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { return new Editors.BrowseFolderEditor(Name, (string)value, propertyName, onChange, onActivate); }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { Control control; if (AllowTemplates) { control = new Editors.CheckBoxTemplateEditor(Name, value, propertyName, onChange, onActivate); } else { var boolValue = false; if (value is bool) { boolValue = (bool)value; } control = new Editors.CheckBoxEditor(Name, boolValue, propertyName, onChange, onActivate); } return(control); }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { Control control; if (Multiline) { control = new Editors.MultilineTextEditor(Name, (string)value, MaxLength, propertyName, onChange, onActivate); } else { control = new Editors.TextEditor(Name, (string)value, MaxLength, propertyName, onChange, onActivate); } return(control); }
/// <summary> /// Returns null, 'cause it has no standard editor /// </summary> /// <returns>null</returns> public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { return null; }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { Control control = null; var iList = value as IList; if (iList != null) { var list = new List <ComboBoxItem>(); foreach (var item in iList) { list.Add(new ComboBoxItem { Display = item.ToString(), Value = item }); } control = new ListEditor(Name, list, ListType, propertyName, body, onChange, onActivate); } return(control); }
public static DependencyProperty <TProperty> Create <TDeclarer, TProperty>(Expression <Func <TDeclarer, TProperty> > getter, TProperty defaultValue = default(TProperty), BindingMode bindingMode = BindingMode.Default, PropertyValidationDelegate <TDeclarer, TProperty> validation = null, PropertyChangingDelegate <TDeclarer, TProperty> propertyChanging = null, PropertyChangedDelegate <TDeclarer, TProperty> propertyChanged = null, CoerceValueDelegate <TDeclarer, TProperty> coerceValue = null) where TDeclarer : class, IDependencyObject { return(new DependencyProperty <TProperty, TDeclarer>(TypeOf <TDeclarer> .TypeInfo, GetPropertyName <TDeclarer, TProperty>(getter), bindingMode, false, defaultValue, coerceValue, validation, propertyChanging, propertyChanged)); }
public static void PropertyChanged(INotifyPropertyChanged @object, string propertyName, PropertyChangedDelegate testCode) { Guard.ArgumentNotNull("object", @object); Guard.ArgumentNotNull("testCode", testCode); bool propertyChangeHappened = false; PropertyChangedEventHandler handler = (sender, args) => { if (propertyName.Equals(args.PropertyName, StringComparison.OrdinalIgnoreCase)) { propertyChangeHappened = true; } }; @object.PropertyChanged += handler; try { testCode(); if (!propertyChangeHappened) { throw new PropertyChangedException(propertyName); } } finally { @object.PropertyChanged -= handler; } }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { Control control = new Editors.IntEditor(Name, (int)value, AllowTemplates, propertyName, onChange, onActivate); return control; }
/// <summary> /// Constructor /// </summary> /// <param name="propertyInfo"></param> /// <param name="callback"></param> public PropertyMapperInfo(PropertyInfo propertyInfo, PropertyChangedDelegate <TSource> callback) { PropertyInfo = propertyInfo; Callback = callback; }
public Property <T> InvokeOn(PropertyChangedDelegate <T> listener) { listener(this, Value, Value); return(this); }
public Property <T> RemoveChangedListener(PropertyChangedDelegate <T> listener) { Changed -= listener; return(this); }
public void Dispose() { _handler = null; }
public static DependencyPropertyKey <TProperty> CreateReadonlyAttachment <TDeclarer, TOwner, TProperty>(String name, CreateValueDelegate <TOwner, TProperty> defaultValueFactory, BindingMode bindingMode = BindingMode.Default, PropertyValidationDelegate <TOwner, TProperty> validation = null, PropertyChangingDelegate <TOwner, TProperty> propertyChanging = null, PropertyChangedDelegate <TOwner, TProperty> propertyChanged = null, CoerceValueDelegate <TOwner, TProperty> coerceValue = null) where TOwner : class, IDependencyObject { ValidatePropertyName(name); new DependencyProperty <TProperty, TOwner>(TypeOf <TDeclarer> .TypeInfo, name, bindingMode, true, defaultValueFactory, coerceValue, validation, propertyChanging, propertyChanged, out DependencyPropertyKey <TProperty> key); return(key); }
/// <summary> /// Returns the UI-editor for this property /// </summary> /// <param name="value">Initial value for editor</param> /// <param name="propertyName">Property name</param> /// <param name="body">The PackageBody of current package</param> /// <param name="onChange">PropertyChanged delegate</param> /// <param name="onActivate">PropertyActivated delegate</param> /// <returns>Windows Forms Control, which supplies the edit value function for this class property</returns> public abstract Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate);
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { Control control = new Editors.ComplexValueEditor(Name, value, ValueType, propertyName, body, onChange, onActivate); return control; }
/// <summary> /// Add PropertyChanged callback /// </summary> /// <param name="expression"></param> /// <param name="callback"></param> /// <returns></returns> public PropertyChangedManager <TSource> AddPropertyChanged <TProperty>(Expression <Func <TSource, TProperty> > expression, PropertyChangedDelegate <TSource> callback) { if (callback == null) { throw new ArgumentNullException($"The value for {nameof(callback)} cannot be null."); } if (!(expression.Body is MemberExpression memberExpression)) { throw new InvalidOperationException("The lambda expression must refer to a property."); } if (!(memberExpression.Member is PropertyInfo propertyInfo)) { throw new InvalidOperationException("The lambda expression must refer to a property."); } string key = propertyInfo.Name; if (_propertyCallbackMapper.ContainsKey(key)) { _propertyCallbackMapper.Remove(key); } _propertyCallbackMapper.Add(key, new PropertyMapperInfo(propertyInfo, callback)); return(this); }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { Control control = new Editors.ComplexValueEditor(Name, value, ValueType, propertyName, body, onChange, onActivate); return(control); }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { var dateTime = (DateTime)value; if (dateTime <= DateTime.MinValue || dateTime >= DateTime.MaxValue) { dateTime = DateTime.Now; } Control control = new Editors.DateTimeEditor(Name, dateTime, AllowTemplates, propertyName, onChange, onActivate); return(control); }
public static DependencyPropertyKey <TProperty> CreateReadonly <TDeclarer, TProperty>(Expression <Func <TDeclarer, TProperty> > getter, CreateValueDelegate <TDeclarer, TProperty> defaultValueFactory, BindingMode bindingMode = BindingMode.Default, PropertyValidationDelegate <TDeclarer, TProperty> validation = null, PropertyChangingDelegate <TDeclarer, TProperty> propertyChanging = null, PropertyChangedDelegate <TDeclarer, TProperty> propertyChanged = null, CoerceValueDelegate <TDeclarer, TProperty> coerceValue = null) where TDeclarer : class, IDependencyObject { new DependencyProperty <TProperty, TDeclarer>(TypeOf <TDeclarer> .TypeInfo, GetPropertyName <TDeclarer, TProperty>(getter), bindingMode, true, defaultValueFactory, coerceValue, validation, propertyChanging, propertyChanged, out DependencyPropertyKey <TProperty> key); return(key); }
/// <summary> /// Returns the UI-editor for this property /// </summary> /// <param name="value">Initial value for editor</param> /// <param name="propertyName">Property name</param> /// <param name="body">The PackageBody of current package</param> /// <param name="onChange">PropertyChanged delegate</param> /// <param name="onActivate">PropertyActivated delegate</param> /// <returns>Windows Forms Control, which supplies the edit value function for this class property</returns> public abstract Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate);
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { return(new Editors.BrowseFileEditor(IsNewFile, Name, (string)value, propertyName, onChange, onActivate)); }
public void Dispose() { _handler = null; }