public void Display(Skybound.VisualTips.VisualTipProvider provider, Skybound.VisualTips.VisualTip tip, System.Drawing.Rectangle toolArea, Skybound.VisualTips.VisualTipDisplayOptions options) { Provider = provider; _DisplayedTip = tip; _Options = options; RightToLeft = tip.RightToLeft; Skybound.VisualTips.Rendering.VisualTipLayout visualTipLayout = provider.Renderer.CreateLayout(tip); Size = visualTipLayout.GetSize(); Location = GetBestLocation(toolArea, Size, options); toolArea.Location = toolArea.Location - (new System.Drawing.Size(Location)); tip.SetRelativeToolArea(toolArea); if (IsLayeredWindow) { Animator.Stop(); using (System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(Width, Height)) using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap)) { provider.Renderer.Draw(new System.Windows.Forms.PaintEventArgs(graphics, new System.Drawing.Rectangle(0, 0, Width, Height)), tip, visualTipLayout); SetAlphaMask(bitmap, (byte)(Provider.Opacity * 255.0)); } } DisplayAnimate(); if (!IsLayeredWindow) { System.Drawing.Rectangle rectangle = visualTipLayout.WindowBounds; Width = rectangle.Width; Region = Provider.Renderer.CreateMaskRegion(tip, visualTipLayout); } }
public void SetToolArea(System.Drawing.Rectangle toolArea, Skybound.VisualTips.VisualTipDisplayOptions options) { Location = GetBestLocation(toolArea, Size, options); _Options = options; }
private System.Drawing.Point GetBestLocation(System.Drawing.Rectangle toolArea, System.Drawing.Size tipSize, Skybound.VisualTips.VisualTipDisplayOptions options) { System.Drawing.Rectangle rectangle1 = System.Windows.Forms.Screen.GetBounds(toolArea); bool flag1 = RightToLeft == System.Windows.Forms.RightToLeft.No; System.Drawing.Rectangle rectangle2 = new System.Drawing.Rectangle(toolArea.Location, tipSize); bool flag2 = (options & Skybound.VisualTips.VisualTipDisplayOptions.PositionMask) == Skybound.VisualTips.VisualTipDisplayOptions.PositionLeft; bool flag3 = (options & Skybound.VisualTips.VisualTipDisplayOptions.PositionMask) == Skybound.VisualTips.VisualTipDisplayOptions.PositionMask; bool flag4 = flag2 || ((options & Skybound.VisualTips.VisualTipDisplayOptions.PositionMask) == Skybound.VisualTips.VisualTipDisplayOptions.PositionRight); if (flag4) { if (flag1 && !flag2) { if (((toolArea.Right + tipSize.Width) > rectangle1.Right) && ((toolArea.Left - tipSize.Width) >= rectangle1.X)) { rectangle2.X -= tipSize.Width; } else { rectangle2.X += toolArea.Width; } } else if (((toolArea.Left - tipSize.Width) < rectangle1.X) && ((toolArea.Right + tipSize.Width) <= rectangle1.Right)) { rectangle2.X += toolArea.Width; } else { rectangle2.X -= tipSize.Width; } } else { if (!flag1) { rectangle2.X -= tipSize.Width - toolArea.Width; } if (flag3) { if (((toolArea.Y - tipSize.Height) < rectangle1.Y) && ((toolArea.Bottom + tipSize.Height) <= rectangle1.Bottom)) { rectangle2.Y += toolArea.Height; } else { rectangle2.Y -= tipSize.Height; } } else if (((toolArea.Bottom + tipSize.Height) > rectangle1.Bottom) && ((toolArea.Y - tipSize.Height) >= rectangle1.Y)) { rectangle2.Y -= tipSize.Height; } else { rectangle2.Y += toolArea.Height; } } if (rectangle2.Right > rectangle1.Right) { rectangle2.X = rectangle1.Right - rectangle2.Width; } if (rectangle2.X < rectangle1.X) { rectangle2.X = rectangle1.X; } if (rectangle2.Bottom > rectangle1.Bottom) { rectangle2.Y = rectangle1.Bottom - rectangle2.Height; } if (rectangle2.Y < rectangle1.Y) { rectangle2.Y = rectangle1.Y; } return(rectangle2.Location); }