Exemplo n.º 1
0
        public void SetPosition(SyntaxRichTextBox syntaxRichTextBox, Point p)
        {
            Rectangle rect   = Screen.PrimaryScreen.WorkingArea;
            Point     screen = syntaxRichTextBox.PointToScreen(new Point(p.X - 20, p.Y + syntaxRichTextBox.LineHeight));

            if ((screen.Y + this.Height) > rect.Height)
            {
                screen = syntaxRichTextBox.PointToScreen(new Point(p.X - 20, p.Y - this.Height));
            }

            if ((screen.X + this.Width) > rect.Width)
            {
                screen.X = rect.Width - this.Width;
            }

            if (screen.X < rect.Left)
            {
                screen.X = rect.Left;
            }

            if (screen.Y < rect.Top)
            {
                screen.Y = rect.Top;
            }

            this.Location = screen;
        }
Exemplo n.º 2
0
        public void SetPosition(Rectangle rect, SyntaxRichTextBox syntaxRichTextBox)
        {
            //Rectangle rect = Screen.PrimaryScreen.WorkingArea;
            Point p = syntaxRichTextBox.GetPositionFromCharIndex(syntaxRichTextBox.SelectionStart);

            p = new Point(p.X - 20 + this.XOffset + 2, p.Y + 2 + syntaxRichTextBox.LineHeight);

            Rectangle client = Screen.PrimaryScreen.WorkingArea;             //  syntaxRichTextBox.ClientRectangle;

            if (p.X < client.Left || p.Y < client.Top || p.X > client.Width || p.Y > client.Height)
            {
                this.Visible = false;
                return;
            }

            Point screen = syntaxRichTextBox.PointToScreen(p);

            //if ((screen.Y + this.Height) > rect.Height)
            //	screen = RichTextBox.PointToScreen(new Point(p.X - 20 + this.XOffset, p.Y - this.Height));

            if (screen.Y > rect.Bottom)
            {
                this.Visible = false;
                return;
                //screen.Y = rect.Bottom;
            }

            if (screen.X > rect.Right)
            {
                this.Visible = false;
                return;
                //screen.X = rect.Right;
            }

            if (screen.X < rect.Left)
            {
                this.Visible = false;
                return;
                //screen.X = rect.Left;
            }

            if ((screen.Y) < rect.Top)
            {
                this.Visible = false;
                return;
                //screen.Y = rect.Top;
            }

            this.Location = screen;
        }