DrawText() public method

public DrawText ( ) : void
return void
Example #1
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);
 }
Example #2
0
        // Handles drawing the ToolTip.
        private void toolTip_Draw(System.Object sender,
                                  System.Windows.Forms.DrawToolTipEventArgs e)
        {
            // Draw the ToolTip differently depending on which
            // control this ToolTip is for.
            // Draw a custom 3D border if the ToolTip is for button1.
            //if (e.AssociatedControl == fpPictureBox1)
            {
                // Draw the standard background.
                e.DrawBackground();

                // Draw the custom 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.ControlDarkDark, 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)
                });

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

                // Draw the standard text with customized formatting options.
                e.DrawText(sf);
            }
        }
Example #3
0
 //user drawn event handler for toolTip
 private void toolTipHint_Draw(object sender, DrawToolTipEventArgs e)
 {
     e.DrawBackground();
     e.DrawBorder();
     e.DrawText();
 }
Example #4
0
        private void variableHover_Draw(object sender, DrawToolTipEventArgs e)
        {
            using (Font fw = new Font(FontFamily.GenericMonospace, ToolTipFontSize))
            {
                var g = e.Graphics;

                DrawToolTipEventArgs args = new DrawToolTipEventArgs(g, e.AssociatedWindow, e.AssociatedControl, e.Bounds, e.ToolTipText,
                                                                     variableHover.BackColor, variableHover.ForeColor, fw);

                args.DrawBackground();
                args.DrawBorder();
                args.DrawText(TextFormatFlags.TextBoxControl);
            }
        }
Example #5
0
        // Handles drawing the ToolTip.
        private void toolTip1_Draw(System.Object sender,
                                   System.Windows.Forms.DrawToolTipEventArgs e)
        {
            // Draw the ToolTip differently depending on which
            // control this ToolTip is for.
            // Draw a custom 3D border if the ToolTip is for button1.
            if (e.AssociatedControl == button1)
            {
                // Draw the standard background.
                e.DrawBackground();

                // Draw the custom 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.ControlDarkDark, 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)
                });

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

                // Draw the standard text with customized formatting options.
                e.DrawText(sf);
            }
            // Draw a custom background and text if the ToolTip is for button2.
            else if (e.AssociatedControl == button2)
            {
                // Draw the custom background.
                e.Graphics.FillRectangle(SystemBrushes.ActiveCaption, e.Bounds);

                // Draw the standard border.
                e.DrawBorder();

                // Draw the custom text.
                // The using block will dispose the StringFormat automatically.
                using (StringFormat sf = new StringFormat())
                {
                    sf.Alignment     = StringAlignment.Center;
                    sf.LineAlignment = StringAlignment.Center;
                    sf.HotkeyPrefix  = System.Drawing.Text.HotkeyPrefix.None;
                    sf.FormatFlags   = StringFormatFlags.NoWrap;
                    using (Font f = new Font("Tahoma", 9))
                    {
                        e.Graphics.DrawString(e.ToolTipText, f,
                                              SystemBrushes.ActiveCaptionText, e.Bounds, sf);
                    }
                }
            }
            // Draw the ToolTip using default values if the ToolTip is for button3.
            else if (e.AssociatedControl == button3)
            {
                e.DrawBackground();
                e.DrawBorder();
                e.DrawText();
            }
        }
        /// <summary>
        ///		Trata el evento de dibujo del toolTip
        /// </summary>
        private void ToolTipExtend_Draw(Object sender, DrawToolTipEventArgs e)
        {
            if (IsToolTipExtend && IsAssignedControl(e.AssociatedControl))
            { // Dibujar fondo con un gradiente de acuerdo al tema de Windows XP
                        Color color1 = SystemColors.Info, color2 = SystemColors.Info;

                    // Identificar que tema se esta usando
              		switch (GetTheme())
              		{	case "Metallic":
                                        color1 = Color.FromArgb(249, 249, 255);
                                        color2 = Color.FromArgb(164, 163, 190);
                            break;
                             case "NormalColor":
                                        color1 = Color.FromArgb(227, 239, 255);
                                        color2 = Color.FromArgb(121, 161, 220);
                            break;
                             case "HomeStead":
                                        color1 = Color.FromArgb(250, 251, 230);
                                        color2 = Color.FromArgb(164, 180, 120);
                            break;
              		}
                    // Pintar el color de fondo
                        e.Graphics.FillRectangle(new LinearGradientBrush(new Point(0, 0), new Point(0, szToolTip.Height),
                                                                                                                 color1, color2),
                                                                 new Rectangle(0, 0, szToolTip.Width, szToolTip.Height));
                    // Dibujar borde con apariencia 3D
                        e.Graphics.DrawLines(SystemPens.ControlLightLight,
                                                                 new Point[] { new Point(0, szToolTip.Height - 1), new Point(0, 0),
                                                                                     new Point(szToolTip.Width - 1, 0)});
                        e.Graphics.DrawLines(SystemPens.ControlDarkDark, new Point[] {new Point(0, szToolTip.Height - 1),
                                                                                                                                            new Point(szToolTip.Width - 1, szToolTip.Height - 1),
                                                                                                                                            new Point(szToolTip.Width - 1, 0)});
                    // Imprimir titulo, si existe
                        if (!string.IsNullOrEmpty(GetTitle(e.AssociatedControl)))
                            e.Graphics.DrawString(GetTitle(e.AssociatedControl), arrObjSection[(int) enumSection.SectionTitle].FontText,
              														new SolidBrush(Color.Black), arrObjSection[(int) enumSection.SectionTitle].Position);
                    // Dibujar icono en la esquina superior derecha, si existe
                        Bitmap icono = (Bitmap) GetIcon(e.AssociatedControl);
                        if (icono != null)
                            {	icono.MakeTransparent(Color.Magenta);
                                e.Graphics.DrawImage(icono, arrObjSection[(int) enumSection.SectionIcon].Position);
                            }
                    // Dibujar imagen descriptiva, si existe
                    // Si es una imagen ancha se mostrará horizontalmente y el texto descriptivo estará debajo de la imagen
                    // Si es una imagen alta se mostrará verticalmente y el texto descriptivo estará en la parte derecha de la imagen
                        Image imagen = GetImage(e.AssociatedControl);
                        if (imagen != null)
                            e.Graphics.DrawImage(imagen, new Rectangle(arrObjSection[(int) enumSection.SectionImage].Position.X, arrObjSection[(int) enumSection.SectionImage].Position.Y, imagen.Width, imagen.Height));
                    // Imprimir texto descriptivo
                    // El texto se imprime de acuerdo a si existe o no una imagen descriptiva
                    // La orientación del texto depende de donde se coloque la imagen descriptiva
                        e.Graphics.DrawString(GetToolTip(e.AssociatedControl), arrObjSection[(int) enumSection.SectionText].FontText, new SolidBrush(Color.Black),
              												arrObjSection[(int) enumSection.SectionText].Position);
                    // Dibujar línea de separación e imprimir texto de pie de ToolTipExtend, si existe
                        if (!string.IsNullOrEmpty(GetFooter(e.AssociatedControl)))
                            {	e.Graphics.DrawLine(new Pen(Color.Black), new Point(1, intPositionLine),
                  												new Point(szToolTip.Width - 1, intPositionLine));
                                e.Graphics.DrawString(GetFooter(e.AssociatedControl), arrObjSection[(int) enumSection.SectionFoot].FontText,
                                                                            new SolidBrush(Color.Black), arrObjSection[(int) enumSection.SectionFoot].Position);
                            }
            }
            else
                { e.DrawBackground();
                    e.DrawBorder();
                    e.DrawText(TextFormatFlags.NoFullWidthCharacterBreak | TextFormatFlags.VerticalCenter);
                }
        }
Example #7
0
 private void tp_Draw(object sender, System.Windows.Forms.DrawToolTipEventArgs e)
 {
     e.DrawBackground();
     e.DrawBorder();
     e.DrawText();
 }
        /// <summary>
        /// OnDraw event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnDraw(object sender, DrawToolTipEventArgs e)
        {
            /* DrawToolTipEventArgs newArgs = new DrawToolTipEventArgs(e.Graphics,
            e.AssociatedWindow, e.AssociatedControl, e.Bounds, e.ToolTipText,
            Color.DarkRed, Color.White, new Font("Arial Unicode MS", 8.25f, FontStyle.Bold));

            newArgs.DrawBackground();

            newArgs.DrawBorder();

            newArgs.DrawText(TextFormatFlags.TextBoxControl);*/

            e.DrawBackground();
            e.DrawBorder();
            e.DrawText();
        }
Example #9
0
		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 = StringCatalog.ModifyFontForLocalization(SystemFonts.DefaultFont);
			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();
		}
 private void toolTip1_Draw(object sender, DrawToolTipEventArgs e)
 {
     e.Graphics.FillRectangle(Brushes.Lime, e.Bounds);   //填充气泡背景
     e.DrawText();                                       //在气泡内绘制文本
 }
Example #11
0
 void Paint(object sender, DrawToolTipEventArgs e)
 {
     e.DrawBackground();
     e.DrawText();
 }
Example #12
0
        private void toolTip_Draw(object sender, DrawToolTipEventArgs e)
        {
            Point diagramMousePosition = e.AssociatedControl.PointToClient(MousePosition);
            string text = string.Format("AAAA {0} {1}\nA Que\n\nCoucou", diagramMousePosition.X, diagramMousePosition.Y);

            Size textSize = TextRenderer.MeasureText(text, e.Font);
            Rectangle newBound = new Rectangle(e.Bounds.X + 20, e.Bounds.Y - 20, textSize.Width + 10, textSize.Height + 10);

            DrawToolTipEventArgs newArgs = new DrawToolTipEventArgs(e.Graphics,
                e.AssociatedWindow, e.AssociatedControl, newBound, text,
                this.BackColor, this.ForeColor, e.Font);
            newArgs.DrawBackground();
            newArgs.DrawBorder();
            newArgs.DrawText(TextFormatFlags.TextBoxControl);

            //e.DrawBackground();
            //e.DrawBorder();
            //using (StringFormat sf = new StringFormat())
            //{
            //    sf.Alignment = StringAlignment.Center;
            //    sf.LineAlignment = StringAlignment.Center;
            //    sf.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.None;
            //    sf.FormatFlags = StringFormatFlags.NoWrap;
            //    using (Font f = new Font("Tahoma", 9))
            //    {
            //        e.Graphics.DrawString(text, f,
            //            SystemBrushes.ActiveCaptionText, e.Bounds, sf);
            //    }
            //}
            //e.DrawText();
        }
Example #13
0
 void m_ToolTip_Draw(object sender, DrawToolTipEventArgs e)
 {
     Graphics g = e.Graphics;
     g.FillRectangle(new SolidBrush(this.m_ToolTip.BackColor), g.ClipBounds);
     //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.ControlDarkDark, 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) });
     TextFormatFlags sf = TextFormatFlags.VerticalCenter | TextFormatFlags.NoFullWidthCharacterBreak;
     e.DrawText(sf);
 }
Example #14
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();
            }
        }