Exemplo n.º 1
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);
        }
Exemplo n.º 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;
		}
Exemplo n.º 3
0
        public static Size GetTipSize(Control control, Graphics graphics, TipSection tipData)
        {
            Size  tipSize  = Size.Empty;
            SizeF tipSizeF = SizeF.Empty;

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

                workingArea = Screen.GetWorkingArea(ownerForm);
            }

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

            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;
            }

            return(tipSize);
        }
Exemplo n.º 4
0
		public static Size GetTipSize(Control control, Graphics graphics, TipSection tipData)
		{
			Size tipSize = Size.Empty;
			SizeF tipSizeF = SizeF.Empty;
			
			if (workingArea == RectangleF.Empty) {
				Form ownerForm = control.FindForm();
				if (ownerForm.Owner != null) {
					ownerForm = ownerForm.Owner;
				}
				
				workingArea = Screen.GetWorkingArea(ownerForm);
			}
			
			PointF screenLocation = control.PointToScreen(Point.Empty);
			
			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;
			}
			
			return tipSize;
		}
Exemplo n.º 5
0
        protected override void OnMaximumSizeChanged()
        {
            base.OnMaximumSizeChanged();

            float currentDim    = 0;
            float otherDim      = 0;
            SizeF availableArea = MaximumSize;

            for (int i = 0; i < tipSections.Length; i++)
            {
                TipSection section = (TipSection)tipSections[i];

                section.SetMaximumSize(availableArea);

                SizeF requiredArea = section.GetRequiredSize();
                offsets[i] = currentDim;

                // It's best to start on pixel borders, so this will
                // round up to the nearest pixel. Otherwise there are
                // weird cutoff artifacts.
                float pixelsUsed;

                if (isHorizontal)
                {
                    pixelsUsed  = (float)Math.Ceiling(requiredArea.Width);
                    currentDim += pixelsUsed;

                    availableArea.Width = Math.Max
                                              (0, availableArea.Width - pixelsUsed);

                    otherDim = Math.Max(otherDim, requiredArea.Height);
                }
                else
                {
                    pixelsUsed  = (float)Math.Ceiling(requiredArea.Height);
                    currentDim += pixelsUsed;

                    availableArea.Height = Math.Max
                                               (0, availableArea.Height - pixelsUsed);

                    otherDim = Math.Max(otherDim, requiredArea.Width);
                }
            }

            foreach (TipSection section in tipSections)
            {
                if (isHorizontal)
                {
                    section.SetAllocatedSize(new SizeF(section.GetRequiredSize().Width, otherDim));
                }
                else
                {
                    section.SetAllocatedSize(new SizeF(otherDim, section.GetRequiredSize().Height));
                }
            }

            if (isHorizontal)
            {
                SetRequiredSize(new SizeF(currentDim, otherDim));
            }
            else
            {
                SetRequiredSize(new SizeF(otherDim, currentDim));
            }
        }