Пример #1
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method deletes an instance of PropertyInstance.</summary>
        ///
        /// <param name="propertyInstance">The PropertyInstance to delete.</param>
        ///--------------------------------------------------------------------------------
        public void DeletePropertyInstance(PropertyInstance propertyInstance)
        {
            bool isItemMatch = false;

            foreach (PropertyInstanceViewModel item in PropertyInstances.ToList <PropertyInstanceViewModel>())
            {
                if (item.PropertyInstance.PropertyInstanceID == propertyInstance.PropertyInstanceID)
                {
                    // remove item from tabs, if present
                    WorkspaceEventArgs message = new WorkspaceEventArgs();
                    message.ItemID = item.PropertyInstance.PropertyInstanceID;
                    Mediator.NotifyColleagues <WorkspaceEventArgs>(MediatorMessages.Command_CloseItemRequested, message);

                    // delete PropertyInstance
                    isItemMatch = true;
                    PropertyInstances.Remove(item);
                    ObjectInstance.PropertyInstanceList.Remove(item.PropertyInstance);
                    Solution.PropertyInstanceList.Remove(item.PropertyInstance);
                    Items.Remove(item);
                    ObjectInstance.ResetModified(true);
                    OnUpdated(this, null);
                    break;
                }
            }
            if (isItemMatch == false)
            {
                ShowIssue(DisplayValues.Issue_DeleteItemNotFound);
            }
        }
Пример #2
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method updates an item of PropertyInstance.</summary>
        ///
        /// <param name="propertyInstance">The PropertyInstance to update.</param>
        ///--------------------------------------------------------------------------------
        public void UpdateEditPropertyInstance(PropertyInstance propertyInstance)
        {
            bool isItemMatch = false;

            foreach (PropertyInstanceViewModel item in PropertyInstances)
            {
                if (item.PropertyInstance.PropertyInstanceID == propertyInstance.PropertyInstanceID)
                {
                    isItemMatch = true;
                    item.PropertyInstance.TransformDataFromObject(propertyInstance, null, false);
                    if (!item.PropertyInstance.ModelPropertyID.IsNullOrEmpty())
                    {
                        item.PropertyInstance.ModelProperty = Solution.ModelPropertyList.FindByID((Guid)item.PropertyInstance.ModelPropertyID);
                    }
                    item.OnUpdated(item, null);
                    break;
                }
            }
            if (isItemMatch == false)
            {
                // add new PropertyInstance
                propertyInstance.ObjectInstance = ObjectInstance;
                PropertyInstanceViewModel newItem = new PropertyInstanceViewModel(propertyInstance, Solution);
                if (!newItem.PropertyInstance.ModelPropertyID.IsNullOrEmpty())
                {
                    newItem.PropertyInstance.ModelProperty = Solution.ModelPropertyList.FindByID((Guid)newItem.PropertyInstance.ModelPropertyID);
                }
                newItem.Updated += new EventHandler(Children_Updated);
                PropertyInstances.Add(newItem);
                ObjectInstance.PropertyInstanceList.Add(propertyInstance);
                Solution.PropertyInstanceList.Add(newItem.PropertyInstance);
                Items.Add(newItem);
                OnUpdated(this, null);
            }
        }
Пример #3
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method disposes of resources in the view model.</summary>
 ///--------------------------------------------------------------------------------
 protected override void OnDispose()
 {
     if (PropertyInstances != null)
     {
         foreach (PropertyInstanceViewModel itemView in PropertyInstances)
         {
             itemView.Updated -= Children_Updated;
             itemView.Dispose();
         }
         PropertyInstances.Clear();
         PropertyInstances = null;
     }
     Model          = null;
     ModelObject    = null;
     ObjectInstance = null;
     ModelProperty  = null;
     base.OnDispose();
 }