///-------------------------------------------------------------------------------- /// <summary>This method applies PropertyInstance updates.</summary> ///-------------------------------------------------------------------------------- public void ProcessEditPropertyInstancePerformed(PropertyInstanceEventArgs data) { if (data != null && data.PropertyInstance != null) { UpdateEditPropertyInstance(data.PropertyInstance); } }
///-------------------------------------------------------------------------------- /// <summary>This method applies PropertyInstance deletes.</summary> ///-------------------------------------------------------------------------------- public void ProcessDeletePropertyInstancePerformed(PropertyInstanceEventArgs data) { if (data != null && data.PropertyInstance != null) { DeletePropertyInstance(data.PropertyInstance); } }
///-------------------------------------------------------------------------------- /// <summary>This method processes the delete PropertyInstance command.</summary> ///-------------------------------------------------------------------------------- public void ProcessDeletePropertyInstanceCommand() { PropertyInstanceEventArgs message = new PropertyInstanceEventArgs(); message.PropertyInstance = PropertyInstance; message.ObjectInstanceID = ObjectInstanceID; message.Solution = Solution; message.WorkspaceID = WorkspaceID; Mediator.NotifyColleagues <PropertyInstanceEventArgs>(MediatorMessages.Command_DeletePropertyInstanceRequested, message); }
///-------------------------------------------------------------------------------- /// <summary>This method sends the edit item performed message to have the /// update applied.</summary> ///-------------------------------------------------------------------------------- public void SendEditPropertyInstancePerformed() { PropertyInstanceEventArgs message = new PropertyInstanceEventArgs(); message.PropertyInstance = PropertyInstance; message.ObjectInstanceID = ObjectInstanceID; message.Solution = Solution; message.WorkspaceID = WorkspaceID; Mediator.NotifyColleagues <PropertyInstanceEventArgs>(MediatorMessages.Command_EditPropertyInstancePerformed, message); }
///-------------------------------------------------------------------------------- /// <summary>This method applies objectinstance deletes.</summary> ///-------------------------------------------------------------------------------- public void ProcessDeleteObjectInstancePerformed(ObjectInstanceEventArgs data) { try { bool isItemMatch = false; if (data != null && data.ObjectInstance != null) { foreach (ObjectInstanceViewModel item in ObjectInstances.ToList <ObjectInstanceViewModel>()) { if (item.ObjectInstance.ObjectInstanceID == data.ObjectInstance.ObjectInstanceID) { // remove item from tabs, if present WorkspaceEventArgs message = new WorkspaceEventArgs(); message.ItemID = item.ObjectInstance.ObjectInstanceID; Mediator.NotifyColleagues <WorkspaceEventArgs>(MediatorMessages.Command_CloseItemRequested, message); // delete children for (int i = item.Items.Count - 1; i >= 0; i--) { if (item.Items[i] is PropertyInstanceViewModel) { PropertyInstanceViewModel child = item.Items[i] as PropertyInstanceViewModel; PropertyInstanceEventArgs childMessage = new PropertyInstanceEventArgs(); childMessage.PropertyInstance = child.PropertyInstance; childMessage.ObjectInstanceID = item.ObjectInstance.ObjectInstanceID; childMessage.Solution = Solution; childMessage.WorkspaceID = child.WorkspaceID; item.ProcessDeletePropertyInstancePerformed(childMessage); } } // delete item isItemMatch = true; ObjectInstances.Remove(item); ModelObject.ObjectInstanceList.Remove(item.ObjectInstance); Items.Remove(item); ModelObject.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 PropertyInstance command.</summary> ///-------------------------------------------------------------------------------- public void ProcessNewPropertyInstanceCommand() { PropertyInstanceEventArgs message = new PropertyInstanceEventArgs(); message.PropertyInstance = new PropertyInstance(); message.PropertyInstance.PropertyInstanceID = Guid.NewGuid(); message.PropertyInstance.ObjectInstanceID = ObjectInstanceID; message.PropertyInstance.ObjectInstance = Solution.ObjectInstanceList.FindByID((Guid)ObjectInstanceID); if (message.PropertyInstance.ObjectInstance != null) { message.PropertyInstance.Order = message.PropertyInstance.ObjectInstance.PropertyInstanceList.Count + 1; } message.PropertyInstance.Solution = Solution; message.ObjectInstanceID = ObjectInstanceID; message.Solution = Solution; message.WorkspaceID = WorkspaceID; Mediator.NotifyColleagues <PropertyInstanceEventArgs>(MediatorMessages.Command_EditPropertyInstanceRequested, message); }