Example #1
0
        public PSM_ClassUnion(XCaseCanvas xCaseCanvas)
            : base(xCaseCanvas)
        {
            #region Template init
            Template = Application.Current.Resources["PSM_ClassUnionTemplate"] as ControlTemplate;
            ApplyTemplate();

            PSM_ClassUnionTemplate gr = Template.FindName("PSM_ClassUnionGrid", this) as PSM_ClassUnionTemplate;
            Border             = gr.FindName("Border") as Border;
            connectorDecorator = gr.FindName("ConnectorDecorator") as Control;
            connectorDecorator.ApplyTemplate();
            #endregion

            ContextMenu = new ContextMenu();
            ContextMenuItem m = new ContextMenuItem("Remove");
            m.Icon   = ContextMenuIcon.GetContextIcon("delete2");
            m.Click += delegate(object sender, RoutedEventArgs e) { ClassUnionController.Remove(); };
            ContextMenu.Items.Add(m);

            ContextMenu.Items.Add(new Separator());
            foreach (ContextMenuItem item in ContextMenuItems)
            {
                ContextMenu.Items.Add(item);
            }
        }
Example #2
0
        /// <summary>
        /// Context menu items for PSM Association
        /// </summary>
        /// <returns></returns>
        public IEnumerable <ContextMenuItem> PSM_AssociationMenuItems()
        {
            if (cutToRoot.Parent != null)
            {
                ((ContextMenu)cutToRoot.Parent).Items.Remove(cutToRoot);
            }
            if (remove.Parent != null)
            {
                ((ContextMenu)remove.Parent).Items.Remove(remove);
            }

            ContextMenuItem moveToContentContainer = new ContextMenuItem("Move to content container");

            moveToContentContainer.Click += delegate
            {
                Controller.MoveToContentContainer(null);
            };

            ContextMenuItem moveToContentChoice = new ContextMenuItem("Move to content choice");

            moveToContentChoice.Click += delegate
            {
                Controller.MoveToContentChoice(null);
            };

            ContextMenuItem moveToClassUnion = new ContextMenuItem("Move to class union");

            moveToClassUnion.Click += delegate
            {
                Controller.MoveToClassUnion(null);
            };


            return(new[] { cutToRoot, remove, moveToContentContainer, moveToContentChoice, moveToClassUnion });
        }
Example #3
0
        public AttributeTextBox(Property property, IControlsAttributes classController)
        {
            this.property        = property;
            this.classController = classController;

            #region property context menu

            this.ContextMenu = new ContextMenu();
            ContextMenuItem remove = new ContextMenuItem("Remove attribute");
            remove.Icon   = ContextMenuIcon.GetContextIcon("delete2");
            remove.Click += delegate { classController.RemoveAttribute(property); };
            this.ContextMenu.Items.Add(remove);

            ContextMenuItem change = new ContextMenuItem("Properties...");
            change.Icon   = ContextMenuIcon.GetContextIcon("pencil");
            change.Click += delegate { classController.ShowAttributeDialog(property); };
            this.ContextMenu.Items.Add(change);

            #endregion

            property.PropertyChanged += OnPropertyChangedEvent;
            MouseDoubleClick         += OnMouseDoubleClick;
            RefreshTextContent();
            BindType();
        }
Example #4
0
        private void InitContextMenu()
        {
            ContextMenu = new ContextMenu();
            ContextMenuItem m = new ContextMenuItem("Remove");

            m.Icon   = ContextMenuIcon.GetContextIcon("delete2");
            m.Click += delegate(object sender, RoutedEventArgs e) { AttributeContainerController.Remove(); };
            ContextMenu.Items.Add(m);

            ContextMenuItem moveToContentContainer = new ContextMenuItem("Move to content container");

            moveToContentContainer.Click += delegate
            {
                AttributeContainerController.MoveToContentContainer(null);
            };

            ContextMenu.Items.Add(moveToContentContainer);

            ContextMenuItem moveToContentChoice = new ContextMenuItem("Move to content choice");

            moveToContentChoice.Click += delegate
            {
                AttributeContainerController.MoveToContentChoice(null);
            };

            ContextMenu.Items.Add(moveToContentChoice);

            ContextMenu.Items.Add(new Separator());
            foreach (ContextMenuItem item in ContextMenuItems)
            {
                ContextMenu.Items.Add(item);
            }
        }
Example #5
0
 public void ResetContextMenu()
 {
     ContextMenu      = new ContextMenu();
     mi_Rename        = new ContextMenuItem("Rename");
     mi_Rename.Icon   = ContextMenuIcon.GetContextIcon("pencil");
     mi_Rename.Click += new System.Windows.RoutedEventHandler(mi_Click);
     ContextMenu.Items.Add(mi_Rename);
 }
Example #6
0
        public PSMAttributeTextBox(IControlsPSMAttributes attributesController)
        {
            this.classController = attributesController;
            this.Text            = "{ any attribute }";
            this.ContextMenu     = new ContextMenu();

            ContextMenuItem removeDefinition = new ContextMenuItem("Remove");

            removeDefinition.Click += delegate
            {
                (this.classController as PSM_ClassController).ChangeAllowAnyAttributeDefinition(false);
            };
            this.ContextMenu.Items.Add(removeDefinition);
        }
Example #7
0
        /// <summary>
        /// Initializes a view representation of a model element
        /// </summary>
        /// <param name="modelElement">Element to be represented</param>
        /// <param name="viewHelper">Element's viewHelper</param>
        /// <param name="controller">Element's controller</param>
        public void InitializeRepresentant(Element modelElement, ViewHelper viewHelper, ElementController controller)
        {
            Controller = (PSM_AssociationController)controller;
            ViewHelper = (PSMAssociationViewHelper)viewHelper;

            ParentRepresentation = (IConnectable)XCaseCanvas.ElementRepresentations[Association.Parent];
            ChildRepresentation  = (IConnectable)XCaseCanvas.ElementRepresentations[Association.Child];

            if (Junction != null)
            {
                Junction.MouseEnter -= junction_MouseEnter;
                Junction.MouseLeave -= junction_MouseLeave;
            }

            if (ViewHelper.Points.Count < 2)
            {
                ViewHelper.Points.Clear();
                ViewHelper.Points.AppendRange(JunctionGeometryHelper.ComputeOptimalConnection(ParentRepresentation, ChildRepresentation));
                if (!ChildRepresentation.IsMeasureValid || !ParentRepresentation.IsMeasureValid)
                {
                    ViewHelper.Points.PointsInvalid = true;
                }
            }

            remove        = new ContextMenuItem("Remove subtree");
            remove.Icon   = ContextMenuIcon.GetContextIcon("delete2");
            remove.Click += delegate { Controller.Remove(); };

            cutToRoot        = new ContextMenuItem("Cut association (add child as new root)");
            cutToRoot.Click += delegate { Controller.CutToRoot(); };

            Junction = new XCaseJunction(XCaseCanvas, ViewHelper.Points);
            Junction.PSM_Association = this;
            Junction.AutoPosModeOnly = true;
            Junction.SelectionOwner  = this;
            Junction.NewConnection(ParentRepresentation, null, ChildRepresentation, null, ViewHelper.Points);
            Junction.Points[1].PositionChanged += AdjustLabelsPositions;

            XCaseCanvas.Children.Add(Junction);
            Junction.EndCapStyle = EJunctionCapStyle.Arrow;
            ((PSMElementViewBase)ChildRepresentation).Connector = this;
            this.StartBindings();
            Association.PropertyChanged += ModelPropertyChanged;
            if (Junction != null)
            {
                Junction.MouseEnter += junction_MouseEnter;
                Junction.MouseLeave += junction_MouseLeave;
            }
        }
Example #8
0
        public PSM_ContentContainer(XCaseCanvas xCaseCanvas)
            : base(xCaseCanvas)
        {
            #region Template Init
            base.Template = Application.Current.Resources["PSM_ContentContainerTemplate"] as ControlTemplate;
            ApplyTemplate();

            PSM_ContentContainerTemplate gr = Template.FindName("PSM_ContentContainerGrid", this) as PSM_ContentContainerTemplate;

            Border  = gr.FindName("Border") as Border;
            TextBox = gr.FindName("txtName") as EditableTextBox;

            connectorDecorator = gr.FindName("ConnectorDecorator") as Control;
            connectorDecorator.ApplyTemplate();
            #endregion

            TextBox.mi_Rename.Header = "Rename content container";

            ContextMenuItem m = new ContextMenuItem("Remove content container");
            m.Icon   = ContextMenuIcon.GetContextIcon("delete2");
            m.Click += delegate(object sender, RoutedEventArgs e) { ContentContainerController.Remove(); };
            TextBox.ContextMenu.Items.Add(m);

            ContextMenuItem moveToContentContainer = new ContextMenuItem("Move to content container");
            moveToContentContainer.Click += delegate
            {
                ContentContainerController.MoveToContentContainer(null);
            };

            TextBox.ContextMenu.Items.Add(moveToContentContainer);

            ContextMenuItem moveToContentChoice = new ContextMenuItem("Move to content choice");
            moveToContentChoice.Click += delegate
            {
                ContentContainerController.MoveToContentChoice(null);
            };

            TextBox.ContextMenu.Items.Add(moveToContentChoice);



            TextBox.ContextMenu.Items.Add(new Separator());
            foreach (ContextMenuItem item in ContextMenuItems)
            {
                TextBox.ContextMenu.Items.Add(item);
            }

            TextBox.TextEdited += delegate(object sender, StringEventArgs args) { Controller.RenameElement <NamedElement>(args.Data, null); XCaseCanvas.InvokeElementSizeChanged(this, null); };
        }
Example #9
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
            });
        }
Example #10
0
        private void InitContextMenu()
        {
            miProperties        = new ContextMenuItem("Properties");
            miProperties.Icon   = ContextMenuIcon.GetContextIcon("properties");
            miProperties.Click += delegate
            {
                new DiagramReferenceDialog(this.DiagramReference,
                                           this.DiagramReferenceController,
                                           this.DiagramReferenceController.DiagramController.
                                           ModelController).ShowDialog();
            };
            TextBox.ContextMenu.Items.Add(miProperties);

            miDelete        = new ContextMenuItem("Remove");
            miDelete.Icon   = ContextMenuIcon.GetContextIcon("delete2");
            miDelete.Click += Remove;
            this.ContextMenu.Items.Add(miDelete);
        }
Example #11
0
        public OperationTextBox(Operation operation, IControlsOperations classController)
        {
            this.operation       = operation;
            this.classController = classController;

            #region Operation context menu

            this.ContextMenu = new ContextMenu();
            ContextMenuItem remove = new ContextMenuItem("Remove operation");
            remove.Icon   = ContextMenuIcon.GetContextIcon("delete2");
            remove.Click += delegate { classController.RemoveOperation(operation); };
            this.ContextMenu.Items.Add(remove);

            #endregion

            operation.PropertyChanged += delegate { RefreshTextContent(); };
            RefreshTextContent();
        }
Example #12
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 });
        }
Example #13
0
        public XCaseComment(XCaseCanvas xCaseCanvas)
            : base(xCaseCanvas)
        {
            #region Commentary Template Init

            Template = (ControlTemplate)Application.Current.Resources["XCaseCommentaryTemplate"];
            ApplyTemplate();

            XCaseCommentTemplate gr = (XCaseCommentTemplate)Template.FindName("CommentaryGrid", this);

            if (gr != null)
            {
                CommentBorder  = gr.FindName("CommentBorder") as Border;
                CommentTextBox = (EditableTextBox)gr.FindName("txtText");

                resizeDecorator = (Control)gr.FindName("ResizeDecorator");
                resizeDecorator.ApplyTemplate();
                Grid g = (Grid)resizeDecorator.Template.FindName("ResizeDecoratorGrid", resizeDecorator);
                foreach (ResizeThumb t in g.Children)
                {
                    t.belongsTo = this;
                }

                connectorDecorator = (Control)gr.FindName("ConnectorDecorator");
                connectorDecorator.ApplyTemplate();
            }

            #endregion

            #region Commentary Context Menu

            ContextMenuItem m = new ContextMenuItem("Remove from diagram");
            m.Icon   = ContextMenuIcon.GetContextIcon("delete2");
            m.Click += new RoutedEventHandler(Remove_Click);
            CommentTextBox.ContextMenu.Items.Add(m);
            CommentTextBox.mi_Rename.Header = "Change";

            #endregion

            CommentTextBox.TextEdited += delegate(object sender, StringEventArgs args) { Controller.ChangeComment(args.Data); };
            PositionChanged           += delegate { CommentTextBox.myEditable = false; };
        }
Example #14
0
        /// <summary>
        /// Returns context menu items for junction.
        /// </summary>
        /// <returns></returns>
        internal IEnumerable <ContextMenuItem> JunctionMenuItems()
        {
            if (!AutoPosModeOnly)
            {
                ContextMenuItem breakCommand = new ContextMenuItem("Break line here");
                breakCommand.Click += delegate
                {
                    ViewController.BreakLine(downPos,
                                             JunctionGeometryHelper.FindHitSegmentIndex(downPos, Points) + 1,
                                             viewHelperPointsCollection, XCaseCanvas.Controller);
                };
                ContextMenuItem autoPosEndsCommand = new ContextMenuItem("Line ends auto-position");
                autoPosEndsCommand.Click += delegate
                {
                    StartPoint.Placement = EPlacementKind.ParentAutoPos;
                    EndPoint.Placement   = EPlacementKind.ParentAutoPos;
                    InvalidateGeometry();
                };

                if (this.Association != null)
                {
                    ContextMenuItem removeEndCommand = new ContextMenuItem("Remove from association");
                    removeEndCommand.Click += delegate
                    {
                        Association.Controller.RemoveAssociationEnd(this.AssociationEnd.AssociationEnd);
                    };
                    return(new[] { breakCommand, autoPosEndsCommand, removeEndCommand });
                }

                return(new[] { breakCommand, autoPosEndsCommand });
            }
            else
            {
                return(new ContextMenuItem[0]);
            }
        }
Example #15
0
        public PSMAttributeTextBox(PSMAttribute Attribute, IControlsPSMAttributes attributesController)
        {
            this.attribute       = Attribute;
            this.classController = attributesController;

            #region property context menu

            this.ContextMenu = new ContextMenu();

            ContextMenuItem miPropagatePIMLess = new ContextMenuItem("Propagate to PIM");
            miPropagatePIMLess.Icon      = ContextMenuIcon.GetContextIcon("AddAttributes");
            miPropagatePIMLess.Click    += delegate { attributesController.PropagatePIMLess(attribute); };
            miPropagatePIMLess.IsEnabled = attribute.RepresentedAttribute == null;
            attribute.PropertyChanged   +=
                delegate(object sender, PropertyChangedEventArgs e)
            {
                if (e.PropertyName == "RepresentedAttribute")
                {
                    miPropagatePIMLess.IsEnabled = attribute.RepresentedAttribute == null;
                }
            };
            this.ContextMenu.Items.Add(miPropagatePIMLess);

            ContextMenuItem remove = new ContextMenuItem("Remove attribute");
            remove.Icon   = ContextMenuIcon.GetContextIcon("delete2");
            remove.Click += delegate { attributesController.RemoveAttribute(attribute); };
            this.ContextMenu.Items.Add(remove);

            if (attributesController is PSM_AttributeContainerController)
            {
                ContextMenuItem returnAttribute = new ContextMenuItem("Move back to class");
                returnAttribute.Click += delegate { ((PSM_AttributeContainerController)attributesController).MoveAttributeBackToClass(attribute); };
                this.ContextMenu.Items.Add(returnAttribute);
            }
            else
            {
                ContextMenuItem miMoveToAC = new ContextMenuItem("Move to attribute container");
                miMoveToAC.Click += delegate { ((PSM_ClassController)attributesController).MoveAttributesToAttributeContainer(null, attribute); };
                this.ContextMenu.Items.Add(miMoveToAC);
            }

            ContextMenuItem change = new ContextMenuItem("Properties...");
            change.Icon   = ContextMenuIcon.GetContextIcon("pencil");
            change.Click += delegate { attributesController.ShowAttributeDialog(attribute); };
            this.ContextMenu.Items.Add(change);

            moveUp        = new ContextMenuItem("Move up");
            moveUp.Click += delegate { attributesController.MoveAttributeUp(attribute); };
            this.ContextMenu.Items.Add(moveUp);


            moveDown        = new ContextMenuItem("Move down");
            moveDown.Click += delegate { attributesController.MoveAttributeDown(attribute); };
            this.ContextMenu.Items.Add(moveDown);


            #endregion

            attribute.PropertyChanged += delegate { RefreshTextContent(); };
            MouseDoubleClick          += OnMouseDoubleClick;
            RefreshTextContent();
        }
Example #16
0
        /// <summary>
        /// Initializes PIM Classes Context Menus
        /// </summary>
        protected virtual void InitContextMenu()
        {
            ContextMenuItem m = new ContextMenuItem("Remove");

            m.Click += new RoutedEventHandler(Remove);
            m.Icon   = ContextMenuIcon.GetContextIcon("delete2");
            txtClassName.ContextMenu.Items.Add(m);
            txtClassName.ContextMenu.Items.Add(new Separator());

            m        = new ContextMenuItem("Autosize");
            m.Click += delegate(object sender, RoutedEventArgs e) { ViewController.ResizeElement(double.NaN, double.NaN, ViewHelper, XCaseCanvas.Controller); };
            txtClassName.ContextMenu.Items.Add(m);
            txtClassName.ContextMenu.Items.Add(new Separator());

            miCollapseAttributes = new ContextMenuItem("Hide attributes")
            {
                IsCheckable = true
            };
            txtClassName.ContextMenu.Items.Add(miCollapseAttributes);
            miCollapseAttributes.Checked +=
                delegate(object sender, RoutedEventArgs e)
            {
                if (!AttributesCollapsed)
                {
                    ViewController.ChangeSectionVisibility(ViewHelper, SectionVisibilityCommand.ESectionVisibilityAction.CollapseAttributes, XCaseCanvas.Controller);
                }
            };
            miCollapseAttributes.Unchecked +=
                delegate(object sender, RoutedEventArgs e)
            {
                if (AttributesCollapsed)
                {
                    ViewController.ChangeSectionVisibility(ViewHelper, SectionVisibilityCommand.ESectionVisibilityAction.ShowAttributes, XCaseCanvas.Controller);
                }
            };

            miCollapseOperations = new ContextMenuItem("Hide operations")
            {
                IsCheckable = true
            };
            txtClassName.ContextMenu.Items.Add(miCollapseOperations);
            miCollapseOperations.Checked +=
                delegate(object sender, RoutedEventArgs e)
            {
                if (!OperationsCollapsed)
                {
                    ViewController.ChangeSectionVisibility(ViewHelper, SectionVisibilityCommand.ESectionVisibilityAction.CollapseOperations, XCaseCanvas.Controller);
                }
            };
            miCollapseOperations.Unchecked +=
                delegate(object sender, RoutedEventArgs e)
            {
                if (OperationsCollapsed)
                {
                    ViewController.ChangeSectionVisibility(ViewHelper, SectionVisibilityCommand.ESectionVisibilityAction.ShowOperations, XCaseCanvas.Controller);
                }
            };

            txtClassName.ContextMenu.Items.Add(new Separator());
            foreach (ContextMenuItem item in classAttributes.PropertiesMenuItems)
            {
                txtClassName.ContextMenu.Items.Add(item);
            }
            foreach (ContextMenuItem item in classOperations.OperationsMenuItems)
            {
                txtClassName.ContextMenu.Items.Add(item);
            }
            foreach (ContextMenuItem item in ContextMenuItems)
            {
                txtClassName.ContextMenu.Items.Add(item);
            }
            txtClassName.ContextMenu.Items.Add(new Separator());
            mDerive      = new ContextMenuItem("Derive PSM class to...");
            mDerive.Icon = ContextMenuIcon.GetContextIcon("class");
            txtClassName.ContextMenuOpening += new ContextMenuEventHandler(mDerive_ContextMenuOpening);
            txtClassName.ContextMenu.Items.Add(mDerive);
            txtClassName.ContextMenu.Items.Add(new Separator());

            ContextMenuItem miProperties = new ContextMenuItem("Properties...");

            miProperties.Icon   = ContextMenuIcon.GetContextIcon("props");
            miProperties.Click += delegate { ClassController.ShowClassDialog(); };
            txtClassName.ContextMenu.Items.Add(miProperties);
        }
Example #17
0
        /// <summary>
        /// Initializes PSM Classes Context Menus
        /// </summary>
        private void InitContextMenu()
        {
            //txtClassName.ResetContextMenu();
            txtClassName.ContextMenuOpening    += ContextMenu_ContextMenuOpening;
            txtRepresentedClassName.ContextMenu = null;
            ContextMenuItem miRemove = new ContextMenuItem("Remove");

            miRemove.Icon   = ContextMenuIcon.GetContextIcon("delete2");
            miRemove.Click += delegate { ClassController.Remove(); };
            txtClassName.ContextMenu.Items.Add(miRemove);
            txtClassName.ContextMenu.Items.Add(new Separator());

            ContextMenuItem miDeriveNew = new ContextMenuItem("Derive another class as root");

            miDeriveNew.Icon   = ContextMenuIcon.GetContextIcon("class");
            miDeriveNew.Click += delegate { ClassController.DeriveNewRootPSMClass(); };
            txtClassName.ContextMenu.Items.Add(miDeriveNew);

            ContextMenuItem miLocatePimClass = new ContextMenuItem("Find represented PIM class");

            miLocatePimClass.Icon   = ContextMenuIcon.GetContextIcon("magnifier");
            miLocatePimClass.Click += delegate {
                ClassController.FindRepresentedClass();
            };
            txtClassName.ContextMenu.Items.Add(miLocatePimClass);

            miLocateRepresentedPSMClass           = new ContextMenuItem("Find represented PSM class");
            miLocateRepresentedPSMClass.Icon      = ContextMenuIcon.GetContextIcon("magnifier");
            miLocateRepresentedPSMClass.IsEnabled = false;
            miLocateRepresentedPSMClass.Click    += delegate
            {
                if (PSMClass.IsStructuralRepresentative)
                {
                    if (PSMClass.RepresentedPSMClass.Diagram == PSMClass.Diagram)
                    {
                        XCaseCanvas.SelectElement(PSMClass.RepresentedPSMClass);
                    }
                    else
                    {
                        ClassController.FindRepresentedPSMClass();
                    }
                }
            };

            txtClassName.ContextMenu.Items.Add(miLocateRepresentedPSMClass);

            miFindStructuralRepresentatives           = new ContextMenuItem("Find Structural Representatives");
            miFindStructuralRepresentatives.Icon      = ContextMenuIcon.GetContextIcon("magnifier");
            miFindStructuralRepresentatives.IsEnabled = true;
            miFindStructuralRepresentatives.Click    += delegate
            {
                if (PSMClass.IsReferencedFromStructuralRepresentative())
                {
                    SelectItemsDialog d     = new SelectItemsDialog();
                    List <PSMClass>   items = new List <Model.PSMClass>();
                    foreach (PSMClass r in PSMClass.RepresentedClassRepresentants)
                    {
                        if (r.RepresentedPSMClass == PSMClass)
                        {
                            items.Add(r);
                        }
                    }
                    d.SetItems(items);
                    if (d.ShowDialog() == true && d.selectedObjects.Count > 0)
                    {
                        XCaseCanvas.SelectElement((PSMElement)d.selectedObjects.First());
                    }
                }
            };
            txtClassName.ContextMenu.Items.Add(miFindStructuralRepresentatives);

            miConvertToRegular        = new ContextMenuItem("Convert to regular PSM class");
            miConvertToRegular.Icon   = ContextMenuIcon.GetContextIcon("class");
            miConvertToRegular.Click +=
                delegate
            {
                SetRepresentedHighlight(false);
                ClassController.SetPSMRepresentedClass(true);
            };

            miConvertToRepresentant        = new ContextMenuItem("Convert to PSM Structural Representative");
            miConvertToRepresentant.Icon   = ContextMenuIcon.GetContextIcon("class");
            miConvertToRepresentant.Click += delegate { ClassController.SetPSMRepresentedClass(false); };

            txtClassName.ContextMenu.Items.Add(miConvertToRepresentant);
            txtClassName.ContextMenu.Items.Add(miConvertToRegular);

            txtClassName.ContextMenu.Items.Add(new Separator());

            miAbstract             = new ContextMenuItem("Abstract class");
            miAbstract.IsCheckable = true;
            miAbstract.Click      += delegate { ClassController.ChangeAbstract(!PSMClass.IsAbstract); };
            txtClassName.ContextMenu.Items.Add(miAbstract);

            miAllowAnyAttribute             = new ContextMenuItem("Allow any attribute");
            miAllowAnyAttribute.IsCheckable = true;
            miAllowAnyAttribute.Click      += delegate { ClassController.ChangeAllowAnyAttributeDefinition(!PSMClass.AllowAnyAttribute); };
            txtClassName.ContextMenu.Items.Add(miAllowAnyAttribute);

            ContextMenuItem miAutosize = new ContextMenuItem("Autosize");

            miAutosize.Click += delegate { ViewController.ResizeElement(double.NaN, double.NaN, ViewHelper, XCaseCanvas.Controller); };
            txtClassName.ContextMenu.Items.Add(miAutosize);
            txtClassName.ContextMenu.Items.Add(new Separator());

            miCollapseAttributes = new ContextMenuItem("Hide attributes")
            {
                IsCheckable = true
            };
            txtClassName.ContextMenu.Items.Add(miCollapseAttributes);
            miCollapseAttributes.Checked +=
                delegate
            {
                if (!AttributesCollapsed)
                {
                    ViewController.ChangeSectionVisibility(ViewHelper, SectionVisibilityCommand.ESectionVisibilityAction.CollapseAttributes, XCaseCanvas.Controller);
                }
            };
            miCollapseAttributes.Unchecked +=
                delegate
            {
                if (AttributesCollapsed)
                {
                    ViewController.ChangeSectionVisibility(ViewHelper, SectionVisibilityCommand.ESectionVisibilityAction.ShowAttributes, XCaseCanvas.Controller);
                }
            };

            miCollapseElementNameLabel = new ContextMenuItem("Hide element name")
            {
                IsCheckable = true
            };
            miCollapseElementNameLabel.Checked +=
                delegate
            {
                if (!ElementNameLabelCollapsed)
                {
                    ViewController.ChangeSectionVisibility(ViewHelper, SectionVisibilityCommand.ESectionVisibilityAction.CollapseElementNameLabel, XCaseCanvas.Controller);
                }
            };
            miCollapseElementNameLabel.Unchecked +=
                delegate
            {
                if (ElementNameLabelCollapsed)
                {
                    ViewController.ChangeSectionVisibility(ViewHelper, SectionVisibilityCommand.ESectionVisibilityAction.ShowElementNameLabel, XCaseCanvas.Controller);
                }
            };
            txtClassName.ContextMenu.Items.Add(miCollapseElementNameLabel);
            txtClassName.ContextMenu.Items.Add(new Separator());

            miElementNameLabelAlignRight = new ContextMenuItem("Aligned to right")
            {
                IsCheckable = true
            };
            miElementNameLabelAlignRight.Checked +=
                delegate
            {
                if (!ElementNameLabelAlignedRight)
                {
                    ViewController.ChangeElementNameLabelAlignment(ViewHelper, true, XCaseCanvas.Controller);
                }
            };

            miElementNameLabelAlignRight.Unchecked +=
                delegate
            {
                if (ElementNameLabelAlignedRight)
                {
                    ViewController.ChangeElementNameLabelAlignment(ViewHelper, false, XCaseCanvas.Controller);
                }
            };
            //txtElementNameLabel.ResetContextMenu();
            txtElementNameLabel.ContextMenu.Items.Add(miElementNameLabelAlignRight);

            txtElementNameLabel.mi_Rename.Header = "Change XML Element name...";

            ContextMenuItem miDeleteElementName = new ContextMenuItem("Delete element name");

            miDeleteElementName.Icon   = ContextMenuIcon.GetContextIcon("delete2");
            miDeleteElementName.Click += delegate { ClassController.ChangeElementName(string.Empty); };
            txtElementNameLabel.ContextMenu.Items.Add(miDeleteElementName);


            foreach (ContextMenuItem item in classAttributes.PropertiesMenuItems)
            {
                txtClassName.ContextMenu.Items.Add(item);
            }
            foreach (ContextMenuItem item in ContextMenuItems)
            {
                txtClassName.ContextMenu.Items.Add(item);
            }

            txtClassName.ContextMenu.Items.Add(new Separator());

            miGroupBy        = new ContextMenuItem("Group by...");
            miGroupBy.Click += delegate { ClassController.GroupBy(); };
            txtClassName.ContextMenu.Items.Add(miGroupBy);

            ContextMenuItem miAddChildren = new ContextMenuItem("Add children...");

            miAddChildren.Icon   = ContextMenuIcon.GetContextIcon("AddChildren");
            miAddChildren.Click += delegate { ClassController.AddChildren(); };
            txtClassName.ContextMenu.Items.Add(miAddChildren);

            ContextMenuItem miAddAttributes = new ContextMenuItem("Attributes...");

            miAddAttributes.Icon   = ContextMenuIcon.GetContextIcon("AddAttributes");
            miAddAttributes.Click += delegate { ClassController.ShowClassDialog(); };
            txtClassName.ContextMenu.Items.Add(miAddAttributes);

            txtClassName.ContextMenu.Items.Add(new Separator());

            ContextMenuItem miProperties = new ContextMenuItem("Properties...");

            miProperties.Icon   = ContextMenuIcon.GetContextIcon("props");
            miProperties.Click += delegate { ClassController.ShowClassDialog(); };
            txtClassName.ContextMenu.Items.Add(miProperties);
        }
Example #18
0
        /// <summary>
        /// Initializes the context menu, creates context menu items.
        /// </summary>
        private void InitializeContextMenu()
        {
            ContextMenu = new ContextMenu();
            ContextMenuItem includeDependent = new ContextMenuItem("Include hidden elements");

            includeDependent.Icon   = ContextMenuIcon.GetContextIcon("branch");
            includeDependent.Click += delegate { IncludeDependentElements(); };
            ContextMenu.Items.Add(includeDependent);

            ContextMenuItem exportPng = new ContextMenuItem("Export diagram to PNG...");

            exportPng.Icon   = ContextMenuIcon.GetContextIcon("Palette");
            exportPng.Click += delegate { ExportToImage(EExportToImageMethod.PNG); };
            ContextMenu.Items.Add(exportPng);

            ContextMenuItem exportPng2 = new ContextMenuItem("Export diagram to PNG (no frame)...");

            exportPng2.Icon   = ContextMenuIcon.GetContextIcon("Palette");
            exportPng2.Click += delegate { ExportToImage(EExportToImageMethod.PNG, false); };
            ContextMenu.Items.Add(exportPng2);

            ContextMenuItem clipboardPng = new ContextMenuItem("Copy as PNG to clipboard");

            clipboardPng.Icon   = ContextMenuIcon.GetContextIcon("Copy");
            clipboardPng.Click += delegate { ExportToImage(EExportToImageMethod.PNGClipBoard); };
            ContextMenu.Items.Add(clipboardPng);

            ContextMenuItem clipboardPng2 = new ContextMenuItem("Copy as PNG to clipboard (no frame)");

            clipboardPng2.Icon   = ContextMenuIcon.GetContextIcon("Copy");
            clipboardPng2.Click += delegate { ExportToImage(EExportToImageMethod.PNGClipBoard, false); };
            ContextMenu.Items.Add(clipboardPng2);

            ContextMenuItem exportXPS = new ContextMenuItem("Export diagram to XPS...");

            exportXPS.Icon   = ContextMenuIcon.GetContextIcon("Palette");
            exportXPS.Click += delegate { ExportToImage(EExportToImageMethod.XPS); };
            ContextMenu.Items.Add(exportXPS);

            ContextMenuItem duplicate = new ContextMenuItem("Duplicate diagram");

            duplicate.Click += delegate
            {
                DuplicateDiagramCommand command =
                    (DuplicateDiagramCommand)
                    DuplicateDiagramCommandFactory.Factory().Create(Controller.ModelController);
                command.Diagram = this.Diagram;
                if (this.Diagram is PIMDiagram)
                {
                    command.PIMElementsOrder = ElementRepresentations.ElementRepresentationOrder;
                }
                command.Execute();
            };
            ContextMenu.Items.Add(duplicate);

            findUnreferencedRoots        = new ContextMenuItem("Find unreferenced root classes");
            findUnreferencedRoots.Click += delegate { SelectUnreferencedRootClasses(); };
            ContextMenu.Items.Add(findUnreferencedRoots);

            findNotNecessaryClasses        = new ContextMenuItem("Find subtrees not required for selected roots");
            findNotNecessaryClasses.Click += delegate { SelectNotRequiredSubtrees(); };
            ContextMenu.Items.Add(findNotNecessaryClasses);

            ContextMenuItem showHideComments = new ContextMenuItem("Show comments");

            showHideComments.IsCheckable = true;
            showHideComments.IsChecked   = true;
            showHideComments.Click      += delegate { ShowHideComments(showHideComments.IsChecked); };
            ContextMenu.Items.Add(showHideComments);
        }