Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DiagramItem" /> class.
        /// </summary>
        /// <param name="definition">The definition.</param>
        /// <param name="parentItem">The parent item.</param>
        /// <param name="slot">The slot.</param>
        internal DiagramItem(DiagramItemDefinition definition, DiagramItem parentItem, SlotCanvas slot)
        {
            ContainingDiagramCanvas = slot;
            Definition = definition;
            ParentItem = parentItem;
            ParentItem._children.Add(this);
            DiagramContext = parentItem.DiagramContext;

            initialize();
        }
Esempio n. 3
0
        /// <summary>
        /// Create context menu according to edits and commands in given definition
        /// </summary>
        /// <param name="diagramDefinition">Definitin of diagram</param>
        /// <param name="context">Context available for diagram definition</param>
        /// <returns>Created context menu</returns>
        private ContextMenu createContextMenu(DiagramDefinition diagramDefinition, DiagramContext context)
        {
            var menu = new ContextMenu();

            //add edit entries
            foreach (var edit in diagramDefinition.Edits)
            {
                if (!edit.IsActive(diagramDefinition.InitialView))
                {
                    continue;
                }

                var item = createEditItem(edit, context);
                menu.Items.Add(item);
            }

            foreach (var menuProvider in diagramDefinition.MenuProviders)
            {
                var item = new MenuItem();
                item.Header = menuProvider.Key;
                item.Tag    = menuProvider.Value;

                menu.Items.Add(item);
            }

            //add command entries
            foreach (var command in diagramDefinition.Commands)
            {
                var item = new MenuItem();
                item.Header = command.Name;

                item.Click += (e, s) => command.Command();
                menu.Items.Add(item);
            }

            return(menu);
        }
Esempio n. 4
0
 /// <summary>
 /// Sets the context of diagram.
 /// </summary>
 /// <param name="context">The context.</param>
 internal void SetContext(DiagramContext context)
 {
     DiagramContext = context;
 }
Esempio n. 5
0
 /// <summary>
 /// Creates the join according to given definition.
 /// </summary>
 /// <param name="definition">The definition of join.</param>
 /// <param name="context">The context of <see cref="DiagramDefinition"/> where join will be displayed.</param>
 /// <returns>Join drawing.</returns>
 public abstract JoinDrawing CreateJoin(JoinDefinition definition, DiagramContext context);