Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XCaseJunction"/> class.
 /// </summary>
 /// <param name="xCaseCanvas">canvas where the control is placed</param>
 /// <param name="association">association that owns the junction</param>
 /// <param name="viewHelperPointsCollection">Reference to a collection of points (in ViewHelper)</param>
 public XCaseJunction(XCaseCanvas xCaseCanvas, PIM_Association association, ObservablePointCollection viewHelperPointsCollection) :
     this(xCaseCanvas, viewHelperPointsCollection)
 {
     this.Association    = association;
     this.SelectionOwner = association;
     InitializeContextMenu();
 }
Пример #2
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 override void InitializeRepresentant(Element modelElement, ViewHelper viewHelper, ElementController controller)
        {
            PIM_Association associationRepresentant = new PIM_Association(XCaseCanvas);

            associationRepresentant.InitializeRepresentant(modelElement, ((AssociationClassViewHelper)viewHelper).AssociationViewHelper,
                                                           new AssociationController((Association)modelElement, controller.DiagramController));

            Association = associationRepresentant;
            Association.AssociationClass = this;
            Association.AssociationName  = null;
            Association.ViewHelper.MainLabelViewHelper.LabelVisible = false;

            AssociationClassViewHelper _viewHelper = (AssociationClassViewHelper)viewHelper;

            if (double.IsNaN(_viewHelper.X) || double.IsNaN(_viewHelper.Y))
            {
                Rect r = RectExtensions.GetEncompassingRectangle(associationRepresentant.participantElements.Values);
                if (associationRepresentant.participantElements.Count > 2)
                {
                    _viewHelper.X = r.GetCenter().X + 30;
                    _viewHelper.Y = r.GetCenter().Y;
                }
                else
                {
                    _viewHelper.X = r.GetCenter().X;
                    _viewHelper.Y = r.GetCenter().Y + 20;
                }
            }


            base.InitializeRepresentant(modelElement, viewHelper, controller);

            if (associationRepresentant.ViewHelper.UseDiamond)
            {
                if (((AssociationClassViewHelper)ViewHelper).Points.Count == 0)
                {
                    ((AssociationClassViewHelper)ViewHelper).Points.AppendRange(
                        JunctionGeometryHelper.ComputeOptimalConnection(this, associationRepresentant.Diamond));
                    ((AssociationClassViewHelper)ViewHelper).Points.PointsInvalid = true;
                }
                junction = new XCaseJunction(XCaseCanvas, ((AssociationClassViewHelper)ViewHelper).Points)
                {
                    Pen = MediaLibrary.DashedBlackPen
                };
                XCaseCanvas.Children.Add(junction);
                junction.NewConnection(this, null, Association.Diamond, null,
                                       ((AssociationClassViewHelper)ViewHelper).Points);
                junction.SelectionOwner = this;
            }
            else
            {
                primitiveJunction = new XCasePrimitiveJunction(XCaseCanvas, this, Association)
                {
                    Pen = MediaLibrary.DashedBlackPen
                };
            }
            this.StartBindings();
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AssociationDiamond"/> class.
        /// </summary>
        /// <param name="xCaseCanvas">Canvas where the control is placed</param>
        /// <param name="association">Association belonging to the association diamond</param>
        /// <param name="viewHelper">ViewHelper for the control</param>
        public AssociationDiamond(XCaseCanvas xCaseCanvas, PIM_Association association, PositionableElementViewHelper viewHelper)
            : base(xCaseCanvas)
        {
            #region AssociationDiamond Template init
            Template = (ControlTemplate)Application.Current.Resources["AssociationDiamondTemplate"];
            ApplyTemplate();

            AssociationDiamondTemplate gr = (AssociationDiamondTemplate)Template.FindName("AssociationDiamondGrid", this);

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

            Association     = association;
            this.viewHelper = viewHelper;

            this.StartBindings(TypeBindingData.EBindingSourceType.View);
        }