Esempio n. 1
0
        private AssociationLabel CreateFellowLabel(AssociationLabelViewHelper labelViewHelper)
        {
            AssociationLabel associationLabel = new AssociationLabel(this.XCaseCanvas, labelViewHelper);

            Junction.XCaseCanvas.Children.Add(associationLabel);
            associationLabel.Text = " ";
            associationLabel.SnapTo(Junction.Points.Last(), false);
            associationLabel.UpdateLayout();
            Canvas.SetZIndex(associationLabel, Canvas.GetZIndex(Junction.SourceElement) + 1);
            associationLabel.PSM_Association = this;
            return(associationLabel);
        }
Esempio n. 2
0
        private AssociationLabel CreateFellowLabel(AssociationLabelViewHelper labelViewHelper)
        {
            AssociationLabel associationLabel = new AssociationLabel(this.XCaseCanvas, labelViewHelper);

            associationLabel.Association = this.Association;
            Junction.XCaseCanvas.Children.Add(associationLabel);
            associationLabel.Text = " ";
            associationLabel.SnapTo(this, false);
            associationLabel.AssociationEnd = this.AssociationEnd;
            associationLabel.UpdateLayout();
            Canvas.SetZIndex(associationLabel, Canvas.GetZIndex(Junction.SourceElement) + 1);
            associationLabel.Dropped += (() => LabelDropped(associationLabel));
            return(associationLabel);
        }
Esempio n. 3
0
        private static bool LabelInBadPosition(AssociationLabel label, Rect elementBounds)
        {
            const int rectangleCorrectionH = 3;
            const int rectangleCorrectionV = 6;

            Rect bounds = label.GetBounds();

            bounds.X     += rectangleCorrectionV;
            bounds.Y     += rectangleCorrectionH;
            bounds.Width  = Math.Max(bounds.Width - 2 * rectangleCorrectionV, 0);
            bounds.Height = Math.Max(bounds.Height - 2 * rectangleCorrectionH, 0);
            if (bounds.IntersectsWith(elementBounds))
            {
                return(true);
            }
            return(false);
        }
Esempio n. 4
0
        private void LabelDropped(AssociationLabel label)
        {
            IConnectable junctionElement;

            if (Junction.StartPoint == this)
            {
                junctionElement = (IConnectable)Junction.SourceElement;
            }
            else
            {
                junctionElement = (IConnectable)Junction.TargetElement;
            }

            Rect elementBounds = junctionElement.GetBounds();

            if (LabelInBadPosition(label, elementBounds))
            {
                AdjustLabelsPositions();
            }
        }