public override NSTableCellView GetCell(Cell item, NSTableCellView reusableCell, NSTableView tv) { TextCell entryCell = (TextCell)item; CellTableViewCell cell = reusableCell as CellTableViewCell; if (cell == null) { cell = new CellTableViewCell(); // (UITableViewCellStyle.Subtitle, (item).GetType ().FullName); } else { cell.Cell.PropertyChanged -= cell.HandlePropertyChanged; } cell.Cell = (Cell)entryCell; entryCell.PropertyChanged += cell.HandlePropertyChanged; cell.PropertyChanged = new Action <object, PropertyChangedEventArgs> (this.HandlePropertyChanged); cell.TextField.StringValue = entryCell.Text; cell.TextField.TextColor = ColorExtensions.ToUIColor(entryCell.TextColor, TextCellRenderer.DefaultTextColor); //cell.DetailTextLabel.Text = entryCell.Detail; //cell.DetailTextLabel.TextColor = ColorExtensions.ToUIColor (entryCell.DetailColor, TextCellRenderer.DefaultDetailColor); TextCellRenderer.UpdateIsEnabled(cell, entryCell); this.UpdateBackground((NSTableCellView)cell, item); return((NSTableCellView)cell); }
public override NSTableCellView GetCell(Cell item, NSTableCellView reusableCell, NSTableView tv) { CellTableViewCell cell = (CellTableViewCell)base.GetCell(item, reusableCell, tv); this.SetImage((ImageCell)item, cell); return(cell); }
public override NSCell GetCell(NSTableView tableView, NSTableColumn tableColumn, nint row) { Cell cell = this.view.Model.GetCell(0, (int)row); var nativeCell = CellTableViewCell.GetNativeCell(tableView, cell, false); // TODO: Figure out Cells return(null); }
protected override void HandlePropertyChanged(object sender, PropertyChangedEventArgs args) { CellTableViewCell cellTableViewCell = (CellTableViewCell)sender; ImageCell cell = (ImageCell)cellTableViewCell.Cell; base.HandlePropertyChanged(sender, args); if (args.PropertyName == ImageCell.ImageSourceProperty.PropertyName) { SetImage(cell, cellTableViewCell); } }
private void UpdateIsEnabled(CellTableViewCell cell, SwitchCell switchCell) { /* * cell.UserInteractionEnabled = switchCell.IsEnabled; * cell.TextLabel.Enabled = switchCell.IsEnabled; * cell.DetailTextLabel.Enabled = switchCell.IsEnabled; * UISwitch uiSwitch = cell.AccessoryView as UISwitch; * if (uiSwitch == null) * return; * uiSwitch.Enabled = switchCell.IsEnabled; */ }
private void SetImage(ImageCell cell, CellTableViewCell target) { // TODO: WTF ? /* * ImageCellRenderer.<SetImage>d__2 stateMachine; * stateMachine.cell = cell; * stateMachine.target = target; * stateMachine.<>t__builder = AsyncVoidMethodBuilder.Create(); * stateMachine.<>1__state = -1; * stateMachine.<>t__builder.Start<ImageCellRenderer.<SetImage>d__2>(ref stateMachine); */ }
/* * public override nint NumberOfSections (NSTableView tableView) * { * if (this.list.IsGroupingEnabled) * return (nint)this.list.TemplatedItems.Count; * return (nint)1; * } * * public override nint RowsInSection (NSTableView tableview, nint section) * { * int num; * if (this.Counts.TryGetValue ((int)section, out num)) * { * this.Counts.Remove ((int)section); * return (nint)num; * } * if (this.list.IsGroupingEnabled) * return (nint)((ICollection)((IList)this.list.TemplatedItems) [(int)section]).Count; * return (nint)this.list.TemplatedItems.Count; * } */ public override NSCell GetCell(NSTableView tableView, NSTableColumn tableColumn, nint row) { NSTableCellView cell1; NSTableViewCell tableViewCell; NSCell cell; nint section = 0; switch (this.list.CachingStrategy) { case ListViewCachingStrategy.RetainElement: Cell cellForPath1 = this.GetCellFor(section, row); cell1 = CellTableViewCell.GetNativeCell(tableView, cellForPath1, false); break; case ListViewCachingStrategy.RecycleElement: cell1 = null; // tableView.DequeueReusableCell ("ContextActionsCell"); if (cell1 == null) { Cell cellForPath2 = this.GetCellFor(section, row); cell1 = CellTableViewCell.GetNativeCell(tableView, cellForPath2, true); break; } TemplatedItemsList <ItemsView <Cell>, Cell> group = this.list.TemplatedItems.GetGroup((int)section); Cell cell2 = (Cell)((INativeElementView)cell1).Element; cell2.SendDisappearing(); Cell content = cell2; group.UpdateContent(content, (int)row); cell2.SendAppearing(); break; default: throw new NotSupportedException(); } // TODO: Figure this out //NSColor color = tableView.IndexPathForSelectedRow == null || // !tableView.IndexPathForSelectedRow.Equals (indexPath) ? this.DefaultBackgroundColor : NSColor.Clear; NSColor color = NSColor.Clear; ListViewRenderer.ListViewDataSource.SetCellBackgroundColor(cell1, color); // TODO: WT.? damit. NSCell, NSTableViewCell, NSTableCellView. Soo confusing //return cell1; return(null); }
protected virtual void HandlePropertyChanged(object sender, PropertyChangedEventArgs args) { CellTableViewCell cell = (CellTableViewCell)sender; TextCell entryCell = (TextCell)cell.Cell; if (args.PropertyName == TextCell.TextProperty.PropertyName) { cell.TextField.StringValue = ((TextCell)cell.Cell).Text; cell.TextField.SizeToFit(); } /* * else if (args.PropertyName == TextCell.DetailProperty.PropertyName) * { * cell.DetailTextLabel.Text = ((TextCell)cell.Cell).Detail; * cell.DetailTextLabel.SizeToFit (); * } */ else if (args.PropertyName == TextCell.TextColorProperty.PropertyName) { cell.TextField.TextColor = ColorExtensions.ToUIColor(entryCell.TextColor, TextCellRenderer.DefaultTextColor); } /* * else if (args.PropertyName == TextCell.DetailColorProperty.PropertyName) * { * cell.DetailTextLabel.TextColor = ColorExtensions.ToUIColor (entryCell.DetailColor, TextCellRenderer.DefaultTextColor); * } */ else { if (!(args.PropertyName == Cell.IsEnabledProperty.PropertyName)) { return; } TextCellRenderer.UpdateIsEnabled(cell, entryCell); } }
private static void UpdateIsEnabled(CellTableViewCell cell, TextCell entryCell) { //cell.UserInteractionEnabled = entryCell.IsEnabled; cell.TextField.Enabled = entryCell.IsEnabled; //cell.DetailTextLabel.Enabled = entryCell.IsEnabled; }
public void Update(NSTableView tableView, Cell cell, NSTableCellView nativeCell) { ListView listView = cell.Parent as ListView; bool flag = listView != null && listView.CachingStrategy == ListViewCachingStrategy.RecycleElement; //TODO: Content Changed /* * if (this.cell != cell & flag) * { * if (cell != null) * cell.ContextActions.CollectionChanged -= OnContextItemsChanged; * cell.ContextActions.CollectionChanged += OnContextItemsChanged; * } */ CGRect frame = Frame; nfloat height = frame.Height; frame = tableView.Frame; nfloat width1 = frame.Width; nativeCell.Frame = new CGRect((nfloat)0, (nfloat)0, width1, height); nativeCell.NeedsLayout = true; var changedEventHandler = new PropertyChangedEventHandler(this.OnMenuItemPropertyChanged); this.tableView = tableView; //this.SetupSelection (tableView); if (this.cell != null) { if (!flag) { this.cell.PropertyChanged -= OnCellPropertyChanged; } if (this.menuItems.Count > 0) { // Not for Mac /* * if (!flag) * cell.ContextActions.CollectionChanged -= OnContextItemsChanged; */ foreach (BindableObject bindableObject in menuItems) { bindableObject.PropertyChanged -= changedEventHandler; } } this.menuItems.Clear(); } this.menuItems.AddRange(cell.ContextActions); this.cell = cell; if (!flag) { cell.PropertyChanged += OnCellPropertyChanged; // Not for Mac //cell.ContextActions.CollectionChanged += OnContextItemsChanged; } bool isOpen = false; if (this.scroller == null) { this.scroller = new NSScrollView(new CGRect((nfloat)0, (nfloat)0, width1, height)); //this.scroller.ScrollsToTop = false; scroller.HorizontalScroller.AlphaValue = 0; nativeCell.AddSubview(scroller); } else { this.scroller.Frame = new CGRect((nfloat)0, (nfloat)0, width1, height); //isOpen = this.ScrollDelegate.IsOpen; for (int index = 0; index < this.buttons.Count; ++index) { NSButton uiButton = this.buttons [index]; // ISSUE: reference to a compiler-generated method uiButton.RemoveFromSuperview(); uiButton.Dispose(); } this.buttons.Clear(); //this.ScrollDelegate.Unhook (this.scroller); //this.ScrollDelegate.Dispose (); } if (this.ContentCell != nativeCell) { if (this.ContentCell != null) { this.ContentCell.RemoveFromSuperview(); this.ContentCell = null; } this.ContentCell = nativeCell; CellTableViewCell cellTableViewCell = this.ContentCell as CellTableViewCell; if ((cellTableViewCell != null ? cellTableViewCell.Cell : (Cell)null) is ImageCell) { nfloat left = (nfloat)57; nfloat right = (nfloat)0; // not for Mac //this.SeparatorInset = new UIEdgeInsets ((nfloat)0, left, (nfloat)0, right); } this.scroller.AddSubview((NSView)nativeCell); } this.SetupButtons(width1, height); NSView uiView = (NSView)null; nfloat width2 = width1; for (int index = this.buttons.Count - 1; index >= 0; --index) { NSButton uiButton = this.buttons [index]; nfloat nfloat = width2; frame = uiButton.Frame; nfloat width3 = frame.Width; width2 = nfloat + width3; this.scroller.AddSubview((NSView)uiButton); } // TODO: Fix //this.scroller.Delegate = (IUIScrollViewDelegate)new ContextScrollViewDelegate (uiView, this.buttons, isOpen); //this.scroller.ContentSize = new CGSize (width2, height); if (isOpen) { //TODO: Open value this.scroller.HorizontalScroller.FloatValue = 0; // ScrollDelegate.ButtonsWidth; this.scroller.VerticalScroller.FloatValue = 0; } else { this.scroller.HorizontalScroller.FloatValue = 0; this.scroller.VerticalScroller.FloatValue = 0; } }