Пример #1
0
        private void UpdateItems(NotifyCollectionChangedEventArgs e, int section, bool resetWhenGrouped)
        {
            NotifyCollectionChangedEventArgsEx changedEventArgsEx = e as NotifyCollectionChangedEventArgsEx;

            if (changedEventArgsEx != null)
            {
                this.dataSource.Counts [section] = changedEventArgsEx.Count;
            }
            bool flag = resetWhenGrouped && this.Element.IsGroupingEnabled;

            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                //this.UpdateEstimatedRowHeight ();
                if (!(e.NewStartingIndex == -1 | flag))
                {
                    this.Control.BeginUpdates();

                    var indexSet = NSIndexSet.FromNSRange(new NSRange(e.NewStartingIndex, e.NewItems.Count));

                    this.Control.InsertRows(indexSet, NSTableViewAnimation.SlideUp);
                    this.Control.EndUpdates();
                    break;
                }
                goto case NotifyCollectionChangedAction.Reset;

            case NotifyCollectionChangedAction.Remove:
                if (!(e.OldStartingIndex == -1 | flag))
                {
                    this.Control.BeginUpdates();

                    var indexSet = NSIndexSet.FromNSRange(new NSRange(e.OldStartingIndex, e.OldItems.Count));

                    Control.RemoveRows(indexSet, NSTableViewAnimation.SlideDown);
                    this.Control.EndUpdates();

                    if (!this.estimatedRowHeight || this.Element.TemplatedItems.Count != 0)
                    {
                        break;
                    }
                    this.estimatedRowHeight = false;
                    break;
                }
                goto case NotifyCollectionChangedAction.Reset;

            case NotifyCollectionChangedAction.Replace:
                if (!(e.OldStartingIndex == -1 | flag))
                {
                    Control.BeginUpdates();
                    var indexSet = NSIndexSet.FromNSRange(new NSRange(e.OldStartingIndex, e.OldItems.Count));
                    Control.ReloadData(indexSet, null);
                    this.Control.EndUpdates();

                    if (!this.estimatedRowHeight || e.OldStartingIndex != 0)
                    {
                        break;
                    }
                    this.estimatedRowHeight = false;
                    break;
                }
                goto case NotifyCollectionChangedAction.Reset;

            case NotifyCollectionChangedAction.Move:
                if (((e.OldStartingIndex == -1 ? 1 : (e.NewStartingIndex == -1 ? 1 : 0)) | (flag ? 1 : 0)) == 0)
                {
                    this.Control.BeginUpdates();
                    for (int index = 0; index < e.OldItems.Count; ++index)
                    {
                        int oldStartingIndex = e.OldStartingIndex;
                        int newStartingIndex = e.NewStartingIndex;
                        if (e.NewStartingIndex < e.OldStartingIndex)
                        {
                            oldStartingIndex += index;
                            newStartingIndex += index;
                        }

                        this.Control.MoveRow(oldStartingIndex, newStartingIndex);
                    }
                    this.Control.EndUpdates();
                    if (!this.estimatedRowHeight || e.OldStartingIndex != 0)
                    {
                        break;
                    }
                    this.estimatedRowHeight = false;
                    break;
                }
                goto case NotifyCollectionChangedAction.Reset;

            case NotifyCollectionChangedAction.Reset:
                this.estimatedRowHeight = false;
                this.Control.ReloadData();
                break;
            }
        }
Пример #2
0
 /// <summary>
 /// This event will be called when the AdditonalQueryPrams dictionary changed. We have to reset the cached values.
 /// </summary>
 private void AdditionalQueryParams_CollectionChanged(object sender, NotifyCollectionChangedEventArgsEx e)
 {
     BuiltQueryParams = null;
 }