コード例 #1
0
        public void DrawText_NullGraphics_ThrowsArgumentNullException()
        {
            var e = new DrawToolTipEventArgs(null, new SubWin32Window(), new Button(), new Rectangle(1, 2, 3, 4), "tooltipText", Color.Red, Color.Blue, SystemFonts.DefaultFont);

            Assert.Throws <ArgumentNullException>("dc", () => e.DrawText());
            Assert.Throws <ArgumentNullException>("dc", () => e.DrawText(TextFormatFlags.Left));
        }
コード例 #2
0
 static void ToolTip2_Draw(object sender, DrawToolTipEventArgs e)
 {
     Debug.Assert(BidiHelper.IsRightToLeft, "Tooltip2 should only be ownerdraw when running RTL");
     e.DrawBackground();
     e.DrawBorder();
     e.DrawText(TextFormatFlags.PreserveGraphicsClipping | TextFormatFlags.RightToLeft | TextFormatFlags.Right);
 }
コード例 #3
0
        private void toolTip1_Draw(object sender, DrawToolTipEventArgs e)
        {
            if (e.AssociatedControl is PictureBox)
            {
                Image img = ((PictureBox)e.AssociatedControl).Image;
                if (img != null)
                {
                    //开始绘制图像
                    e.Graphics.CompositingQuality = CompositingQuality.HighQuality;
                    e.Graphics.DrawImage(img, e.Bounds);

                    LinearGradientBrush linGrBrush = new LinearGradientBrush(
                        new Point(0, 10),
                        new Point(200, 10),
                        Color.FromArgb(255, 255, 0, 0),                              // Opaque red
                        Color.FromArgb(255, 0, 0, 255));                             // Opaque blue
                    Font f = new Font("宋体", 10, FontStyle.Bold);
                    e.Graphics.DrawString("双击打开图像", f, linGrBrush, 2, 2);
                    return;
                }
            }

            //其他控件,或PictureBox无图像时
            e.DrawBackground();
            e.DrawBorder();
            e.DrawText();
        }
コード例 #4
0
 private void toolTip1_Draw(object sender, DrawToolTipEventArgs e)
 {
     e.DrawBackground();
     e.DrawBorder();
     e.DrawText(TextFormatFlags.Default);
     Report.ReportStatus(e.ToolTipText);
 }
コード例 #5
0
        private void toolTip1_Draw(object sender, DrawToolTipEventArgs e)
        {
            if (e.AssociatedControl == this.pnlMain)
            {
                e.DrawBackground();
                e.Graphics.FillRectangle(Brushes.GhostWhite, e.Bounds);

                // Draw a border to appear 3-dimensional.
                e.Graphics.DrawLines(SystemPens.ControlLightLight, new Point[] {
                    new Point(0, e.Bounds.Height - 1),
                    new Point(0, 0),
                    new Point(e.Bounds.Width - 1, 0)
                });
                e.Graphics.DrawLines(SystemPens.Control, new Point[] {
                    new Point(0, e.Bounds.Height - 1),
                    new Point(e.Bounds.Width - 1, e.Bounds.Height - 1),
                    new Point(e.Bounds.Width - 1, 0)
                });

                e.Graphics.DrawString(
                    e.ToolTipText,
                    this._tooltipFont,
                    Program.SecularDayBrush,
                    new RectangleF(e.Bounds.X - 20, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height),
                    this._tooltipStringFormat);
            }
            else
            {
                e.DrawBackground();
                e.DrawBorder();
                e.DrawText();
            }
        }
コード例 #6
0
 void toolTip1_Draw(object sender, DrawToolTipEventArgs e)
 {
     if (_isNoteToolTip)
     {
         e.Graphics.CompositingMode = CompositingMode.SourceOver;
         e.Graphics.CopyFromScreen(_mousePoint, e.Bounds.Location, e.Bounds.Size);
         e.Graphics.FillRectangle(new SolidBrush(toolTip1.BackColor), e.Bounds);
         toolTip1.ForeColor = Color.Black;
         e.DrawText(TextFormatFlags.TextBoxControl | TextFormatFlags.ModifyString | TextFormatFlags.HorizontalCenter);
     }
     else
     {
         e.DrawBackground();
         e.DrawBorder();
         e.DrawText();
     }
 }
コード例 #7
0
ファイル: Form1.cs プロジェクト: IbrahemAbdElfattah/WiShark
 private void toolTip1_Draw(object sender, DrawToolTipEventArgs e)
 {
     //tool tip draw handler
     //setting backcolor
     e.DrawBackground();
     e.DrawBorder();
     e.DrawText();
 }
コード例 #8
0
 public void DrawText_HasGraphicsWithFlags_Success(string tooltipText, Font font)
 {
     using (var image = new Bitmap(10, 10))
         using (Graphics graphics = Graphics.FromImage(image))
         {
             var e = new DrawToolTipEventArgs(graphics, new SubWin32Window(), new Button(), new Rectangle(1, 2, 3, 4), tooltipText, Color.Red, Color.Blue, font);
             e.DrawText(TextFormatFlags.Bottom);
         }
 }
コード例 #9
0
 public void DrawText_InvokeTextFormatFlags_Success(IWin32Window associatedWindow, Control associatedControl, Rectangle bounds, string toolTipText, Color backColor, Color foreColor, Font font)
 {
     using (var image = new Bitmap(10, 10))
         using (Graphics graphics = Graphics.FromImage(image))
         {
             var e = new DrawToolTipEventArgs(graphics, associatedWindow, associatedControl, bounds, toolTipText, backColor, foreColor, font);
             e.DrawText(TextFormatFlags.Bottom);
         }
 }
コード例 #10
0
        private void toolTip1_Draw(object sender, DrawToolTipEventArgs e)
        {
            ToolTip   toolTip = (ToolTip)sender;
            Graphics  g       = e.Graphics;
            Rectangle r       = e.Bounds;

            g.FillRectangle(Brushes.White, r);
            g.DrawRectangle(Pens.Black, r);
            e.DrawText();
        }
コード例 #11
0
ファイル: ContextMenu.cs プロジェクト: lypvc/vimage
        private void ToolTipDraw(object sender, DrawToolTipEventArgs e)
        {
            System.Drawing.Rectangle bounds = e.Bounds;
            bounds.Height -= 1;
            DrawToolTipEventArgs newArgs = new DrawToolTipEventArgs(e.Graphics, e.AssociatedWindow, e.AssociatedControl, bounds, e.ToolTipText,
                                                                    ToolTip.BackColor, ToolTip.ForeColor, e.Font);

            newArgs.DrawBackground();
            newArgs.DrawText(TextFormatFlags.VerticalCenter);
        }
コード例 #12
0
        private void Tlp_Draw(object sender, DrawToolTipEventArgs e)
        {
            tlp.UseAnimation = true;
            DrawToolTipEventArgs newArgs = new DrawToolTipEventArgs(e.Graphics,
                                                                    e.AssociatedWindow, e.AssociatedControl, e.Bounds, e.ToolTipText,
                                                                    this.BackColor, Color.Yellow, FontManager.GetFont("IRANSans", 9.5f, System.Drawing.FontStyle.Regular) /*Font("IRANSans(FaNum)_Medium", 10f,FontStyle.Regular)*/);

            newArgs.DrawBackground();
            newArgs.DrawBorder();
            newArgs.DrawText(TextFormatFlags.TextBoxControl);
        }
コード例 #13
0
        // the boundary box should be set here via ToolTip PopUp event to the measured size of the text to draw
        private void OnDraw(object sender, DrawToolTipEventArgs e)
        {
            //Console.WriteLine( $"OnDraw: {e.Bounds.Width} x {e.Bounds.Height}" );
            DrawToolTipEventArgs newArgs = new DrawToolTipEventArgs(e.Graphics,
                                                                    e.AssociatedWindow, e.AssociatedControl, e.Bounds, e.ToolTipText,
                                                                    this.BackColor, this.ForeColor, ttFont /*new Font ( e.Font, FontStyle.Regular ) */);

            newArgs.DrawBackground( );
            newArgs.DrawBorder( );
            newArgs.DrawText(TextFormatFlags.TextBoxControl | TextFormatFlags.VerticalCenter | TextFormatFlags.NoPrefix);
        }
コード例 #14
0
 private void Benimtooltip_Draw(object sender, DrawToolTipEventArgs e)
 {
     e.DrawBackground();
     e.DrawBorder();
     e.DrawText();
     var t = (ToolTip)sender;
     var h = t.GetType().GetProperty("Handle",
                                     System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
     var handle   = (IntPtr)h.GetValue(t);
     var location = new Point(650, 650);
     var ss       = MoveWindow(handle, location.X, location.Y, e.Bounds.Width, e.Bounds.Height, false);
 }
コード例 #15
0
        void balloonToolTip_Draw(object sender, DrawToolTipEventArgs e)
        {
            e.Graphics.FillRectangle(new SolidBrush(this.PanelBackgroundColor), e.Bounds);

            // Specify custom text formatting flags.
            TextFormatFlags sf = TextFormatFlags.VerticalCenter |
                                 TextFormatFlags.HorizontalCenter |
                                 TextFormatFlags.NoFullWidthCharacterBreak;

            // Draw the standard text with customized formatting options.
            e.DrawText(sf);
        }
コード例 #16
0
        private void OnDraw(object sender, DrawToolTipEventArgs e)
        {
            if (OwnerDraw)
            {
                DrawToolTipEventArgs newArgs = new DrawToolTipEventArgs(e.Graphics,
                                                                        e.AssociatedWindow, e.AssociatedControl, e.Bounds, e.ToolTipText,
                                                                        BackColor, ForeColor, m_font);

                newArgs.DrawBackground();
                newArgs.DrawBorder();
                newArgs.DrawText(TextFormatFlags.TextBoxControl);
            }
        }
コード例 #17
0
        private void toolTip1_Draw(object sender, DrawToolTipEventArgs e)
        {
            e.DrawBackground();
            e.DrawBorder();
            e.DrawText();
            var t = (ToolTip)sender;
            var h = t.GetType().GetProperty("Handle",
                                            System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
            var handle   = (IntPtr)h.GetValue(t);
            var c        = e.AssociatedControl;
            var location = c.Parent.PointToScreen(new Point(c.Right - e.Bounds.Width, c.Bottom));

            MoveWindow(handle, location.X, location.Y, e.Bounds.Width, e.Bounds.Height, false);
        }
コード例 #18
0
        private void ToolTip_Draw(object sender, DrawToolTipEventArgs e)
        {
            e.DrawBackground();
            e.DrawBorder();
            switch (e.AssociatedControl.Name)
            {
            case "trackBar1":
                e.Graphics.DrawString($"播放速度\n{speedBar.Value}∈[-10,10]", e.Font, new SolidBrush(Color.Black), new PointF(2, 2));
                break;

            default:
                e.DrawText();
                break;
            }
        }
コード例 #19
0
        private void OnDraw(object sender, DrawToolTipEventArgs e)
        {
            var newArgs = new DrawToolTipEventArgs(e.Graphics,
                                                   e.AssociatedWindow,
                                                   e.AssociatedControl,
                                                   e.Bounds,
                                                   e.ToolTipText,
                                                   BackColor,
                                                   ForeColor,
                                                   Font);

            newArgs.DrawBackground();
            newArgs.DrawBorder();
            newArgs.DrawText();
        }
コード例 #20
0
 private void toolTip_Draw(object sender, DrawToolTipEventArgs e)
 {
     try
     {
         this.ToolTipCurrent.ForeColor = this.Style.White;
         this.ToolTipCurrent.BackColor = this.Style.Black;
         e.DrawBackground();
         e.DrawBorder();
         e.DrawText();
     }
     catch (Exception ex)
     {
         ShowMessage(MessageType.Error, string.Format("An error occurred while drawing a tooltip.{0}Method: {1}.{2}{0}Exception: {3}",
                                                      Environment.NewLine, ex.Message, this.GetType().Name, MethodBase.GetCurrentMethod().Name));
     }
 }
コード例 #21
0
ファイル: Dash.cs プロジェクト: sillsdev/wesay
        private void _toolTip_Draw(object sender, DrawToolTipEventArgs e)
        {
            DashboardButton button = e.AssociatedControl as DashboardButton;

            // Default behavior for non-button tooltips
            if (button == null)
            {
                e.DrawBackground();
                e.DrawBorder();
                e.DrawText();
                return;
            }
            DisplaySettings.Default.PaintBackground(e.Graphics, e.Bounds, this);
            e.DrawBorder();
            string title         = button.ThingToShowOnDashboard.LocalizedLongLabel;
            Font   localizedFont = (Font)StringCatalog.LabelFont.Clone();
            Font   boldFont      = new Font(localizedFont, FontStyle.Bold);
            int    titleHeight   =
                TextRenderer.MeasureText(e.Graphics,
                                         title,
                                         boldFont,
                                         new Size(e.Bounds.Width - 6, int.MaxValue),
                                         ToolTipFormatFlags).Height;
            Rectangle titleBounds = new Rectangle(e.Bounds.Left + 3,
                                                  e.Bounds.Top + 3,
                                                  e.Bounds.Width - 6,
                                                  e.Bounds.Top + 2 + titleHeight);
            Rectangle descriptionBounds = new Rectangle(e.Bounds.Left + 18,
                                                        e.Bounds.Top + 3 + titleHeight,
                                                        e.Bounds.Width - 21,
                                                        e.Bounds.Height - 8 - titleHeight);

            TextRenderer.DrawText(e.Graphics,
                                  title,
                                  boldFont,
                                  titleBounds,
                                  Color.Black,
                                  ToolTipFormatFlags);
            TextRenderer.DrawText(e.Graphics,
                                  GetToolTipDescription(button.ThingToShowOnDashboard),
                                  localizedFont,
                                  descriptionBounds,
                                  Color.Black,
                                  ToolTipFormatFlags);
            localizedFont.Dispose();
            boldFont.Dispose();
        }
コード例 #22
0
        private static void ToolTip_Draw(object sender, DrawToolTipEventArgs e)
        {
            ToolTip   toolTip = (ToolTip)sender;
            Rectangle bounds  = e.Bounds;

            bounds.Offset(TOOLTIP_XOFFSET, TOOLTIP_YOFFSET);
            DrawToolTipEventArgs newArgs = new DrawToolTipEventArgs(
                e.Graphics,
                e.AssociatedWindow,
                e.AssociatedControl,
                bounds,
                e.ToolTipText,
                toolTip.BackColor,
                toolTip.ForeColor,
                (Font)toolTip.Tag);

            newArgs.DrawBackground();
            newArgs.DrawBorder();
            newArgs.DrawText(TextFormatFlags.TextBoxControl);
        }
コード例 #23
0
        void OPMToolTip_Draw(object sender, DrawToolTipEventArgs e)
        {
            if (e.AssociatedControl != null && _data.ContainsKey(e.AssociatedControl))
            {
                e.Graphics.CompositingMode    = CompositingMode.SourceOver;
                e.Graphics.CompositingQuality = CompositingQuality.HighQuality;
                e.Graphics.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                e.Graphics.SmoothingMode      = SmoothingMode.AntiAlias;
                e.Graphics.TextRenderingHint  = TextRenderingHint.ClearTypeGridFit;
                e.Graphics.TextContrast       = 5;

                //e.DrawBackground();
                //e.DrawBorder();

                using (LinearGradientBrush b = new LinearGradientBrush(e.Bounds,
                                                                       ControlPaint.Light(ThemeManager.GradientNormalColor1),
                                                                       ControlPaint.Light(ThemeManager.GradientNormalColor2), 90))
                {
                    e.Graphics.FillRectangle(b, e.Bounds);
                }

                using (Pen p = new Pen(ThemeManager.BorderColor))
                {
                    Rectangle rc = new Rectangle(e.Bounds.Location,
                                                 new Size(e.Bounds.Width - 1, e.Bounds.Height - 1));

                    e.Graphics.DrawRectangle(p, rc);
                }

                DrawContents(e.Graphics, _data[e.AssociatedControl]);
            }
            else
            {
                // Fallback to regular tooltip
                e.DrawBorder();
                e.DrawBackground();
                e.DrawText();
            }
        }
コード例 #24
0
        public static void DrawMessage(DrawToolTipEventArgs e)
        {
            LinearGradientBrush gradientDefault = new LinearGradientBrush(e.Bounds,
                                                                          Color.White, Color.Lavender,
                                                                          LinearGradientMode.Vertical);

            // Draw the custom background
            e.Graphics.FillRectangle(gradientDefault, e.Bounds);

            // Draw the custom border to appear 3-dimensional
            e.Graphics.DrawLines(new Pen(Color.Gray), new Point[] {
                new Point(0, e.Bounds.Height - 1),
                new Point(e.Bounds.Width - 1, e.Bounds.Height - 1),
                new Point(e.Bounds.Width - 1, 0)
            });
            e.Graphics.DrawLines(new Pen(Color.DarkGray), new Point[] {
                new Point(0, e.Bounds.Height - 1),
                new Point(0, 0),
                new Point(e.Bounds.Width - 1, 0)
            });

            // Draw the standard text with customized formatting options
            e.DrawText(sff);
        }
コード例 #25
0
        public static void DrawInfo(DrawToolTipEventArgs e)
        {
            LinearGradientBrush gradientInfo = new LinearGradientBrush(e.Bounds,
                                                                       ColorTheme.TipGradient.Color,
                                                                       ColorTheme.TipGradient.BackgroundColor,
                                                                       LinearGradientMode.Vertical);

            // Draw the custom background
            e.Graphics.FillRectangle(gradientInfo, e.Bounds);

            if (ColorTheme.IsDarkTheme)
            {
                Rectangle border = new Rectangle(e.Bounds.Location, new Size(e.Bounds.Width - 1, e.Bounds.Height - 1));
                e.Graphics.DrawRectangle(new Pen(ColorTheme.TipBorderFrame), border);

                Point locationText = e.Bounds.Location;
                locationText.Offset(3, 1);
                e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
                Font font;
                if (e.Font.Size > 11.5f)
                {
                    font = new Font(e.Font.FontFamily, 11.5f, FontStyle.Regular, GraphicsUnit.Pixel);
                }
                else
                {
                    font = e.Font;
                }
                e.Graphics.DrawString(e.ToolTipText, font, ColorTheme.TipText, locationText, sf);
            }
            else
            {
                e.DrawBorder();
                // Draw the standard text with customized formatting options
                e.DrawText(sff);
            }
        }
コード例 #26
0
 private static void ToolTip_Draw(object sender, DrawToolTipEventArgs e)
 {
     e.DrawBackground();
     e.DrawBorder();
     e.DrawText(TextFormatFlags.VerticalCenter | TextFormatFlags.LeftAndRightPadding);
 }
コード例 #27
0
 void Paint(object sender, DrawToolTipEventArgs e)
 {
     e.DrawBackground();
     e.DrawText();
 }
コード例 #28
0
ファイル: PopEditorForm.cs プロジェクト: BrokenShards/Popcon
 private void DrawTip(object sender, DrawToolTipEventArgs e)
 {
     e.DrawBackground();
     e.DrawBorder();
     e.DrawText();
 }
コード例 #29
0
 private void ToolTipInfo_Draw(object sender, DrawToolTipEventArgs e)
 {
     e.DrawBackground();
     e.DrawBorder();
     e.DrawText(TextFormatFlags.VerticalCenter | TextFormatFlags.LeftAndRightPadding | TextFormatFlags.TextBoxControl);
 }
コード例 #30
0
ファイル: Calendar.cs プロジェクト: AndrianDTR/Atlantic
 // Handles drawing the ToolTip.
 private void OnDrawStats(System.Object sender, DrawToolTipEventArgs e)
 {
     e.DrawBackground();
     e.DrawBorder();
     e.DrawText();
 }
コード例 #31
0
ファイル: YouTubeThumb.cs プロジェクト: 0xC0LD/YTthumb
 private void HelpBallon_Draw(object sender, DrawToolTipEventArgs e)
 {
     e.DrawBackground();
     e.DrawBorder();
     e.DrawText();
 }