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(); }
public RunConfigurationsList() { listStore = new Xwt.ListStore(configCol, configNameCol, configIconCol); list = new Xwt.ListView(listStore); list.HeadersVisible = false; var imgCell = new ImageCellView { ImageField = configIconCol }; var textCell = new TextCellView { MarkupField = configNameCol }; list.Columns.Add(GettextCatalog.GetString("Name"), imgCell, textCell); Content = list; list.SelectionChanged += (s, o) => SelectionChanged?.Invoke(this, o); list.RowActivated += (s, o) => RowActivated?.Invoke(this, o); }
internal static FrameworkElementFactory CreateBoundCellRenderer(CellView view) { TextCellView textView = view as TextCellView; if (textView != null) { FrameworkElementFactory factory = new FrameworkElementFactory(typeof(SWC.TextBlock)); if (textView.TextField != null) { factory.SetBinding(SWC.TextBlock.TextProperty, new Binding(".[" + textView.TextField.Index + "]")); } factory.SetValue(SWC.Control.PaddingProperty, new Thickness(2)); return(factory); } ImageCellView imageView = view as ImageCellView; if (imageView != null) { FrameworkElementFactory factory = new FrameworkElementFactory(typeof(SWC.Image)); if (imageView.ImageField != null) { var binding = new Binding(".[" + imageView.ImageField.Index + "]") { Converter = new ImageToImageSourceConverter() }; factory.SetBinding(SWC.Image.SourceProperty, binding); } 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(); }
public ImageTableCell(ImageCellView cellView) { this.cellView = cellView; }
public void CopyFrom(object other) { var ob = (ImageTableCell)other; cellView = ob.cellView; }
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(); }
void Build() { Title = GettextCatalog.GetString("User Extensions"); Height = 480; Width = 640; var mainHBox = new HBox(); addinImageField = new DataField <Image> (); addinNameField = new DataField <string> (); addinField = new DataField <Addin> (); addinsListStore = new ListStore(addinImageField, addinNameField, addinField); addinsListView = new ListView(); addinsListView.HeadersVisible = false; addinsListView.SelectionMode = SelectionMode.Multiple; addinsListView.DataSource = addinsListStore; mainHBox.PackStart(addinsListView, true, true); var column = new ListViewColumn(); var imageCellView = new ImageCellView(); imageCellView.ImageField = addinImageField; column.Views.Add(imageCellView); var cellView = new TextCellView(); cellView.MarkupField = addinNameField; column.Views.Add(cellView); addinsListView.Columns.Add(column); var buttonVBox = new VBox(); enableButton = new Button(); enableButton.Label = GettextCatalog.GetString("Enable"); buttonVBox.PackStart(enableButton); disableButton = new Button(); disableButton.Label = GettextCatalog.GetString("Disable"); buttonVBox.PackStart(disableButton); var separator = new HSeparator(); buttonVBox.PackStart(separator); enableAllButton = new Button(); enableAllButton.Label = GettextCatalog.GetString("Enable All"); buttonVBox.PackStart(enableAllButton); disableAllButton = new Button(); disableAllButton.Label = GettextCatalog.GetString("Disable All"); buttonVBox.PackStart(disableAllButton); separator = new HSeparator(); buttonVBox.PackStart(separator); restartButton = new Button(); restartButton.Label = GettextCatalog.GetString("Restart {0}", BrandingService.ApplicationName); buttonVBox.PackStart(restartButton); mainHBox.PackStart(buttonVBox, false, false); Content = mainHBox; var closeButton = new DialogButton(Command.Close); closeButton.Clicked += CloseButtonClicked; Buttons.Add(closeButton); }