Summary description for DiagramUtil.
        private void CalcLinkSize()
        {
            if (!needCalcLinkSize)
            {
                return;
            }

            Size sizeTmp = Size.Empty;

            if (lines.Length > 1)
            {
                Point[] points = new Point[lines.Length * 2];
                int     i      = 0;
                foreach (LineElement ln in lines)
                {
                    points[i]     = ln.Point1;
                    points[i + 1] = ln.Point2;
                    i            += 2;
                }
                Point upper = DiagramUtil.GetUpperPoint(points);
                Point lower = DiagramUtil.GetLowerPoint(points);

                sizeTmp = new Size(lower.X - upper.X, lower.Y - upper.Y);
            }

            size = sizeTmp;

            needCalcLinkSize = false;
        }
Example #2
0
        internal CardinalDirection GetDirection()
        {
            Rectangle rec      = new Rectangle(parentElement.Location, parentElement.Size);
            Point     refPoint = new Point(this.location.X - parentElement.Location.X + (this.size.Width / 2),
                                           this.location.Y - parentElement.Location.Y + (this.size.Height / 2));

            return(DiagramUtil.GetDirection(rec, refPoint));
        }
Example #3
0
        private void UpdateUpperSelectionPoint()
        {
            //Get upper selecion point
            Point[] points = new Point[document.SelectedElements.Count];
            int     p      = 0;

            foreach (BaseElement el in document.SelectedElements)
            {
                points[p] = el.Location;
                p++;
            }
            upperSelPoint = DiagramUtil.GetUpperPoint(points);
        }
Example #4
0
        private Size MeasureTextSize()
        {
            string text    = labelTextBox.Text;
            Size   sizeTmp = Size.Empty;

            if (direction == LabelEditDirection.UpDown)
            {
                sizeTmp = DiagramUtil.MeasureString(text, labelElement.Font, labelTextBox.Size.Width, labelElement.Format);
            }
            else if (direction == LabelEditDirection.Both)
            {
                sizeTmp = DiagramUtil.MeasureString(text, labelElement.Font);
            }

            sizeTmp.Height += 30;

            return(sizeTmp);
        }
Example #5
0
        public static void SetTextBoxLocation(BaseElement el, TextBox tb)
        {
            if (!(el is ILabelElement))
            {
                return;
            }

            LabelElement lab = ((ILabelElement)el).Label;

            el.Invalidate();
            lab.Invalidate();

            if (lab.Text.Length > 0)
            {
                tb.Location = lab.Location;
                tb.Size     = lab.Size;
            }
            else
            {
                string tmpText = "XXXXXXX";
                Size   sizeTmp = DiagramUtil.MeasureString(tmpText, lab.Font, lab.Size.Width, lab.Format);

                if (el is BaseLinkElement)
                {
                    tb.Size     = sizeTmp;
                    tb.Location = new Point(el.Location.X + (el.Size.Width / 2) - (sizeTmp.Width / 2),
                                            el.Location.Y + (el.Size.Height / 2) - (sizeTmp.Height / 2));
                }
                else
                {
                    sizeTmp.Width = el.Size.Width;
                    tb.Size       = sizeTmp;
                    tb.Location   = new Point(el.Location.X,
                                              el.Location.Y + (el.Size.Height / 2) - (sizeTmp.Height / 2));
                }
            }

            SetTextBoxBorder(tb);
        }
        private void CalcLinkLocation()
        {
            //CalcLink();

            if (!needCalcLinkLocation)
            {
                return;
            }

            Point[] points = new Point[lines.Length * 2];
            int     i      = 0;

            foreach (LineElement ln in lines)
            {
                points[i]     = ln.Point1;
                points[i + 1] = ln.Point2;
                i            += 2;
            }

            location = DiagramUtil.GetUpperPoint(points);

            needCalcLinkLocation = false;
        }