public static FloatWithUnitRow Create(
     string title, Func <FloatWithUnit> getter, Action <FloatWithUnit> setter,
     IDataSourceListener dataSourceListener)
 {
     getter.RequireNotNull(nameof(getter));
     setter.RequireNotNull(nameof(setter));
     dataSourceListener.RequireNotNull(nameof(dataSourceListener));
     return(new FloatWithUnitRow(
                title,
                () =>
     {
         var floatWithUnit = getter();
         return $"{NumberFormatter.Instance.FormatNFloat(floatWithUnit.Value)} ({floatWithUnit.Unit})";
     },
                getter,
                newValue =>
     {
         setter(newValue);
         dataSourceListener.OnDataChange();
     },
                rowIndexPathPair =>
     {
         var row = rowIndexPathPair.Item1;
         dataSourceListener.GetFloatWithUnit(row.Title, getter(), newValue => row.Setter(newValue));
     }));
 }
 public static OptionRow <TValue> Create(string title, Func <TValue> getter,
                                         Action <Tuple <OptionRow <TValue>, NSIndexPath> > onSelect, IDataSourceListener dataSourceListener)
 {
     getter.RequireNotNull(nameof(getter));
     onSelect.RequireNotNull(nameof(onSelect));
     dataSourceListener.RequireNotNull(nameof(dataSourceListener));
     return(new OptionRow <TValue>(title, getter, null, tuple =>
     {
         onSelect(tuple);
         dataSourceListener.OnDataChange();
     }));
 }
Beispiel #3
0
 public static BoolOptionRow Create(string title,
                                    Func <bool> getter,
                                    Action <bool> setter,
                                    IDataSourceListener dataSourceListener)
 {
     getter.RequireNotNull(nameof(getter));
     setter.RequireNotNull(nameof(setter));
     dataSourceListener.RequireNotNull(nameof(dataSourceListener));
     return(new BoolOptionRow(title, getter, b =>
     {
         setter(b);
         dataSourceListener.OnDataChange();
     }, tuple =>
     {
         var row = tuple.Item1;
         row.Setter(!row.Getter());
     }));
 }
 public static ChoiceRow <TEnumeration> Create(string title, TEnumeration[] options,
                                               Func <TEnumeration> getter, Action <TEnumeration> setter, IDataSourceListener dataSourceListener)
 {
     getter.RequireNotNull(nameof(getter));
     setter.RequireNotNull(nameof(setter));
     dataSourceListener.RequireNotNull(nameof(dataSourceListener));
     return(new ChoiceRow <TEnumeration>(title, getter, value =>
     {
         setter(value);
         dataSourceListener.OnDataChange();
     }, tuple =>
     {
         var row = tuple.Item1;
         dataSourceListener.PresentChoice(
             row.Title,
             options,
             getter(),
             value => row.Setter(value)
             );
     }));
 }
Beispiel #5
0
 public static SymbologyRow Create(Func <SymbologySettings> getter,
                                   Action <SymbologySettings> setter, IDataSourceListener dataSourceListener)
 {
     getter.RequireNotNull(nameof(getter));
     setter.RequireNotNull(nameof(setter));
     return(new SymbologyRow(
                getter().Symbology.ReadableName(),
                getter,
                settings =>
     {
         setter(settings);
         dataSourceListener.OnDataChange();
     },
                tuple =>
     {
         var row = tuple.Item1;
         dataSourceListener.PresentSymbologySettings(
             row.Getter(),
             settings => row.Setter(settings)
             );
     }
                ));
 }