示例#1
0
 private void Tooltip_Draw(object sender, DrawToolTipEventArgs e)
 {
     using (bm = new QuickBitmap(e.Bounds.Size))
     {
         e.Graphics.Clear(this._tooltip.BackColor);
         ee = new DrawToolTipEventArgs(bm.Graphics, e.AssociatedWindow, e.AssociatedControl, new Rectangle(0, 0, e.Bounds.Width, e.Bounds.Height), e.ToolTipText, this._tooltip.BackColor, this._tooltip.ForeColor, this._tooltip.Font);
         ee.Graphics.Clear(Color.Transparent);
         ee.DrawBorder();
         //e.Graphics.CopyFromScreen(new Point(e.Bounds.X + MousePosition.X, e.Bounds.Y + MousePosition.Y), Point.Empty, e.Bounds.Size, CopyPixelOperation.SourceCopy);
         ee.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
         ee.Bounds.Offset(2, 2);
         ee.Bounds.Inflate(-4, -4);
         PSO2Plugin _plug = ee.AssociatedControl.Tag as PSO2Plugin;
         if (_plug != null && !_plug.Managed)
         {
             var       _stringSize = _plug.GetToolTip(true, this._tooltip.Font, this._tooltip.PreferedSize.Width, TextFormatFlags.Left);
             Rectangle rect        = new Rectangle(ee.Bounds.X, ee.Bounds.Y, _stringSize.Size.Width, _stringSize.Size.Height);
             TextRenderer.DrawText(ee.Graphics, _stringSize.Result, this._tooltip.Font, rect, this._tooltip.ForeColor, this._tooltip.BackColor, TextFormatFlags.Left);
             using (Font f = new Font(this._tooltip.Font.FontFamily, this._tooltip.Font.Size, FontStyle.Bold))
             {
                 _stringSize = TextRendererWrapper.WrapString(_plug.GetWarningMessage(), this._tooltip.PreferedSize.Width, f, TextFormatFlags.Left);
                 TextRenderer.DrawText(ee.Graphics, _stringSize.Result, f, new Rectangle(ee.Bounds.X, ee.Bounds.Y + rect.Height, _stringSize.Size.Width, _stringSize.Size.Height), Color.Red, this._tooltip.BackColor, TextFormatFlags.Left);
             }
         }
         else
         {
             TextRenderer.DrawText(ee.Graphics, ee.ToolTipText, this._tooltip.Font, ee.Bounds, Color.FromArgb(255, 255, 255), Color.FromArgb(17, 17, 17), TextFormatFlags.Left);
         }
         e.Graphics.DrawImage(bm.Bitmap, e.Bounds, ee.Bounds, GraphicsUnit.Pixel);
     }
 }
 public WrapStringResult GetToolTip(bool ignoreWarning, System.Drawing.Font _font, int _preferedWidth, System.Windows.Forms.TextFormatFlags _flag)
 {
     System.Text.StringBuilder sb = new System.Text.StringBuilder();
     sb.AppendFormat("- " + LanguageManager.GetMessageText("PSO2Plugin_Filename", "Filename: {0}"), this.Filename);
     sb.AppendFormat("\r\n- " + LanguageManager.GetMessageText("PSO2Plugin_Author", "Author: {0}"), string.IsNullOrWhiteSpace(this.Author) ? "Unknown" : this.Author);
     if (!string.IsNullOrWhiteSpace(this.Version))
     {
         sb.AppendFormat("\r\n- " + LanguageManager.GetMessageText("PSO2Plugin_Version", "Version: {0}"), this.Version);
     }
     sb.AppendFormat("\r\n- " + LanguageManager.GetMessageText("PSO2Plugin_Description", "Description: {0}"), string.IsNullOrWhiteSpace(this.Description) ? "None" : this.Description);
     if (!string.IsNullOrWhiteSpace(this.Homepage))
     {
         sb.AppendFormat("\r\n- " + LanguageManager.GetMessageText("PSO2Plugin_Homepage", "Homepage: {0}"), this.Homepage);
     }
     if (!ignoreWarning && !this.Managed)
     {
         sb.Append("\r\n" + this.GetWarningMessage());
     }
     return(TextRendererWrapper.WrapString(sb.ToString(), _preferedWidth, _font, _flag));
 }
示例#3
0
        private void Tooltip_Popup(object sender, PopupEventArgs e)
        {
            PSO2Plugin _plug = e.AssociatedControl.Tag as PSO2Plugin;

            if (_plug != null)
            {
                if (!_plug.Managed)
                {
                    var _stringSize = _plug.GetToolTip(true, this._tooltip.Font, this._tooltip.PreferedSize.Width, TextFormatFlags.Left);

                    Rectangle rect1 = new Rectangle(0, 0, _stringSize.Size.Width, _stringSize.Size.Height);
                    using (Font f = new Font(this._tooltip.Font.FontFamily, this._tooltip.Font.Size, FontStyle.Bold))
                    {
                        _stringSize   = TextRendererWrapper.WrapString(_plug.GetWarningMessage(), this._tooltip.PreferedSize.Width, f, TextFormatFlags.Left);
                        e.ToolTipSize = new Size(Math.Max(rect1.Width, _stringSize.Size.Width) + 4, rect1.Height + _stringSize.Size.Height + 4);
                    }
                }
                else
                {
                    var _stringSize = _plug.GetToolTip(true, this._tooltip.Font, this._tooltip.PreferedSize.Width, TextFormatFlags.Left);
                    e.ToolTipSize = new Size(_stringSize.Size.Width + 4, _stringSize.Size.Height + 4);
                }
            }
        }