Пример #1
0
 public OneWayBindingToString(string propertyName, object dataSource, string dataMember, StringByValue oneWayConverter)
     : base (propertyName, dataSource, dataMember)
 {
     this.GetStringByValue = oneWayConverter ?? delegate { return ""; };
     this.FormattingEnabled = true;
     this.Format += new ConvertEventHandler(FormatAndStoreValue);
     this.Parse += new ConvertEventHandler(RestoreValue);
 }
Пример #2
0
 /// <summary>
 /// It seems WinForm doesn't allow simple one-way from model to form control.
 /// If it is possible, this code should be replaced
 /// StringByValue should take value. Creator of this binding should control the real type of the value.
 /// </summary>
 /// <returns>new binding</returns>
 public static Binding CreateOneWayReadToString(string propertyName, object dataSource, string dataMember, StringByValue oneWayConverter)
 {
     OneWayBindingToString bind = new OneWayBindingToString(propertyName, dataSource, dataMember, oneWayConverter);
     bind.FormattingEnabled = true;
     bind.Format += new ConvertEventHandler(BindingHelper.Invert);
     bind.Parse += new ConvertEventHandler(BindingHelper.Invert);
     return bind;
 }
Пример #3
0
 public OneWayBindingToString(string propertyName, object dataSource, string dataMember, StringByValue oneWayConverter)
     : base(propertyName, dataSource, dataMember)
 {
     this.GetStringByValue  = oneWayConverter ?? delegate { return(""); };
     this.FormattingEnabled = true;
     this.Format           += new ConvertEventHandler(FormatAndStoreValue);
     this.Parse            += new ConvertEventHandler(RestoreValue);
 }
Пример #4
0
        /// <summary>
        /// It seems WinForm doesn't allow simple one-way from model to form control.
        /// If it is possible, this code should be replaced
        /// StringByValue should take value. Creator of this binding should control the real type of the value.
        /// </summary>
        /// <returns>new binding</returns>
        public static Binding CreateOneWayReadToString(string propertyName, object dataSource, string dataMember, StringByValue oneWayConverter)
        {
            OneWayBindingToString bind = new OneWayBindingToString(propertyName, dataSource, dataMember, oneWayConverter);

            bind.FormattingEnabled = true;
            bind.Format           += new ConvertEventHandler(BindingHelper.Invert);
            bind.Parse            += new ConvertEventHandler(BindingHelper.Invert);
            return(bind);
        }