Esempio n. 1
0
        public static Binder <TSource, UISegmentedControl> Titles <TSource, TPropertyType>(this Binder <TSource, UISegmentedControl> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, string[]> converter = null)
            where TSource : class
        {
            return(binder.Property(property, b =>
            {
                var list = new string[b.NumberOfSegments];
                for (int i = 0; i < b.NumberOfSegments; i++)
                {
                    list[i] = b.TitleAt(i);
                }

                return list;
            }, (b, v) =>
            {
                if (v == null)
                {
                    b.RemoveAllSegments();
                }
                else if (b.NumberOfSegments != v.Length)
                {
                    b.RemoveAllSegments();
                    for (int i = 0; i < v.Length; i++)
                    {
                        b.InsertSegment(v[i], i, false);
                    }
                }
                else
                {
                    for (int i = 0; i < v.Length; i++)
                    {
                        b.SetTitle(v[i], i);
                    }
                }
            }, converter));
        }
Esempio n. 2
0
        public static Binder <TSource, SeekBar> Progress <TSource, TPropertyType>(this Binder <TSource, SeekBar> binder, Expression <Func <TSource, TPropertyType> > property, ITwoWayConverter <TPropertyType, float> converter = null)
            where TSource : class
        {
            converter = converter ?? Transmute.Transmuter.Default.GetTwoWayConverter <TPropertyType, float>();
            var finalconverter = converter.Chain(PercentToAmountConverter);

            return(binder.Property <TPropertyType, int, SeekBar.ProgressChangedEventArgs>(property, b => b.Progress, nameof(SeekBar.ProgressChanged), finalconverter));
        }
Esempio n. 3
0
        public static Binder <TSource, UISegmentedControl> Selected <TSource, TPropertyType>(this Binder <TSource, UISegmentedControl> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, int> converter = null)
            where TSource : class
        {
            converter = converter ?? Converters.Default <TPropertyType, int>();
            var finalConverter = converter.Chain(Converters.Default <int, nint>());

            return(binder.Property <TPropertyType, nint, EventArgs>(property, b => b.SelectedSegment, nameof(UISegmentedControl.ValueChanged), finalConverter));
        }
Esempio n. 4
0
        public static Binder <TSource, UIButton> Title <TSource, TPropertyType>(this Binder <TSource, UIButton> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, string> converter = null)
            where TSource : class
        {
            Action <UIButton, string> setter = (b, v) => b.SetTitle(v, UIControlState.Normal);
            Func <UIButton, string>   getter = (b) => b.Title(UIControlState.Normal);

            return(binder.Property(property, getter, setter, converter));
        }
Esempio n. 5
0
        public static Binder <TSource, WKWebView> HtmlContent <TSource, TPropertyType>(this Binder <TSource, WKWebView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, string> converter = null)
            where TSource : class
        {
            Action <WKWebView, string> setter = (b, v) => b.LoadHtmlString(v, null);
            Func <WKWebView, string>   getter = (b) => { throw new InvalidOperationException("No synchronous way to get HTML from WKWebView"); };           // FIXME add two way async bindings

            return(binder.Property(property, getter, setter, converter));
        }
Esempio n. 6
0
        public static Binder <TSource, UIWebView> HtmlContent <TSource, TPropertyType>(this Binder <TSource, UIWebView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, string> converter = null)
            where TSource : class
        {
            Action <UIWebView, string> setter = (b, v) => b.LoadHtmlString(v, null);
            Func <UIWebView, string>   getter = (b) => b.EvaluateJavascript("document.documentElement.outerHTML");

            return(binder.Property(property, getter, setter, converter));
        }
Esempio n. 7
0
        public static Binder <TSource, UIButton> Image <TSource, TPropertyType>(this Binder <TSource, UIButton> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, UIImage> converter = null)
            where TSource : class
        {
            Action <UIButton, UIImage> setter = (b, v) => b.SetImage(v, UIControlState.Normal);
            Func <UIButton, UIImage>   getter = (b) => b.CurrentImage;

            return(binder.Property(property, getter, setter, converter));
        }
Esempio n. 8
0
        public static Binder <TSource, UISegmentedControl> Selected <TSource, TPropertyType>(this Binder <TSource, UISegmentedControl> binder, Expression <Func <TSource, TPropertyType> > property, ITwoWayConverter <TPropertyType, int> converter = null)
            where TSource : class
        {
            if (converter == null)
            {
                converter = Transmuter.Default.GetTwoWayConverter <TPropertyType, int>();
            }

            var nconverter = converter.Chain(Transmuter.Default.GetTwoWayConverter <int, nint>());

            return(binder.Property <TPropertyType, nint, EventArgs>(property, b => b.SelectedSegment, nameof(UISegmentedControl.ValueChanged), nconverter));
        }
Esempio n. 9
0
 public static Binder <TSource, UIActivityIndicatorView> IsAnimating <TSource, TPropertyType>(this Binder <TSource, UIActivityIndicatorView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, bool> converter = null)
     where TSource : class
 {
     return(binder.Property(property, b => b.IsAnimating, (b, v) => { if (v)
                                                                      {
                                                                          b.StartAnimating();
                                                                      }
                                                                      else
                                                                      {
                                                                          b.StopAnimating();
                                                                      } }, converter));
 }
Esempio n. 10
0
File: View.cs Progetto: delort/Wires
 public static Binder <TSource, TView> Visibility <TSource, TView, TPropertyType>(this Binder <TSource, TView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, ViewStates> converter = null)
     where TSource : class
     where TView : View
 {
     return(binder.Property(property, b => b.Visibility, converter));
 }
Esempio n. 11
0
 public static Binder <TSource, ToggleButton> Checked <TSource, TPropertyType>(this Binder <TSource, ToggleButton> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, bool> converter = null)
     where TSource : class
 {
     return(binder.Property <TPropertyType, bool, CompoundButton.CheckedChangeEventArgs>(property, b => b.Checked, nameof(ToggleButton.CheckedChange), converter));
 }
Esempio n. 12
0
 public static Binder <TSource, TView> UserInteractionEnabled <TSource, TView, TPropertyType>(this Binder <TSource, TView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, bool> converter = null)
     where TSource : class
     where TView : UIView
 {
     return(binder.Property(property, b => b.UserInteractionEnabled, converter));
 }
Esempio n. 13
0
 public static Binder <TSource, ImageView> Image <TSource, TPropertyType>(this Binder <TSource, ImageView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, Bitmap> converter = null)
     where TSource : class
 {
     return(binder.Property(property, b => ((BitmapDrawable)b.Drawable).Bitmap, (b, v) => b.SetImageBitmap(v), converter));
 }
Esempio n. 14
0
 public static Binder <TSource, TView> Frame <TSource, TView, TPropertyType>(this Binder <TSource, TView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, CGRect> converter = null)
     where TSource : class
     where TView : UIView
 {
     return(binder.Property(property, b => b.Frame, converter));
 }
Esempio n. 15
0
 public static Binder <TSource, UIImageView> Image <TSource, TPropertyType>(this Binder <TSource, UIImageView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, UIImage> converter = null)
     where TSource : class
 {
     return(binder.Property(property, b => b.Image, converter));
 }
Esempio n. 16
0
 public static Binder <TSource, UIStepper> MinimumValue <TSource, TPropertyType>(this Binder <TSource, UIStepper> binder, Expression <Func <TSource, TPropertyType> > property, TwoWayConverter <TPropertyType, double> converter = null)
     where TSource : class
 {
     return(binder.Property <TPropertyType, double, EventArgs>(property, b => b.MinimumValue, nameof(UIStepper.ValueChanged), converter));
 }
Esempio n. 17
0
 public static Binder <TSource, EditText> Text <TSource, TPropertyType>(this Binder <TSource, EditText> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, string> converter = null)
     where TSource : class
 {
     return(binder.Property <TPropertyType, string, TextChangedEventArgs>(property, b => b.Text, nameof(EditText.TextChanged), converter));
 }
Esempio n. 18
0
File: View.cs Progetto: delort/Wires
 public static Binder <TSource, TView> Background <TSource, TView, TPropertyType>(this Binder <TSource, TView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, Drawable> converter = null)
     where TSource : class
     where TView : View
 {
     return(binder.Property(property, b => b.Background, converter));
 }
Esempio n. 19
0
File: View.cs Progetto: delort/Wires
 public static Binder <TSource, TView> Alpha <TSource, TView, TPropertyType>(this Binder <TSource, TView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, float> converter = null)
     where TSource : class
     where TView : View
 {
     return(binder.Property(property, b => b.Alpha, converter));
 }
Esempio n. 20
0
 public static Binder <TSource, UIProgressView> TrackTintColor <TSource, TPropertyType>(this Binder <TSource, UIProgressView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, UIColor> converter = null)
     where TSource : class
 {
     return(binder.Property(property, b => b.TrackTintColor, converter));
 }
Esempio n. 21
0
 public static Binder <TSource, ProgressBar> Progress <TSource, TPropertyType>(this Binder <TSource, ProgressBar> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, int> converter = null)
     where TSource : class
 {
     return(binder.Property(property, b => b.Progress, converter));
 }
Esempio n. 22
0
 public static IBinding Text <TSource, TPropertyType>(this Binder <TSource, TextView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, string> converter = null)
     where TSource : class
 {
     return(binder.Property(property, b => b.Text, converter));
 }
Esempio n. 23
0
 public static Binder <TSource, UISwitch> On <TSource, TPropertyType>(this Binder <TSource, UISwitch> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, bool> converter = null)
     where TSource : class
 {
     return(binder.Property <TPropertyType, bool, EventArgs>(property, b => b.On, nameof(UISwitch.ValueChanged), converter));
 }
Esempio n. 24
0
 public static Binder <TSource, UIActivityIndicatorView> Color <TSource, TPropertyType>(this Binder <TSource, UIActivityIndicatorView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, UIColor> converter = null)
     where TSource : class
 {
     return(binder.Property(property, b => b.Color, converter));
 }
Esempio n. 25
0
 public static Binder <TSource, UIDatePicker> Date <TSource, TPropertyType>(this Binder <TSource, UIDatePicker> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, NSDate> converter = null)
     where TSource : class
 {
     return(binder.Property <TPropertyType, NSDate, EventArgs>(property, v => v.Date, nameof(UISlider.ValueChanged), converter));
 }
Esempio n. 26
0
 public static Binder <TSource, UIViewController> Title <TSource, TPropertyType>(this Binder <TSource, UIViewController> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, string> converter = null)
     where TSource : class
 {
     return(binder.Property(property, b => b.Title, converter));
 }
Esempio n. 27
0
 public static Binder <TSource, Button> Text <TSource, TPropertyType>(this Binder <TSource, Button> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, string> converter = null)
     where TSource : class
 {
     return(binder.Property(property, x => x.Text, converter));
 }
Esempio n. 28
0
 public static Binder <TSource, UIViewController> BackTitle <TSource, TPropertyType>(this Binder <TSource, UIViewController> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, string> converter = null)
     where TSource : class
 {
     return(binder.Property(property, b => b.NavigationItem.BackBarButtonItem.Title, (b, v) => new UIBarButtonItem(v, UIBarButtonItemStyle.Plain, null), converter));
 }
Esempio n. 29
0
 public static Binder <TSource, UITextView> Text <TSource, TPropertyType>(this Binder <TSource, UITextView> binder, Expression <Func <TSource, TPropertyType> > property, ITwoWayConverter <TPropertyType, string> converter = null)
     where TSource : class
 {
     return(binder.Property <TPropertyType, string, EventArgs> (property, b => b.Text, nameof(UITextView.Changed), converter));
 }
Esempio n. 30
0
 public static Binder <TSource, TView> Hidden <TSource, TView, TPropertyType>(this Binder <TSource, TView> binder, Expression <Func <TSource, TPropertyType> > property, IConverter <TPropertyType, bool> converter = null)
     where TSource : class
     where TView : UIView
 {
     return(binder.Property(property, b => b.Hidden, converter));
 }