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); }
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); }
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); }
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(); } }