public static Size DrawTip(Control control, Graphics graphics, TipSection tipData)
        {
            Size       empty        = Size.Empty;
            SizeF      requiredSize = SizeF.Empty;
            PointF     screen       = control.PointToScreen(Point.Empty);
            RectangleF workingArea  = TipPainter.GetWorkingArea(control);
            SizeF      sizeF        = new SizeF(workingArea.Right - screen.X - 4f, workingArea.Bottom - screen.Y - 2f);

            if (sizeF.Width > 0f && sizeF.Height > 0f)
            {
                graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
                tipData.SetMaximumSize(sizeF);
                requiredSize = tipData.GetRequiredSize();
                tipData.SetAllocatedSize(requiredSize);
                requiredSize += new SizeF(4f, 2f);
                empty         = Size.Ceiling(requiredSize);
            }
            if (control.ClientSize != empty)
            {
                control.ClientSize = empty;
            }
            if (empty != Size.Empty)
            {
                Rectangle  rectangle  = new Rectangle(Point.Empty, empty - new Size(1, 1));
                RectangleF rectangleF = new RectangleF(2f, 1f, requiredSize.Width - 4f, requiredSize.Height - 2f);
                graphics.DrawRectangle(SystemPens.WindowFrame, rectangle);
                tipData.Draw(new PointF(2f, 1f));
            }
            return(empty);
        }
示例#2
0
        public static Size DrawTip(Control control, Graphics graphics, TipSection tipData)
        {
            Size  tipSize  = Size.Empty;
            SizeF tipSizeF = SizeF.Empty;

            PointF screenLocation = control.PointToScreen(Point.Empty);

            if (workingArea == RectangleF.Empty)
            {
                Form ownerForm = control.FindForm();
                if (ownerForm.Owner != null)
                {
                    ownerForm = ownerForm.Owner;
                }

                workingArea = Screen.GetWorkingArea(ownerForm);
            }

            SizeF maxLayoutSize = new SizeF(workingArea.Right - screenLocation.X - HorizontalBorder * 2,
                                            workingArea.Bottom - screenLocation.Y - VerticalBorder * 2);

            if (maxLayoutSize.Width > 0 && maxLayoutSize.Height > 0)
            {
                graphics.TextRenderingHint =
                    TextRenderingHint.AntiAliasGridFit;

                tipData.SetMaximumSize(maxLayoutSize);
                tipSizeF = tipData.GetRequiredSize();
                tipData.SetAllocatedSize(tipSizeF);

                tipSizeF += new SizeF(HorizontalBorder * 2,
                                      VerticalBorder * 2);
                tipSize = Size.Ceiling(tipSizeF);
            }

            if (control.ClientSize != tipSize)
            {
                control.ClientSize = tipSize;
            }

            if (tipSize != Size.Empty)
            {
                Rectangle borderRectangle = new Rectangle
                                                (Point.Empty, tipSize - new Size(1, 1));

                RectangleF displayRectangle = new RectangleF
                                                  (HorizontalBorder, VerticalBorder,
                                                  tipSizeF.Width - HorizontalBorder * 2,
                                                  tipSizeF.Height - VerticalBorder * 2);

                // DrawRectangle draws from Left to Left + Width. A bug? :-/
                graphics.DrawRectangle(SystemPens.WindowFrame,
                                       borderRectangle);
                tipData.Draw(new PointF(HorizontalBorder, VerticalBorder));
            }
            return(tipSize);
        }
示例#3
0
        public static Size DrawFixedWidthTip(Control control, Graphics graphics, TipSection tipData)
        {
            var tipSize  = Size.Empty;
            var tipSizeF = SizeF.Empty;

            PointF screenLocation = control.PointToScreen(new Point(control.Width, y: 0));

            RectangleF workingArea = GetWorkingArea(control);

            var maxLayoutSize = new SizeF(
                screenLocation.X - HorizontalBorder * 2,
                workingArea.Bottom - screenLocation.Y - VerticalBorder * 2);

            if (maxLayoutSize.Width > 0 && maxLayoutSize.Height > 0)
            {
                graphics.TextRenderingHint =
                    TextRenderingHint.AntiAliasGridFit;

                tipData.SetMaximumSize(maxLayoutSize);
                tipSizeF = tipData.GetRequiredSize();
                tipData.SetAllocatedSize(tipSizeF);

                tipSizeF += new SizeF(
                    HorizontalBorder * 2,
                    VerticalBorder * 2);
                tipSize = Size.Ceiling(tipSizeF);
            }

            if (control.Height != tipSize.Height)
            {
                control.Height = tipSize.Height;
            }

            if (tipSize != Size.Empty)
            {
                var borderRectangle = new Rectangle
                                          (Point.Empty, control.Size - new Size(width: 1, height: 1));

//                var displayRectangle = new RectangleF
//                (
//                    HorizontalBorder, VerticalBorder,
//                    tipSizeF.Width - HorizontalBorder*2,
//                    tipSizeF.Height - VerticalBorder*2);

                // DrawRectangle draws from Left to Left + Width. A bug? :-/
                graphics.DrawRectangle(
                    SystemPens.WindowFrame,
                    borderRectangle);
                tipData.Draw(new PointF(HorizontalBorder, VerticalBorder));
            }

            return(tipSize);
        }
        public static Size DrawTip(Control control, Graphics graphics, TipSection tipData)
        {
            Size tipSize = Size.Empty;
            SizeF tipSizeF = SizeF.Empty;

            PointF screenLocation = control.PointToScreen(Point.Empty);

            if (workingArea == RectangleF.Empty) {
                Form ownerForm = control.FindForm();
                if (ownerForm.Owner != null) {
                    ownerForm = ownerForm.Owner;
                }

                workingArea = Screen.GetWorkingArea(ownerForm);
            }

            SizeF maxLayoutSize = new SizeF(workingArea.Right - screenLocation.X - HorizontalBorder * 2,
                                            workingArea.Bottom - screenLocation.Y - VerticalBorder * 2);

            if (maxLayoutSize.Width > 0 && maxLayoutSize.Height > 0) {
                graphics.TextRenderingHint =
                TextRenderingHint.AntiAliasGridFit;

                tipData.SetMaximumSize(maxLayoutSize);
                tipSizeF = tipData.GetRequiredSize();
                tipData.SetAllocatedSize(tipSizeF);

                tipSizeF += new SizeF(HorizontalBorder * 2,
                                      VerticalBorder   * 2);
                tipSize = Size.Ceiling(tipSizeF);
            }

            if (control.ClientSize != tipSize) {
                control.ClientSize = tipSize;
            }

            if (tipSize != Size.Empty) {
                Rectangle borderRectangle = new Rectangle
                (Point.Empty, tipSize - new Size(1, 1));

                RectangleF displayRectangle = new RectangleF
                (HorizontalBorder, VerticalBorder,
                 tipSizeF.Width - HorizontalBorder * 2,
                 tipSizeF.Height - VerticalBorder * 2);

                // DrawRectangle draws from Left to Left + Width. A bug? :-/
                graphics.DrawRectangle(SystemPens.WindowFrame,
                                       borderRectangle);
                tipData.Draw(new PointF(HorizontalBorder, VerticalBorder));
            }
            return tipSize;
        }
示例#5
0
        public static Size DrawTip(Control control, Graphics graphics, TipSection tipData)
        {
            Size  tipSize  = Size.Empty;
            SizeF tipSizeF = SizeF.Empty;

            PointF screenLocation = control.PointToScreen(Point.Empty);

            RectangleF workingArea = GetWorkingArea(control);

            SizeF maxLayoutSize = new SizeF(workingArea.Right - screenLocation.X - HorizontalBorder * 2,
                                            workingArea.Bottom - screenLocation.Y - VerticalBorder * 2);

            if (maxLayoutSize.Width > 0 && maxLayoutSize.Height > 0)
            {
                graphics.TextRenderingHint =
                    TextRenderingHint.ClearTypeGridFit;
                graphics.TextContrast = 0;

                tipData.SetMaximumSize(maxLayoutSize);
                tipSizeF = tipData.GetRequiredSize();
                tipData.SetAllocatedSize(tipSizeF);

                tipSizeF += new SizeF(HorizontalBorder * 2,
                                      VerticalBorder * 2);
                tipSize = Size.Ceiling(tipSizeF);
            }

            if (control.ClientSize != tipSize)
            {
                control.ClientSize = tipSize;
            }

            if (tipSize != Size.Empty)
            {
                Rectangle borderRectangle = new Rectangle
                                                (Point.Empty, tipSize - new Size(1, 1));

                RectangleF displayRectangle = new RectangleF
                                                  (HorizontalBorder, VerticalBorder,
                                                  tipSizeF.Width - HorizontalBorder * 2,
                                                  tipSizeF.Height - VerticalBorder * 2);

                Pen borderFrame = new Pen((darkScheme) ? Color.FromArgb(0x70, 0x70, 0x80) : Color.Black);

                // DrawRectangle draws from Left to Left + Width. A bug? :-/
                graphics.DrawRectangle(borderFrame,
                                       borderRectangle);
                tipData.Draw(new PointF(HorizontalBorder, VerticalBorder));
            }
            return(tipSize);
        }
示例#6
0
        public static Size DrawFixedWidthTip(Control control, Graphics graphics, TipSection tipData)
        {
            Size tipSize = Size.Empty;
            SizeF tipSizeF = SizeF.Empty;

            PointF screenLocation = control.PointToScreen(new Point(control.Width, 0));

            RectangleF workingArea = GetWorkingArea(control);

            SizeF maxLayoutSize = new SizeF(screenLocation.X - HorizontalBorder * 2,
                                            workingArea.Bottom - screenLocation.Y - VerticalBorder * 2);

            if (maxLayoutSize.Width > 0 && maxLayoutSize.Height > 0) {
                graphics.TextRenderingHint =
                    TextRenderingHint.AntiAliasGridFit;

                tipData.SetMaximumSize(maxLayoutSize);
                tipSizeF = tipData.GetRequiredSize();
                tipData.SetAllocatedSize(tipSizeF);

                tipSizeF += new SizeF(HorizontalBorder * 2,
                                      VerticalBorder   * 2);
                tipSize = Size.Ceiling(tipSizeF);
            }

            if (control.Height != tipSize.Height) {
                control.Height = tipSize.Height;
            }

            if (tipSize != Size.Empty) {
                Rectangle borderRectangle = new Rectangle
                    (Point.Empty, control.Size - new Size(1, 1));

                RectangleF displayRectangle = new RectangleF
                    (HorizontalBorder, VerticalBorder,
                     tipSizeF.Width - HorizontalBorder * 2,
                     tipSizeF.Height - VerticalBorder * 2);

                // DrawRectangle draws from Left to Left + Width. A bug? :-/
                graphics.DrawRectangle(SystemPens.WindowFrame,
                                       borderRectangle);
                tipData.Draw(new PointF(HorizontalBorder, VerticalBorder));
            }
            return tipSize;
        }
示例#7
0
		public static Size DrawTip(Control control, Graphics graphics, TipSection tipData)
		{
			Size tipSize = Size.Empty;
			SizeF tipSizeF = SizeF.Empty;
			
			PointF screenLocation = control.PointToScreen(Point.Empty);
			
			if (workingArea == RectangleF.Empty) {
				Form ownerForm = control.FindForm();
				if (ownerForm.Owner != null) {
					ownerForm = ownerForm.Owner;
				}
				
				workingArea = Screen.GetWorkingArea(ownerForm);
			}
				
			SizeF maxLayoutSize = new SizeF(workingArea.Right /*- screenLocation.X*/ - HorizontalBorder * 2,
			                                workingArea.Bottom /*- screenLocation.Y*/ - VerticalBorder * 2);
			if (maxLayoutSize.Width > 0 && maxLayoutSize.Height > 0) {
				/*graphics.TextRenderingHint =
				TextRenderingHint.AntiAliasGridFit;*/
				
				tipData.SetMaximumSize(maxLayoutSize);
				tipSizeF = tipData.GetRequiredSize();
				tipData.SetAllocatedSize(tipSizeF);
				
				tipSizeF += new SizeF(HorizontalBorder * 2,
				                      VerticalBorder   * 2);
				tipSize = Size.Ceiling(tipSizeF);
			}
			
			if (control is ICSharpCode.TextEditor.Gui.InsightWindow.PABCNETInsightWindow)
			{
				Rectangle rect = Rectangle.Ceiling(workingArea);
				Point pt = (control as ICSharpCode.TextEditor.Gui.InsightWindow.PABCNETInsightWindow).GetCusorCoord();
				if (pt.X + tipSize.Width > rect.Width)
				{
					control.Location = new Point(rect.Width-tipSize.Width,pt.Y);
				}
			}
			else
			{
				Rectangle rect = Rectangle.Ceiling(workingArea);
				Point pt = control.Location;
				if (pt.X + tipSize.Width > rect.Width)
				{
					if (rect.Width-tipSize.Width > 0)
					control.Location = new Point(rect.Width-tipSize.Width,pt.Y);
					else
					control.Location = new Point(10,pt.Y);
				}
			}
			
			if (control.ClientSize != tipSize) {
				control.ClientSize = tipSize;
			}
			
			if (tipSize != Size.Empty) {
				Rectangle borderRectangle = new Rectangle
				(Point.Empty, tipSize - new Size(1, 1));
				
				RectangleF displayRectangle = new RectangleF
				(HorizontalBorder, VerticalBorder,
				 tipSizeF.Width - HorizontalBorder * 2,
				 tipSizeF.Height - VerticalBorder * 2);
				
				// DrawRectangle draws from Left to Left + Width. A bug? :-/
				graphics.DrawRectangle(SystemPens.WindowFrame,
				                       borderRectangle);
				tipData.Draw(new PointF(HorizontalBorder, VerticalBorder));
			}
			return tipSize;
		}
示例#8
0
        public static Size DrawTip(Control control, Graphics graphics, TipSection tipData)
        {
            Size  tipSize  = Size.Empty;
            SizeF tipSizeF = SizeF.Empty;

            PointF screenLocation = control.PointToScreen(Point.Empty);

            if (workingArea == RectangleF.Empty)
            {
                Form ownerForm = control.FindForm();
                if (ownerForm.Owner != null)
                {
                    ownerForm = ownerForm.Owner;
                }

                workingArea = Screen.GetWorkingArea(ownerForm);
            }

            SizeF maxLayoutSize = new SizeF(workingArea.Right /*- screenLocation.X*/ - HorizontalBorder * 2,
                                            workingArea.Bottom /*- screenLocation.Y*/ - VerticalBorder * 2);

            if (maxLayoutSize.Width > 0 && maxLayoutSize.Height > 0)
            {
                /*graphics.TextRenderingHint =
                 * TextRenderingHint.AntiAliasGridFit;*/

                tipData.SetMaximumSize(maxLayoutSize);
                tipSizeF = tipData.GetRequiredSize();
                tipData.SetAllocatedSize(tipSizeF);

                tipSizeF += new SizeF(HorizontalBorder * 2,
                                      VerticalBorder * 2);
                tipSize = Size.Ceiling(tipSizeF);
            }

            if (control is ICSharpCode.TextEditor.Gui.InsightWindow.PABCNETInsightWindow)
            {
                Rectangle rect = Rectangle.Ceiling(workingArea);
                Point     pt   = (control as ICSharpCode.TextEditor.Gui.InsightWindow.PABCNETInsightWindow).GetCusorCoord();
                if (pt.X + tipSize.Width > rect.Width)
                {
                    control.Location = new Point(rect.Width - tipSize.Width, pt.Y);
                }
            }
            else
            {
                Rectangle rect = Rectangle.Ceiling(workingArea);
                Point     pt   = control.Location;
                if (pt.X + tipSize.Width > rect.Width)
                {
                    if (rect.Width - tipSize.Width > 0)
                    {
                        control.Location = new Point(rect.Width - tipSize.Width, pt.Y);
                    }
                    else
                    {
                        control.Location = new Point(10, pt.Y);
                    }
                }
            }

            if (control.ClientSize != tipSize)
            {
                control.ClientSize = tipSize;
            }

            if (tipSize != Size.Empty)
            {
                Rectangle borderRectangle = new Rectangle
                                                (Point.Empty, tipSize - new Size(1, 1));

                RectangleF displayRectangle = new RectangleF
                                                  (HorizontalBorder, VerticalBorder,
                                                  tipSizeF.Width - HorizontalBorder * 2,
                                                  tipSizeF.Height - VerticalBorder * 2);

                // DrawRectangle draws from Left to Left + Width. A bug? :-/
                graphics.DrawRectangle(SystemPens.WindowFrame,
                                       borderRectangle);
                tipData.Draw(new PointF(HorizontalBorder, VerticalBorder));
            }
            return(tipSize);
        }