Beispiel #1
0
 /// <summary>
 /// Remove Binding
 /// </summary>
 public void UnBind()
 {
     if (_property != null)
     {
         _property.UnBind();
         _property = null;
     }
 }
        /// <summary>
        /// Provide two-way binding
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="propertyLambda"></param>
        public void BindTwoWay <T>(Expression <Func <T> > propertyLambda)
        {
            _property = new PropDelegate <T>(propertyLambda, OnPropertyChanged);

            Items.AddRange(Enum.GetNames(typeof(T)));

            OnPropertyChanged();
            this.SelectedIndexChanged += new EventHandler(EnumCtl_SelectedIndexChanged);
        }
Beispiel #3
0
        /// <summary>
        /// Provide two-way binding
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="propertyLambda"></param>
        public void BindTwoWay <T>(Expression <Func <T> > propertyLambda)
        {
            if (!(typeof(T).IsSubclassOf(typeof(MDouble.MDoubleBase))))
            {
                throw new Exception("");
            }
            _property = new MDoublePropDelegate <T>(propertyLambda, OnChanged);

            if (string.IsNullOrEmpty(lblName.Text))
            {
                lblName.Text = _property.Name;
            }

            OnChanged();
        }
 /// <summary>
 /// Remove Binding
 /// </summary>
 public void UnBind()
 {
     if (_propertyForRead != null)
     {
         _propertyForRead.UnBind();
         _propertyForRead = null;
     }
     if (_propertyForWrite != null)
     {
         _propertyForWrite.UnBind();
         _propertyForWrite = null;
     }
     tbValue.Text   = string.Empty;
     OnValueChanged = null;
     OnApplyValue   = null;
     Enabled        = false;
 }
        /// <summary>
        /// Provide two-way binding
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="propertyLambdaForRead"></param>
        /// <param name="propertyLambdaForWrite"></param>
        public void BindTwoWay <T>(Expression <Func <T> > propertyLambdaForRead, Expression <Func <T> > propertyLambdaForWrite)
        {
            if (!typeof(T).Equals(typeof(MDouble.MDoubleBase)) && !(typeof(T).IsSubclassOf(typeof(MDouble.MDoubleBase))))
            {
                throw new Exception("Must be of type MDoubleBase");
            }
            _propertyForRead = new MDoublePropDelegate <T>(propertyLambdaForRead, OnChanged);
            if (propertyLambdaForWrite != null)
            {
                _propertyForWrite = new MDoublePropDelegate <T>(propertyLambdaForWrite);
            }

            if (string.IsNullOrEmpty(lblName.Text))
            {
                lblName.Text = _propertyForRead.Name;
            }
            tbValue.Multiline = false;
            OnChanged();
            Enabled = true;
        }
Beispiel #6
0
        /// <summary>
        /// Provide two-way binding
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="propertyLambda"></param>
        public void BindTwoWay <T>(Expression <Func <T> > propertyLambda)
        {
            _property = new PropDelegate <T>(propertyLambda, OnPropertyChanged);

            string[] enumNames = Enum.GetNames(typeof(T));
            string   origVal   = _property.SValue;

            foreach (Control ctl in Controls)
            {
                if (ctl is RadioButton && ctl.TabIndex < enumNames.Length)
                {
                    RadioButton rb = ctl as RadioButton;
                    if (string.IsNullOrEmpty(rb.Text))
                    {
                        rb.Text = enumNames[ctl.TabIndex].Replace('_', ' ');
                    }
                    rb.Tag = enumNames[ctl.TabIndex];
                    //rb.Checked = origVal == rb.Tag.ToString();
                    rb.CheckedChanged += new EventHandler(OnCheckedChanged);
                }
            }

            OnPropertyChanged();
        }
Beispiel #7
0
        /// <summary>
        /// Provide two-way binding
        /// </summary>
        /// <param name="propertyLambda"></param>
        public void BindTwoWay(Expression <Func <string> > propertyLambda)
        {
            _property = new StringPropDelegate(propertyLambda, OnChanged);

            OnChanged();
        }