internal static FrameworkElementFactory CreateBoundCellRenderer(CellView view, string dataPath = ".") { TextCellView textView = view as TextCellView; if (textView != null) { FrameworkElementFactory factory = new FrameworkElementFactory(typeof(SWC.TextBlock)); factory.SetValue(FrameworkElement.MarginProperty, CellMargins); if (textView.TextField != null) { factory.SetBinding(SWC.TextBlock.TextProperty, new Binding(dataPath + "[" + textView.TextField.Index + "]")); } return(factory); } ImageCellView imageView = view as ImageCellView; if (imageView != null) { FrameworkElementFactory factory = new FrameworkElementFactory(typeof(ImageBox)); factory.SetValue(FrameworkElement.MarginProperty, CellMargins); if (imageView.ImageField != null) { var binding = new Binding(dataPath + "[" + imageView.ImageField.Index + "]") { Converter = new ImageToImageSourceConverter() }; factory.SetBinding(ImageBox.ImageSourceProperty, binding); } return(factory); } CanvasCellView canvasView = view as CanvasCellView; if (canvasView != null) { FrameworkElementFactory factory = new FrameworkElementFactory(typeof(CanvasCellViewBackend)); factory.SetValue(FrameworkElement.MarginProperty, CellMargins); factory.SetValue(CanvasCellViewBackend.CellViewProperty, view); return(factory); } throw new NotImplementedException(); }
internal static FrameworkElementFactory CreateBoundCellRenderer(ApplicationContext ctx, WidgetBackend parent, CellView view, string dataPath = ".") { ICellViewFrontend fr = view; TextCellView textView = view as TextCellView; if (textView != null) { // if it's an editable textcontrol, use a TextBox, if not use a TextBlock. Reason for this is that // a user usually expects to be able to edit a text if a text cursor is appearing above a field. FrameworkElementFactory factory; if (textView.Editable || textView.EditableField != null) { factory = new FrameworkElementFactory(typeof(SWC.TextBox)); if (textView.Editable) { factory.SetValue(SWC.TextBox.IsReadOnlyProperty, false); } else { factory.SetBinding(SWC.TextBox.IsEnabledProperty, new Binding(dataPath + "[" + textView.EditableField.Index + "]")); } if (textView.TextField != null) { factory.SetBinding(SWC.TextBox.TextProperty, new Binding(dataPath + "[" + textView.TextField.Index + "]")); } else { factory.SetValue(SWC.TextBox.TextProperty, textView.Text); } } else { factory = new FrameworkElementFactory(typeof(SWC.TextBlock)); if (textView.MarkupField != null) { factory.SetBinding(SWC.TextBlock.TextProperty, new Binding(dataPath + "[" + textView.MarkupField.Index + "]") { Converter = new MarkupToPlainTextConverter() }); } else if (textView.TextField != null) { factory.SetBinding(SWC.TextBlock.TextProperty, new Binding(dataPath + "[" + textView.TextField.Index + "]")); } else { factory.SetValue(SWC.TextBlock.TextProperty, textView.Text); } } var cb = new TextCellViewBackend(); cb.Initialize(view, factory, parent as ICellRendererTarget); fr.AttachBackend(parent.Frontend, cb); return(factory); } ImageCellView imageView = view as ImageCellView; if (imageView != null) { FrameworkElementFactory factory = new FrameworkElementFactory(typeof(ImageBox)); if (imageView.ImageField != null) { var binding = new Binding(dataPath + "[" + imageView.ImageField.Index + "]"); binding.Converter = new ImageToImageSourceConverter(ctx); factory.SetBinding(ImageBox.ImageSourceProperty, binding); } var cb = new CellViewBackend(); cb.Initialize(view, factory, parent as ICellRendererTarget); fr.AttachBackend(parent.Frontend, cb); return(factory); } CanvasCellView canvasView = view as CanvasCellView; if (canvasView != null) { var cb = new CanvasCellViewBackend(); FrameworkElementFactory factory = new FrameworkElementFactory(typeof(CanvasCellViewPanel)); factory.SetValue(CanvasCellViewPanel.CellViewBackendProperty, cb); cb.Initialize(view, factory, parent as ICellRendererTarget); fr.AttachBackend(parent.Frontend, cb); return(factory); } CheckBoxCellView cellView = view as CheckBoxCellView; if (cellView != null) { FrameworkElementFactory factory = new FrameworkElementFactory(typeof(SWC.CheckBox)); if (cellView.EditableField == null) { factory.SetValue(FrameworkElement.IsEnabledProperty, cellView.Editable); } else { factory.SetBinding(SWC.CheckBox.IsEnabledProperty, new Binding(dataPath + "[" + cellView.EditableField.Index + "]")); } factory.SetValue(SWC.CheckBox.IsThreeStateProperty, cellView.AllowMixed); if (cellView.ActiveField != null) { factory.SetBinding(SWC.CheckBox.IsCheckedProperty, new Binding(dataPath + "[" + cellView.ActiveField.Index + "]")); } var cb = new CheckBoxCellViewBackend(); cb.Initialize(view, factory, parent as ICellRendererTarget); fr.AttachBackend(parent.Frontend, cb); return(factory); } throw new NotImplementedException(); }
internal static FrameworkElementFactory CreateBoundCellRenderer(CellView view, string dataPath = ".") { TextCellView textView = view as TextCellView; if (textView != null) { // if it's an editable textcontrol, use a TextBox, if not use a TextBlock. Reason for this is that // a user usually expects to be able to edit a text if a text cursor is appearing above a field. FrameworkElementFactory factory; if (textView.EditableField == null) { if (textView.Editable) { factory = new FrameworkElementFactory(typeof(SWC.TextBox)); factory.SetValue(FrameworkElement.MarginProperty, CellMargins); factory.SetValue(SWC.TextBox.IsReadOnlyProperty, false); if (textView.TextField != null) { factory.SetBinding(SWC.TextBox.TextProperty, new Binding(dataPath + "[" + textView.TextField.Index + "]")); } } else { factory = new FrameworkElementFactory(typeof(SWC.TextBlock)); factory.SetValue(FrameworkElement.MarginProperty, CellMargins); if (textView.TextField != null) { factory.SetBinding(SWC.TextBlock.TextProperty, new Binding(dataPath + "[" + textView.TextField.Index + "]")); } } } else { factory = new FrameworkElementFactory(typeof(SWC.TextBox)); factory.SetValue(FrameworkElement.MarginProperty, CellMargins); factory.SetBinding(SWC.TextBox.IsEnabledProperty, new Binding(dataPath + "[" + textView.EditableField.Index + "]")); if (textView.TextField != null) { factory.SetBinding(SWC.TextBox.TextProperty, new Binding(dataPath + "[" + textView.TextField.Index + "]")); } } return(factory); } ImageCellView imageView = view as ImageCellView; if (imageView != null) { FrameworkElementFactory factory = new FrameworkElementFactory(typeof(ImageBox)); factory.SetValue(FrameworkElement.MarginProperty, CellMargins); if (imageView.ImageField != null) { var binding = new Binding(dataPath + "[" + imageView.ImageField.Index + "]") { Converter = new ImageToImageSourceConverter() }; factory.SetBinding(ImageBox.ImageSourceProperty, binding); } return(factory); } CanvasCellView canvasView = view as CanvasCellView; if (canvasView != null) { FrameworkElementFactory factory = new FrameworkElementFactory(typeof(CanvasCellViewBackend)); factory.SetValue(FrameworkElement.MarginProperty, CellMargins); factory.SetValue(CanvasCellViewBackend.CellViewProperty, view); return(factory); } CheckBoxCellView cellView = view as CheckBoxCellView; if (cellView != null) { FrameworkElementFactory factory = new FrameworkElementFactory(typeof(SWC.CheckBox)); if (cellView.EditableField == null) { factory.SetValue(FrameworkElement.IsEnabledProperty, cellView.Editable); } else { factory.SetBinding(SWC.CheckBox.IsEnabledProperty, new Binding(dataPath + "[" + cellView.EditableField.Index + "]")); } factory.SetValue(SWC.CheckBox.IsThreeStateProperty, cellView.AllowMixed); factory.SetValue(FrameworkElement.MarginProperty, CellMargins); if (cellView.ActiveField != null) { factory.SetBinding(SWC.CheckBox.IsCheckedProperty, new Binding(dataPath + "[" + cellView.ActiveField.Index + "]")); } return(factory); } throw new NotImplementedException(); }
public CustomCellRenderer(CanvasCellView cellView) { this.cellView = cellView; }
public void CopyFrom(object other) { var ob = (CanvasTableCell)other; cellView = ob.cellView; }
public CanvasTableCell(CanvasCellView cellView) { this.cellView = cellView; }