public UIMenuItemSlider(
            string text,
            UIMenuAction action = null,
            FieldBinding field  = null,
            float step          = 0.1f,
            Color c             = default(Color))
            : base(action)
        {
            if (c == new Color())
            {
                c = Colors.MenuOption;
            }
            UIDivider uiDivider = new UIDivider(true, 0.0f);
            UIText    uiText    = new UIText(text, c);

            uiText.align = UIAlign.Left;
            uiDivider.leftSection.Add((UIComponent)uiText, true);
            UIProgressBar uiProgressBar = new UIProgressBar(30f, 7f, field, step);

            uiProgressBar.align = UIAlign.Right;
            uiDivider.rightSection.Add((UIComponent)uiProgressBar, true);
            this.rightSection.Add((UIComponent)uiDivider, true);
            this._arrow         = new UIImage("contextArrowRight");
            this._arrow.align   = UIAlign.Right;
            this._arrow.visible = false;
            this.leftSection.Add((UIComponent)this._arrow, true);
            this._field = field;
            this._step  = step;
        }
Пример #2
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                picker.ValueChanged -= OnDatePickerValueChanged;
            }

            _target = null;
            base.Dispose(disposing);
        }
Пример #3
0
    protected internal virtual FieldBinding VisitFieldBinding(FieldBinding fb)
    {
        var r = Visit(fb.Binding);

        if (r == fb.Binding)
        {
            return(fb);
        }

        return(new FieldBinding(fb.FieldInfo, r));
    }
Пример #4
0
    public Expression GetBinding(FieldInfo fi)
    {
        if (Bindings == null)
        {
            throw new InvalidOperationException("EntityInitiExpression not completed");
        }

        FieldBinding binding = Bindings.Where(fb => ReflectionTools.FieldEquals(fi, fb.FieldInfo)).SingleEx(() => "field '{0}' in {1} (field Ignored?)".FormatWith(fi.Name, this.Type.TypeName()));

        return(binding.Binding);
    }
Пример #5
0
 public ContextTextbox(string text, IContextListener owner, FieldBinding field = null)
     : base(owner)
 {
     this.itemSize.x = 150f;
     this.itemSize.y = 16f;
     this._text      = text;
     this._field     = field;
     if (field == null)
     {
         this._field = new FieldBinding((object)this, "isChecked");
     }
     this._fancyFont = new FancyBitmapFont("smallFont");
 }
Пример #6
0
        private void cmdAdd_Click(object sender, EventArgs e)
        {
            _binding.HasChanges = true;

            var field   = _binding.AddField();
            var binding = new FieldBinding(field);

            _fields.Add(binding);
            lstFields.UpdateLayout();
            lstFields.ScrollIntoView(binding);

            Dispatcher.BeginInvoke(() =>
                                   binding.IsEditing = true);
        }
Пример #7
0
 public UINumber(
     float wide,
     float high,
     FieldBinding field,
     string append            = "",
     FieldBinding filterField = null,
     MatchSetting setting     = null)
     : base("0", Color.White)
 {
     this._setting     = setting;
     this._field       = field;
     this._append      = append;
     this._filterField = filterField;
 }
Пример #8
0
        private void Configure(FieldBinding binding)
        {
            var widget = (DateWidget)binding
                         .Metadata
                         .Widget();

            picker.Mode = widget.Time
                ? UIDatePickerMode.Time
                : UIDatePickerMode.Date;

            DateTime currentValue;

            if (DateTime.TryParse(binding.ValueProvider.Value, out currentValue))
            {
                picker.SetDate(currentValue, false);
            }
        }
 public ContextRadio(
     string text,
     bool selected,
     object index,
     IContextListener owner,
     FieldBinding field = null)
     : base(owner)
 {
     this.itemSize.x   = 150f;
     this.itemSize.y   = 16f;
     this._text        = text;
     this._selected    = field == null ? selected : field.value == index;
     this._field       = field;
     this._index       = index;
     this.depth        = new Depth(0.8f);
     this._radioButton = new SpriteMap("Editor/radioButton", 16, 16);
 }
Пример #10
0
        /// <summary>
        ///     Evaluates the current state of the field binding
        ///     and decides the optimal row height for rendering.
        /// </summary>
        /// <param name="binding">The backing field binding.</param>
        internal static float GetHeightForRow(FieldBinding binding)
        {
            if (UseImageCell(binding))
            {
                return(ImageCellHeight);
            }

            if (UseLargeTextCell(binding))
            {
                return(binding.IsValid
                    ? LargeTextCellHeight
                    : LargeTextErrorCellHeight);
            }

            return(binding.IsValid
                ? TextCellHeight
                : TextErrorCellHeight);
        }
Пример #11
0
 public ContextFile(
     string text,
     IContextListener owner,
     FieldBinding field   = null,
     ContextFileType type = ContextFileType.Level)
     : base(owner)
 {
     this.itemSize.x = 150f;
     this.itemSize.y = 16f;
     this._text      = text;
     this._field     = field;
     this.depth      = new Depth(0.8f);
     this._type      = type;
     this.fancy      = true;
     if (field != null)
     {
         return;
     }
     this._field = new FieldBinding((object)this, "isChecked");
 }
Пример #12
0
 public ContextFile(
     string text,
     IContextListener owner,
     FieldBinding field,
     ContextFileType type,
     string valTooltip)
     : base(owner)
 {
     this.itemSize.x = 150f;
     this.itemSize.y = 16f;
     this._text      = text;
     this._field     = field;
     this.depth      = new Depth(0.8f);
     this._type      = type;
     this.fancy      = true;
     if (field == null)
     {
         this._field = new FieldBinding((object)this, "isChecked");
     }
     this.tooltip = valTooltip;
 }
Пример #13
0
 internal static bool UseImageCell(FieldBinding binding)
 {
     return(binding.Metadata.Widget() is ImageWidgetDefinition);
 }
Пример #14
0
 internal static bool UseLargeTextCell(FieldBinding binding)
 {
     //TODO: Ask Rolim for a "large text" widget and then get rid of this method.
     return("longdescription_.ldtext".Equals(binding.Metadata.Attribute,
                                             StringComparison.OrdinalIgnoreCase));
 }
 public UIChangingText(float wide, float high, FieldBinding field, FieldBinding filterBinding)
     : base("ON OFF  ", Color.White)
 {
     this._field         = field;
     this._filterBinding = filterBinding;
 }
Пример #16
0
        /// <summary>
        /// Compile the data extractor method for a given object <see cref="Type"/>.
        /// </summary>
        /// <param name="type">The type of object for which bindings are to be compiled.</param>
        /// <param name="bindings">The set of mutable field bindings that are to be mapped.</param>
        private static Func<Object, IDictionary<String, Object>> CompileGetStateMethod(Type type, FieldBinding[] bindings)
        {
            var methodBody = new List<Expression>();
            var value = Expression.Parameter(typeof(Object), "value");
            var result = Expression.Label(typeof(IDictionary<String, Object>));
            var state = Expression.Variable(typeof(IDictionary<String, Object>), "state");
            var source = Expression.Variable(type, "source");

            methodBody.Add(Expression.Assign(state, Expression.New(DictionaryConstructor, Expression.Constant(bindings.Length))));
            methodBody.Add(Expression.Assign(source, Expression.Convert(value, type)));

            foreach (var binding in bindings)
            {
                var expression = Expression.Call(state, DictionaryAddMethod, Expression.Constant(binding.Metadata.Name), Expression.Convert(Expression.Field(source, binding.Field), typeof(Object)));

                if (binding.Metadata.EmitDefaultValue)
                    methodBody.Add(expression);
                else
                    methodBody.Add(Expression.IfThen(Expression.NotEqual(Expression.Field(source, binding.Field), Expression.Default(binding.Field.FieldType)), expression));
            }

            methodBody.Add(Expression.Return(result, state));
            methodBody.Add(Expression.Label(result, Expression.TypeAs(Expression.Constant(null), state.Type)));

            return Expression.Lambda<Func<Object, IDictionary<String, Object>>>(Expression.Block(new[] { state, source }, methodBody), value).Compile();
        }
Пример #17
0
            /// <summary>
            ///     Evaluates the binding state and decides
            ///     which cell template must be constructed.
            /// </summary>
            /// <param name="tableView">The parent <see cref="UITableView"/>.</param>
            /// <param name="fieldBinding">The field binding backing the cell.</param>
            public static DetailFieldCellBase ConstructFieldCell(UITableView tableView, FieldBinding fieldBinding)
            {
                if (DetailFieldCellBase.UseImageCell(fieldBinding))
                {
                    return(ConstructImageCell(tableView, fieldBinding));
                }

                if (DetailFieldCellBase.UseLargeTextCell(fieldBinding))
                {
                    return(fieldBinding.IsValid
                        ? ConstructFieldLargeTextCell(tableView, fieldBinding)
                        : ConstructFieldLargeTextErrorCell(tableView, fieldBinding));
                }

                return(fieldBinding.IsValid
                    ? ConstructFieldPlainCell(tableView, fieldBinding)
                    : ConstructFieldPlainErrorCell(tableView, fieldBinding));
            }
Пример #18
0
            /// <summary>
            ///     Constructs a cell with a label and a large
            ///     textbox, in an invalid input state.
            /// </summary>
            /// <param name="tableView">The parent <see cref="UITableView"/>.</param>
            /// <param name="fieldBinding">The field binding backing the cell.</param>
            private static DetailFieldCellBase ConstructFieldLargeTextErrorCell(UITableView tableView, FieldBinding fieldBinding)
            {
                var cell = (DetailFieldLargeTextErrorCell)tableView.DequeueReusableCell("DetailFieldLargeTextErrorCell");

                cell.Construct(fieldBinding.Metadata, (ValueProvider)fieldBinding.ValueProvider);

                cell.Message = fieldBinding
                               .AsIDataErrorInfo()
                               .Error;

                return(cell);
            }
Пример #19
0
        private void Attach(FieldBinding binding)
        {
            _target = binding;

            Configure(binding);
        }
Пример #20
0
            public static Attachment Attach(UITableView tableView, NSIndexPath toIndexPath, FieldBinding toField, DetailDatePickerCell datePicker)
            {
                if (tableView == null)
                {
                    throw new ArgumentNullException("tableView");
                }
                if (toIndexPath == null)
                {
                    throw new ArgumentNullException("toIndexPath");
                }
                if (toField == null)
                {
                    throw new ArgumentNullException("toField");
                }
                if (datePicker == null)
                {
                    throw new ArgumentNullException("datePicker");
                }

                var datePickerPath = IndexPathForAttachment(toIndexPath);

                tableView.InsertRows(new[] { datePickerPath }, UITableViewRowAnimation.Fade);
                datePicker.Attach(toField);

                return(new Attachment(tableView, toIndexPath, datePicker, datePickerPath));
            }
Пример #21
0
        /// <summary>
        /// Compile the data assignment method for a given object <see cref="Type"/>.
        /// </summary>
        /// <param name="type">The type of object for which bindings are to be compiled.</param>
        /// <param name="bindings">The set of mutable field bindings that are to be mapped.</param>
        private static Action<Object, IDictionary<String, Object>> CompileSetStateMethod(Type type, FieldBinding[] bindings)
        {
            var methodBody = new List<Expression>();
            var value = Expression.Parameter(typeof(Object), "value");
            var result = Expression.Variable(typeof(Object), "result");
            var state = Expression.Parameter(typeof(IDictionary<String, Object>), "state");
            var source = Expression.Variable(type, "source");

            methodBody.Add(Expression.Assign(source, Expression.Convert(value, type)));

            foreach (var binding in bindings)
            {
                var tryGetValue = Expression.Call(state, DictionaryTryGetValueMethod, Expression.Constant(binding.Metadata.Name), result);
                var assignValue = Expression.Assign(Expression.Field(source, binding.Field), Expression.Convert(result, binding.Field.FieldType));
                var expression = binding.Metadata.IsRequired
                                     ? Expression.IfThenElse(tryGetValue, assignValue, Expression.Throw(Expression.New(MissingMemberExceptionConstructor, Expression.Constant(type.FullName), Expression.Constant(binding.Metadata.Name))))
                                     : Expression.IfThen(tryGetValue, assignValue);

                methodBody.Add(expression);
            }

            return Expression.Lambda<Action<Object, IDictionary<String, Object>>>(Expression.Block(new[] { source, result }, methodBody), value, state).Compile();
        }
 public static void SetBinding(this BackingFieldsStore.IBackingFieldInfo target, FieldBinding binding)
 {
     FieldBindingOperations.SetBinding(target, binding);
 }
Пример #23
0
            /// <summary>
            ///     Constructs a cell containing an image thumbnail.
            /// </summary>
            /// <param name="tableView">The parent <see cref="UITableView"/>.</param>
            /// <param name="fieldBinding">The field binding backing the cell.</param>
            private static DetailFieldCellBase ConstructImageCell(UITableView tableView, FieldBinding fieldBinding)
            {
                var cell = (DetailImageCell)tableView.DequeueReusableCell("DetailImageCell");

                cell.Construct(fieldBinding.Metadata, (ValueProvider)fieldBinding.ValueProvider);

                return(cell);
            }
Пример #24
0
 public void AddBinding(string fieldName, FieldBinding binding)
 {
     this.AddAssociatedControl(binding.BoundControl);
     this.Bindings.Add(fieldName, binding);
 }
Пример #25
0
            /// <summary>
            /// Initializes a new instance of <see cref="ObjectBinding"/>.
            /// </summary>
            /// <param name="fields">The object fields.</param>
            /// <param name="getState">The read binding.</param>
            /// <param name="setState">The write binding.</param>
            public ObjectBinding(FieldBinding[] fields, Func<Object, IDictionary<String, Object>> getState, Action<Object, IDictionary<String, Object>> setState)
            {
                Verify.NotNull(fields, nameof(fields));
                Verify.NotNull(getState, nameof(getState));
                Verify.NotNull(setState, nameof(setState));

                this.fields = fields.ToDictionary(binding => binding.Metadata.Name, binding => binding);
                this.getState = getState;
                this.setState = setState;
            }