/// <summary> /// Ons the element changed. /// </summary> /// <param name="e">E.</param> protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.ListView> e) { base.OnElementChanged(e); if (e.OldElement is EnhancedListView oldElement) { oldElement.Renderer = null; if (Control != null) { Control.Delegate = null; } if (ScrollDelegate != null) { ScrollDelegate.Source = null; ScrollDelegate.Element = null; ScrollDelegate.Dispose(); ScrollDelegate = null; } } if (e.NewElement is EnhancedListView newElement) { newElement.Renderer = this; ScrollDelegate = new ScrollDelegate(newElement, Control.Source); Control.Delegate = ScrollDelegate; } }
protected override void Dispose(bool disposing) { if (!_disposed && disposing) { _disposed = true; ScrollDelegate.Source = null; ScrollDelegate.Element = null; ScrollDelegate?.Dispose(); ScrollDelegate = null; Control.Delegate = null; } base.Dispose(disposing); }
/// <summary> /// Ons the element changed. /// </summary> /// <param name="e">E.</param> protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.ListView> e) { base.OnElementChanged(e); if (e.OldElement is EnhancedListView oldElement) { /* * oldElement.RendererScrollBy -= ScrollBy; * oldElement.RendererScrollTo -= ScrollTo; * oldElement.RendererScrollOffset -= ScrollOffset; * oldElement.RendererHeaderHeight -= HeaderHeight; * oldElement.GetScrollEnabled -= GetScrollEnabled; */ oldElement.Renderer = null; if (Control != null) { Control.Delegate = null; } if (ScrollDelegate != null) { ScrollDelegate.Source = null; ScrollDelegate.Element = null; ScrollDelegate = null; } } if (e.NewElement is EnhancedListView newElement) { /* * newElement.RendererScrollBy += ScrollBy; * newElement.RendererScrollTo += ScrollTo; * newElement.RendererScrollOffset += ScrollOffset; * newElement.RendererHeaderHeight += HeaderHeight; */ newElement.Renderer = this; ScrollDelegate = new ScrollDelegate(newElement, Control.Source); Control.Delegate = ScrollDelegate; } }
public void Update(UITableView tableView, Cell cell, UITableViewCell nativeCell) { var parentListView = cell.RealParent as ListView; var recycling = parentListView != null && parentListView.CachingStrategy == ListViewCachingStrategy.RecycleElement; if (_cell != cell && recycling) { if (_cell != null) { ((INotifyCollectionChanged)_cell.ContextActions).CollectionChanged -= OnContextItemsChanged; } ((INotifyCollectionChanged)cell.ContextActions).CollectionChanged += OnContextItemsChanged; } var height = Frame.Height; var width = tableView.Frame.Width; nativeCell.Frame = new RectangleF(0, 0, width, height); nativeCell.SetNeedsLayout(); var handler = new PropertyChangedEventHandler(OnMenuItemPropertyChanged); _tableView = tableView; SetupSelection(tableView); if (_cell != null) { if (!recycling) { _cell.PropertyChanged -= OnCellPropertyChanged; } if (_menuItems.Count > 0) { if (!recycling) { ((INotifyCollectionChanged)_cell.ContextActions).CollectionChanged -= OnContextItemsChanged; } foreach (var item in _menuItems) { item.PropertyChanged -= handler; } } _menuItems.Clear(); } _menuItems.AddRange(cell.ContextActions); _cell = cell; if (!recycling) { cell.PropertyChanged += OnCellPropertyChanged; ((INotifyCollectionChanged)_cell.ContextActions).CollectionChanged += OnContextItemsChanged; } var isOpen = false; if (_scroller == null) { _scroller = new UIScrollView(new RectangleF(0, 0, width, height)); _scroller.ScrollsToTop = false; _scroller.ShowsHorizontalScrollIndicator = false; if (Forms.IsiOS8OrNewer) { _scroller.PreservesSuperviewLayoutMargins = true; } ContentView.AddSubview(_scroller); } else { _scroller.Frame = new RectangleF(0, 0, width, height); isOpen = ScrollDelegate.IsOpen; for (var i = 0; i < _buttons.Count; i++) { var b = _buttons[i]; b.RemoveFromSuperview(); b.Dispose(); } _buttons.Clear(); ScrollDelegate.Unhook(_scroller); ScrollDelegate.Dispose(); } if (ContentCell != nativeCell) { if (ContentCell != null) { ContentCell.RemoveFromSuperview(); ContentCell = null; } ContentCell = nativeCell; //Hack: if we have a ImageCell the insets are slightly different, //the inset numbers user below were taken using the Reveal app from the default cells if ((ContentCell as CellTableViewCell)?.Cell is ImageCell) { nfloat imageCellInsetLeft = 57; nfloat imageCellInsetRight = 0; if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { imageCellInsetLeft = 89; imageCellInsetRight = imageCellInsetLeft / 2; } SeparatorInset = new UIEdgeInsets(0, imageCellInsetLeft, 0, imageCellInsetRight); } _scroller.AddSubview(nativeCell); } SetupButtons(width, height); UIView container = null; var totalWidth = width; for (var i = _buttons.Count - 1; i >= 0; i--) { var b = _buttons[i]; totalWidth += b.Frame.Width; if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { _scroller.AddSubview(b); } else { if (container == null) { container = new iOS7ButtonContainer(b.Frame.Width); _scroller.InsertSubview(container, 0); } container.AddSubview(b); } } _scroller.Delegate = new ContextScrollViewDelegate(container, _buttons, isOpen); _scroller.ContentSize = new SizeF(totalWidth, height); if (isOpen) { _scroller.SetContentOffset(new PointF(ScrollDelegate.ButtonsWidth, 0), false); } else { _scroller.SetContentOffset(new PointF(0, 0), false); } }
public void PrepareForDeselect() { ScrollDelegate.PrepareForDeselect(_scroller); }
public static extern ScrollDelegate SetScrollCallback(WindowHandle window, ScrollDelegate callback);
protected void OnScroll(float oldPos, float newPos) { float delta = newPos - oldPos; int firstVisibleCellIndex = FirstVisibleCellIndex; int lastVisibleCellIndex = LastVisibleCellIndex; if (delta > 0) { int rowsCount = RowsCount; // wipe invisible rows while (!IsCellVisible(firstVisibleCellIndex, newPos) && VisibleCellsCount > 0) { RemoveVisibleCell(FirstVisibleCell); ++firstVisibleCellIndex; } if (VisibleCellsCount > 0) // not all rows were wiped: just append more visible cells at the end { for (int cellIndex = lastVisibleCellIndex + 1; cellIndex < rowsCount && IsCellVisible(cellIndex, newPos); ++cellIndex) { CTableViewCell cell = TableCellForRow(cellIndex); m_visibleCells.AddLastItem(cell); } } else { int rowIndex = FindFirstVisibleRow(newPos, lastVisibleCellIndex + 1, rowsCount - 1); while (rowIndex < rowsCount && IsCellVisible(rowIndex, newPos)) { CTableViewCell cell = TableCellForRow(rowIndex); m_visibleCells.AddLastItem(cell); ++rowIndex; } } } else if (delta < 0) { while (this.VisibleCellsCount > 0 && !IsCellVisible(lastVisibleCellIndex, newPos)) { RemoveVisibleCell(LastVisibleCell); --lastVisibleCellIndex; } if (VisibleCellsCount > 0) // not all rows were wiped: just prepend more visible cells at the beginning { for (int cellIndex = firstVisibleCellIndex - 1; cellIndex >= m_cellsEntries.HeadIndex && IsCellVisible(cellIndex, newPos); --cellIndex) { CTableViewCell cell = TableCellForRow(cellIndex); m_visibleCells.AddFirstItem(cell); } } else { int rowIndex = FindLastVisibleRow(newPos, m_cellsEntries.HeadIndex, firstVisibleCellIndex - 1); while (rowIndex >= m_cellsEntries.HeadIndex && IsCellVisible(rowIndex, newPos)) { CTableViewCell cell = TableCellForRow(rowIndex); m_visibleCells.AddFirstItem(cell); --rowIndex; } } } if (ScrollDelegate != null) { ScrollDelegate.OnTableScroll(this, oldPos); } }
private void Initialize() { this.holoScriptApp = new HoloScriptApplication(); //this.logHandler = new HoloScript.LogsGeneratedDelegate(OnLogGenerated); //this.holoScriptApp.OnLogGenerated += logHandler; // // Required for Windows Form Designer support // InitializeComponent(); filteredOutFunctionList = new ArrayList(); filteredOutLogQueue = new System.Collections.Queue(); // build the error code hash tables LoadErrorCodeTables(); this.scrollUpHandler = new ScrollDelegate(this.LogListViewScrollUp); this.scrollDownHandler = new ScrollDelegate(this.LogListViewScrollDown); this.scrollLeftHandler = new ScrollDelegate(this.LogListViewScrollLeft); this.scrollRightHandler = new ScrollDelegate(this.LogListViewScrollRight); this.lv_LogInformation.OnScrollUp += scrollUpHandler; this.lv_LogInformation.OnScrollDown += scrollDownHandler; this.lv_LogInformation.OnScrollLeft += scrollLeftHandler; this.lv_LogInformation.OnScrollRight += scrollRightHandler; // this.numLogEntries = 0; // this.numVisibleLogEntries = 0; this.currentLogEntry = 0; // this.lastLogEntryInListView = -1; lv_ToolTip = new ToolTip(); lv_ToolTip.AutoPopDelay = 4000; lv_ToolTip.InitialDelay = 500; lv_ToolTip.ReshowDelay = 500; lv_ToolTip.ShowAlways = true; this.diskLimitUnit = "KB"; this.memLimitUnit = "KB"; this.networkSpeed = 100; this.SavedLogFileName = ""; this.searchInfo = ""; // this.loadingPreviouslySavedLogFile = false; }
public static extern ScrollDelegate SetScrollCallback(IntPtr window, ScrollDelegate callback);
private void OnDestroy() { onDrag = null; onEndDrag = null; }
public ScrollCommand(ScrollDelegate del, int direction) { _del = del; _direction = direction; }