/// <summary> /// Adds the menu edit. /// </summary> /// <param name="menu">The menu.</param> /// <param name="edit">The edit.</param> /// <exception cref="System.NotSupportedException">Cannot specify multiple exclude edits</exception> private void addMenuEdit(ContextMenu menu, EditDefinition edit) { if (!edit.IsActive(DiagramContext.Diagram.InitialView)) return; switch (edit.Name) { case ".exclude": if (ParentExcludeEdit != null) throw new NotSupportedException("Cannot specify multiple exclude edits"); ParentExcludeEdit = edit; break; case ".accept": AcceptEdits.Add(edit); break; default: var item = new MenuItem(); item.Header = edit.Name; menu.Items.Add(item); item.Click += (e, s) => { try { edit.Commit(DiagramContext.Diagram.InitialView); } catch (Exception) { } }; break; } }
/// <summary> /// Create <see cref="MenuItem"/> representing given edit /// </summary> /// <param name="edit">Represented edit</param> /// <param name="context">Context of edit</param> /// <returns>Created <see cref="MenuItem"/></returns> private static MenuItem createEditItem(EditDefinition edit, DiagramContext context) { var item = new MenuItem(); item.Header = edit.Name; item.Click += (e, s) => edit.Commit(context.Diagram.InitialView); return(item); }
/// <summary> /// Attach edit for item with attachingID. /// </summary> /// <param name="attachingID">The attaching identifier.</param> /// <param name="editDefinition">The edit definition.</param> public void AttachEdit(string attachingID, EditDefinition editDefinition) { _attachedEdits.Add(attachingID, editDefinition); }
/// <summary> /// Adds the edit of item. /// </summary> /// <param name="editDefinition">The edit definition.</param> public void AddEdit(EditDefinition editDefinition) { _edits.Add(editDefinition); }