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; }
protected override void Dispose(bool disposing) { if (disposing) { picker.ValueChanged -= OnDatePickerValueChanged; } _target = null; base.Dispose(disposing); }
protected internal virtual FieldBinding VisitFieldBinding(FieldBinding fb) { var r = Visit(fb.Binding); if (r == fb.Binding) { return(fb); } return(new FieldBinding(fb.FieldInfo, r)); }
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); }
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"); }
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); }
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; }
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); }
/// <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); }
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"); }
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; }
internal static bool UseImageCell(FieldBinding binding) { return(binding.Metadata.Widget() is ImageWidgetDefinition); }
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; }
/// <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(); }
/// <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)); }
/// <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); }
private void Attach(FieldBinding binding) { _target = binding; Configure(binding); }
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)); }
/// <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); }
/// <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); }
public void AddBinding(string fieldName, FieldBinding binding) { this.AddAssociatedControl(binding.BoundControl); this.Bindings.Add(fieldName, binding); }
/// <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; }