///-------------------------------------------------------------------------------- /// <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 (StageTransitionViewModel item in StageTransitions) { if (item.IsEdited == true) { item.Update(); } } // send update for any new children foreach (StageTransitionViewModel item in ItemsToAdd.OfType <StageTransitionViewModel>()) { item.Update(); StageTransitions.Add(item); } ItemsToAdd.Clear(); // send delete for any deleted children foreach (StageTransitionViewModel item in ItemsToDelete.OfType <StageTransitionViewModel>()) { item.Delete(); StageTransitions.Remove(item); } ItemsToDelete.Clear(); // reset modified for children foreach (StageTransitionViewModel item in StageTransitions) { item.ResetModified(false); } }
///-------------------------------------------------------------------------------- /// <summary>This method loads StageTransitions into the view model.</summary> /// /// <param name="stage">The stage to load.</param> /// <param name="solution">The associated solution.</param> /// <param name="loadChildren">Flag indicating whether to perform a deeper load.</param> ///-------------------------------------------------------------------------------- public void LoadStageTransitions(Stage stage, Solution solution, bool loadChildren = true) { // attach the items Items.Clear(); if (StageTransitions == null) { StageTransitions = new EnterpriseDataObjectList <StageTransitionViewModel>(); } if (loadChildren == true) { foreach (StageTransition item in stage.ToStageTransitionList) { StageTransitionViewModel itemView = new StageTransitionViewModel(item, solution); itemView.Updated += new EventHandler(Children_Updated); StageTransitions.Add(itemView); Items.Add(itemView); } } }
///-------------------------------------------------------------------------------- /// <summary>This method applies stagetransition updates.</summary> ///-------------------------------------------------------------------------------- public void ProcessEditStageTransitionPerformed(StageTransitionEventArgs data) { try { bool isItemMatch = false; if (data != null && data.StageTransition != null) { foreach (StageTransitionViewModel item in StageTransitions) { if (item.StageTransition.StageTransitionID == data.StageTransition.StageTransitionID) { isItemMatch = true; item.StageTransition.TransformDataFromObject(data.StageTransition, null, false); item.OnUpdated(item, null); item.ShowInTreeView(); break; } } if (isItemMatch == false) { // add new StageTransition data.StageTransition.ToStage = Stage; StageTransitionViewModel newItem = new StageTransitionViewModel(data.StageTransition, Solution); newItem.Updated += new EventHandler(Children_Updated); StageTransitions.Add(newItem); Stage.ToStageTransitionList.Add(newItem.StageTransition); Solution.StageTransitionList.Add(newItem.StageTransition); Items.Add(newItem); OnUpdated(this, null); newItem.ShowInTreeView(); } } } catch (Exception ex) { ShowIssue(ex.Message + ex.StackTrace); } }
///-------------------------------------------------------------------------------- /// <summary>This method adds an instance of StageTransition to the view model.</summary> /// /// <param name="itemView">The StageTransition to add.</param> ///-------------------------------------------------------------------------------- public void AddStageTransition(StageTransitionViewModel itemView) { itemView.Updated += new EventHandler(Children_Updated); StageTransitions.Add(itemView); Add(itemView); }