Ejemplo n.º 1
0
        internal IEnumerable <ContextMenuItem> AssociationMenuItems()
        {
            ContextMenuItem addCommentary = new ContextMenuItem("Add commentary");

            addCommentary.Icon   = ContextMenuIcon.GetContextIcon("comment");
            addCommentary.Click += delegate
            {
                NewModelCommentToDiagramCommand command = (NewModelCommentToDiagramCommand)CommandFactoryBase <NewModelCommentaryToDiagramCommandFactory> .Factory().Create(Controller.DiagramController);

                command.AnnotatedElement = Association;
                if (Diamond != null)
                {
                    command.X = Diamond.Left + Diamond.ActualWidth + 20;
                    command.Y = Diamond.Top + 20;
                }
                else
                {
                    Point p = FindClosestPoint(simpleAssociationJunction.GetBounds().GetCenter());
                    command.X = p.X + 20;
                    command.Y = p.Y + 20;
                }
                command.Set(Controller.DiagramController.ModelController, null);
                command.Execute();
            };
            ContextMenuItem demo = new ContextMenuItem("Binding demo - show that binding to association properties works");

            demo.Click += demo_Click;
            ContextMenuItem resetLabels = new ContextMenuItem("Reset all labels position");

            resetLabels.Click += delegate { ResetAllLabelsPositions(); };

            ContextMenuItem switchDiamond = new ContextMenuItem("Switch diamond ");

            switchDiamond.Click += delegate
            {
                ViewController.SwitchAssociationDiamond(ViewHelper, Association, Controller.DiagramController);
            };

            return(new[]
            {
                resetLabels,
                                                #if DEBUG
                demo,
                                                #endif
                addCommentary,
                switchDiamond
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns context menu items.
        /// </summary>
        /// <returns></returns>
        internal IEnumerable <ContextMenuItem> GeneralizationMenuItems()
        {
            ContextMenuItem addCommentary = new ContextMenuItem("Add commentary");

            addCommentary.Click += delegate
            {
                NewModelCommentToDiagramCommand command = (NewModelCommentToDiagramCommand)CommandFactoryBase <NewModelCommentaryToDiagramCommandFactory> .Factory().Create(Controller.DiagramController);

                command.AnnotatedElement = Generalization;

                Point p = JunctionGeometryHelper.FindClosestPoint(GeneralizationJunction, GeneralizationJunction.GetBounds().GetCenter());
                command.X = p.X + 20;
                command.Y = p.Y + 20;

                command.Set(Controller.DiagramController.ModelController, null);
                command.Execute();
            };
            return(new ContextMenuItem[] { addCommentary });
        }