Exemplo n.º 1
0
        internal void SetBindableComponent(IBindableComponent value)
        {
            if (this.control != value)
            {
                IBindableComponent oldTarget = control;
                BindTarget(false);
                this.control = value;
                BindTarget(true);
                try {
                    CheckBinding();
                }
                catch {
                    BindTarget(false);
                    control = oldTarget;
                    BindTarget(true);
                    throw;
                }

                // We are essentially doing to the listManager what we were doing to the
                // BindToObject: bind only when the control is created and it has a BindingContext
                BindingContext.UpdateBinding((control != null && IsComponentCreated(control) ? control.BindingContext: null), this);
                Form form = value as Form;
                if (form != null)
                {
                    form.Load += new EventHandler(FormLoaded);
                }
            }
        }
Exemplo n.º 2
0
 private static void Bind(IBindableComponent bindable, Item item)
 {
     bindable.DataBindings.Add("Text", item, "Text");
     bindable.DataBindings.Add("ToolTipText", item, "ToolTipText");
     bindable.DataBindings.Add("Enabled", item, "Enabled");
     bindable.DataBindings.Add("Visible", item, "Visible");
 }
Exemplo n.º 3
0
        public ControlBindingsCollection(IBindableComponent control)
        {
            bindable_component = control;
            //control = control as Widget;

            default_datasource_update_mode = DataSourceUpdateMode.OnValidation;
        }
Exemplo n.º 4
0
        void AddDataBinding(IBindableComponent component, string propertyName, object dataSource, string dataMember)
        {
            Binding dataBinding = new Binding(propertyName, dataSource, dataMember, false, DataSourceUpdateMode.OnPropertyChanged);

            component.DataBindings.Add(dataBinding);
            _dataBindings.Add(dataBinding);
        }
 internal void SetBindableComponent(IBindableComponent value)
 {
     if (this.control != value)
     {
         IBindableComponent control = this.control;
         this.BindTarget(false);
         this.control = value;
         this.BindTarget(true);
         try
         {
             this.CheckBinding();
         }
         catch
         {
             this.BindTarget(false);
             this.control = control;
             this.BindTarget(true);
             throw;
         }
         BindingContext.UpdateBinding(((this.control != null) && IsComponentCreated(this.control)) ? this.control.BindingContext : null, this);
         Form form = value as Form;
         if (form != null)
         {
             form.Load += new EventHandler(this.FormLoaded);
         }
     }
 }
Exemplo n.º 6
0
 public static void Bind <T, U>(this IBindableComponent component,
                                Binding binding, Func <T, U> transform)
 {
     binding.Parse  += (s, e) => e.Value = transform((T)e.Value);
     binding.Format += (s, e) => e.Value = transform((T)e.Value);
     component.DataBindings.Add(binding);
 }
Exemplo n.º 7
0
        internal void SetBindableComponent(IBindableComponent value)
        {
            if (BindableComponent != value)
            {
                IBindableComponent oldTarget = BindableComponent;
                BindTarget(false);
                BindableComponent = value;
                BindTarget(true);
                try
                {
                    CheckBinding();
                }
                catch
                {
                    BindTarget(false);
                    BindableComponent = oldTarget;
                    BindTarget(true);
                    throw;
                }

                // We are essentially doing to the listManager what we were doing to the
                // BindToObject: bind only when the control is created and it has a BindingContext
                BindingContext.UpdateBinding((BindableComponent is not null && IsComponentCreated(BindableComponent) ? BindableComponent.BindingContext : null), this);
                if (value is Form form)
                {
                    form.Load += new EventHandler(FormLoaded);
                }
            }
        }
        public ControlBindingsCollection(IBindableComponent control)
        {
            bindable_component = control;
            //control = control as Widget;

            default_datasource_update_mode = DataSourceUpdateMode.OnValidation;
        }
		internal ControlBindingsCollection (Control control) {
			this.control = control;
#if NET_2_0
			bindable_component = control as IBindableComponent;
			default_datasource_update_mode = DataSourceUpdateMode.OnValidation;
#endif
		}
Exemplo n.º 10
0
 private void Bind(IBindableComponent control, string property)
 {
     if (control != null)
     {
         control.DataBindings.Add("Text", vault, property, true, DataSourceUpdateMode.OnPropertyChanged,
                                  0, "000");
     }
 }
Exemplo n.º 11
0
 public Binding BindObject(IBindableComponent bindableObj, IColumn column, NullValue nullValue)
 {
     if (dbManager.GetDataColumn(column).DefaultValue is System.DBNull && nullValue == NullValue.SetNull)
     {
         dbManager.GetDataColumn(column).DefaultValue = column.DefaultValue;
     }
     return(bindableObj.DataBindings.Add("Value", dbManager.MasterBinding, column.Name));
 }
Exemplo n.º 12
0
        internal ControlBindingsCollection(Control control)
        {
            this.control = control;
#if NET_2_0
            bindable_component             = control as IBindableComponent;
            default_datasource_update_mode = DataSourceUpdateMode.OnValidation;
#endif
        }
Exemplo n.º 13
0
 private void Bind(IBindableComponent control, string property)
 {
     if (control != null)
     {
         control.DataBindings.Add("Text", vault, property, true, DataSourceUpdateMode.OnPropertyChanged,
                                  0, "000");
     }
 }
Exemplo n.º 14
0
        public static Binding AddDataBinding <TD, TDp>(
            IBindableComponent control,
            TD data, Expression <Func <TD, TDp> > dataProperty)
        {
            if (control == null)
            {
                throw new ArgumentNullException(nameof(control));
            }
            if (dataProperty == null)
            {
                throw new ArgumentNullException(nameof(dataProperty));
            }
            var    dataMemberBody = (MemberExpression)dataProperty.Body;
            var    dataMemberName = dataMemberBody.Member.Name;
            string name           = null;
            // Add TextBox.
            var textBox = control as TextBox;

            if (textBox != null)
            {
                name = nameof(textBox.Text);
            }
            // Add ComboBox.
            var comboBox = control as ComboBox;

            if (comboBox != null)
            {
                name = string.IsNullOrEmpty(comboBox.ValueMember)
                                        ? nameof(comboBox.SelectedItem)
                                        : nameof(comboBox.SelectedValue);
            }
            // Add CheckBox.
            var checkBox = control as CheckBox;

            if (checkBox != null)
            {
                name = nameof(checkBox.Checked);
            }
            // Add NumericUpDown.
            var upDown = control as NumericUpDown;

            if (upDown != null)
            {
                name = nameof(upDown.Value);
            }
            // If type is missing then throw error.
            if (string.IsNullOrEmpty(name))
            {
                throw new Exception(string.Format("Add control Type '{0}' to ControlsHelper.AddDataBinding(control, data, dataProperty) method!", control.GetType()));
            }
            // Add data binding.
            return(control.DataBindings.Add(name, data, dataMemberName,
                                            false,
                                            DataSourceUpdateMode.OnPropertyChanged,
                                            null,
                                            null,
                                            null));
        }
Exemplo n.º 15
0
 internal static bool IsComponentCreated(IBindableComponent component)
 {
     System.Windows.Forms.Control control = component as System.Windows.Forms.Control;
     if (control != null)
     {
         return(control.Created);
     }
     return(true);
 }
Exemplo n.º 16
0
 /// <summary>
 ///   Attaches a binding to a component, using the given format transformation.
 /// </summary>
 ///
 /// <typeparam name="TSource">The type of the source property.</typeparam>
 /// <typeparam name="TDestination">The type of the destination.</typeparam>
 ///
 /// <param name="component">The component to which the binding applies (such as a control in the form).</param>
 /// <param name="propertyName">The name of the control property to bind.</param>
 /// <param name="dataSource">An object that represents the data source.</param>
 /// <param name="dataMember">The property or list to bind to.</param>
 /// <param name="format">The format transformation which transforms the model's property to a control's value.</param>
 ///
 public static Binding Bind <TSource, TDestination>(this IBindableComponent component,
                                                    string propertyName, object dataSource, string dataMember, Func <TSource, TDestination> format)
 {
     if (component == null)
     {
         throw new ArgumentNullException("component");
     }
     return(Bind(component, new Binding(propertyName, dataSource, dataMember), format));
 }
        public void Ctor_IBindableComponent(IBindableComponent control, Control expectedControl)
        {
            var collection = new ControlBindingsCollection(control);

            Assert.Same(control, collection.BindableComponent);
            Assert.Same(expectedControl, collection.Control);
            Assert.Equal(DataSourceUpdateMode.OnValidation, collection.DefaultDataSourceUpdateMode);
            Assert.Empty(collection);
        }
Exemplo n.º 18
0
 /// <summary>
 ///   Attaches a binding to a component, using the given format transformation.
 /// </summary>
 ///
 /// <param name="component">The component to which the binding applies (such as a control in the form).</param>
 /// <param name="binding">The binding object which defines the property being bound (such as a ViewModel property).</param>
 ///
 public static Binding Bind(this IBindableComponent component, Binding binding)
 {
     if (component == null)
     {
         throw new ArgumentNullException("component");
     }
     component.DataBindings.Add(binding);
     return(binding);
 }
Exemplo n.º 19
0
        private static void SetBinding(IBindableComponent control, string propertyName, object dataSource, string dataMember)
        {
            Contract.Requires(control != null);
            Contract.Requires(propertyName != null);
            Contract.Requires(dataSource != null);
            Contract.Requires(dataMember != null);

            control.DataBindings.Add(propertyName, dataSource, dataMember, true, DataSourceUpdateMode.OnPropertyChanged);
        }
 public static void Bind <T>(this IBindableComponent component, T value, Expression <Func <object> > controlProperty, Expression <Func <T, object> > modelProperty)
     where T : INotifyPropertyChanged
 {
     component.DataBindings.Add(new Binding(
                                    StringExtensions.PropertyName(controlProperty),
                                    value,
                                    StringExtensions.PropertyName(modelProperty),
                                    true,
                                    DataSourceUpdateMode.OnPropertyChanged));
 }
Exemplo n.º 21
0
        /// <summary>
        /// Method for retrieving the bound meta data column of a given editor.
        /// </summary>
        private MetaDataColumn getEditorColumn(IBindableComponent editor)
        {
            if (editor.DataBindings.Count == 0)
            {
                return(null);
            }
            var colName = editor.DataBindings[0].BindingMemberInfo.BindingField;

            return(!_data.Columns.ContainsName(colName) ? null : _data.Columns.ItemByName(colName));
        }
Exemplo n.º 22
0
        protected void Bind(IBindableComponent component, string propertyName, string dataMember, IValueConverter converter = null, DataSourceUpdateMode dataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged)
        {
            var binding = new CustomBinding(propertyName, this, dataMember, converter)
            {
                DataSourceUpdateMode = dataSourceUpdateMode,
                ControlUpdateMode    = ControlUpdateMode.OnPropertyChanged
            };

            component.DataBindings.Add(binding);
            _bindings[dataMember] = binding;
        }
Exemplo n.º 23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BindingProviderBase&lt;T&gt;"/> class.
        /// </summary>
        /// <param name="bindableComponent">The owner.</param>
        protected BindingProviderBase(IBindableComponent bindableComponent)
        {
            this.owner = bindableComponent;
            if (this.owner != null)
            {
                this.bindingContext = owner.BindingContext;
            }

            this.logicalItems = new List <T>();

            this.UpdateLogicalPropertiesCache();
        }
Exemplo n.º 24
0
        public void SetMemoBobinaControl(ACBrECF ecf, IBindableComponent control)
        {
            ECFInfo info;

            if (!this.infos.TryGetValue(ecf.Handle, out info))
            {
                info     = new ECFInfo();
                info.ECF = ecf;
                infos.Add(ecf.Handle, info);
            }

            info.Control = control;
        }
Exemplo n.º 25
0
        // Is the binadable component in a 'created' (ready-to-use) state? For controls,
        // this depends on whether the window handle has been created yet. For everything
        // else, we'll assume they are always in a created state.
        internal static bool IsComponentCreated(IBindableComponent component)
        {
            Control ctrl = (component as Control);

            if (ctrl != null)
            {
                return(ctrl.Created);
            }
            else
            {
                return(true);
            }
        }
 public static bool IsBound(this GridItem item, out IBindableComponent component)
 {
     if (item == null)
     {
         throw new ArgumentNullException(nameof(item));
     }
     if (GetBindableObject(item) is IBindableComponent bindableComponent && (item.PropertyDescriptor?.Attributes.OfType <BindableAttribute>().FirstOrDefault() ?? BindableAttribute.Default).Bindable)
     {
         component = bindableComponent;
         return(bindableComponent.DataBindings.Cast <Binding>().Any(b => b.PropertyName == GetBindablePropertyDescriptor(item.PropertyDescriptor).Name));
     }
     component = null;
     return(false);
 }
Exemplo n.º 27
0
//        private void rbSplit_CheckedChanged(object sender, EventArgs e) {
//            if (rbSplit.Checked) SplitBehavior = SplitBehavior.Split;
//        }
//
//        private void rbSkip_CheckedChanged(object sender, EventArgs e) {
//            if (rbSkip.Checked) SplitBehavior = SplitBehavior.Skip;
//        }

        private void AddRadioCheckedBinding <T>(IBindableComponent component, object dataSource, string dataMember,
                                                T trueValue)
        {
            var binding = new Binding(nameof(RadioButton.Checked), dataSource, dataMember, true,
                                      DataSourceUpdateMode.OnPropertyChanged);

            binding.Parse += (s, a) => {
                if ((bool)a.Value)
                {
                    a.Value = trueValue;
                }
            };
            binding.Format += (s, a) => a.Value = ((T)a.Value).Equals(trueValue);
            component.DataBindings.Add(binding);
        }
Exemplo n.º 28
0
        /// <summary>
        ///   Attaches a binding to a component, using the given format transformation.
        /// </summary>
        ///
        /// <param name="component">The component to which the binding applies (such as a control in the form).</param>
        /// <param name="propertyName">The name of the control property to bind.</param>
        /// <param name="dataSource">An object that represents the data source.</param>
        /// <param name="dataMember">The property or list to bind to.</param>
        ///
        public static Binding Bind(this IBindableComponent component,
                                   string propertyName, object dataSource, string dataMember)
        {
            if (component == null)
            {
                throw new ArgumentNullException("component");
            }

            Binding binding = new Binding(propertyName, dataSource, dataMember);

            binding.DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged;
            binding.ControlUpdateMode    = ControlUpdateMode.OnPropertyChanged;

            return(Bind(component, binding));
        }
Exemplo n.º 29
0
 /// <summary>
 ///   Attaches a binding to a component, using the given format transformation.
 /// </summary>
 ///
 /// <typeparam name="TSource">The type of the source property.</typeparam>
 /// <typeparam name="TDestination">The type of the destination.</typeparam>
 ///
 /// <param name="component">The component to which the binding applies (such as a control in the form).</param>
 /// <param name="binding">The binding object which defines the property being bound (such as a ViewModel property).</param>
 /// <param name="format">The format transformation which transforms the model's property to a control's value.</param>
 ///
 public static Binding Bind <TSource, TDestination>(this IBindableComponent component,
                                                    Binding binding, Func <TSource, TDestination> format)
 {
     if (component == null)
     {
         throw new ArgumentNullException("component");
     }
     if (binding == null)
     {
         throw new ArgumentNullException("binding");
     }
     binding.Format           += (sender, e) => e.Value = format((TSource)e.Value);
     binding.FormattingEnabled = true;
     component.DataBindings.Add(binding);
     return(binding);
 }
Exemplo n.º 30
0
        internal void SetControl(IBindableComponent control)
        {
            if (control == this.control)
            {
                return;
            }

            this.source = (control is IBindableDecorator) ?
                          ((IBindableDecorator)control).Component : control;

            control_property = TypeDescriptor.GetProperties(source).Find(property_name, true);

            if (control_property == null)
            {
                throw new ArgumentException(String.Concat("Cannot bind to property '", property_name, "' on target control."));
            }
            if (control_property.IsReadOnly)
            {
                throw new ArgumentException(String.Concat("Cannot bind to property '", property_name, "' because it is read only."));
            }

            data_type = control_property.PropertyType;             // Getting the PropertyType is kinda slow and it should never change, so it is cached

            /*Widget ctrl = control as Widget;
             * if (ctrl != null) {
             *      ctrl.Validating += new CancelEventHandler (ControlValidatingHandler);
             *      if (!ctrl.IsHandleCreated)
             *              ctrl.HandleCreated += new EventHandler (ControlCreatedHandler);
             * }*/

            control.Validating += new CancelEventHandler(ControlValidatingHandler);
//			if (!control.IsHandleCreated)
//				control.HandleCreated += new EventHandler (ControlCreatedHandler);

            EventDescriptor prop_changed_event = GetPropertyChangedEvent(source, property_name);

            if (prop_changed_event != null)
            {
                prop_changed_event.AddEventHandler(control, new EventHandler(ControlPropertyChangedHandler));
            }

            this.control = control;
            UpdateIsBinding();
        }
Exemplo n.º 31
0
        internal void SetControl(Control control)
#endif
        {
            if (control == this.control)
            {
                return;
            }

            control_property = TypeDescriptor.GetProperties(control).Find(property_name, true);

            if (control_property == null)
            {
                throw new ArgumentException(String.Concat("Cannot bind to property '", property_name, "' on target control."));
            }
            if (control_property.IsReadOnly)
            {
                throw new ArgumentException(String.Concat("Cannot bind to property '", property_name, "' because it is read only."));
            }

            data_type = control_property.PropertyType;             // Getting the PropertyType is kinda slow and it should never change, so it is cached

            Control ctrl = control as Control;

            if (ctrl != null)
            {
                ctrl.Validating += new CancelEventHandler(ControlValidatingHandler);
                if (!ctrl.IsHandleCreated)
                {
                    ctrl.HandleCreated += new EventHandler(ControlCreatedHandler);
                }
            }

#if NET_2_0
            EventDescriptor prop_changed_event = GetPropertyChangedEvent(control, property_name);
            if (prop_changed_event != null)
            {
                prop_changed_event.AddEventHandler(control, new EventHandler(ControlPropertyChangedHandler));
            }
#endif
            this.control = control;
            UpdateIsBinding();
        }
Exemplo n.º 32
0
 private void PushChanges()
 {
     if (this.Dirty)
     {
         IComponentChangeService service           = this.host.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
         PropertyDescriptor      member            = null;
         IBindableComponent      bindableComponent = this.bindings.BindableComponent;
         if ((service != null) && (bindableComponent != null))
         {
             member = TypeDescriptor.GetProperties(bindableComponent)["DataBindings"];
             if (member != null)
             {
                 service.OnComponentChanging(bindableComponent, member);
             }
         }
         this.bindings.Clear();
         TreeNode node = this.propertiesTreeView.Nodes[0];
         for (int i = 0; i < node.Nodes.Count; i++)
         {
             BindingTreeNode node2 = node.Nodes[i] as BindingTreeNode;
             if (node2.Binding != null)
             {
                 this.bindings.Add(node2.Binding);
             }
         }
         TreeNode node3 = this.propertiesTreeView.Nodes[1];
         for (int j = 0; j < node3.Nodes.Count; j++)
         {
             BindingTreeNode node4 = node3.Nodes[j] as BindingTreeNode;
             if (node4.Binding != null)
             {
                 this.bindings.Add(node4.Binding);
             }
         }
         if (((service != null) && (bindableComponent != null)) && (member != null))
         {
             service.OnComponentChanged(bindableComponent, member, null, null);
         }
     }
 }
Exemplo n.º 33
0
        private void Bind(IBindableComponent bindable, Item item)
        {
            _bindingManager.Bindings.Add(new Binding(bindable, "Text", item, "Text")
            {
                Mode = BindingMode.OneWayToTarget
            });

            _bindingManager.Bindings.Add(new Binding(bindable, "ToolTipText", item, "ToolTipText")
            {
                Mode = BindingMode.OneWayToTarget
            });

            _bindingManager.Bindings.Add(new Binding(bindable, "Enabled", item, "Enabled")
            {
                Mode = BindingMode.OneWayToTarget
            });

            _bindingManager.Bindings.Add(new Binding(bindable, "Visible", item, "Visible")
            {
                Mode = BindingMode.OneWayToTarget
            });
        }
 public ControlBindingsCollection(IBindableComponent control)
 {
     this.control = control;
 }
Exemplo n.º 35
0
		internal void SetControl (IBindableComponent control)
		{
			if (control == this.control)
				return;

			control_property = TypeDescriptor.GetProperties (control).Find (property_name, true);			

			if (control_property == null)
				throw new ArgumentException (String.Concat ("Cannot bind to property '", property_name, "' on target control."));
			if (control_property.IsReadOnly)
				throw new ArgumentException (String.Concat ("Cannot bind to property '", property_name, "' because it is read only."));
				
			data_type = control_property.PropertyType; // Getting the PropertyType is kinda slow and it should never change, so it is cached

			Control ctrl = control as Control;
			if (ctrl != null) {
				ctrl.Validating += new CancelEventHandler (ControlValidatingHandler);
				if (!ctrl.IsHandleCreated)
					ctrl.HandleCreated += new EventHandler (ControlCreatedHandler);
			}

			EventDescriptor prop_changed_event = GetPropertyChangedEvent (control, property_name);
			if (prop_changed_event != null)
				prop_changed_event.AddEventHandler (control, new EventHandler (ControlPropertyChangedHandler));
			this.control = control;
			UpdateIsBinding ();
		}
 internal ControlBindingsCollection(Widget control)
 {
     bindable_component = control as IBindableComponent;
     default_datasource_update_mode = DataSourceUpdateMode.OnValidation;
 }
 /// <include file='doc\ControlBindingsCollection.uex' path='docs/doc[@for="ControlBindingsCollection.ControlBindingsCollection"]/*' />
 public ControlBindingsCollection(IBindableComponent control) : base() {
     Debug.Assert(control != null, "How could a controlbindingscollection not have a control associated with it!");
     this.control = control;
 }
        /// <summary>
        /// Processes the control.
        /// </summary>
        /// <param name="control">The control.</param>
        private void ProcessControl(IBindableComponent control)
        {
            if (control == null) throw new ArgumentNullException("control");

            bool hasWarning = false;
            bool hasInfo = false;

            foreach (Binding binding in control.DataBindings)
            {
                // get the Binding if appropriate
                if (binding.DataSource == DataSource)
                {
                    string propertyName = binding.BindingMemberInfo.BindingField;

                    bool bError = _errorList.ContainsKey(propertyName);
                    bool bWarn = _warningList.ContainsKey(propertyName);
                    bool bInfo = _infoList.ContainsKey(propertyName);

                    // set flags to indicat if Warning or Info is highest severity; else false
                    if (_showMostSevereOnly)
                    {
                        bInfo = bInfo && !bWarn && !bError;
                        bWarn = bWarn && !bError;
                    }

                    int offsetInformation = _offsetInformation;
                    int offsetWarning = _offsetWarning;

                    // Set / fix offsets
                    // by default the setting are correct for Error (0), Warning and Info
                    if (!bError)
                    {
                        if (bWarn)
                        {
                            // warning and possibly info, no error
                            offsetInformation = _offsetInformation - _offsetWarning;
                            offsetWarning = 0;
                        }
                        else
                        {
                            // Info only
                            offsetInformation = 0;
                        }
                    }
                    else if (!bWarn)
                    {
                        offsetInformation = _offsetInformation - _offsetWarning;
                    }


                    // should warning be visible
                    if (_visibleWarning && bWarn)
                    {
                        errorProviderWarn.SetError(binding.Control, _warningList[propertyName]);
                        errorProviderWarn.SetIconPadding(binding.Control,
                                                              base.GetIconPadding(binding.Control) +
                                                              offsetWarning);
                        errorProviderWarn.SetIconAlignment(binding.Control,
                                                                base.GetIconAlignment(binding.Control));
                        hasWarning = true;
                    }

                    // should info be shown
                    if (_visibleInformation && bInfo)
                    {
                        errorProviderInfo.SetError(binding.Control, _infoList[propertyName]);
                        errorProviderInfo.SetIconPadding(binding.Control,
                                                              base.GetIconPadding(binding.Control) +
                                                              offsetInformation);
                        errorProviderInfo.SetIconAlignment(binding.Control,
                                                                base.GetIconAlignment(binding.Control));

                        hasInfo = true;
                    }
                }
            }

            if (!hasWarning) errorProviderWarn.SetError((Control)control, string.Empty);
            if (!hasInfo) errorProviderInfo.SetError((Control)control, string.Empty);
        }
Exemplo n.º 39
0
        // Is the binadable component in a 'created' (ready-to-use) state? For controls,
        // this depends on whether the window handle has been created yet. For everything
        // else, we'll assume they are always in a created state.
        internal static bool IsComponentCreated(IBindableComponent component) {
            Control ctrl = (component as Control);

            if (ctrl != null) {
                return ctrl.Created;
            }
            else {
                return true;
            }
        }
 internal void SetBindableComponent(IBindableComponent value)
 {
     if (this.control != value)
     {
         IBindableComponent control = this.control;
         this.BindTarget(false);
         this.control = value;
         this.BindTarget(true);
         try
         {
             this.CheckBinding();
         }
         catch
         {
             this.BindTarget(false);
             this.control = control;
             this.BindTarget(true);
             throw;
         }
         BindingContext.UpdateBinding(((this.control != null) && IsComponentCreated(this.control)) ? this.control.BindingContext : null, this);
         Form form = value as Form;
         if (form != null)
         {
             form.Load += new EventHandler(this.FormLoaded);
         }
     }
 }
Exemplo n.º 41
0
        internal void SetBindableComponent(IBindableComponent value) {
            if (this.control != value) {
                IBindableComponent oldTarget = control;
                BindTarget(false);
                this.control = value;
                BindTarget(true);
                try {
                    CheckBinding();
                }
                catch {
                    BindTarget(false);
                    control = oldTarget;
                    BindTarget(true);
                    throw;
                }

                // We are essentially doing to the listManager what we were doing to the
                // BindToObject: bind only when the control is created and it has a BindingContext
                BindingContext.UpdateBinding((control != null && IsComponentCreated(control) ? control.BindingContext: null), this);
                Form form = value as Form;
                if (form != null) {
                    form.Load += new EventHandler(FormLoaded);
                }
            }
        }
	// Constructors
	public ControlBindingsCollection(IBindableComponent control) {}
Exemplo n.º 43
0
		public void SetMemoBobinaControl(ACBrECF ecf, IBindableComponent control)
		{
			ECFInfo info;

			if (!this.infos.TryGetValue(ecf.Handle, out info))
			{
				info = new ECFInfo();
				info.ECF = ecf;
				infos.Add(ecf.Handle, info);
			}

			info.Control = control;
		}
 internal static bool IsComponentCreated(IBindableComponent component)
 {
     System.Windows.Forms.Control control = component as System.Windows.Forms.Control;
     if (control != null)
     {
         return control.Created;
     }
     return true;
 }