コード例 #1
0
ファイル: QueryDesigner.cs プロジェクト: crstnsz/VisualQuery
        /// <summary>
        /// Adiciona um Join visual ao Editor
        /// </summary>
        /// <param name="join"></param>
        void AddVisualJoin(Join join)
        {
            _query.Joins.Add(join);
            VisualJoin _visualObject = new VisualJoin();

            _visualObject.Top          = 10;
            _visualObject.Left         = 10;
            _visualObject.Join         = join;
            _visualObject.JoinChanged += new JoinEventHandler(visualJoin_JoinChanged);
            _visualObject.JoinDeleted += new JoinEventHandler(visualJoin_JoinDeleted);
            _visualObject.TableLeft    = _visualTables[join.Left.Table.FullName];
            _visualObject.TableRight   = _visualTables[join.Right.Table.FullName];
            _visualJoins.Add(_visualObject);

            this.splitContainerWork.Panel1.Controls.Add(_visualObject);
        }
コード例 #2
0
ファイル: QueryDesigner.cs プロジェクト: crstnsz/VisualQuery
        /// <summary>
        /// Desenha o Join na Área de Edição
        /// </summary>
        /// <param name="e">Argumento de Desenho. Ponteiro para o pintor do Windows</param>
        /// <param name="visualJoin">Elemento visual do Join</param>
        /// <param name="leftPoint">Ponto que indica Onde se encontra a tabela a esquerda</param>
        /// <param name="leftSize">Largura e Altura do Objeto a esquerda</param>
        /// <param name="rightPoint">Ponto que indica Onde se encontra a tabela a direita</param>
        /// <param name="rightSize">Largura e Altura do Objeto a esquerda</param>
        private void DrawJoin(PaintEventArgs e, VisualJoin visualJoin, Point leftPoint, Size leftSize, Point rightPoint, Size rightSize)
        {
            // Caneta para desenhas as linhas.
            Pen bluePen = new Pen(Color.Blue, 2);

            Point _leftLineStart;
            Point _leftLineEnd;
            Point _rightLineStart;
            Point _rightLineEnd;
            Point _linkTopLineStart;
            Point _linkTopLineEnd;
            Point _linkBottonLineStart;
            Point _linkBottonLineEnd;


            bool _twoByLeft = false;

            // Verifica se a conexão vai acontecer toda pela esquerda. caso em que tabela da direita está antes da tabela da esquerda
            if (leftPoint.X + leftSize.Width > rightPoint.X)
            {
                _twoByLeft     = true;
                _leftLineStart = new Point(leftPoint.X - 80, leftPoint.Y);
                _leftLineEnd   = leftPoint;

                _rightLineStart = new Point(_leftLineStart.X, rightPoint.Y);
                _rightLineEnd   = rightPoint;

                if (leftPoint.Y < rightPoint.Y)
                {
                    _linkTopLineStart = _leftLineStart;
                    _linkTopLineEnd   = _rightLineStart;
                }
                else
                {
                    _linkTopLineStart = _rightLineStart;
                    _linkTopLineEnd   = _leftLineStart;
                }
            }
            else
            {
                _leftLineStart = new Point(leftPoint.X + leftSize.Width, leftPoint.Y);
                _rightLineEnd  = rightPoint;

                int _midle = (_leftLineStart.X + _rightLineEnd.X) / 2;

                _leftLineEnd    = new Point(_midle, _leftLineStart.Y);
                _rightLineStart = new Point(_midle, _rightLineEnd.Y);

                if (leftPoint.Y < rightPoint.Y)
                {
                    _linkTopLineStart = _leftLineEnd;
                    _linkTopLineEnd   = _rightLineStart;
                }
                else
                {
                    _linkTopLineStart = _rightLineStart;
                    _linkTopLineEnd   = _leftLineEnd;
                }
            }

            Point _joinPosition = new Point(((_linkTopLineStart.X + _linkTopLineEnd.X) / 2) - visualJoin.UnitHeight / 2,
                                            ((_linkTopLineStart.Y + _linkTopLineEnd.Y) / 2) - visualJoin.UnitHeight / 2);

            if (_joinPosition != visualJoin.Location)
            {
                visualJoin.Location = _joinPosition;
            }

            _linkBottonLineEnd   = _linkTopLineEnd;
            _linkTopLineEnd.Y    = visualJoin.Top;
            _linkBottonLineStart = new Point(_linkTopLineEnd.X, visualJoin.Top + visualJoin.Height);

            bool _midleLine = true;

            if (_twoByLeft)
            {
                if (_leftLineStart.Y > visualJoin.Top && _leftLineStart.Y < visualJoin.Top + visualJoin.Height)
                {
                    _leftLineStart.X  = visualJoin.Left + visualJoin.Width;
                    _rightLineStart.X = visualJoin.Left + visualJoin.Width;
                    _midleLine        = false;
                }
            }
            else
            {
                if (_leftLineStart.Y > visualJoin.Top && _leftLineStart.Y < visualJoin.Top + visualJoin.Height)
                {
                    _leftLineEnd.X    = visualJoin.Left;
                    _rightLineStart.X = visualJoin.Left + visualJoin.Width;
                    _midleLine        = false;
                }
            }

            if (_twoByLeft)
            {
                e.Graphics.DrawLine(bluePen, new PointF(_leftLineStart.X, _leftLineStart.Y), new PointF(_leftLineEnd.X, _leftLineEnd.Y));
                if (_midleLine)
                {
                    e.Graphics.DrawLine(bluePen, new PointF(_linkTopLineStart.X, _linkTopLineStart.Y), new PointF(_linkTopLineEnd.X, _linkTopLineEnd.Y));
                    e.Graphics.DrawLine(bluePen, new PointF(_linkBottonLineStart.X, _linkBottonLineStart.Y), new PointF(_linkBottonLineEnd.X, _linkBottonLineEnd.Y));
                }
                e.Graphics.DrawLine(bluePen, new PointF(_rightLineStart.X, _rightLineStart.Y), new PointF(_rightLineEnd.X, _rightLineEnd.Y));
            }
            else
            {
                e.Graphics.DrawLine(bluePen, new PointF(_leftLineStart.X, _leftLineStart.Y), new PointF(_rightLineEnd.X, _rightLineEnd.Y));
            }
        }