public void PhotoLibraryDidChange(PHChange changeInstance) { // Change notifications may be made on a background queue. Re-dispatch to the // main queue before acting on the change as we'll be updating the UI. DispatchQueue.MainQueue.DispatchSync(() => { // Check each of the three top-level fetches for changes. // Update the cached fetch result. var changeDetails = changeInstance.GetFetchResultChangeDetails(allPhotos); if (changeDetails != null) { // Update the cached fetch result. allPhotos = changeDetails.FetchResultAfterChanges; // (The table row for this one doesn't need updating, it always says "All Photos".) } // Update the cached fetch results, and reload the table sections to match. changeDetails = changeInstance.GetFetchResultChangeDetails(smartAlbums); if (changeDetails != null) { smartAlbums = changeDetails.FetchResultAfterChanges; TableView.ReloadSections(NSIndexSet.FromIndex((int)Section.SmartAlbums), UITableViewRowAnimation.Automatic); } changeDetails = changeInstance.GetFetchResultChangeDetails(userCollections); if (changeDetails != null) { userCollections = changeDetails.FetchResultAfterChanges; TableView.ReloadSections(NSIndexSet.FromIndex((int)Section.UserCollections), UITableViewRowAnimation.Automatic); } }); }
// Reloads the action set section. void UpdateActionSetSection() { var actionSetSection = NSIndexSet.FromIndex((int)HomeKitObjectSection.ActionSet); TableView.ReloadSections(actionSetSection, UITableViewRowAnimation.Automatic); UpdateTriggerAddRow(); }
protected virtual void ReloadSection(nint section, NotifyCollectionChangedEventArgs args) { if (args == null) { throw new ArgumentNullException(nameof(args)); } switch (args.Action) { case NotifyCollectionChangedAction.Add: CollectionView.PerformBatchUpdates(() => CollectionView.InsertItems(args.ToNewIndexPaths(section)), null); break; case NotifyCollectionChangedAction.Move: CollectionView.MoveItem(args.ToOldIndexPath(section), args.ToNewIndexPath(section)); break; case NotifyCollectionChangedAction.Replace: CollectionView.PerformBatchUpdates(() => CollectionView.ReloadItems(args.ToNewIndexPaths(section)), null); break; case NotifyCollectionChangedAction.Remove: CollectionView.PerformBatchUpdates(() => CollectionView.DeleteItems(args.ToOldIndexPaths(section)), null); break; default: CollectionView.ReloadSections(NSIndexSet.FromIndex(section)); break; } }
public void Append(ObjectValueNode node) { int index; if (AllowWatchExpressions) { index = Root.Children.Count - 1; Core.LoggingService.LogInfo("MacObjectValueTreeViewDataSource.Append: Inserting '{0}' at index {1}", node.Name, index); Insert(Root, index, node); } else { index = Root.Children.Count; Core.LoggingService.LogInfo("MacObjectValueTreeViewDataSource.Append: Adding '{0}' at index {1}", node.Name, index); Add(Root, node); } var indexes = NSIndexSet.FromIndex(index); treeView.InsertItems(indexes, null, NSTableViewAnimation.None); if (treeView.Controller.GetNodeWasExpandedAtLastCheckpoint(node)) { if (TryGetValue(node, out MacObjectValueNode x)) { treeView.ExpandItem(x); } } }
protected NSIndexSet GetSectionFromPlainIndex(IEnumerable <TData> collection, int headerIndex) { var index = collection.Take(headerIndex).OfType <TSection> ().Count(); var nsIndex = NSIndexSet.FromIndex(index); return(nsIndex); }
// TODO: For the next version, group changed event will appropriately be done, too. protected virtual void UpdateGroups(NotifyCollectionChangedEventArgs e) { var exArgs = e as NotifyCollectionChangedEventArgsEx; if (exArgs != null) { DataSource.Counts[e.NewStartingIndex] = exArgs.Count; } switch (e.Action) { case NotifyCollectionChangedAction.Add: Control.PerformBatchUpdates(() => { Control.InsertSections(NSIndexSet.FromIndex(e.NewStartingIndex)); }, (finished) => { }); break; case NotifyCollectionChangedAction.Remove: Control.PerformBatchUpdates(() => { Control.DeleteSections(NSIndexSet.FromIndex(e.OldStartingIndex)); }, (finished) => { }); break; // the other pattern } }
public virtual void SetSource(IListDataSource source, IBackend sourceBackend) { this.source = source; RowHeights = new List <nfloat> (); for (int i = 0; i < source.RowCount; i++) { RowHeights.Add(-1); } tsource = new ListSource(source); Table.DataSource = tsource; //TODO: Reloading single rows would be slightly more efficient. // According to NSTableView.ReloadData() documentation, // only the visible rows are reloaded. source.RowInserted += (sender, e) => { RowHeights.Insert(e.Row, -1); Table.ReloadData(); }; source.RowDeleted += (sender, e) => { RowHeights.RemoveAt(e.Row); Table.ReloadData(); }; source.RowChanged += (sender, e) => { UpdateRowHeight(e.Row); Table.ReloadData(NSIndexSet.FromIndex(e.Row), NSIndexSet.FromNSRange(new NSRange(0, Table.ColumnCount))); }; source.RowsReordered += (sender, e) => { RowHeights.Clear(); Table.ReloadData(); }; }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { tableView.DeselectRow(indexPath, true); switch ((AddAccessoryTableViewSection)indexPath.Section) { case AddAccessoryTableViewSection.Rooms: if (!Home.IsAdmin()) { return; } selectedRoom = Home.GetAllRooms() [indexPath.Row]; var sections = NSIndexSet.FromIndex((nint)(int)AddAccessoryTableViewSection.Rooms); tableView.ReloadSections(sections, UITableViewRowAnimation.Automatic); break; case AddAccessoryTableViewSection.Identify: IdentifyAccessory(); break; case AddAccessoryTableViewSection.Name: break; default: throw new InvalidOperationException("Unexpected `AddAccessoryTableViewSection` value."); } }
public void Append(ObjectValueNode node) { int index; if (AllowWatchExpressions) { index = Root.Children.Count - 1; Core.LoggingService.LogInfo("MacObjectValueTreeViewDataSource.Append: Inserting '{0}' at index {1}", node.Name, index); Insert(Root, index, node); } else { index = Root.Children.Count; Core.LoggingService.LogInfo("MacObjectValueTreeViewDataSource.Append: Adding '{0}' at index {1}", node.Name, index); Add(Root, node); } treeView.BeginUpdates(); try { var indexes = NSIndexSet.FromIndex(index); treeView.InsertItems(indexes, null, NSTableViewAnimation.None); RestoreExpandedState(node.Children); } finally { treeView.EndUpdates(); } }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { tableView.DeselectRow(indexPath, true); if (indexPath.Section == 0) { if (indexPath.Row == 0) { parent.Orientation = PrintHelper.ORIENTATION.PORTRAIT; } else { parent.Orientation = PrintHelper.ORIENTATION.LANDSCAPE; } } else if (indexPath.Section == 1) { if (indexPath.Row == 0) { parent.Range = PrintHelper.RANGE.CURRENT; } else { parent.Range = PrintHelper.RANGE.CUSTOM; } } tableView.ReloadSections(NSIndexSet.FromIndex(indexPath.Section), UITableViewRowAnimation.None); }
protected void RemoveSection() { _items.RemoveAt(0); _tableView.BeginUpdates(); _tableView.DeleteSections(NSIndexSet.FromIndex(0), UITableViewRowAnimation.Fade); _tableView.EndUpdates(); }
// Handles selection of a recurrence cell. // If the newly selected recurrence component is the previously selected // recurrence component, reset the current selected component to `-1` and deselect that row. void SelectRecurrenceComponent(UITableView tableView, NSIndexPath indexPath) { bool isPreviouslySelected = indexPath.Row == TimerTriggerCreator.SelectedRecurrenceIndex; TimerTriggerCreator.SelectedRecurrenceIndex = isPreviouslySelected ? -1 : indexPath.Row; tableView.ReloadSections(NSIndexSet.FromIndex(indexPath.Section), UITableViewRowAnimation.Automatic); }
private void UpdateSectionNoAnimation(Section section) { int secIndex = Element.Model.GetSectionIndex(section); Control.BeginUpdates(); Control.ReloadSections(NSIndexSet.FromIndex(secIndex), UITableViewRowAnimation.None); Control.EndUpdates(); }
public override void DidEndLiveTransition(NSPageController pageController) { // Update the NSTableView selection appDelegate.TableView.SelectRows(NSIndexSet.FromIndex(appDelegate.PageController.SelectedIndex), false); // tell page controller to complete the transition and display the updated file card appDelegate.PageController.CompleteTransition(); }
void UpdateSectionFade(Section section) { var secIndex = Element.Model.GetSectionIndex(section); Control.BeginUpdates(); Control.ReloadSections(NSIndexSet.FromIndex(secIndex), UITableViewRowAnimation.Fade); Control.EndUpdates(); }
public void UpdateRowHeight(nint row) { if (updatingRowHeight) { return; } RowHeights[(int)row] = CalcRowHeight(row); Table.NoteHeightOfRowsWithIndexesChanged(NSIndexSet.FromIndex(row)); }
/// <summary> /// Add a group using the native in-place modifier. /// </summary> /// <param name="groupIndexInView">The index of the group from the native collection view's perspective, ie ignoring empty groups /// if HidesIfEmpty=true.</param> private void AddGroup(int groupIndexInView) { NativePanel?.InsertSections(NSIndexSet.FromIndex(groupIndexInView)); if (ManagedVirtualizingPanel != null) { Refresh(); } }
private void ReplaceGroup(int groupIndexInView) { NativePanel?.ReloadSections(NSIndexSet.FromIndex(groupIndexInView)); if (ManagedVirtualizingPanel != null) { Refresh(); } }
public void handleCollectionChanges(IEnumerable <CollectionChange> changes) { lock (animationLock) { if (changes.Any(c => c.Type == CollectionChangeType.Reload)) { tableView.ReloadData(); return; } tableView.BeginUpdates(); foreach (var change in changes) { NSIndexPath indexPath = NSIndexPath.FromRowSection(change.Index.Row, change.Index.Section); NSIndexPath[] indexPaths = { indexPath }; NSMutableIndexSet indexSet = (NSMutableIndexSet)NSIndexSet.FromIndex(change.Index.Section).MutableCopy(); switch (change.Type) { case CollectionChangeType.AddRow: tableView.InsertRows(indexPaths, UITableViewRowAnimation.Automatic); break; case CollectionChangeType.RemoveRow: tableView.DeleteRows(indexPaths, UITableViewRowAnimation.Automatic); break; case CollectionChangeType.UpdateRow: tableView.ReloadRows(indexPaths, UITableViewRowAnimation.Automatic); break; case CollectionChangeType.MoveRow: if (change.OldIndex.HasValue) { NSIndexPath oldIndexPath = NSIndexPath.FromRowSection(change.OldIndex.Value.Row, change.OldIndex.Value.Section); tableView.MoveRow(oldIndexPath, indexPath); dataSource.RefreshHeader(tableView, change.OldIndex.Value.Section); } break; case CollectionChangeType.AddSection: tableView.InsertSections(indexSet, UITableViewRowAnimation.Automatic); break; case CollectionChangeType.RemoveSection: tableView.DeleteSections(indexSet, UITableViewRowAnimation.Automatic); break; } dataSource.RefreshHeader(tableView, change.Index.Section); } tableView.EndUpdates(); } }
public void RemoveAt(int idx, UITableViewRowAnimation anim) { if (idx < 0 || idx >= _sections.Count) { return; } _sections.RemoveAt(idx); _tableView.Get()?.DeleteSections(NSIndexSet.FromIndex(idx), anim); }
public override UIView GetViewForHeader(UITableView tableView, nint section) { var btn = new UIButton(new CGRect(0, 0, tableView.Frame.Width, NativeListCell.HEIGHT)); btn.TitleEdgeInsets = new UIEdgeInsets(btn.TitleEdgeInsets.Top, NativeListCell.ParentItemLeftPadding, btn.TitleEdgeInsets.Bottom, btn.TitleEdgeInsets.Right); btn.AutoresizingMask = UIViewAutoresizing.All; //set section header right side image if (!string.IsNullOrEmpty(Settings [(int)section].SelectedStateIcon) && !string.IsNullOrEmpty(Settings [(int)section].DeselectedStateIcon)) { var btnImg = btn.ViewWithTag((int)section); if (btnImg != null) { btnImg.RemoveFromSuperview(); } var img = !Settings [(int)section].IsSelected ? new UIImageView(UIImage.FromBundle(Settings [(int)section].DeselectedStateIcon)) : new UIImageView(UIImage.FromBundle(Settings [(int)section].SelectedStateIcon)); img.Tag = (int)section; img.Frame = new CGRect( btn.Frame.Width - NativeListCell.HEIGHT - 20, 0, NativeListCell.HEIGHT, NativeListCell.HEIGHT ); img.ContentMode = UIViewContentMode.Center; img.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin; btn.AddSubview(img); } //ADD SEPERATOR LINE AT BOTTOM var seperatorLine = new UIView(new CGRect(0, NativeListCell.HEIGHT - 1, tableView.Frame.Width, 1)); seperatorLine.BackgroundColor = UIColor.LightGray; seperatorLine.Alpha = 0.3f; seperatorLine.AutoresizingMask = UIViewAutoresizing.FlexibleWidth; btn.AddSubview(seperatorLine); btn.SetTitle(Settings [(int)section].Title, UIControlState.Normal); btn.Font = UIFont.BoldSystemFontOfSize(NativeListCell.FontSize); btn.BackgroundColor = UIColor.Clear; btn.HorizontalAlignment = UIControlContentHorizontalAlignment.Left; btn.SetTitleColor(UIColor.DarkGray, UIControlState.Normal); btn.TouchUpInside += (sender, e) => { //put in your code to toggle your boolean value here if (Settings [(int)section].OnClickListener != null) { Settings [(int)section].OnClickListener.Invoke(Settings [(int)section]); } Settings [(int)section].IsSelected = !Settings [(int)section].IsSelected; //reload this section tableView.ReloadSections(NSIndexSet.FromIndex(section), UITableViewRowAnimation.Automatic); }; return(btn); }
private void ReloadNativeItems() { if (this.measuredSize.IsEmpty) { return; } UIView.AnimationsEnabled = false; ((UITableView)this.NativeUIElement).ReloadSections(NSIndexSet.FromIndex(0), UITableViewRowAnimation.None); UIView.AnimationsEnabled = true; }
public void ReloadSection(Section section, UITableViewRowAnimation animation = UITableViewRowAnimation.Fade) { if (!_sections.Contains(section)) { return; } var index = _sections.IndexOf(section); var indexSet = NSIndexSet.FromIndex(index); _tableView.Get().ReloadSections(indexSet, animation); }
public override void AwakeFromNib() { base.AwakeFromNib(); this.Window.WeakDelegate = this; mSpeechSynth.WeakDelegate = this; // Voices voicesTableView.WeakDelegate = this; voicesTableView.WeakDataSource = this; // Phrases PhrasesTableViewSource = new PhrasesTableViewSource(new WeakReference(this)); phrasesTableView.Source = PhrasesTableViewSource; phrasesTableView.mainWindowController = new WeakReference(this); // Select row for default voice in voicesTableView string defaultVoice = NSSpeechSynthesizer.DefaultVoice; int defaultRow = -1; for (int i = 0; i < mVoices.Count <string>(); i++) { if (mVoices[i] == defaultVoice) { defaultRow = i; break; } } NSIndexSet indices = NSIndexSet.FromIndex(defaultRow); voicesTableView.SelectRows(indices, false); voicesTableView.ScrollRowToVisible(defaultRow); // Handles when return is pressed while editing or textField loses focus textField.Activated += (object sender, EventArgs e) => { // If the add button is enabled, then add this item to the list if (btnAddPhrase.Enabled) { btnAddPhrase.PerformClick(textField); } }; textField.Changed += (object sender, EventArgs e) => { if (phrasesTableView.SelectedRow > -1) { string text = textField.StringValue; phrasesTableView.DeselectAll(textField); textField.StringValue = text; textField.CurrentEditor.SelectedRange = new NSRange(text.Length, 0); btnAddPhrase.Enabled = true; } }; }
private void ToggleProductViewControllerDemo(object sender, EventArgs e) { demoProductViewController = ((UISwitch)sender).On; TableView.ReloadSections(NSIndexSet.FromIndex(0), UITableViewRowAnimation.Automatic); // // Add 3D Touch peek and pop for product previewing // if (demoProductViewController == true && [[UITraitCollection class] respondsToSelector:@selector(traitCollectionWithForceTouchCapability:)] && self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable) { // [self registerForPreviewingWithDelegate:self sourceView:self.tableView]; // } else if ([[UITraitCollection class] respondsToSelector:@selector(traitCollectionWithForceTouchCapability:)] && self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable) { // [self registerForPreviewingWithDelegate:self sourceView:self.tableView]; // } }
void HandleCollapseEvent(Chapter chapter, NSIndexPath indexPath) { try { dictionary [chapter].Clear(); collectionView.ReloadSections(NSIndexSet.FromIndex(indexPath.Section)); } catch (Exception ex) { Logger.WriteLineDebugging("NoteDataSource - HandleCollapseEvent: {0}", ex.ToString()); } }
public void ToggleSelected() { var updated = new List<nuint>(); for (int i = 0; i < dataSource.Items.Count; ++i) { if (tableView.IsRowSelected(i)) { updated.Add((nuint)i); dataSource.Items[i].IsSelected = !dataSource.Items[i].IsSelected; } }; tableView.ReloadData(NSIndexSet.FromArray(updated.ToArray()), NSIndexSet.FromIndex(0)); }
//private nfloat height { get; set; } public override UIView GetViewForHeader(UITableView tableView, nint section) { var btn = new UIButton(new CGRect(0, 0, tableView.Frame.Width, HEIGHT)); btn.TitleEdgeInsets = new UIEdgeInsets(btn.TitleEdgeInsets.Top, NativeListCell.ParentItemLeftPadding, btn.TitleEdgeInsets.Bottom, btn.TitleEdgeInsets.Right); btn.AutoresizingMask = UIViewAutoresizing.FlexibleWidth; //ADD SEPERATOR LINE AT BOTTOM var seperatorLine = new UIView(new CGRect(0, HEIGHT - 1, tableView.Frame.Width, 1)); seperatorLine.BackgroundColor = UIColor.LightGray; seperatorLine.Alpha = 0.3f; seperatorLine.AutoresizingMask = UIViewAutoresizing.FlexibleWidth; btn.AddSubview(seperatorLine); btn.SetTitle(Settings[(int)section].Title, UIControlState.Normal); btn.Font = UIFont.BoldSystemFontOfSize(NativeListCell.FontSize); btn.BackgroundColor = UIColor.Clear; btn.HorizontalAlignment = UIControlContentHorizontalAlignment.Left; btn.SetTitleColor(UIColor.DarkGray, UIControlState.Normal); btn.TouchUpInside += (sender, e) => { //put in your code to toggle your boolean value here if (Settings[(int)section].OnClickListener != null) { Settings[(int)section].OnClickListener.Invoke(Settings[(int)section]); } Settings[(int)section].IsSelected = !Settings[(int)section].IsSelected; //reload this section tableView.ReloadSections(NSIndexSet.FromIndex(section), UITableViewRowAnimation.Automatic); //tableView.RowHeight = height; //tableView.r //tableView.VisibleCells[1].SizeToFit(); //tableView.AutosizesSubviews = true; //tableView.ReloadData(); }; //tableView.DataSource = new GrowRowTableDataSource(this); //TableView.Delegate = new GrowRowTableDelegate(this); //tableView.RowHeight = UITableView.AutomaticDimension; //tableView.EstimatedRowHeight = 40f; //tableView.ReloadData(); // //tableView.RowHeight = height; //tableView.SizeToFit(); return(btn); }
public virtual void SetSource(IListDataSource source, IBackend sourceBackend) { this.source = source; tsource = new ListSource(source); Table.DataSource = tsource; //TODO: Reloading single rows would be slightly more efficient. // According to NSTableView.ReloadData() documentation, // only the visible rows are reloaded. source.RowInserted += (sender, e) => Table.ReloadData(); source.RowDeleted += (sender, e) => Table.ReloadData(); source.RowChanged += (sender, e) => Table.ReloadData(NSIndexSet.FromIndex(e.Row), NSIndexSet.FromNSRange(new NSRange(0, Table.ColumnCount - 1))); source.RowsReordered += (sender, e) => Table.ReloadData(); }
protected override void HandleGroupsRemove(NotifyKeyGroupCollectionChangedEventArgs <TKey, TItem> args) { foreach (var sectionsRange in args.OldItemRanges) { int sectionIndex = sectionsRange.Index; foreach (var section in sectionsRange.OldItems) { _collectionViewRef.Target?.DeleteSections(NSIndexSet.FromIndex(sectionIndex)); sectionIndex++; } } }