Ejemplo n.º 1
0
		/// <summary>
		/// Adds a new dual binding between the widget and the specified source binding
		/// </summary>
		/// <param name="widget">Widget to add the binding to</param>
		/// <param name="widgetPropertyName">Property on the widget to update</param>
		/// <param name="sourceBinding">Binding to get/set the value to from the widget</param>
		/// <param name="mode">Mode of the binding</param>
		/// <returns>A new instance of the DualBinding class that is used to control the binding</returns>
		public static DualBinding Bind (this Widget widget, string widgetPropertyName, DirectBinding sourceBinding, DualBindingMode mode = DualBindingMode.TwoWay)
		{
			var binding = new DualBinding (
				sourceBinding,
				new ObjectBinding(widget, widgetPropertyName),
				mode
			);
			widget.Bindings.Add (binding);
			return binding;
		}
Ejemplo n.º 2
0
        public static DualBinding Bind(this ObjectBinding controlBinding, DirectBinding valueBinding, DualBindingMode mode = DualBindingMode.TwoWay)
        {
            var binding = new DualBinding(
                valueBinding,
                controlBinding,
                mode
                );
            var control = controlBinding.DataItem as Control;

            if (control != null)
            {
                control.Bindings.Add(binding);
            }
            return(binding);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the DualBinding class with two specified bindings
        /// </summary>
        /// <param name="source">Binding for retrieving the source value from</param>
        /// <param name="destination">Binding for setting the destination value to</param>
        /// <param name="mode">Mode of the binding</param>
        public DualBinding(DirectBinding source, DirectBinding destination, DualBindingMode mode = DualBindingMode.TwoWay)
        {
            this.Source      = source;
            this.Destination = destination;

            if (mode == DualBindingMode.OneWay || mode == DualBindingMode.TwoWay)
            {
                source.DataValueChanged += HandleSourceChanged;
            }
            if (mode == DualBindingMode.OneWayToSource || mode == DualBindingMode.TwoWay)
            {
                destination.DataValueChanged += HandleDestinationChanged;
            }

            // set initial value
            this.SetDestination();
        }
Ejemplo n.º 4
0
 public static DualBinding Bind(this Control control, IndirectBinding controlBinding, DirectBinding valueBinding, DualBindingMode mode = DualBindingMode.TwoWay)
 {
     return(Bind(controlBinding: new ObjectBinding(control, controlBinding), valueBinding: valueBinding, mode: mode));
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Adds a new dual binding between the control and the specified source binding
        /// </summary>
        /// <param name="control">Control to add the binding to</param>
        /// <param name="widgetPropertyName">Property on the control to update</param>
        /// <param name="sourceBinding">Binding to get/set the value to from the control</param>
        /// <param name="mode">Mode of the binding</param>
        /// <returns>A new instance of the DualBinding class that is used to control the binding</returns>
        public static DualBinding Bind(this Control control, string widgetPropertyName, DirectBinding sourceBinding, DualBindingMode mode = DualBindingMode.TwoWay)
        {
            var binding = new DualBinding(
                sourceBinding,
                new ObjectBinding(control, widgetPropertyName),
                mode
                );

            control.Bindings.Add(binding);
            return(binding);
        }
Ejemplo n.º 6
0
		/// <summary>
		/// Initializes a new instance of the DualBinding class with two specified bindings
		/// </summary>
		/// <param name="source">Binding for retrieving the source value from</param>
		/// <param name="destination">Binding for setting the destination value to</param>
		/// <param name="mode">Mode of the binding</param>
		public DualBinding (DirectBinding source, DirectBinding destination, DualBindingMode mode = DualBindingMode.TwoWay)
		{
			this.Source = source;
			this.Destination = destination;
			this.Mode = mode;
			
			if (mode == DualBindingMode.OneWay || mode == DualBindingMode.TwoWay)
				source.DataValueChanged += HandleSourceChanged;
			if (mode == DualBindingMode.OneWayToSource || mode == DualBindingMode.TwoWay)
				destination.DataValueChanged += HandleDestinationChanged;

			// set initial value
			this.SetDestination ();
		}