///-------------------------------------------------------------------------------- /// <summary>This method is used to copy/paste a new item.</summary> /// /// <param name="copyItem">The item to copy/paste.</param> /// <param name="savePaste">Flag to determine whether to save the results of the paste.</param> ///-------------------------------------------------------------------------------- public StageTransitionViewModel PasteStageTransition(StageTransitionViewModel copyItem, bool savePaste = true) { StageTransition newItem = new StageTransition(); newItem.ReverseInstance = new StageTransition(); newItem.TransformDataFromObject(copyItem.StageTransition, null, false); newItem.StageTransitionID = Guid.NewGuid(); newItem.IsAutoUpdated = false; newItem.ToStage = Stage; newItem.Solution = Solution; StageTransitionViewModel newView = new StageTransitionViewModel(newItem, Solution); newView.ResetModified(true); AddStageTransition(newView); // paste children if (savePaste == true) { Solution.StageTransitionList.Add(newItem); Stage.ToStageTransitionList.Add(newItem); newView.OnUpdated(this, null); Solution.ResetModified(true); } return(newView); }
///-------------------------------------------------------------------------------- /// <summary>This method adds to StageTransition adds.</summary> ///-------------------------------------------------------------------------------- public void AddNewStageTransition() { StageTransitionViewModel item = new StageTransitionViewModel(); item.StageTransition = new StageTransition(); item.StageTransition.StageTransitionID = Guid.NewGuid(); item.StageTransition.ToStage = Stage; item.StageTransition.ToStageID = Stage.StageID; item.StageTransition.Solution = Solution; item.Solution = Solution; #region protected #endregion protected StageTransitionsFolder.ItemsToAdd.Add(item); StageTransitionsFolder.Items.Add(item); }
///-------------------------------------------------------------------------------- /// <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 to StageTransition deletes.</summary> ///-------------------------------------------------------------------------------- public void AddToDeletedStageTransitions(StageTransitionViewModel item) { StageTransitionsFolder.ItemsToDelete.Add(item); StageTransitionsFolder.Items.Remove(item); }
///-------------------------------------------------------------------------------- /// <summary>This method deletes an instance of StageTransition from the view model.</summary> /// /// <param name="itemView">The StageTransition to delete.</param> ///-------------------------------------------------------------------------------- public void DeleteStageTransition(StageTransitionViewModel itemView) { itemView.Updated -= Children_Updated; StageTransitions.Remove(itemView); Delete(itemView); }
///-------------------------------------------------------------------------------- /// <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); }