///-------------------------------------------------------------------------------- /// <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 (XmlSourceViewModel item in XmlSources) { if (item.IsEdited == true) { item.Update(); } } // send update for any new children foreach (XmlSourceViewModel item in ItemsToAdd.OfType <XmlSourceViewModel>()) { item.Update(); XmlSources.Add(item); } ItemsToAdd.Clear(); // send delete for any deleted children foreach (XmlSourceViewModel item in ItemsToDelete.OfType <XmlSourceViewModel>()) { item.Delete(); XmlSources.Remove(item); } ItemsToDelete.Clear(); // reset modified for children foreach (XmlSourceViewModel item in XmlSources) { item.ResetModified(false); } }
///-------------------------------------------------------------------------------- /// <summary>This method applies xml specification source deletes.</summary> ///-------------------------------------------------------------------------------- public void ProcessDeleteXmlSourcePerformed(XmlSourceEventArgs data) { bool isItemMatch = false; if (data != null && data.XmlSource != null) { foreach (XmlSourceViewModel item in XmlSources.ToList <XmlSourceViewModel>()) { if (item.XmlSource.SpecificationSourceID == data.XmlSource.SpecificationSourceID) { // remove item from tabs, if present WorkspaceEventArgs message = new WorkspaceEventArgs(); message.ItemID = item.XmlSource.SpecificationSourceID; Mediator.NotifyColleagues <WorkspaceEventArgs>(MediatorMessages.Command_CloseItemRequested, message); // delete item isItemMatch = true; XmlSources.Remove(item); Solution.XmlSourceList.Remove(item.XmlSource); Items.Remove(item); Solution.ResetModified(true); OnUpdated(this, null); break; } } if (isItemMatch == false) { ShowIssue(DisplayValues.Issue_DeleteItemNotFound); } } }
///-------------------------------------------------------------------------------- /// <summary>This method applies xmlsource updates.</summary> ///-------------------------------------------------------------------------------- public void ProcessEditXmlSourcePerformed(XmlSourceEventArgs data) { try { bool isItemMatch = false; if (data != null && data.XmlSource != null) { foreach (XmlSourceViewModel item in XmlSources) { if (item.XmlSource.SpecificationSourceID == data.XmlSource.SpecificationSourceID) { isItemMatch = true; item.XmlSource.TransformDataFromObject(data.XmlSource, null, false); item.OnUpdated(item, null); item.ShowInTreeView(); break; } } if (isItemMatch == false) { // add new XmlSource data.XmlSource.Solution = Solution; XmlSourceViewModel newItem = new XmlSourceViewModel(data.XmlSource, Solution); newItem.Updated += new EventHandler(Children_Updated); XmlSources.Add(newItem); Solution.XmlSourceList.Add(newItem.XmlSource); Items.Add(newItem); OnUpdated(this, null); newItem.ShowInTreeView(); } } } catch (Exception ex) { ShowIssue(ex.Message + ex.StackTrace); } }