Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 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();
 }
Exemplo n.º 4
0
 public Property <T> AddChangedListener(PropertyChangedDelegate <T> listener, bool invoke = false)
 {
     Changed += listener;
     if (invoke)
     {
         listener(this, Value, Value);
     }
     return(this);
 }
Exemplo n.º 5
0
 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
        }
Exemplo n.º 7
0
 /// <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;
 }
Exemplo n.º 8
0
 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;
 }
Exemplo n.º 9
0
 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;
 }
Exemplo n.º 10
0
 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
		}
Exemplo n.º 12
0
 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();
 }
Exemplo n.º 13
0
 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;
 }
Exemplo n.º 14
0
 /// <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);
 }
Exemplo n.º 15
0
 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();
 }
Exemplo n.º 16
0
 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);
 }
Exemplo n.º 17
0
 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);
 }
Exemplo n.º 18
0
 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;
 }
Exemplo n.º 19
0
 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);
 }
Exemplo n.º 20
0
 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;
     }
 }
Exemplo n.º 21
0
 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;
     }
 }
Exemplo n.º 22
0
 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);
 }
Exemplo n.º 23
0
 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;
 }
Exemplo n.º 24
0
 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;
 }
Exemplo n.º 25
0
 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();
     }
 }
Exemplo n.º 26
0
 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();
     }
 }
Exemplo n.º 27
0
 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;
 }
Exemplo n.º 28
0
 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);
 }
Exemplo n.º 29
0
 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);
 }
Exemplo n.º 30
0
 public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate)
 {
     return new Editors.BrowseFolderEditor(Name, (string)value, propertyName, onChange, onActivate);
 }
Exemplo n.º 31
0
        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);
        }
Exemplo n.º 32
0
        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);
        }
Exemplo n.º 33
0
 /// <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;
 }
Exemplo n.º 34
0
        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));
 }
Exemplo n.º 36
0
        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;
            }
        }
Exemplo n.º 37
0
 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;
 }
Exemplo n.º 38
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="propertyInfo"></param>
 /// <param name="callback"></param>
 public PropertyMapperInfo(PropertyInfo propertyInfo, PropertyChangedDelegate <TSource> callback)
 {
     PropertyInfo = propertyInfo;
     Callback     = callback;
 }
Exemplo n.º 39
0
 public Property <T> InvokeOn(PropertyChangedDelegate <T> listener)
 {
     listener(this, Value, Value);
     return(this);
 }
Exemplo n.º 40
0
 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);
 }
Exemplo n.º 43
0
 /// <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);
Exemplo n.º 44
0
 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;
 }
Exemplo n.º 45
0
        /// <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);
        }
Exemplo n.º 46
0
        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);
        }
Exemplo n.º 47
0
        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);
 }
Exemplo n.º 49
0
 /// <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);
Exemplo n.º 50
0
 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;
		}