예제 #1
0
 HRESULT IUICollectionChangedEvent.OnChanged(CollectionChange action, uint oldIndex, object oldItem, uint newIndex, object newItem)
 {
     if (ChangedEvent != null)
     {
         ChangedEvent(_collection, new UICollectionChangedEventArgs(action, oldIndex, oldItem, newIndex, newItem));
     }
     return HRESULT.S_OK;
 }
예제 #2
0
 public UICollectionChangedEventArgs(CollectionChange action, uint oldIndex, object oldItem, uint newIndex, object newItem)
 {
     _action = action;
     _oldIndex = oldIndex;
     _oldItem = oldItem;
     _newIndex = newIndex;
     _newItem = newItem;
 }
 public VectorChangedEventArgs WithCollectionChange(CollectionChange value)
 {
     Contract.Ensures(Contract.Result<VectorChangedEventArgs>() != null, nameof(WithCollectionChange));
     return value == CollectionChange ? this : new VectorChangedEventArgs(value, Index);
 }
 public VectorChangedEventArgs(CollectionChange cc, int index = -1)
 {
     _cc    = cc;
     _index = (uint)index;
 }
예제 #5
0
 /// <summary>
 /// Construct an eventargs
 /// </summary>
 /// <param name="cc">collection change type</param>
 /// <param name="index">index of item changed</param>
 /// <param name="item">item changed</param>
 public VectorChangedEventArgs(CollectionChange cc, int index = -1, object item = null)
 {
     CollectionChange = cc;
     Index = (uint)index;
 }
 /// <summary>
 /// Fires the <see cref="CollectionChanged"/> event.
 /// </summary>
 protected virtual void OnCollectionChanged(CollectionChange change, T value)
 {
     CollectionChanged?.Invoke(this, new CollectionChangedEventArgs <T>(change, value));
 }
예제 #7
0
        private void InvokeMapChanged(CollectionChange change, string key)
        {
            var eventHandler = MapChanged;

            eventHandler?.Invoke(this, new ObservableDictionaryChangedEventArgs(change, key));
        }
예제 #8
0
 public ObservableDictionaryChangedEventArgs(CollectionChange change, string key)
 {
     this.CollectionChange = change;
     this.Key = key;
 }
예제 #9
0
 private void CollectionOnChanged(CollectionChange <T> change)
 {
     _updateAction(new BindingCollectionChange <T>(change.AddedItems, false, change.RemovedItems.ToArray()));
 }
 public WinRTVectorChangedEventArgs(CollectionChange change, int index)
 {
     CollectionChange = change;
     Index            = (uint)index;
 }
예제 #11
0
 /// <summary>
 /// Class constructor that creates instance of <see cref="SettingsManagerItemChanedEventArgs"/>.
 /// </summary>
 /// <param name="key">Key of the item changed.</param>
 /// <param name="change">Type of the change.</param>
 public SettingsManagerItemChanedEventArgs(string key,
                                           CollectionChange change)
 {
     Key = key;
     CollectionChange = change;
 }
예제 #12
0
 private protected virtual void RaiseVectorChanged(CollectionChange action, uint index)
 {
     return;
 }
예제 #13
0
 /// <summary>
 /// There are no comments for CollectionChangeSet in the schema.
 /// </summary>
 public void AddToCollectionChangeSet(CollectionChange collectionChange)
 {
     base.AddObject("CollectionChangeSet", collectionChange);
 }
예제 #14
0
 public void Clear()
 {
     menuGroups = new List <MenuGroup>();
     CollectionChange?.Invoke(this, new EventArgs());
 }
예제 #15
0
 public ViewChangedEventArgs(List <AddRemoveResult> changedGroups, CollectionChange action)
 {
     this.Changes = changedGroups;
     this.Action  = action;
 }
예제 #16
0
 private void RaiseMapChanged(CollectionChange change, K key)
 {
     MapChanged?.Invoke(this, new ObservableDictionaryChangedEventArgs(change, key));
 }
 /// <summary>
 /// Initializes a new instance of the VectorChangedEventArgs class.
 /// </summary>
 /// <param name="change">The change to the vector.</param>
 /// <param name="index">Index of the changed element.</param>
 public VectorChangedEventArgs(CollectionChange change, uint index)
 {
     this.CollectionChange = change;
     this.Index            = index;
 }
예제 #18
0
 public ViewChangingEventArgs(IList changedItems, CollectionChange action)
 {
     this.ChangedItems = changedItems;
     this.Action       = action;
 }
예제 #19
0
 private void RaiseVectorChanged(CollectionChange change, int index)
 {
     VectorChanged?.Invoke(this, new VectorChangedEventArgs(change, (uint)index));
 }
예제 #20
0
 /// <summary>
 /// Creates an instance with the specified key and change.
 /// </summary>
 /// <param name="change">Change type.</param>
 /// <param name="key">Key of the changed entry, when relevant.</param>
 public MapChangedEventArgs(CollectionChange change, TKey key)
 {
     CollectionChange = change;
     Key = key;
 }
예제 #21
0
 public VectorChangedEventArgs(CollectionChange cc, int index = -1, object item = null)
 {
     _cc    = cc;
     _index = (uint)index;
     _item  = item;
 }
예제 #22
0
 public DictionaryExChangedEventArgs(CollectionChange change, K key)
 {
     CollectionChange = change;
     Key = key;
 }
 public VectorChangedEventArgs(CollectionChange collectionChange, int index = -1)
 {
     _collectionChange = collectionChange;
     _index = (uint)index;
 }
예제 #24
0
 public VectorChangedEventArgs(CollectionChange collectionChange, uint index)
 {
     this.collectionChange = collectionChange;
     this.index = index;
 }
 private VectorChangedEventArgs(CollectionChange collectionChange, uint index)
 {
     CollectionChange = collectionChange;
     Index = index;
 }
예제 #26
0
 /// <summary>
 /// Fires the <see cref="DictionaryChanged"/> event.
 /// </summary>
 protected virtual void OnDictionaryChanged(CollectionChange change, TKey key, TValue value)
 {
     DictionaryChanged?.Invoke(this, new DictionaryChangedEventArgs <TKey, TValue>(change, key, value));
 }
예제 #27
0
 protected void RaiseViewChanged(List <AddRemoveResult> changes, CollectionChange action)
 {
     base.RaiseViewChanged(this, changes, action);
 }
예제 #28
0
 public VectorChangedEventArgs(CollectionChange type, uint index)
 {
     this.CollectionChange = type;
     this.Index = index;
 }
예제 #29
0
파일: ItemList.cs 프로젝트: Daoting/dt
 public ItemListChangedArgs(CollectionChange p_change, int p_index)
 {
     CollectionChange = p_change;
     Index            = p_index;
 }
 public static VectorChangedEventArgs Create(CollectionChange collectionChange = CollectionChange.Reset, uint index = 0)
 {
     Contract.Ensures(Contract.Result<VectorChangedEventArgs>() != null, nameof(Create));
     return new VectorChangedEventArgs(collectionChange, index);
 }
예제 #31
0
 protected void RaiseViewChanged(object sender, List <AddRemoveResult> changes, CollectionChange action)
 {
     if (this.ViewChanged != null)
     {
         this.ViewChanged(sender, new ViewChangedEventArgs(changes, action));
     }
 }
예제 #32
0
 public ObservableDictionaryChangedEventArgs(CollectionChange change, K key)
 {
     CollectionChange = change;
     Key = key;
 }
        //For flowchart reacting to ModelItem changes we are concerned of the following scenarios:
        //1. FlowElements being deleted from the Flowchart.Nodes collection or Flowswitch cases being deleted from ItemsCollection
        //2. FlowElements being added to the Flowchart.Nodes collection or Flowswitch cases being added from ItemsCollection
        //3. Properties being changed in FlowStep(Next), FlowDecision(True, false), FlowSwitch(Default) (Any of the flowelemnet should be present in the elements collection).
        //4. Flowswitch cases being added/remove via Cases.Dicitionary
        void ModelTreeManager_EditingScopeCompleted(object sender, EditingScopeEventArgs e)
        {
            Fx.Assert(this.panel != null, "This code should not be hit if panel is null");
            foreach (Change change in e.EditingScope.Changes)
            {
                //Case 1, 2.
                if (change is CollectionChange)
                {
                    CollectionChange collectionChange = change as CollectionChange;
                    if (collectionChange.Collection.Equals(this.ModelItem.Properties["Nodes"].Collection))
                    {
                        if (collectionChange.Operation == CollectionChange.OperationType.Delete)
                        {
                            this.DeleteShapeVisual(this.flowNodeToUIElement[collectionChange.Item]);
                        }
                        else
                        {
                            this.AddFlowElementsToDesigner(new List <ModelItem> {
                                collectionChange.Item
                            });
                            //An editing scope change references the ModelItem.
                            //Hence in case of multiple changes to the same modelItem within the same EditingScope, we will see all the changes on the ModelItem for each change.
                            //Eg. Suppose following two changes are in the same editing scope: 1. Add ModelItem item1 to Collection, 2. Change a property on this MI, item1.Prop1
                            //In this case, EditingScope.Changes.Count will be 2.
                            //Since an EditingScope change keeps a reference to the ModelItem changed, when we process the first change, the second change would already be reflected on the ModelItem.
                            //Hence, while processing CollectionChange for item1, item1.Prop1 will already reflect the new value.
                            //Also there will be another change notifying the change in item1.Prop1.
                            //AddFlowElementsToDesigner() method, walks through the properties of a newly added item and creates any links if required.
                            //This is necessary for Paste scenario where we want to create links between Items added to the Nodes Collection.
                            //Because of this behavior of AddFlowElementsToDesigner(), before reacting to a property change for adding a link, we will always verify that the link does not already exists.
                        }
                    }
                    if (collectionChange.Collection.Parent != null && collectionChange.Collection.Parent.Parent != null &&
                        this.ModelItem.Properties["Nodes"].Collection.Contains(collectionChange.Collection.Parent.Parent) &&
                        collectionChange.Collection.Parent.Parent.ItemType.IsGenericType &&
                        collectionChange.Collection.Parent.Parent.ItemType.GetGenericTypeDefinition() == typeof(FlowSwitch <>))
                    {
                        ModelItem item     = collectionChange.Item;
                        string    caseName = GenericFlowSwitchHelper.GetString(item.Properties["Key"].ComputedValue, item.Properties["Key"].PropertyType);

                        Connector connector = this.GetLinkOnCanvas(collectionChange.Collection.Parent.Parent,
                                                                   item.Properties["Value"].Value, GenericFlowSwitchHelper.FlowSwitchCasesKeyIdentifier + caseName);
                        if (collectionChange.Operation == CollectionChange.OperationType.Delete)
                        {
                            if (connector != null)
                            {
                                this.DeleteLinkVisual(connector);
                            }
                        }
                        else if (collectionChange.Operation == CollectionChange.OperationType.Insert)
                        {
                            if (connector == null)
                            {
                                //Prepending GenericFlowSwitchHelper.FlowSwitchCasesKeyIdentifier to differentiate between the FlowSwitch's Property Default and key Default.
                                connector = this.CreatePropertyLink(collectionChange.Collection.Parent.Parent,
                                                                    item.Properties["Value"].Value,
                                                                    GenericFlowSwitchHelper.FlowSwitchCasesKeyIdentifier + caseName);
                                Fx.Assert(connector != null, "Link not created");
                                this.panel.Children.Add(connector);
                            }
                            else
                            {
                                RefreshFlowSwitchLinkModelItem(/* flowSwitchModelItem = */ collectionChange.Collection.Parent.Parent, connector, false);
                            }
                        }
                    }
                }
                else if (change is DictionaryChange)
                {
                    // case 4
                    DictionaryChange dictionaryChange = change as DictionaryChange;

                    if (dictionaryChange.Dictionary.Parent != null &&
                        this.ModelItem.Properties["Nodes"].Collection.Contains(dictionaryChange.Dictionary.Parent) &&
                        dictionaryChange.Dictionary.Parent.ItemType.IsGenericType &&
                        dictionaryChange.Dictionary.Parent.ItemType.GetGenericTypeDefinition() == typeof(FlowSwitch <>))
                    {
                        ModelItem flowSwitchModelItem = dictionaryChange.Dictionary.Parent;
                        ModelItem caseTargetModelItem = dictionaryChange.Value;
                        string    caseName            = GenericFlowSwitchHelper.GetString(dictionaryChange.Key == null ? null : dictionaryChange.Key.GetCurrentValue(), dictionaryChange.Key == null ? null : dictionaryChange.Key.ItemType);
                        string    caseNameInModelItem = GenericFlowSwitchHelper.FlowSwitchCasesKeyIdentifier + caseName;

                        Connector connector = this.GetLinkOnCanvas(
                            flowSwitchModelItem,
                            caseTargetModelItem,
                            caseNameInModelItem);

                        if (dictionaryChange.Operation == DictionaryChange.OperationType.Delete)
                        {
                            if (connector != null)
                            {
                                this.DeleteLinkVisual(connector);
                            }
                        }
                        else if (dictionaryChange.Operation == DictionaryChange.OperationType.Insert)
                        {
                            if (connector == null)
                            {
                                connector = this.CreatePropertyLink(
                                    flowSwitchModelItem,
                                    caseTargetModelItem,
                                    caseNameInModelItem);
                                this.panel.Children.Add(connector);
                            }
                        }
                    }
                }
                //Case 3.
                else if (change is PropertyChange)
                {
                    PropertyChange propertyChange = change as PropertyChange;

                    if (this.ModelItem.Properties["Nodes"].Collection.Contains(propertyChange.Owner) ||
                        (propertyChange.PropertyName == "StartNode" && propertyChange.Owner == this.ModelItem))
                    {
                        if (propertyChange.OldValue != null &&
                            IsFlowNode(propertyChange.OldValue))
                        {
                            Connector link = GetLinkOnCanvas(propertyChange.Owner, propertyChange.OldValue, propertyChange.PropertyName);
                            //Debug.Assert(link != null, "Link not found on designer");
                            if (link != null)
                            {
                                this.DeleteLinkVisual(link);
                            }
                        }
                        if (propertyChange.NewValue != null &&
                            IsFlowNode(propertyChange.NewValue))
                        {
                            Connector oldLink = GetLinkOnCanvas(propertyChange.Owner, propertyChange.NewValue, propertyChange.PropertyName);
                            //If this connector has already been added don't add again.
                            if (oldLink == null)
                            {
                                Connector link = CreatePropertyLink(propertyChange.Owner, propertyChange.NewValue, propertyChange.PropertyName);
                                Fx.Assert(link != null, "Link not created");
                                this.panel.Children.Add(link);
                            }
                            else
                            {
                                if (GenericFlowSwitchHelper.IsGenericFlowSwitch(propertyChange.Owner.ItemType))
                                {
                                    this.RefreshFlowSwitchLinkModelItem(/* flowSwitchModelItem = */ propertyChange.Owner, oldLink, true);
                                }
                            }
                        }

                        //handling for the case where the FlowStep.Action changes:
                        //Explicitly adding a check for FlowStep, because other FlowNodes have properties of type Activity, which we don't want to react to.
                        //AddFlowElementsToDesigner() will add the links originating out of the shape that is changing.
                        //We have to take care of refreshing the links coming into the shape that is changing.
                        if (typeof(FlowStep).IsAssignableFrom(propertyChange.Owner.ItemType))
                        {
                            List <Connector> oldIncomingConnectors = new List <Connector>();
                            if (propertyChange.OldValue != null && IsFlowStepAction(propertyChange.OldValue))
                            {
                                UIElement oldShape = this.flowNodeToUIElement[propertyChange.Owner];
                                oldIncomingConnectors = this.GetInComingConnectors(oldShape);
                                this.DeleteShapeVisual(oldShape);
                            }
                            if (propertyChange.NewValue != null && IsFlowStepAction(propertyChange.NewValue))
                            {
                                this.AddFlowElementsToDesigner(new List <ModelItem> {
                                    propertyChange.Owner
                                });
                                foreach (Connector oldConnector in oldIncomingConnectors)
                                {
                                    Connector newConnector = CreateLink(FreeFormPanel.GetSourceConnectionPoint(oldConnector),
                                                                        this.flowNodeToUIElement[propertyChange.Owner], FlowchartDesigner.GetLinkModelItem(oldConnector));
                                    this.panel.Children.Add(newConnector);
                                }
                            }
                        }
                    }
                }
            }
        }