コード例 #1
0
        public BoundCollectionChangedEventArgs(string propertyName, NotifyCollectionChangedEventArgs sourceEventArgs, IBinding binding, object[] PreviousCollectionContent)
        {
            Argument.NotNull(() => sourceEventArgs);

            this.PropertyName = propertyName;
            this.SourceEventArgs = sourceEventArgs;
            this.Binding = binding;
            this.PreviousCollectionContent = PreviousCollectionContent;
        }
コード例 #2
0
    void ActiveItems_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
    {
        if(e.OldItems != null)
        {
            foreach(ISelectable item in e.OldItems)
            {
                item.RemoveHighlightColor(ActiveColor);
            }
        }

        if (e.NewItems != null)
        {
            foreach (ISelectable item in e.NewItems)
            {
                item.AddHighlightColor(ActiveColor);
            }
        }
    }
コード例 #3
0
      void Polygons_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
      {
         if(e.NewItems != null)
         {
            foreach(GMapPolygon obj in e.NewItems)
            {
               if(obj != null)
               {
                  obj.Overlay = this;
                  Control.UpdatePolygonLocalPosition(obj);
               }
            }
         }

         if(!Control.HoldInvalidation)
         {
            Control.Core_OnNeedInvalidation();
         }
      }
コード例 #4
0
        public void Test_New()
        {
            var args = new NotifyCollectionChangedEventArgs<int>(NotifyCollectionChangedAction.Add, new List<int> { 1 }, null);
            Assert.Equal(NotifyCollectionChangedAction.Add, args.Action);
            Assert.NotNull(args.NewItems);
            Assert.Equal(1, args.NewItems.Count);
            Assert.Contains(1, args.NewItems);
            Assert.Null(args.OldItems);

            args = new NotifyCollectionChangedEventArgs<int>(NotifyCollectionChangedAction.Move, new List<int> { 1 }, new List<int> { 3, 4 });
            Assert.Equal(NotifyCollectionChangedAction.Move, args.Action);
            Assert.NotNull(args.NewItems);
            Assert.Equal(1, args.NewItems.Count);
            Assert.Contains(1, args.NewItems);
            Assert.NotNull(args.OldItems);
            Assert.Equal(2, args.OldItems.Count);
            Assert.Contains(3, args.OldItems);
            Assert.Contains(4, args.OldItems);

            args = new NotifyCollectionChangedEventArgs<int>(NotifyCollectionChangedAction.Remove, null, new List<int> { 3, 4 });
            Assert.Equal(NotifyCollectionChangedAction.Remove, args.Action);
            Assert.Null(args.NewItems);
            Assert.NotNull(args.OldItems);
            Assert.Equal(2, args.OldItems.Count);
            Assert.Contains(3, args.OldItems);
            Assert.Contains(4, args.OldItems);

            args = new NotifyCollectionChangedEventArgs<int>(NotifyCollectionChangedAction.Replace, new List<int> { 1 }, new List<int> { 5 });
            Assert.Equal(NotifyCollectionChangedAction.Replace, args.Action);
            Assert.NotNull(args.NewItems);
            Assert.Equal(1, args.NewItems.Count);
            Assert.Contains(1, args.NewItems);
            Assert.NotNull(args.OldItems);
            Assert.Equal(1, args.OldItems.Count);
            Assert.Contains(5, args.OldItems);

            args = new NotifyCollectionChangedEventArgs<int>(NotifyCollectionChangedAction.Reset, null, null);
            Assert.Equal(NotifyCollectionChangedAction.Reset, args.Action);
            Assert.Null(args.NewItems);
            Assert.Null(args.OldItems);
        }
コード例 #5
0
        public void collection_changed_is_not_propagated_from_child_node_after_disconnect()
        {
            var propertyName = "Nested";

            var obj = new TestClass();
            var childEventStream = new Subject<BoundCollectionChangedEventArgs>();

            InitMocks();
            InitTestObjectWithCollectionChangedStream(childEventStream, obj);

            var events = new List<BoundCollectionChangedEventArgs>();

            testObject.CollectionChangedEventStream.Subscribe(ev => events.Add(ev));

            testObject.Disconnect();

            var fakeCollectionChangedEventArgs = new NotifyCollectionChangedEventArgs();
            childEventStream.OnNext(new BoundCollectionChangedEventArgs(propertyName, fakeCollectionChangedEventArgs, null, null));

            Assert.Empty(events);
        }
コード例 #6
0
        public void collection_changed_is_propagated_from_child_node()
        {
            var propertyName = "Nested";

            var obj = new TestClass();
            var childEventStream = new Subject<BoundCollectionChangedEventArgs>();

            InitMocks();
            InitTestObjectWithCollectionChangedStream(childEventStream, obj);

            var events = new List<BoundCollectionChangedEventArgs>();

            testObject.CollectionChangedEventStream.Subscribe(ev => events.Add(ev));

            var fakeCollectionChangedEventArgs = new NotifyCollectionChangedEventArgs();
            childEventStream.OnNext(new BoundCollectionChangedEventArgs(propertyName, fakeCollectionChangedEventArgs, null, null));

            Assert.Equal(1, events.Count);
            Assert.Equal(propertyName, events[0].PropertyName);
            Assert.Equal(fakeCollectionChangedEventArgs, events[0].SourceEventArgs);
        }
コード例 #7
0
        public void BoundCollectionChanged_event_from_child_passed_on()
        {
            InitMocks(1);

            var childEventStream = new Subject<BoundCollectionChangedEventArgs>();

            mockArrayItemBindings[0]
                .Setup(m => m.CollectionChangedEventStream)
                .Returns(childEventStream);

            InitTestObject(testArray);

            var events = new List<BoundCollectionChangedEventArgs>();
            testObject.CollectionChangedEventStream.Subscribe(ev => events.Add(ev));

            var fakeCollectionChangedEventArgs = new NotifyCollectionChangedEventArgs();
            childEventStream.OnNext(new BoundCollectionChangedEventArgs("Nested", fakeCollectionChangedEventArgs, null, null));

            Assert.Equal(1, events.Count);
            Assert.Equal("Nested", events[0].PropertyName);
            Assert.Equal(fakeCollectionChangedEventArgs, events[0].SourceEventArgs);
        }
コード例 #8
0
ファイル: QueryModel.cs プロジェクト: natemcmaster/Relinq
 private void ResultOperators_CollectionChanged (object sender, NotifyCollectionChangedEventArgs e)
 {
   ArgumentUtility.CheckNotNull ("e", e);
   ArgumentUtility.CheckItemsNotNullAndType ("e.NewItems", e.NewItems, typeof (ResultOperatorBase));
 }
コード例 #9
0
 private void ItemPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     NotifyCollectionChangedEventArgs args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, sender, sender, IndexOf((T)sender));
     //OnCollectionChanged(args);
 }
コード例 #10
0
ファイル: OrderByClause.cs プロジェクト: natemcmaster/Relinq
 private void Orderings_CollectionChanged (object sender, NotifyCollectionChangedEventArgs e)
 {
   ArgumentUtility.CheckNotNull ("e", e);
   ArgumentUtility.CheckItemsNotNullAndType ("e.NewItems", e.NewItems, typeof (Ordering));
 }
コード例 #11
0
        private void FramesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.OldItems != null && e.OldItems.Count > 0)
            {
                foreach (MetroTileFrame item in e.OldItems)
                {
                    item.PropertyChanged -= FramePropertyChanged;
                }
            }
            if (e.NewItems != null && e.NewItems.Count > 0)
            {
                foreach (MetroTileFrame item in e.NewItems)
                {
                    item.PropertyChanged += FramePropertyChanged;
                }
            }

            if (_CurrentFrame >= _Frames.Count)
            {
                _CurrentFrame = 0;
                this.Refresh();
            }
        }
コード例 #12
0
        protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
        {
            this.ReindexItems();

            base.OnItemsChanged(e);
        }
コード例 #13
0
 private void Lights_CollectionChanged(object sender, NotifyCollectionChangedEventArgs<Light> e)
 {
     this.buildPhotonMaps = true;
 }
コード例 #14
0
 void items_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     updateItems();
 }
コード例 #15
0
 protected void PropertyGroupsChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     OnPropertyChanged(nameof(PropertyGroups));
 }
コード例 #16
0
ファイル: ServerManager.cs プロジェクト: Blueil/Fork
 private void ServerListChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     //EntitySerializer.Instance.StoreEntities(Entities);
     ApplicationManager.Instance.TriggerServerListEvent(this, new EventArgs());
     ApplicationManager.Instance.MainViewModel.SetServerList(ref entities);
 }
コード例 #17
0
        /* Implementation */

        private void ModsOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            RaiseCanExecute(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
        }
コード例 #18
0
ファイル: ConfigurationBase.cs プロジェクト: Conaugh/dashing
 private void EventListenersCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     // let's make this real simple, just invalidate the eventhandlers property
     this.EventHandlers.Invalidate(this.EventListeners);
 }
コード例 #19
0
 void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     InvalidateEnumerator();
 }
コード例 #20
0
 void points_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     addPointCommand.RaiseCanExecuteChanged();
     removePointCommand.RaiseCanExecuteChanged();
 }
コード例 #21
0
ファイル: HubBinder.cs プロジェクト: emfix/7Pass-Remake
 private void OnCollectionChanged(object sender,
                                  NotifyCollectionChangedEventArgs e)
 {
     _hub.Dispatcher.RunAsync(
         CoreDispatcherPriority.Normal, Apply);
 }
コード例 #22
0
      void Routes_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
      {
         if(e.NewItems != null)
         {
            foreach(GMapRoute obj in e.NewItems)
            {
               if(obj != null)
               {
                  obj.Overlay = this;
                  if(Control != null)
                  {
                     Control.UpdateRouteLocalPosition(obj);
                  }
               }
            }
         }

         if(Control != null)
         {
            if(!Control.HoldInvalidation)
            {
               Control.Core.Refresh.Set();
            }
         }
      }
コード例 #23
0
 /// <summary>
 /// Forwards CollectionChanged notifications for the GenericTypeArguments property to the parent model element
 /// </summary>
 /// <param name="sender">The collection that raised the change</param>
 /// <param name="e">The original event data</param>
 private void GenericTypeArgumentsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     this.OnCollectionChanged("GenericTypeArguments", e, _genericTypeArgumentsReference);
 }
コード例 #24
0
ファイル: GridRow.cs プロジェクト: huamanhtuyen/VNACCS
        void CellsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
                case NotifyCollectionChangedAction.Replace:
                case NotifyCollectionChangedAction.Add:
                    GridPanel panel = GridPanel;

                    if (e.Action == NotifyCollectionChangedAction.Replace)
                    {
                        for (int i = 0; i < e.OldItems.Count; i++)
                        {
                            GridCell cell = e.OldItems[i] as GridCell;

                            if (cell != null)
                            {
                                if (panel.ExpDictionary.ContainsKey(cell))
                                    panel.ExpDictionary.Remove(cell);
                            }
                        }
                    }

                    for (int i = 0; i < e.NewItems.Count; i++)
                    {
                        GridCell cell = e.NewItems[i] as GridCell;

                        if (cell != null)
                        {
                            cell.Parent = this;
                            cell.ColumnIndex = e.NewStartingIndex + i;

                            if (panel != null)
                            {
                                string newExp = cell.Value as string;

                                if (newExp != null)
                                {
                                    newExp = newExp.Trim();

                                    if (newExp.StartsWith("="))
                                        cell.SetCellExp(panel, newExp);
                                }
                            }
                        }
                    }
                    break;

                default:
                    for (int i = 0; i < _Cells.Count; i++)
                    {
                        _Cells[i].Parent = this;
                        _Cells[i].ColumnIndex = i;
                    }
                    break;
            }

            if (SuperGrid != null)
            {
                GridCell cell = SuperGrid.ActiveElement as GridCell;

                if (cell != null)
                {
                    if (cell.GridRow == this && cell.ColumnIndex < Cells.Count)
                        SuperGrid.ActiveElement = Cells[cell.ColumnIndex];
                }
            }

            NeedsMeasured = true;

            if (GridPanel != null && GridPanel.VirtualMode == false)
                InvalidateLayout();
        }
コード例 #25
0
 private void OnChildrenCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 => OnChildrenChanged();
コード例 #26
0
 private void Primitives_CollectionChanged(object sender, NotifyCollectionChangedEventArgs<Primitive> e)
 {
     this.buildPhotonMaps = true;
 }
コード例 #27
0
ファイル: DrawableHitObject.cs プロジェクト: yurabolt/osu
 private void onSamplesChanged(object sender, NotifyCollectionChangedEventArgs e) => LoadSamples();
コード例 #28
0
ファイル: ObservableStack.cs プロジェクト: DanzeJr/TachiShop
 private void RaiseCollectionChanged(NotifyCollectionChangedEventArgs e)
 {
     CollectionChanged?.Invoke(this, e);
 }
コード例 #29
0
 public static void RaiseCollectionChanged(this INotifyCollectionChanged sender, NotifyCollectionChangedEventArgs eventArgs) =>
 Events.InvokeEvent(sender, nameof(INotifyCollectionChanged.CollectionChanged), eventArgs);
コード例 #30
0
 void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     UpdatePoints();
 }
コード例 #31
0
 private void parentItemsContentChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     resetParentItems();
 }
コード例 #32
0
        void CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                if (e.NewStartingIndex != -1)
                {
                    if (e.NewItems.Count == 1)
                    {
                        InsertItem(e.NewStartingIndex, (TItem)e.NewItems[0]);
                    }
                    else
                    {
                        InsertRange(e.NewStartingIndex, e.NewItems.Cast <TItem>());
                    }
                }
                else
                {
                    AddRange(e.NewItems.Cast <TItem>());
                }
                break;

            case NotifyCollectionChangedAction.Move:
                if (e.OldStartingIndex != -1)
                {
                    RemoveRange(e.OldStartingIndex, e.OldItems.Count);
                }
                else
                {
                    RemoveRange(e.OldItems.Cast <TItem>());
                }
                InsertRange(e.NewStartingIndex, e.NewItems.Cast <TItem>());
                break;

            case NotifyCollectionChangedAction.Remove:
                if (e.OldStartingIndex != -1)
                {
                    if (e.OldItems.Count == 1)
                    {
                        RemoveItem(e.OldStartingIndex);
                    }
                    else
                    {
                        RemoveRange(e.OldStartingIndex, e.OldItems.Count);
                    }
                }
                else
                {
                    RemoveRange(e.OldItems.Cast <TItem>());
                }
                break;

            case NotifyCollectionChangedAction.Replace:
                if (e.OldStartingIndex != -1)
                {
                    RemoveRange(e.OldStartingIndex, e.OldItems.Count);
                    InsertRange(e.OldStartingIndex, e.NewItems.Cast <TItem>());
                }
                else
                {
                    for (int i = 0; i < e.OldItems.Count; i++)
                    {
                        var index = IndexOf((TItem)e.OldItems[i]);
                        RemoveItem(index);
                        InsertItem(index, (TItem)e.NewItems[i]);
                    }
                }
                break;

            case NotifyCollectionChangedAction.Reset:
                Reset();
                break;
            }
        }
コード例 #33
0
 protected virtual void OnItemsCollectionChagned(object sender, NotifyCollectionChangedEventArgs e) =>
 _tablayout.Visibility = (SectionController.GetItems().Count > 1) ? ViewStates.Visible : ViewStates.Gone;
コード例 #34
0
 private void SkippedRecurrencesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     OnPropertyChanged(new PropertyChangedEventArgs("SkippedRecurrences"));
 }
コード例 #35
0
        protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
        {
            base.OnCollectionChanged(e);

            owner.Invalidate();
        }
コード例 #36
0
 private void OnMenuItemsChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     QueueReset();
 }
コード例 #37
0
 private void OnNotifyCollectionChanged(NotifyCollectionChangedEventArgs args)
 {
     this.CollectionChanged?.Invoke(this, args);
 }
コード例 #38
0
ファイル: QueryModel.cs プロジェクト: natemcmaster/Relinq
    private void BodyClauses_CollectionChanged (object sender, NotifyCollectionChangedEventArgs e)
    {
      ArgumentUtility.CheckNotNull ("e", e);
      ArgumentUtility.CheckItemsNotNullAndType ("e.NewItems", e.NewItems, typeof (IBodyClause));

      if (e.NewItems != null)
      {
        foreach (var fromClause in e.NewItems.OfType<IFromClause>())
          _uniqueIdentifierGenerator.AddKnownIdentifier (fromClause.ItemName);
      }
    }
コード例 #39
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, NotifyCollectionChangedEventArgs e)
 {
     BuiltQueryParams = null;
 }
コード例 #40
0
ファイル: GridRow.cs プロジェクト: huamanhtuyen/VNACCS
        void ItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            GridPanel panel = GridPanel;

            bool dataRowChange = false;

            switch (e.Action)
            {
                case NotifyCollectionChangedAction.Replace:
                case NotifyCollectionChangedAction.Add:

                    foreach (GridElement item in e.NewItems)
                    {
                        if (panel != null && panel.VirtualMode == true)
                            throw new Exception("Virtual Grid can not have nested items.");

                        item.Parent = this;
                        item.NeedsMeasured = true;

                        if (panel != null)
                        {
                            GridRow row = item as GridRow;

                            if (row != null)
                            {
                                dataRowChange = true;

                                if (e.Action == NotifyCollectionChangedAction.Replace)
                                    panel.RemoveFromExpDictionary(row);

                                panel.AddToExpDictionary(row);
                            }
                            else
                            {
                                panel.NeedToUpdateIndicees = true;
                            }

                            panel.ExpandDeletedAtIndex(FullIndex + 1, 1);
                            panel.NeedToUpdateIndicees = true;
                        }
                    }

                    if (dataRowChange == true && panel.GroupColumns.Count > 0)
                        NeedsGrouped = true;
                    break;

                case NotifyCollectionChangedAction.Reset:
                    if (panel != null)
                    {
                        dataRowChange = true;

                        panel.ClearAll();
                        panel.ExpDictionary.Clear();
                    }
                    break;

                case NotifyCollectionChangedAction.Remove:
                    if (panel != null)
                    {
                        dataRowChange = true;

                        panel.ClearAll();

                        if (panel.ExpDictionary.Count > 0)
                        {
                            foreach (GridContainer item in e.OldItems)
                                panel.RemoveFromExpDictionary(item as GridRow);
                        }
                    }
                    break;
            }

            InvalidateLayout();

            if (dataRowChange == true)
            {
                panel.UpdateRowCount();

                SuperGrid.Invalidate();
            }
        }
コード例 #41
0
ファイル: GMapOverlay.cs プロジェクト: neolu/MissionPlanner
      void Markers_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
      {
         if(e.NewItems != null)
         {
            foreach(GMapMarker obj in e.NewItems)
            {
               if(obj != null)
               {
                  obj.Overlay = this;
                  Control.UpdateMarkerLocalPosition(obj);
               }
            }
         }

         if(e.Action == NotifyCollectionChangedAction.Remove || e.Action == NotifyCollectionChangedAction.Reset)
         {
#if !PocketPC
            if(Control.IsMouseOverMarker)
            {
               Control.IsMouseOverMarker = false;
               Control.Cursor = Cursors.Default;
            }
#endif
         }

         if(!Control.HoldInvalidation)
         {
            Control.Core_OnNeedInvalidation();
         }
      }
コード例 #42
0
ファイル: GridGroup.cs プロジェクト: huamanhtuyen/VNACCS
        void ItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            GridPanel panel = GridPanel;

            if (panel != null)
            {
                panel.NeedToUpdateIndicees = true;
                panel.InvalidateLayout();
            }
        }
コード例 #43
0
ファイル: Polygon.cs プロジェクト: hksonngan/sharptracing
 private void vertices_CollectionChanged(object sender, NotifyCollectionChangedEventArgs<Point3D> e)
 {
     switch (e.Action) {
         case NotifyCollectionChangedAction.Add:
         case NotifyCollectionChangedAction.Remove:
         case NotifyCollectionChangedAction.Replace:
             this.Preprocess();
             break;
     }
 }
コード例 #44
0
 private void Materials_CollectionChanged(object sender, NotifyCollectionChangedEventArgs<Material> e)
 {
     this.buildPhotonMaps = true;
 }
コード例 #45
0
        private void OnZoneCategoriesCollectionChanged(object sender, NotifyCollectionChangedEventArgs<IZoneCategory> e)
        {
            var referenceList = new List<IZoneCategory>();

            if (e.Action != NotifyCollectionChangedAction.Move)
            {
                referenceList.AddRange(e.NewItems);
                referenceList.AddRange(e.OldItems);

                if (referenceList != null)
                {
                    foreach (IZoneCategory currentItem in referenceList)
                    {
                        if (ZoneCategoryListChanged != null)
                        {
                            ZoneCategoryListChanged(this, currentItem);
                        }
                    }
                }
            }
        }
コード例 #46
0
 protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs args)
 {
     CollectionChanged?.Invoke(this, args);
 }
コード例 #47
0
 private void ItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs args)
 {
     InitItems(Items);
 }
コード例 #48
0
 /// <summary>
 /// Occurs when the items collection changes.
 /// </summary>
 private async void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     await CollectionChangedAsync(e);
 }
コード例 #49
0
ファイル: ObservableStack.cs プロジェクト: DanzeJr/TachiShop
 protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
 {
     RaiseCollectionChanged(e);
     RaisePropertyChanged(new PropertyChangedEventArgs(nameof(Count)));
 }
コード例 #50
0
ファイル: WrapTooth.xaml.cs プロジェクト: tjdrud1090/project
 private void OnPointCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     RegisterCollectionItemPropertyChanged(e.NewItems);
     UnRegisterCollectionItemPropertyChanged(e.OldItems);
     SetWrapToothRect();
 }
コード例 #51
0
 void RepositoriesOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) {
     UpdateTokens();
 }
コード例 #52
0
		public static void Raise (this NotifyCollectionChangedEventHandler handler, object sender, NotifyCollectionChangedEventArgs e)
		{
			if (handler != null)
				handler (sender, e);
		}
コード例 #53
0
ファイル: QParam.cs プロジェクト: radtek/datawf
 private void ValueListChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     OnPropertyChanged(sender == ValueLeft ? nameof(ValueLeft) : nameof(ValueRight));
 }
コード例 #54
0
        private void OnActivityCategoriesCollectionChanged(
            object sender, NotifyCollectionChangedEventArgs<IActivityCategory> e)
        {
            var referenceList = new List<IActivityCategory>();

            if (e.Action != NotifyCollectionChangedAction.Move)
            {
                referenceList.AddRange(e.NewItems);
                referenceList.AddRange(e.OldItems);

                if (referenceList != null)
                {
                    foreach (IActivityCategory currentItem in referenceList)
                    {
                        if (ActivityCategoryListChanged != null)
                        {
                            ActivityCategoryListChanged(this, currentItem);
                        }
                    }
                }
            }

            // Refresh our callbacks so that it registers the new categories
            this.UnregisterCategoryCallback(m_CurrentLogbook);
            this.RegisterCategoryCallback(m_CurrentLogbook);
        }
コード例 #55
0
        /// <summary>
        /// Handles quick access menu items chages
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnQuickAccessItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                for (var i = 0; i < e.NewItems.Count; i++)
                {
                    if (this.menuDownButton != null)
                    {
                        this.menuDownButton.Items.Insert(e.NewStartingIndex + i + 1, e.NewItems[i]);
                    }
                    else
                    {
                        this.AddLogicalChild(e.NewItems[i]);
                    }
                }
                break;

            case NotifyCollectionChangedAction.Remove:
                foreach (var item in e.OldItems)
                {
                    if (this.menuDownButton != null)
                    {
                        this.menuDownButton.Items.Remove(item);
                    }
                    else
                    {
                        this.RemoveLogicalChild(item);
                    }
                }
                break;

            case NotifyCollectionChangedAction.Replace:
                foreach (var item in e.OldItems)
                {
                    if (this.menuDownButton != null)
                    {
                        this.menuDownButton.Items.Remove(item);
                    }
                    else
                    {
                        this.RemoveLogicalChild(item);
                    }
                }

                var ii = 0;
                foreach (var item in e.NewItems)
                {
                    if (this.menuDownButton != null)
                    {
                        this.menuDownButton.Items.Insert(e.NewStartingIndex + ii + 1, item);
                    }
                    else
                    {
                        this.AddLogicalChild(item);
                    }

                    ii++;
                }
                break;
            }
        }
コード例 #56
0
ファイル: Selector.cs プロジェクト: jbruening/ugui-mvvm
 protected override void CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     base.CollectionChanged(sender, e);
     ValidateSelected();
 }
コード例 #57
0
 private void _keyColumns_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     VulcanOnCollectionPropertyChanged("KeyColumns", e);
 }
コード例 #58
0
ファイル: GMapOverlay.cs プロジェクト: prathika3692/greatmaps
      void Markers_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
      {
         if(e.NewItems != null)
         {
            foreach(GMapMarker obj in e.NewItems)
            {
               if(obj != null)
               {
                  obj.Overlay = this;
                  if(Control != null)
                  {
                     Control.UpdateMarkerLocalPosition(obj);
                  }
               }
            }
         }

         if(Control != null)
         {
            if(e.Action == NotifyCollectionChangedAction.Remove || e.Action == NotifyCollectionChangedAction.Reset)
            {
               if(Control.IsMouseOverMarker)
               {
                  Control.IsMouseOverMarker = false;
#if !PocketPC
                  Control.RestoreCursorOnLeave();
#endif
               }
            }

            if(!Control.HoldInvalidation)
            {
               Control.Invalidate();
            }
         }
      }
コード例 #59
0
ファイル: ItemsContainer.cs プロジェクト: tyrant39001/Tyrant
        void notifyCollectionChanged_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
                case NotifyCollectionChangedAction.Add:
                    {
                        int index = e.NewStartingIndex;
                        foreach (var item in e.NewItems)
                            AddItem(item, index++);
                        UpdateItemsFinish();
                    }
                    break;
                case NotifyCollectionChangedAction.Move:
                    {
                        int i = 0;
                        foreach (var dataItem in e.OldItems)
                        {
                            if (dataItem == null)
                                continue;
                            int index = e.OldStartingIndex + i;
                            if (index < 0 || index >= sourceCollection.Count)
                                continue;
                            var oldItem = sourceCollection[index];
                            if (oldItem == null)
                                continue;
                            var oldI = GetBindedItemFromData(oldItem);
                            var newI = GetBindedItemFromData(dataItem);
                            if (oldI == null || newI == null)
                                continue;
                            dic_obj_go[oldItem] = newI;
                            SetDataContext(newI, oldItem);
                            dic_obj_go[dataItem] = oldI;
                            SetDataContext(oldI, dataItem);
                        }
                    }
                    break;
                case NotifyCollectionChangedAction.Remove:
                    {
                        var itemList = new List<object>();
                        foreach (var item in e.OldItems)
                        {
                            if (item != null)
                            {
                                var node = GetBindedItemFromData(item);
                                if (node != null)
                                {
                                    dic_obj_go.Remove(item);
                                    itemList.Add(node);
                                }
                            }
                        }
                        itemsContainerNode.DestroyItems(itemList);
                        UpdateItemsFinish();
                    }
                    break;
                case NotifyCollectionChangedAction.Replace:
                    {
                        int oldItemsCount = e.OldItems.Count;
                        int newItemsCount = e.NewItems.Count;
                        int minCount = oldItemsCount < newItemsCount ? oldItemsCount : newItemsCount;
                        for (int i = 0; i < minCount; ++i)
                        {
                            var oldItem = e.OldItems[i];
                            var newItem = e.NewItems[i];
                            if (oldItem == null || newItem == null)
                                continue;

                            var item = GetBindedItemFromData(oldItem);
                            if (item == null)
                                AddItem(item, e.OldStartingIndex + i);
                            else
                            {
                                dic_obj_go.Remove(oldItem);
                                dic_obj_go[newItem] = item;
                                SetDataContext(item, newItem);
                            }
                        }
                    }
                    break;
                case NotifyCollectionChangedAction.Reset:
                    UpdateItems();
                    break;
            }
        }