protected override void Dispose(bool disposing) { if (!isDisposed) { isDisposed = true; if (disposing) { label?.RemoveFromSuperviewWithoutNeedingDisplay(); label?.Dispose(); disclosure?.RemoveFromSuperviewWithoutNeedingDisplay(); disclosure?.Dispose(); } label = null; disclosure = null; } base.Dispose(disposing); }
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; } }