Exemple #1
0
        /// <summary>
        /// Binds a control already bound to a property to another property. A property change event for the original bound property  will be simulated on property change.
        /// </summary>
        /// <param name="control">The control to bind.</param>
        /// <param name="property">The name of the auxiliary property to listen. Should be relative to the root of EditorState.</param>
        /// <exception cref="ArgumentException">If the given control has not been bound to a property.</exception>
        public void BindControlToAuxiliaryPropertyChange(Control control, string property)
        {
            if (!controlBinds.ContainsKey(control))
            {
                throw new ArgumentException("Control '" + control.Name + "' has not been bound to a property.");
            }
            ControlBind thisBind = controlBinds[control];

            rsel.Register(property, (object sender, PropertyChangeEventArgs e) =>
            {
                if (e.PropertyName == property)
                {
                    RefreshBind(thisBind);
                }
            });
        }
Exemple #2
0
 private void BindControl(Component control, string bindPropertyName, string handlerPropertyName, PropertyChangeEventHandler handler)
 {
     lock (binderLock)
     {
         if (controlBinds.ContainsKey(control))
         {
             if (controlBinds[control].Property == bindPropertyName)
             {
                 return;
             }
             throw new ArgumentException("Control is already bound to a property.");
         }
         controlBinds[control] = new ControlBind(bindPropertyName, handler);
         rsel.RegisterAndCall(handlerPropertyName, handler);
     }
 }
Exemple #3
0
        /// <summary>
        /// Binds a control already bound to a property to a setting property. A property change event will be simulated on setting change.
        /// </summary>
        /// <param name="control">The control to bind.</param>
        /// <param name="settingProperty">The name of the setting property to listen. Should be relative to the root of EditorSettings.</param>
        /// <exception cref="ArgumentException">If the given control has not been bound to a property.</exception>
        public void BindControlToSettingChange(Control control, string settingProperty)
        {
            if (!controlBinds.ContainsKey(control))
            {
                throw new ArgumentException("Control '" + control.Name + "' has not been bound to a property.");
            }
            ControlBind thisBind             = controlBinds[control];
            string      listenedPropertyName = thisBind.Property;

            this.state.SettingChanged += (object sender, PropertyChangeEventArgs e) =>
            {
                if (PropertyUtil.IsAncestralProperty(settingProperty, e.PropertyName))
                {
                    RefreshBind(thisBind);
                }
            };
        }
Exemple #4
0
 private void RefreshBind(ControlBind bind)
 {
     bind.Handler(this, new PropertyChangeEventArgs(bind.Property, rsel.GetPropertyValue(bind.Property)));
 }