public override Control OnCreate(CellEventArgs args) { if (ItemBinding == null) { return(null); } Initialize(args); var model = Model; var dval = ItemBinding.GetValue(args.Item); var tval = Convert(model.Property); var picker = new ColorPicker { Value = tval == dval ? dval : tval }; picker.ValueChanged += (sender, eventArgs) => { model.ToolboxValue = picker.Value.ToString(); }; if (!Model.Property.CanWrite) { picker.Enabled = false; } var layout = new TableLayout(1, 1); layout.Add(picker, 0, 0, true, true); return(layout); }
/// <summary> /// Normally we will just the general implementation for this. The exception is when we /// are trying to bind to this from the TypeName attribute of an EntityTypeMapping. In this /// case, we need to return IsTypeOf(typeName) if the ETM needs it that way. /// Simillary we need to return "Collection(typeName)" string for the ReturnType attribute of a FunctionImport. /// </summary> /// <param name="binding"></param> /// <returns></returns> internal override string GetRefNameForBinding(ItemBinding binding) { var etm = binding.Parent as EntityTypeMapping; if (etm != null && etm.Kind == EntityTypeMappingKind.IsTypeOf) { return(string.Format( CultureInfo.InvariantCulture, EntityTypeMapping.IsTypeOfFormat, NormalizedNameExternal)); } var fi = binding.Parent as FunctionImport; if (fi != null) { return(string.Format( CultureInfo.InvariantCulture, FunctionImport.CollectionFormat, NormalizedNameExternal)); } return(base.GetRefNameForBinding(binding)); }
/// <summary> /// Paints the cell when <see cref="CustomCell.SupportsControlView"/> is false. /// </summary> /// <remarks> /// For platforms like GTK and WinForms which don't support using a custom control per cell, this will be called /// to paint the content of the cell when it is not in edit mode. /// </remarks> /// <param name="args">Cell paint arguments.</param> public override void OnPaint(CellPaintEventArgs args) { if (ItemBinding == null) { return; } var value = ItemBinding.GetValue(args.Item); args.DrawCenteredText(Convert.ToString(value)); }
/// <summary> /// Paints the cell when <see cref="CustomCell.SupportsControlView"/> is false. /// </summary> /// <remarks> /// For platforms like GTK and WinForms which don't support using a custom control per cell, this will be called /// to paint the content of the cell when it is not in edit mode. /// </remarks> /// <param name="args">Cell paint arguments.</param> public override void OnPaint(CellPaintEventArgs args) { if (ItemBinding == null) { return; } var value = ItemBinding.GetValue(args.Item); args.DrawCenteredText(string.Format("{0:d}", value)); }
/// <summary> /// Paints the cell when <see cref="CustomCell.SupportsControlView"/> is false. /// </summary> /// <remarks> /// For platforms like GTK and WinForms which don't support using a custom control per cell, this will be called /// to paint the content of the cell when it is not in edit mode. /// </remarks> /// <param name="args">Cell paint arguments.</param> public override void OnPaint(CellPaintEventArgs args) { if (ItemBinding == null) { return; } var value = ItemBinding.GetValue(args.Item); var color = args.IsSelected ? SystemColors.HighlightText : SystemColors.ControlText; args.Graphics.DrawText(SystemFonts.Default(), color, args.ClipRectangle.Location, Convert.ToString(value)); }
private void CheckWhetherBindingTargetsAreDisposed(ItemBinding itemBinding) { if (_checkBindingIntegrity && itemBinding != null) { if (itemBinding.IsBindingTargetDisposed && !_staleItemBindingList.Contains(itemBinding)) { _staleItemBindingList.Add(itemBinding); } } }
/// <summary> /// Given an item binding, return the target of the binding if it is mapped to something in c-space /// </summary> /// <param name="itemBinding"></param> /// <returns></returns> private static EFObject GetCSpaceObjectFromBinding(ItemBinding itemBinding) { foreach (EFObject dep in itemBinding.ResolvedTargets) { var cModel = dep.RuntimeModelRoot() as ConceptualEntityModel; if (cModel != null) { return(dep); } } return(null); }
/// <summary> /// Special case for FunctionImport /// We need to return "Collection(typeName)" string for the ReturnType attribute of a FunctionImport. /// </summary> /// <param name="binding"></param> /// <returns></returns> internal override string GetRefNameForBinding(ItemBinding binding) { var fi = binding.Parent as FunctionImport; if (fi != null) { return(string.Format( CultureInfo.InvariantCulture, FunctionImport.CollectionFormat, NormalizedNameExternal)); } return(base.GetRefNameForBinding(binding)); }
/// <summary> /// Paints the cell when <see cref="CustomCell.SupportsControlView"/> is false. /// </summary> /// <remarks> /// For platforms like GTK and WinForms which don't support using a custom control per cell, this will be called /// to paint the content of the cell when it is not in edit mode. /// </remarks> /// <param name="args">Cell paint arguments.</param> public override void OnPaint(CellPaintEventArgs args) { if (ItemBinding == null) { return; } var value = ItemBinding.GetValue(args.Item); var color = args.IsSelected ? SystemColors.HighlightText : SystemColors.ControlText; args.Graphics.DrawText(SystemFonts.Default(), color, args.ClipRectangle.Location, value.ToHex(ShowAlpha)); var rect = args.ClipRectangle; rect.Left = rect.Right - 35; args.Graphics.FillRectangle(value, rect); }
/// <summary> /// Paints the cell when <see cref="CustomCell.SupportsControlView"/> is false. /// </summary> /// <remarks> /// For platforms like GTK and WinForms which don't support using a custom control per cell, this will be called /// to paint the content of the cell when it is not in edit mode. /// </remarks> /// <param name="args">Cell paint arguments.</param> public override void OnPaint(CellPaintEventArgs args) { if (ItemBinding == null) { return; } var value = ItemBinding.GetValue(args.Item); const int size = 35; var rect = args.ClipRectangle; rect.Right -= size; args.DrawCenteredText(value.ToHex(ShowAlpha), rect: rect); rect = args.ClipRectangle; rect.Left = rect.Right - size; args.Graphics.FillRectangle(value, rect); }
/// <summary> /// Creates the content control for the cell. /// </summary> /// <remarks> /// The control returned may be reused for other cells, so it is ideal to use MVVM data binding using /// BindDataContext() /// methods of your controls. /// This should return the same control for each row, otherwise the incorrect control may be shown on certain cells. /// </remarks> /// <param name="args">Cell arguments.</param> public override Control OnCreate(CellEventArgs args) { if (ItemBinding == null) { return(null); } var checkBox = new CheckBox(); checkBox.CheckedBinding.BindDataContext(ItemBinding); var label = new Label { Wrap = WrapMode.None, VerticalAlignment = VerticalAlignment.Center }; label.MouseDoubleClick += (sender, e) => checkBox.Checked = !checkBox.Checked; label.Bind(c => c.TextColor, args, a => a.CellTextColor); label.TextBinding.BindDataContext(ItemBinding.Convert(r => Convert.ToString(r))); return(new TableLayout { Spacing = new Size(5, 0), Rows = { new TableRow(new TableCell(label, true), checkBox) } }); }
public override Control OnCreate(CellEventArgs args) { var item = (IPropertyEditorModel)args.Item; if (item == null) { return(new Label { Text = "Unsupported" }); } var text = ItemBinding.GetValue(item); var label = new Label { Text = text }; return(new Panel { Padding = new Padding(2), Content = label }); }
/// <summary> /// This the text that should be written out to the XML that can refer back to this /// item. Most items can use the NormalizedNameExternal so that is what we /// will use by default. /// </summary> /// <param name="binding"></param> /// <returns></returns> internal virtual string GetRefNameForBinding(ItemBinding binding) { return NormalizedNameExternal; }
/// <summary> /// Creates the content control for the cell. /// </summary> /// <remarks> /// The control returned may be reused for other cells, so it is ideal to use MVVM data binding using /// BindDataContext() /// methods of your controls. /// This should return the same control for each row, otherwise the incorrect control may be shown on certain cells. /// </remarks> /// <param name="args">Cell arguments.</param> public override Control OnCreate(CellEventArgs args) { if (ItemBinding == null) { return(null); } var picker = new ColorPicker(); picker.ValueBinding.BindDataContext(ItemBinding); if (!ShowHex) { return(picker); } var mask = ShowAlpha ? "\\#>AAAAAAAA" : "\\#>AAAAAA"; Control value; if (HexEditable) { var textBox = new MaskedTextBox { Provider = new FixedMaskedTextProvider(mask), InsertMode = InsertKeyMode.Overwrite, BackgroundColor = Colors.Transparent, ShowBorder = false }; textBox.TextChanging += (sender, e) => { e.Cancel = !e.Text.ToCharArray().Select(r => r.ToString()).All("0123456789abcdefABCDEF".Contains); }; var colorBinding = textBox.Bind(c => c.TextColor, args, a => a.CellTextColor); textBox.TextBinding.BindDataContext(ItemBinding.Convert(v => v.ToHex(ShowAlpha), v => { Color c; Color.TryParse(v, out c); return(c); })); textBox.GotFocus += (sender, e) => { colorBinding.Mode = DualBindingMode.Manual; textBox.BackgroundColor = SystemColors.ControlBackground; textBox.TextColor = SystemColors.ControlText; }; textBox.LostFocus += (sender, e) => { textBox.BackgroundColor = Colors.Transparent; colorBinding.Mode = DualBindingMode.TwoWay; colorBinding.Update(); }; value = textBox; } else { var label = new Label(); label.Bind(c => c.TextColor, args, a => a.CellTextColor); label.TextBinding.BindDataContext(ItemBinding.Convert(v => v.ToHex(ShowAlpha), v => { Color c; Color.TryParse(v, out c); return(c); })); value = label; } return(new StackLayout { Orientation = Orientation.Horizontal, VerticalContentAlignment = VerticalAlignment.Stretch, Items = { new StackLayoutItem(value, expand: true), picker } }); }
/// <summary> /// A property is always referred to by its bare Name. This is because a property is always /// referred to in the context of an EntityType. /// </summary> internal override string GetRefNameForBinding(ItemBinding binding) { return(LocalName.Value); }
/// <summary> /// Normally we will just the general implementation for this. The exception is when we /// are trying to bind to this from the TypeName attribute of an EntityTypeMapping. In this /// case, we need to return IsTypeOf(typeName) if the ETM needs it that way. /// Simillary we need to return "Collection(typeName)" string for the ReturnType attribute of a FunctionImport. /// </summary> /// <param name="binding"></param> /// <returns></returns> internal override string GetRefNameForBinding(ItemBinding binding) { var etm = binding.Parent as EntityTypeMapping; if (etm != null && etm.Kind == EntityTypeMappingKind.IsTypeOf) { return string.Format( CultureInfo.InvariantCulture, EntityTypeMapping.IsTypeOfFormat, NormalizedNameExternal); } var fi = binding.Parent as FunctionImport; if (fi != null) { return string.Format( CultureInfo.InvariantCulture, FunctionImport.CollectionFormat, NormalizedNameExternal); } return base.GetRefNameForBinding(binding); }
/// <summary> /// An EntitySet is always referred to by its bare Name. This is because an EntitySet is always /// referred to in the context of an EntityContainer. /// </summary> internal override string GetRefNameForBinding(ItemBinding binding) { return LocalName.Value; }
internal void AddBindingForRebind(ItemBinding itemBinding) { _itemsToRebind.Add(itemBinding); }
/// <summary> /// Given an item binding, return the target of the binding if it is mapped to something in c-space /// </summary> /// <param name="itemBinding"></param> /// <returns></returns> private static EFObject GetCSpaceObjectFromBinding(ItemBinding itemBinding) { foreach (EFObject dep in itemBinding.ResolvedTargets) { var cModel = dep.RuntimeModelRoot() as ConceptualEntityModel; if (cModel != null) { return dep; } } return null; }
/// <summary> /// Special case for FunctionImport /// We need to return "Collection(typeName)" string for the ReturnType attribute of a FunctionImport. /// </summary> /// <param name="binding"></param> /// <returns></returns> internal override string GetRefNameForBinding(ItemBinding binding) { var fi = binding.Parent as FunctionImport; if (fi != null) { return string.Format( CultureInfo.InvariantCulture, FunctionImport.CollectionFormat, NormalizedNameExternal); } return base.GetRefNameForBinding(binding); }
/// <summary> /// An AssociationSetEnd is always referred to by its bare Name. This is because an AssociationSetEnd is always /// referred to in the context of an AssociationSet. /// </summary> internal override string GetRefNameForBinding(ItemBinding binding) { return(Role.RefName); }
/// <summary> /// An AssociationSetEnd is always referred to by its bare Name. This is because an AssociationSetEnd is always /// referred to in the context of an AssociationSet. /// </summary> internal override string GetRefNameForBinding(ItemBinding binding) { return Role.RefName; }