コード例 #1
0
ファイル: Map.cs プロジェクト: ghq1254544150/_SharpMap
        private void LayersCollectionChanged(object sender, NotifyCollectionChangingEventArgs e)
        {
            OnLayersCollectionChanged(e);

            if (CollectionChanged != null)
            {
                CollectionChanged(sender, e);
            }
        }
コード例 #2
0
        /// <summary>
        ///     Invokes the <c>CollectionChanging</c> event.
        /// </summary>
        protected virtual void OnCollectionChanging(NotifyCollectionChangingEventArgs e)
        {
            NotifyCollectionChangingEventHandler handler = CollectionChanging;

            if (handler != null)
            {
                handler(this, e);
            }
        }
コード例 #3
0
 private void RegularGrid_Components_CollectionChanged(object sender, NotifyCollectionChangingEventArgs e)
 {
     if (e.Action == NotifyCollectionChangeAction.Add)
     {
         var component = (IVariable)e.Item;
         component.Attributes[CoordinateName] = IsTimeDependent ? "time y x" : "y x";
     }
     isDirty = true;
 }
コード例 #4
0
ファイル: Variable.cs プロジェクト: Sony-NS/SharpMap
 protected override void ArgumentsCollectionChanged(object sender, NotifyCollectionChangingEventArgs e)
 {
     //if a function
     if (!IsIndependent)
     {
         IsAutoSorted = false;
     }
     base.ArgumentsCollectionChanged(sender, e);
 }
コード例 #5
0
ファイル: MapControl.cs プロジェクト: Sony-NS/SharpMap
        private void map_CollectionChanged_Delayed(object sender, NotifyCollectionChangingEventArgs e)
        {
            if (IsDisposed || !IsHandleCreated) // must be called before InvokeRequired
            {
                return;
            }

            map_CollectionChanged(sender, e);
        }
コード例 #6
0
        private void RaiseCollectionChanging(object sender, NotifyCollectionChangingEventArgs e)
        {
            OnCollectionChanging(sender, e);
            var eventHandler = CollectionChanging;

            if (eventHandler != null)
            {
                eventHandler(this, e);
            }
        }
コード例 #7
0
        void notifyCollectionChanged_CollectionChanged(object sender, NotifyCollectionChangingEventArgs e)
        {
            if (!TrackChanges)
            {
                return;
            }

            if (ExcludedTypes.Contains(sender.GetType()))
            {
                return;
            }

            NotifyCollectionChangeMemento memento;

            collectionChangeMementos.TryGetValue(sender, out memento);

            if (memento == null)
            {
                throw new NotSupportedException("CollectionChanged received without CollectionChanging");
            }

            memento.RememberNewValues(sender, e);
            collectionChangeMementos.Remove(sender);

            if (currentEditableObjectMemento != null)
            {
                if (e.Action == NotifyCollectionChangeAction.Replace)
                {
                    log.DebugFormat("adding collection change to edit action {0}: {1}:{2} -> {3}:{4}", memento.Action,
                                    memento.OldValue ?? "null", memento.OldIndex, memento.NewValue ?? "null",
                                    memento.NewIndex);
                }
                else
                {
                    log.DebugFormat("adding collection change to edit action {0}: {1}:{2}", memento.Action,
                                    memento.NewValue ?? "null", memento.NewIndex);
                }
            }
            else
            {
                if (e.Action == NotifyCollectionChangeAction.Replace)
                {
                    log.DebugFormat("saving undo for collection change {0}: {1}:{2} -> {3}:{4}", memento.Action,
                                    memento.OldValue ?? "null", memento.OldIndex, memento.NewValue ?? "null",
                                    memento.NewIndex);
                }
                else
                {
                    log.DebugFormat("saving undo for collection change {0}: {1}:{2}", memento.Action,
                                    memento.NewValue ?? "null", memento.NewIndex);
                }
            }

            AddMemento(memento);
        }
コード例 #8
0
 private void FireCollectionChangedEvent(NotifyCollectionChangeAction action, object item, int index, object oldItem = null)
 {
     if (CollectionChanged != null)
     {
         var args = new NotifyCollectionChangingEventArgs(action, item, index, -1)
         {
             OldItem = oldItem
         };
         CollectionChanged(this, args);
     }
 }
コード例 #9
0
        private bool FireCollectionChangingEvent(NotifyCollectionChangeAction action, T item, int index)
        {
            if (CollectionChanging != null)
            {
                var args = new NotifyCollectionChangingEventArgs(action, item, index, -1);
                CollectionChanging(this, args);
                return(!args.Cancel);
            }

            return(true);
        }
コード例 #10
0
        void FeaturesCollectionChanged(object sender, NotifyCollectionChangingEventArgs e)
        {
            if (sender != features || e.Action == NotifyCollectionChangeAction.Replace)
            {
                return;
            }

            ThrowExceptionOnModificationWhenInNetCdf();

            UpdateGeometry();
        }
コード例 #11
0
        void ComponentsCollectionChanged(object sender, NotifyCollectionChangingEventArgs e)
        {
            if (function == null || function.IsEditing)
            {
                return;
            }

            changing = true;
            Clear();
            ResetBindings();
            changing = false;
        }
コード例 #12
0
ファイル: Variable.cs プロジェクト: ghq1254544150/_SharpMap
        protected override void ArgumentsCollectionChanged(object sender, NotifyCollectionChangingEventArgs e)
        {
            isIndependentDirty = true; // performance optimization

            //if a function
            if (Arguments.Count > 0)
            {
                IsAutoSorted = false;
            }

            base.ArgumentsCollectionChanged(sender, e);
        }
コード例 #13
0
        protected override void SetItemInternal(int index, T item, out bool shouldRaiseEvents)
        {
            shouldRaiseEvents = true;
            int originalIndex = index;

            if (_filter != null)
            {
                originalIndex = _filterCollection.GetKey(index);
            }
            if (_notifyCollectionChanging != null)
            {
                using (SuspendInternal())
                    Items[originalIndex] = item;
                return;
            }
            T oldItem = Items[originalIndex];
            NotifyCollectionChangingEventArgs args = GetCollectionChangeArgs(NotifyCollectionChangedAction.Replace,
                                                                             oldItem, item,
                                                                             index);

            OnCollectionChanging(args);
            if (args.Cancel)
            {
                shouldRaiseEvents = false;
                return;
            }

            if (_notifyCollectionChanged != null)
            {
                using (SuspendInternal())
                    Items[originalIndex] = item;
                return;
            }

            Items[originalIndex] = item;
            if (_filter == null || _filter(item))
            {
                if (_filter != null)
                {
                    _filterCollection.Values[index] = item;
                }
                EventsTracker.AddEvent(args.ChangedEventArgs);
            }
            else
            {
                if (_filter != null)
                {
                    _filterCollection.RemoveAt(index);
                }
                EventsTracker.AddEvent(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item,
                                                                            index));
            }
        }
コード例 #14
0
        protected override int InsertItemInternal(IList <T> items, int index, T item, bool isAdd, NotificationType notificationType)
        {
            if (_filter == null)
            {
                return(base.InsertItemInternal(items, index, item, isAdd, GetBaseNotificationType(notificationType)));
            }

            var filterCollection = GetFilterCollection();
            int originalIndex    = index;

            if (isAdd)
            {
                originalIndex = items.Count;
            }
            else if (filterCollection.Count != 0)
            {
                if (index != 0)
                {
                    originalIndex = filterCollection.GetKey(index - 1) + 1;
                }
                else
                {
                    originalIndex = filterCollection.GetKey(index);
                }
            }
            NotifyCollectionChangingEventArgs args = null;

            if (HasChangingFlag(notificationType))
            {
                args = GetCollectionChangeArgs(NotifyCollectionChangedAction.Add, item, index);
                OnCollectionChanging(args);
                if (args.Cancel)
                {
                    return(-1);
                }
            }

            items.Insert(originalIndex, item);
            if (_isSourceNotifiable)
            {
                return(originalIndex);
            }

            UpdateFilterItems(filterCollection, originalIndex, 1);
            if (!_filter(item))
            {
                return(-1);
            }
            originalIndex = filterCollection.Add(originalIndex, item);
            OnCollectionChanged(args?.ChangedEventArgs ?? new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, index), notificationType);
            return(originalIndex);
        }
コード例 #15
0
 private void Functions_CollectionChanging(object sender, NotifyCollectionChangingEventArgs e)
 {
     switch (e.Action)
     {
     case NotifyCollectionChangeAction.Add:
         var function = (IFunction)e.Item;
         if (functions.Contains(function))
         {
             throw new ArgumentOutOfRangeException("Function already registered in the store");
         }
         break;
     }
 }
コード例 #16
0
        /// <summary>
        ///     Removes all items from the collection.
        /// </summary>
        protected virtual void ClearItemsInternal(out bool shouldRaiseEvents)
        {
            shouldRaiseEvents = false;
            NotifyCollectionChangingEventArgs args = GetCollectionChangeArgs();

            OnCollectionChanging(args);
            if (args.Cancel)
            {
                return;
            }

            Items.Clear();
            EventsTracker.AddEvent(args.ChangedEventArgs);
            shouldRaiseEvents = true;
        }
コード例 #17
0
ファイル: GroupLayer.cs プロジェクト: ghq1254544150/_SharpMap
        protected void LayersCollectionChanged(object sender, NotifyCollectionChangingEventArgs e)
        {
            // performance
            if (!created || cloning)
            {
                return;
            }

            OnLayersCollectionChanged(e);

            if (CollectionChanged != null)
            {
                CollectionChanged(sender, e);
            }
        }
コード例 #18
0
 /// <summary>
 /// Listens for changes in reduce array and throws exception if reduction is
 /// not possible for the given dimension
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void Reduce_CollectionChanged(object sender, NotifyCollectionChangingEventArgs e)
 {
     //check whether reduced dimensions are bound by offsets
     for (int i = 0; i < parent.Rank; i++)
     {
         if (Reduce[i])
         {
             bool isLimitedToOneIndex = OffsetEnd[i] == OffsetStart[i] || (SelectedIndexes[i] != null && SelectedIndexes[i].Length <= 1);
             if (!isLimitedToOneIndex)
             {
                 throw new InvalidOperationException("Reduction not possible because dimension " + i +
                                                     " is not bound to a single index");
             }
         }
     }
 }
コード例 #19
0
        public void RemoveAt(int index)
        {
            this.OwnerListElement.CheckReadyForUnboundMode();
            RadListDataItem radListDataItem        = this.useDataView ? this.dataLayer.DataView[index] : this.dataLayer.ListSource[index];
            NotifyCollectionChangingEventArgs args = new NotifyCollectionChangingEventArgs(NotifyCollectionChangedAction.Remove, (object)radListDataItem);

            this.ownerListElement.OnItemsChanging(args);
            if (args.Cancel)
            {
                return;
            }
            radListDataItem.DataLayer = (ListDataLayer)null;
            radListDataItem.Owner     = (RadListElement)null;
            this.dataLayer.ListSource.Remove(radListDataItem);
            this.ownerListElement.OnItemsChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, (object)radListDataItem));
        }
コード例 #20
0
ファイル: MapControl.cs プロジェクト: Sony-NS/SharpMap
        private void tools_CollectionChanged(object sender, NotifyCollectionChangingEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangeAction.Add:
                ((IMapTool)e.Item).MapControl = this;
                break;

            case NotifyCollectionChangeAction.Remove:
                ((IMapTool)e.Item).MapControl = null;
                break;

            default:
                break;
            }
        }
コード例 #21
0
        private void BranchFeaturesOnCollectionChanged(object sender, NotifyCollectionChangingEventArgs e)
        {
            if (!Equals(sender, branchFeatures))
            {
                return;
            }

            var branchFeature = (IBranchFeature)e.Item;

            switch (e.Action)
            {
            case NotifyCollectionChangeAction.Add:
                branchFeature.Branch = this;
                break;
            }
        }
コード例 #22
0
ファイル: Network.cs プロジェクト: Sony-NS/SharpMap
 private void Nodes_CollectionChanging(object sender, NotifyCollectionChangingEventArgs e)
 {
     switch (e.Action)
     {
     case NotifyCollectionChangeAction.Add:
         if (sender == Nodes)
         {
             var node = (INode)e.Item;
             if (node.Network != this)
             {
                 node.Network = this;
             }
         }
         break;
     }
 }
コード例 #23
0
        public void Insert(int index, RadListDataItem item)
        {
            this.OwnerListElement.CheckReadyForUnboundMode();
            item.DataLayer = this.dataLayer;
            item.Owner     = this.ownerListElement;
            NotifyCollectionChangingEventArgs args1 = new NotifyCollectionChangingEventArgs(NotifyCollectionChangedAction.Add, (object)item);

            this.ownerListElement.OnItemsChanging(args1);
            if (args1.Cancel)
            {
                return;
            }
            NotifyCollectionChangedEventArgs args2 = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, (object)item);

            this.dataLayer.ListSource.Insert(index, item);
            this.ownerListElement.OnItemsChanged(args2);
        }
コード例 #24
0
ファイル: GroupLayer.cs プロジェクト: ghq1254544150/_SharpMap
        private void OnLayersCollectionChanged(NotifyCollectionChangingEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangeAction.Add:     //set map property for layers being added
                SetMapInLayer((ILayer)e.Item);
                ((ILayer)e.Item).RenderRequired = true;
                break;

            case NotifyCollectionChangeAction.Remove:
                RenderRequired = true;    //render the group if a layer got removed.
                break;

            case NotifyCollectionChangeAction.Replace:
                throw new NotImplementedException();
            }
        }
コード例 #25
0
        void HandleActivitiesCollectionChanged(object sender, NotifyCollectionChangingEventArgs e)
        {
            //only local changes...get this in the EventedList...
            if (sender != activities)
            {
                return;
            }

            if (e.Action == NotifyCollectionChangeAction.Add)
            {
                ((IActivity)e.Item).StatusChanged += HandleActivityStatusChanged;
            }
            else if (e.Action == NotifyCollectionChangeAction.Remove)
            {
                ((IActivity)e.Item).StatusChanged -= HandleActivityStatusChanged;
            }
        }
コード例 #26
0
        protected override void InsertItem(int index, T item)
        {
            var e1 = new NotifyCollectionChangingEventArgs <T>(NotifyCollectionChangedAction.Add, item, index);

            OnCollectionChanging(e1);

            if (!e1.IsEnable)
            {
                return;
            }

            base.InsertItem(index, item);

            var e = new NotifyCollectionChangedEventArgs <T>(NotifyCollectionChangedAction.Add, item, index);

            OnCollectionChanged(e);
        }
コード例 #27
0
        /// <summary>
        ///     Removes the item at the specified index of the collection.
        /// </summary>
        /// <param name="index">
        ///     The zero-based index of the element to remove.
        /// </param>
        /// <param name="shouldRaiseEvents"></param>
        protected virtual void RemoveItemInternal(int index, out bool shouldRaiseEvents)
        {
            shouldRaiseEvents = false;
            T removedItem = Items[index];
            NotifyCollectionChangingEventArgs args = GetCollectionChangeArgs(NotifyCollectionChangedAction.Remove,
                                                                             removedItem, index);

            OnCollectionChanging(args);
            if (args.Cancel)
            {
                return;
            }

            Items.RemoveAt(index);
            EventsTracker.AddEvent(args.ChangedEventArgs);
            shouldRaiseEvents = true;
        }
コード例 #28
0
        /// <summary>
        ///     Inserts an item into the collection at the specified index.
        /// </summary>
        /// <param name="index">
        ///     The zero-based index at which <paramref name="item" /> should be inserted.
        /// </param>
        /// <param name="item">
        ///     The object to insert.
        /// </param>
        /// <param name="isAdd"></param>
        /// <param name="shouldRaiseEvents"></param>
        protected virtual int InsertItemInternal(int index, T item, bool isAdd, out bool shouldRaiseEvents)
        {
            shouldRaiseEvents = false;
            NotifyCollectionChangingEventArgs args = GetCollectionChangeArgs(NotifyCollectionChangedAction.Add, item,
                                                                             index);

            OnCollectionChanging(args);
            if (args.Cancel)
            {
                return(-1);
            }

            Items.Insert(index, item);
            EventsTracker.AddEvent(args.ChangedEventArgs);
            shouldRaiseEvents = true;
            return(index);
        }
コード例 #29
0
        protected virtual int InsertItemInternal(IList <T> items, int index, T item, bool isAdd, NotificationType notificationType)
        {
            NotifyCollectionChangingEventArgs args = null;

            if (HasChangingFlag(notificationType))
            {
                args = GetCollectionChangeArgs(NotifyCollectionChangedAction.Add, item, index);
                OnCollectionChanging(args);
                if (args.Cancel)
                {
                    return(-1);
                }
            }

            items.Insert(index, item);
            OnCollectionChanged(args?.ChangedEventArgs ?? new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, index), notificationType);
            return(index);
        }
コード例 #30
0
        protected virtual bool RemoveItemInternal(IList <T> items, int index, NotificationType notificationType)
        {
            var removedItem = items[index];
            NotifyCollectionChangingEventArgs args = null;

            if (HasChangingFlag(notificationType))
            {
                args = GetCollectionChangeArgs(NotifyCollectionChangedAction.Remove, removedItem, index);
                OnCollectionChanging(args);
                if (args.Cancel)
                {
                    return(false);
                }
            }
            items.RemoveAt(index);
            OnCollectionChanged(args?.ChangedEventArgs ?? new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, removedItem, index), notificationType);
            return(true);
        }
コード例 #31
0
 private void assignments_CollectionChanging(object sender, NotifyCollectionChangingEventArgs e)
 {
     // TODO: implement collection changing restrictions
     switch (e.Action)
     {
         case System.Collections.Specialized.NotifyCollectionChangedAction.Add:
             foreach (StartingLineupAssignment newAssignment in e.NewItems)
             {
                 if (!newAssignment.Player.Positions.Contains(newAssignment.Position)) { throw new ArgumentException("Player cannot fill this position."); }
                 if (this.Assignments.Where(assignment => assignment.Player == newAssignment.Player).Count() > 0) { throw new ArgumentException("Player cannot be assigned to multiple positions."); }
                 if (this.GetAvailablePositions(newAssignment.Position).Count <= 0) { throw new ArgumentException("No available positions of this type are avilable."); }
                 if (!newAssignment.Player.IsPlaying(this.Date)) { throw new ArgumentException("Player is not playing on the specified date."); }
             }
             break;
         case System.Collections.Specialized.NotifyCollectionChangedAction.Replace:
             //TODO: throw an exception if player slot is already filled
             break;
         case System.Collections.Specialized.NotifyCollectionChangedAction.Move:
         case System.Collections.Specialized.NotifyCollectionChangedAction.Remove:
         case System.Collections.Specialized.NotifyCollectionChangedAction.Reset:
         default:
             break;
     }
 }