///-------------------------------------------------------------------------------- /// <summary>This method applies enumeration deletes.</summary> ///-------------------------------------------------------------------------------- public void ProcessDeleteEnumerationPerformed(EnumerationEventArgs data) { try { bool isItemMatch = false; if (data != null && data.Enumeration != null) { foreach (EnumerationViewModel item in Enumerations.ToList <EnumerationViewModel>()) { if (item.Enumeration.EnumerationID == data.Enumeration.EnumerationID) { // remove item from tabs, if present WorkspaceEventArgs message = new WorkspaceEventArgs(); message.ItemID = item.Enumeration.EnumerationID; Mediator.NotifyColleagues <WorkspaceEventArgs>(MediatorMessages.Command_CloseItemRequested, message); // delete children for (int i = item.Items.Count - 1; i >= 0; i--) { if (item.Items[i] is ValueViewModel) { ValueViewModel child = item.Items[i] as ValueViewModel; ValueEventArgs childMessage = new ValueEventArgs(); childMessage.Value = child.Value; childMessage.EnumerationID = item.Enumeration.EnumerationID; childMessage.Solution = Solution; childMessage.WorkspaceID = child.WorkspaceID; item.ProcessDeleteValuePerformed(childMessage); } } // delete item isItemMatch = true; Enumerations.Remove(item); Model.EnumerationList.Remove(item.Enumeration); Items.Remove(item); Model.ResetModified(true); OnUpdated(this, null); break; } } if (isItemMatch == false) { ShowIssue(DisplayValues.Issue_DeleteItemNotFound); } } } catch (Exception ex) { ShowIssue(ex.Message + ex.StackTrace); } }
///-------------------------------------------------------------------------------- /// <summary>This method processes the new enumeration command.</summary> ///-------------------------------------------------------------------------------- public void ProcessNewEnumerationCommand() { EnumerationEventArgs message = new EnumerationEventArgs(); message.Enumeration = new Enumeration(); message.Enumeration.EnumerationID = Guid.NewGuid(); message.Enumeration.ModelID = Model.ModelID; message.Enumeration.Model = Model; message.ModelID = Model.ModelID; message.Enumeration.Solution = Solution; message.Solution = Solution; message.WorkspaceID = WorkspaceID; Mediator.NotifyColleagues <EnumerationEventArgs>(MediatorMessages.Command_EditEnumerationRequested, message); }
///-------------------------------------------------------------------------------- /// <summary>This method applies enumeration updates.</summary> ///-------------------------------------------------------------------------------- public void ProcessEditEnumerationPerformed(EnumerationEventArgs data) { try { bool isItemMatch = false; if (data != null && data.Enumeration != null) { foreach (EnumerationViewModel item in Enumerations) { if (item.Enumeration.EnumerationID == data.Enumeration.EnumerationID) { isItemMatch = true; item.Enumeration.TransformDataFromObject(data.Enumeration, null, false); item.OnUpdated(item, null); item.ShowInTreeView(); break; } } if (isItemMatch == false) { // add new Enumeration data.Enumeration.Model = Model; EnumerationViewModel newItem = new EnumerationViewModel(data.Enumeration, Solution); newItem.Updated += new EventHandler(Children_Updated); Enumerations.Add(newItem); Model.EnumerationList.Add(newItem.Enumeration); Solution.EnumerationList.Add(newItem.Enumeration); Items.Add(newItem); OnUpdated(this, null); newItem.ShowInTreeView(); } } } catch (Exception ex) { ShowIssue(ex.Message + ex.StackTrace); } }