Пример #1
0
        public AddsEditsDeletesSet(
            List <TItem> oldItems,
            List <TItem> newItems,
            Func <TItem, object> keySelector,
            Func <TItem, TItem, bool> itemsAreEqualComparer,
            Func <TItem, bool> itemCannotBeDeletedSelector = null)
        {
            OldItems = oldItems;
            NewItems = newItems;

            foreach (TItem newItem in newItems)
            {
                object newItemKey      = keySelector(newItem);
                TItem  matchingOldItem = oldItems.FirstOrDefault(oldItem => keySelector(oldItem).Equals(newItemKey));

                if (matchingOldItem == null)
                {
                    // No matching old item - this is a new item
                    ItemsToAdd.Add(newItem);
                }
                else
                {
                    // Found a matching old item
                    if (itemsAreEqualComparer(newItem, matchingOldItem))
                    {
                        // Items match - the item has not been changed
                        ItemsWithNoChanges.Add(new OldAndNew <TItem> {
                            Old = matchingOldItem, New = newItem
                        });
                    }
                    else
                    {
                        // Items don't match - there are changes
                        ItemsToChange.Add(new OldAndNew <TItem> {
                            Old = matchingOldItem, New = newItem
                        });
                    }
                }
            }

            foreach (TItem oldItem in oldItems)
            {
                object oldItemKey      = keySelector(oldItem);
                TItem  matchingNewItem = newItems.FirstOrDefault(newItem => keySelector(newItem).Equals(oldItemKey));

                if (matchingNewItem == null)
                {
                    // No matching new item - this item has been deleted
                    ItemsToDelete.Add(oldItem);
                }
            }

            if (itemCannotBeDeletedSelector != null)
            {
                ItemsThatCannotBeDeleted = ItemsToDelete.Where(itemCannotBeDeletedSelector).ToList();
            }
        }
        ///--------------------------------------------------------------------------------
        /// <summary>This method adds a relationship to the view model.</summary>
        ///
        /// <param name="relationship">The relationship to add.</param>
        ///--------------------------------------------------------------------------------
        public void CreateRelationship(DiagramRelationshipViewModel relationship)
        {
            // add diagram relationship to solution diagram
            DiagramRelationships.Add(relationship);
            Items.Add(relationship);

            // add to diagram relationships to add list
            ItemsToAdd.Add(relationship);
            Refresh(false);
        }
Пример #3
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method adds to Entity adds.</summary>
        ///--------------------------------------------------------------------------------
        public void AddNewEntity()
        {
            EntityViewModel item = new EntityViewModel();

            item.Entity           = new Entity();
            item.Entity.EntityID  = Guid.NewGuid();
            item.Entity.Feature   = EditFeature;
            item.Entity.FeatureID = EditFeature.FeatureID;
            item.Entity.Solution  = Solution;
            item.Solution         = Solution;

            #region protected
            #endregion protected

            ItemsToAdd.Add(item);
            Items.Add(item);
        }
Пример #4
0
        private void OnBrowse()
        {
            OpenFileDialog openFile = new OpenFileDialog()
            {
                FileName        = "",
                Filter          = "Executable File (*.exe)|*.exe",
                CheckFileExists = true,
                CheckPathExists = true,
                Multiselect     = true
            };

            if (openFile.ShowDialog().Value)
            {
                foreach (var name in openFile.FileNames)
                {
                    if (!name.ToLower().Contains("mgr21"))
                    {
                        ItemsToAdd.Add(name);
                    }
                }
            }
        }
        ///--------------------------------------------------------------------------------
        /// <summary>This method creates an entity and adds to the view model.</summary>
        ///
        /// <param name="entity">The entity to add.</param>
        /// <param name="position">The desired position to place the entity.</param>
        ///--------------------------------------------------------------------------------
        public DiagramEntityViewModel CreateEntity(EntityViewModel entity, Point position)
        {
            // create diagram entity and add to solution diagram
            DiagramEntity dropDiagram = new DiagramEntity();

            dropDiagram.DiagramEntityID = Guid.NewGuid();
            DiagramEntityViewModel diagramEntity = new DiagramEntityViewModel(dropDiagram, entity, this);

            diagramEntity.X      = Math.Max(0, position.X);
            diagramEntity.Y      = Math.Max(0, position.Y);
            diagramEntity.Width  = Double.NaN;
            diagramEntity.Height = Double.NaN;
            DiagramEntities.Add(diagramEntity);
            Items.Add(diagramEntity);
            ClearSelectedItems();
            diagramEntity.IsSelected = true;
            diagramEntity.ZIndex     = ++ZIndex;

            // add to diagram entites to add list
            ItemsToAdd.Add(diagramEntity);
            Refresh(false);
            return(diagramEntity);
        }
Пример #6
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method puts an item into the add queue.</summary>
 ///
 /// <param name="item">The item to add.</param>
 ///--------------------------------------------------------------------------------
 public virtual void Add(WorkspaceViewModel item)
 {
     ItemsToAdd.Add(item);
     Items.Add(item);
 }