コード例 #1
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method updates the view model data and sends update command back
        /// to the solution builder.</summary>
        ///--------------------------------------------------------------------------------
        protected override void OnUpdate()
        {
            // send update for any updated children
            foreach (PropertyReferenceViewModel item in PropertyReferences)
            {
                if (item.IsEdited == true)
                {
                    item.Update();
                }
            }
            // send update for any new children
            foreach (PropertyReferenceViewModel item in ItemsToAdd.OfType <PropertyReferenceViewModel>())
            {
                item.Update();
                PropertyReferences.Add(item);
            }
            ItemsToAdd.Clear();

            // send delete for any deleted children
            foreach (PropertyReferenceViewModel item in ItemsToDelete.OfType <PropertyReferenceViewModel>())
            {
                item.Delete();
                PropertyReferences.Remove(item);
            }
            ItemsToDelete.Clear();

            // reset modified for children
            foreach (PropertyReferenceViewModel item in PropertyReferences)
            {
                item.ResetModified(false);
            }
        }
コード例 #2
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method loads PropertyReferences into the view model.</summary>
 ///
 /// <param name="entity">The entity to load.</param>
 /// <param name="solution">The associated solution.</param>
 /// <param name="loadChildren">Flag indicating whether to perform a deeper load.</param>
 ///--------------------------------------------------------------------------------
 public void LoadPropertyReferences(Entity entity, Solution solution, bool loadChildren = true)
 {
     // attach the items
     Items.Clear();
     if (PropertyReferences == null)
     {
         PropertyReferences = new EnterpriseDataObjectList <PropertyReferenceViewModel>();
     }
     if (loadChildren == true)
     {
         foreach (PropertyReference item in entity.PropertyReferenceList)
         {
             PropertyReferenceViewModel itemView = new PropertyReferenceViewModel(item, solution);
             itemView.Updated += new EventHandler(Children_Updated);
             PropertyReferences.Add(itemView);
             Items.Add(itemView);
         }
     }
 }
コード例 #3
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method applies propertyreference updates.</summary>
 ///--------------------------------------------------------------------------------
 public void ProcessEditPropertyReferencePerformed(PropertyReferenceEventArgs data)
 {
     try
     {
         bool isItemMatch = false;
         if (data != null && data.PropertyReference != null)
         {
             foreach (PropertyReferenceViewModel item in PropertyReferences)
             {
                 if (item.PropertyReference.PropertyID == data.PropertyReference.PropertyID)
                 {
                     isItemMatch = true;
                     item.PropertyReference.TransformDataFromObject(data.PropertyReference, null, false);
                     item.OnUpdated(item, null);
                     item.ShowInTreeView();
                     break;
                 }
             }
             if (isItemMatch == false)
             {
                 // add new PropertyReference
                 data.PropertyReference.Entity = Entity;
                 PropertyReferenceViewModel newItem = new PropertyReferenceViewModel(data.PropertyReference, Solution);
                 newItem.Updated += new EventHandler(Children_Updated);
                 PropertyReferences.Add(newItem);
                 Entity.PropertyReferenceList.Add(newItem.PropertyReference);
                 Solution.PropertyReferenceList.Add(newItem.PropertyReference);
                 Items.Add(newItem);
                 OnUpdated(this, null);
                 newItem.ShowInTreeView();
             }
         }
     }
     catch (Exception ex)
     {
         ShowIssue(ex.Message + ex.StackTrace);
     }
 }
コード例 #4
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method adds an instance of PropertyReference to the view model.</summary>
 ///
 /// <param name="itemView">The PropertyReference to add.</param>
 ///--------------------------------------------------------------------------------
 public void AddPropertyReference(PropertyReferenceViewModel itemView)
 {
     itemView.Updated += new EventHandler(Children_Updated);
     PropertyReferences.Add(itemView);
     Add(itemView);
 }