public override NSTableCellView GetCell(Cell item, NSTableCellView reusableCell, NSTableView tv) { EntryCell entryCell = (EntryCell)item; EntryCellRenderer.EntryCellTableViewCell cell = reusableCell as EntryCellRenderer.EntryCellTableViewCell; if (cell == null) { cell = new EntryCellRenderer.EntryCellTableViewCell((item).GetType().FullName); } else { cell.Cell.PropertyChanged -= OnCellPropertyChanged; cell.TextFieldTextChanged -= new EventHandler(EntryCellRenderer.OnTextFieldTextChanged); cell.KeyboardDoneButtonPressed -= new EventHandler(EntryCellRenderer.OnKeyBoardDoneButtonPressed); } CellRenderer.SetRealCell((BindableObject)item, (NSTableCellView)cell); cell.Cell = item; cell.Cell.PropertyChanged += OnCellPropertyChanged; cell.TextFieldTextChanged += new EventHandler(EntryCellRenderer.OnTextFieldTextChanged); cell.KeyboardDoneButtonPressed += new EventHandler(EntryCellRenderer.OnKeyBoardDoneButtonPressed); this.UpdateBackground((NSTableCellView)cell, (Cell)entryCell); EntryCellRenderer.UpdateLabel(cell, entryCell); EntryCellRenderer.UpdateText(cell, entryCell); //EntryCellRenderer.UpdateKeyboard (cell, entryCell); EntryCellRenderer.UpdatePlaceholder(cell, entryCell); EntryCellRenderer.UpdateLabelColor(cell, entryCell); EntryCellRenderer.UpdateHorizontalTextAlignment(cell, entryCell); EntryCellRenderer.UpdateIsEnabled(cell, entryCell); return((NSTableCellView)cell); }
private static void UpdateText(EntryCellRenderer.EntryCellTableViewCell cell, EntryCell entryCell) { if (cell.TextField.StringValue == entryCell.Text) { return; } cell.TextField.StringValue = entryCell.Text; }
private static void OnCellPropertyChanged(object sender, PropertyChangedEventArgs e) { EntryCell entryCell = (EntryCell)sender; EntryCellRenderer.EntryCellTableViewCell cell = (EntryCellRenderer.EntryCellTableViewCell)CellRenderer.GetRealCell((BindableObject)entryCell); if (e.PropertyName == EntryCell.LabelProperty.PropertyName) { EntryCellRenderer.UpdateLabel(cell, entryCell); } else if (e.PropertyName == EntryCell.TextProperty.PropertyName) { EntryCellRenderer.UpdateText(cell, entryCell); } else if (e.PropertyName == EntryCell.PlaceholderProperty.PropertyName) { EntryCellRenderer.UpdatePlaceholder(cell, entryCell); } //else if (e.PropertyName == EntryCell.KeyboardProperty.PropertyName) // EntryCellRenderer.UpdateKeyboard (cell, entryCell); else if (e.PropertyName == EntryCell.LabelColorProperty.PropertyName) { EntryCellRenderer.UpdateLabelColor(cell, entryCell); } else if (e.PropertyName == EntryCell.HorizontalTextAlignmentProperty.PropertyName) { EntryCellRenderer.UpdateHorizontalTextAlignment(cell, entryCell); } else { if (!(e.PropertyName == Cell.IsEnabledProperty.PropertyName)) { return; } EntryCellRenderer.UpdateIsEnabled(cell, entryCell); } }
private static void UpdateIsEnabled(EntryCellRenderer.EntryCellTableViewCell cell, EntryCell entryCell) { //cell.UserInteractionEnabled = entryCell.IsEnabled; //cell.DetailTextLabel.Enabled = entryCell.IsEnabled; cell.TextField.Enabled = entryCell.IsEnabled; }
private static void UpdatePlaceholder(EntryCellRenderer.EntryCellTableViewCell cell, EntryCell entryCell) { cell.TextField.PlaceholderString = entryCell.Placeholder; }
// Not for Mac /* * private static void UpdateKeyboard (EntryCellRenderer.EntryCellTableViewCell cell, EntryCell entryCell) * { * Extensions.ApplyKeyboard ((IUITextInput)cell.TextField, entryCell.Keyboard); * } */ private static void UpdateLabelColor(EntryCellRenderer.EntryCellTableViewCell cell, EntryCell entryCell) { cell.TextField.TextColor = ColorExtensions.ToUIColor(entryCell.LabelColor, EntryCellRenderer.DefaultTextColor); }
private static void UpdateLabel(EntryCellRenderer.EntryCellTableViewCell cell, EntryCell entryCell) { cell.TextField.StringValue = entryCell.Label; }
private static void UpdateHorizontalTextAlignment(EntryCellRenderer.EntryCellTableViewCell cell, EntryCell entryCell) { cell.TextField.Alignment = AlignmentExtensions.ToNativeTextAlignment(entryCell.HorizontalTextAlignment); }
private static void OnTextFieldTextChanged(object sender, EventArgs eventArgs) { EntryCellRenderer.EntryCellTableViewCell cellTableViewCell = (EntryCellRenderer.EntryCellTableViewCell)sender; ((EntryCell)cellTableViewCell.Cell).Text = cellTableViewCell.TextField.StringValue; }