コード例 #1
0
ファイル: DualBinding.cs プロジェクト: yaram/Eto
        /// <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 <T> source, DirectBinding <T> destination, DualBindingMode mode = DualBindingMode.TwoWay)
        {
            Source      = source;
            Destination = destination;
            this.mode   = mode;

            SetBinding(true);
        }
コード例 #2
0
ファイル: BindableBinding.cs プロジェクト: yaram/Eto
        /// <summary>
        /// Binds the specified <paramref name="sourceBinding"/> to this binding.
        /// </summary>
        /// <remarks>
        /// This creates a <see cref="DualBinding{TValue}"/> between the specified <paramref name="sourceBinding"/> and this binding.
        /// The binding is added to the <see cref="IBindable.Bindings"/> collection.
        /// </remarks>
        /// <param name="sourceBinding">Source binding to bind from.</param>
        /// <param name="mode">Dual binding mode.</param>
        public override DualBinding <TValue> Bind(DirectBinding <TValue> sourceBinding, DualBindingMode mode = DualBindingMode.TwoWay)
        {
            var binding = base.Bind(sourceBinding, mode);

            if (DataItem != null)
            {
                DataItem.Bindings.Add(binding);
            }
            return(binding);
        }
コード例 #3
0
ファイル: Control.binding.cs プロジェクト: CheckTech/Eto
        /// <summary>
        /// Adds a new dual binding between the control and the specified source binding
        /// </summary>
        /// <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 DualBinding <T> Bind <T>(string widgetPropertyName, DirectBinding <T> sourceBinding, DualBindingMode mode = DualBindingMode.TwoWay)
        {
            var binding = new DualBinding <T>(
                sourceBinding,
                new ControlBinding <Control, T>(this, new PropertyBinding <T>(widgetPropertyName)),
                mode
                );

            Bindings.Add(binding);
            return(binding);
        }
コード例 #4
0
ファイル: Control.binding.cs プロジェクト: sami1971/Eto
        /// <summary>
        /// Adds a new dual binding between the control and the specified source binding
        /// </summary>
        /// <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 DualBinding Bind(string widgetPropertyName, DirectBinding sourceBinding, DualBindingMode mode = DualBindingMode.TwoWay)
        {
            var binding = new DualBinding(
                sourceBinding,
                new ObjectBinding(this, widgetPropertyName),
                mode
                );

            Bindings.Add(binding);
            return(binding);
        }
コード例 #5
0
ファイル: Control.binding.cs プロジェクト: CheckTech/Eto
        /// <summary>
        /// Adds a new binding to the control with a direct value binding
        /// </summary>
        /// <param name="controlBinding">Binding to get/set the value from the control.</param>
        /// <param name="valueBinding">Value binding to get/set the value from another source.</param>
        /// <param name="mode">Mode of the binding</param>
        public DualBinding <T> Bind <T>(IndirectBinding <T> controlBinding, DirectBinding <T> valueBinding, DualBindingMode mode = DualBindingMode.TwoWay)
        {
            var binding = new ControlBinding <Control, T>(this, controlBinding);

            return(binding.Bind(sourceBinding: valueBinding, mode: mode));
        }
コード例 #6
0
        /// <summary>
        /// Adds a new binding to the control with a direct value binding
        /// </summary>
        /// <param name="bindable">Bindable object to add the binding to</param>
        /// <param name="controlBinding">Binding to get/set the value from the control.</param>
        /// <param name="valueBinding">Value binding to get/set the value from another source.</param>
        /// <param name="mode">Mode of the binding</param>
        public static DualBinding <T> Bind <T>(this IBindable bindable, IndirectBinding <T> controlBinding, DirectBinding <T> valueBinding, DualBindingMode mode = DualBindingMode.TwoWay)
        {
            var binding = new BindableBinding <IBindable, T>(bindable, controlBinding);

            return(binding.Bind(sourceBinding: valueBinding, mode: mode));
        }
コード例 #7
0
        /// <summary>
        /// Adds a new dual binding between the control and the specified source binding
        /// </summary>
        /// <param name="bindable">Bindable object 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 <T> Bind <T>(this IBindable bindable, string widgetPropertyName, DirectBinding <T> sourceBinding, DualBindingMode mode = DualBindingMode.TwoWay)
        {
            var binding = new DualBinding <T>(
                sourceBinding,
                new BindableBinding <IBindable, T>(bindable, Binding.Property <T>(widgetPropertyName)),
                mode
                );

            bindable.Bindings.Add(binding);
            return(binding);
        }
コード例 #8
0
 /// <summary>
 /// Bind a control property to the specified <paramref name="sourceBinding"/> direct binding.
 /// </summary>
 /// <param name="control">Control to bind to.</param>
 /// <param name="controlProperty">Control property expression.</param>
 /// <param name="sourceBinding">Source binding to get/set the values.</param>
 /// <param name="mode">Mode of the binding.</param>
 /// <typeparam name="TWidget">The type of the control.</typeparam>
 /// <typeparam name="TValue">The type of the property.</typeparam>
 public static DualBinding <TValue> Bind <TWidget, TValue>(this TWidget control, Expression <Func <TWidget, TValue> > controlProperty, DirectBinding <TValue> sourceBinding, DualBindingMode mode = DualBindingMode.TwoWay)
     where TWidget : IBindable
 {
     return(control.Bind(Binding.Property(controlProperty), sourceBinding, mode));
 }
コード例 #9
0
ファイル: Control.binding.cs プロジェクト: sami1971/Eto
        public DualBinding Bind(IndirectBinding controlBinding, DirectBinding valueBinding, DualBindingMode mode = DualBindingMode.TwoWay)
        {
            var binding = new ObjectBinding(this, controlBinding);

            return(binding.Bind(valueBinding: valueBinding, mode: mode));
        }
コード例 #10
0
        /// <summary>
        /// Bind a control property to the specified <paramref name="sourceBinding"/> direct binding.
        /// </summary>
        /// <param name="control">Control to bind to.</param>
        /// <param name="controlProperty">Control property expression.</param>
        /// <param name="sourceBinding">Source binding to get/set the values.</param>
        /// <param name="mode">Mode of the binding.</param>
        /// <typeparam name="TWidget">The type of the control.</typeparam>
        /// <typeparam name="TValue">The type of the property.</typeparam>
        public static DualBinding <TValue> Bind <TWidget, TValue>(this TWidget control, Expression <Func <TWidget, TValue> > controlProperty, DirectBinding <TValue> sourceBinding, DualBindingMode mode = DualBindingMode.TwoWay)
            where TWidget : IBindable
        {
            var controlExpression = controlProperty.GetMemberInfo();
            var binding           = control.Bind <TValue>(new PropertyBinding <TValue>(controlExpression.Member.Name), sourceBinding, mode);

            return(binding);
        }
コード例 #11
0
 /// <summary>
 /// Gets a binding with the inverse of the specified nullable boolean value binding.
 /// </summary>
 /// <returns>A new binding to the inverse value.</returns>
 /// <param name="binding">Binding to invert.</param>
 public static DirectBinding <bool> Inverse(this DirectBinding <bool> binding)
 {
     return(binding.Convert(c => !c, c => !c));
 }