예제 #1
0
        public ReferenceCanvas(SubjectReferenceView view, SubjectCanvas subject, SubjectCanvas target)
        {
            View = view;

            Subject = subject;

            Target = target;

            if (View.type == ReferencesType.Dependency || View.type == ReferencesType.Realization)
            {
                _BindingCreator.Type = PathType.Dashed;
            }

            _PathBinding = _BindingCreator.Create(GeometryCreator.Create(this));

            Arrow = new ArrowCanvas(this);
        }
예제 #2
0
        public LabelBinding(SubjectCanvas subject)
        {
            switch (subject.View.type)
            {
            case SubjectType.Abstract_Class:
                Text = "<<Abstract class>>\n" + subject.View.Name;
                break;

            case SubjectType.Interface:
                Text = "<<Interface>>\n" + subject.View.Name;
                break;

            case SubjectType.Class:
                Text = "<<Class>>\n" + subject.View.Name;
                break;

            default:
                throw new Exception("Subject cannot be a basic type");
            }

            Left = (int)(subject.Center.X - (subject.Width / 2));

            Top = (int)(subject.Center.Y - (subject.Height / 4));
        }
예제 #3
0
        /// <summary>
        /// Returns 4 Points.
        /// 1 - touch subject,
        /// 2 - перпендикулярна 1 на відстані ArrowLength,
        /// 3 - аналогічно 2, але рядом з 4,
        /// 4 - touch target
        /// </summary>
        /// <param name="element">ReferenceCanvas</param>
        /// <returns></returns>
        public static IList <Point> GetPoints(ICanvasElement element)
        {
            var reference = (ReferenceCanvas)element;

            var vector = reference.Subject.Center - reference.Target.Center;

            List <Point> points = null;

            SubjectCanvas first = null; SubjectCanvas second = null;

            if (Math.Abs(vector.X) <= Math.Abs(vector.Y))
            {
                if (reference.Subject.Center.Y < reference.Target.Center.Y)
                {
                    first  = reference.Target;
                    second = reference.Subject;
                }
                else
                {
                    first  = reference.Subject;
                    second = reference.Target;
                }

                points = new List <Point>()
                {
                    new Point()
                    {
                        X = first.Center.X,
                        Y = first.Center.Y - (first.Height / 2.0)
                    },
                    new Point()
                    {
                        X = first.Center.X,
                        Y = first.Center.Y - (first.Height / 2.0) - ArrowLength
                    },
                    new Point()
                    {
                        X = second.Center.X,
                        Y = second.Center.Y + (second.Height / 2.0) + ArrowLength
                    },
                    new Point()
                    {
                        X = second.Center.X,
                        Y = second.Center.Y + (second.Height / 2.0)
                    },
                };
            }
            else
            {
                if (reference.Subject.Center.X < reference.Target.Center.X)
                {
                    first  = reference.Subject;
                    second = reference.Target;
                }
                else
                {
                    first  = reference.Target;
                    second = reference.Subject;
                }

                points = new List <Point>()
                {
                    new Point()
                    {
                        X = first.Center.X + (first.Width / 2.0),
                        Y = first.Center.Y
                    },
                    new Point()
                    {
                        X = first.Center.X + (first.Width / 2.0) + ArrowLength,
                        Y = first.Center.Y
                    },
                    new Point()
                    {
                        X = second.Center.X - (second.Width / 2.0) - ArrowLength,
                        Y = second.Center.Y
                    },
                    new Point()
                    {
                        X = second.Center.X - (second.Width / 2.0),
                        Y = second.Center.Y
                    },
                };
            }

            if (first.Center != reference.Subject.Center)
            {
                points.Reverse();
            }

            return(points);
        }