Esempio n. 1
0
        public override void PaintValue(PaintValueEventArgs e)
        {
            string   text = e.Value.ToString();
            Bitmap   bp   = new Bitmap(e.Bounds.Width, e.Bounds.Height);
            Graphics g    = Graphics.FromImage(bp);

            Brush bg, fg;

            bg = SystemBrushes.Window;
            fg = SystemBrushes.WindowText;

            g.FillRectangle(SystemBrushes.Highlight, e.Bounds);

            IntPtr  hdc = g.GetHdc();
            GDIFont gf  = new GDIFont(text, 9);
            int     a   = 0;
            IntPtr  res = NativeGdi32Api.SelectObject(hdc, gf.hFont);

            NativeGdi32Api.SetTextColor(hdc, ColorTranslator.ToWin32(SystemColors.Window));
            NativeGdi32Api.SetBkMode(hdc, 0);
            NativeUser32Api.TabbedTextOut(hdc, 1, 1, "abc", 3, 0, ref a, 0);
            NativeGdi32Api.SelectObject(hdc, res);
            gf.Dispose();
            g.ReleaseHdc(hdc);
            e.Graphics.DrawImage(bp, e.Bounds.Left, e.Bounds.Top);

            //	e.Graphics.DrawString ("abc",new Font (text,10f),SystemBrushes.Window,3,0);
        }
Esempio n. 2
0
        private void LB_DrawItem(object sender, DrawItemEventArgs e)
        {
            bool selected = (e.State & DrawItemState.Selected) == DrawItemState.Selected;

            if (e.Index == -1)
                return;


            object li = FontListbox.Items[e.Index];
            string text = li.ToString();
            Brush bg, fg;

            if (selected)
            {
                bg = SystemBrushes.Highlight;
                fg = SystemBrushes.HighlightText;
                //fg=Brushes.Black;
            }
            else
            {
                bg = SystemBrushes.Window;
                fg = SystemBrushes.WindowText;
            }

            //e.Graphics.FillRectangle (SystemBrushes.Window,0,e.Bounds.Top,e.Bounds.Width ,FontListbox.ItemHeight); 			
            if (selected)
            {
                int ofs = 37;
                e.Graphics.FillRectangle(SystemBrushes.Window, new Rectangle(ofs, e.Bounds.Top, e.Bounds.Width - ofs, FontListbox.ItemHeight));
                e.Graphics.FillRectangle(SystemBrushes.Highlight, new Rectangle(ofs + 1, e.Bounds.Top + 1, e.Bounds.Width - ofs - 2, FontListbox.ItemHeight - 2));
                System.Windows.Forms.ControlPaint.DrawFocusRectangle(e.Graphics, new Rectangle(ofs, e.Bounds.Top, e.Bounds.Width - ofs, FontListbox.ItemHeight));
            }
            else
            {
                e.Graphics.FillRectangle(SystemBrushes.Window, 0, e.Bounds.Top, e.Bounds.Width, FontListbox.ItemHeight);
            }


            e.Graphics.DrawString(text, e.Font, fg, 38, e.Bounds.Top + 4);

            e.Graphics.SetClip(new Rectangle(1, e.Bounds.Top + 2, 34, FontListbox.ItemHeight - 4));


            e.Graphics.FillRectangle(SystemBrushes.Highlight, new Rectangle(1, e.Bounds.Top + 2, 34, FontListbox.ItemHeight - 4));

            IntPtr hdc = e.Graphics.GetHdc();
            GDIFont gf = new GDIFont(text, 9);
            int a = 0;
            IntPtr res = NativeGdi32Api.SelectObject(hdc, gf.hFont);
            NativeGdi32Api.SetTextColor(hdc, ColorTranslator.ToWin32(SystemColors.Window));
            NativeGdi32Api.SetBkMode(hdc, 0);
            NativeUser32Api.TabbedTextOut(hdc, 3, e.Bounds.Top + 5, "abc", 3, 0, ref a, 0);
            NativeGdi32Api.SelectObject(hdc, res);
            gf.Dispose();
            e.Graphics.ReleaseHdc(hdc);
            e.Graphics.DrawRectangle(Pens.Black, new Rectangle(1, e.Bounds.Top + 2, 34, FontListbox.ItemHeight - 4));
            e.Graphics.ResetClip();

        }
Esempio n. 3
0
        public override void PaintValue(PaintValueEventArgs e)
        {
            string text = e.Value.ToString();
            Bitmap bp = new Bitmap(e.Bounds.Width, e.Bounds.Height);
            Graphics g = Graphics.FromImage(bp);

            Brush bg, fg;

            bg = SystemBrushes.Window;
            fg = SystemBrushes.WindowText;

            g.FillRectangle(SystemBrushes.Highlight, e.Bounds);

            IntPtr hdc = g.GetHdc();
            GDIFont gf = new GDIFont(text, 9);
            int a = 0;
            IntPtr res = NativeGdi32Api.SelectObject(hdc, gf.hFont);
            NativeGdi32Api.SetTextColor(hdc, ColorTranslator.ToWin32(SystemColors.Window));
            NativeGdi32Api.SetBkMode(hdc, 0);
            NativeUser32Api.TabbedTextOut(hdc, 1, 1, "abc", 3, 0, ref a, 0);
            NativeGdi32Api.SelectObject(hdc, res);
            gf.Dispose();
            g.ReleaseHdc(hdc);
            e.Graphics.DrawImage(bp, e.Bounds.Left, e.Bounds.Top);

            //	e.Graphics.DrawString ("abc",new Font (text,10f),SystemBrushes.Window,3,0);
        }
Esempio n. 4
0
		public GDIBrush OutlineBrush; //background brush

        #region IDisposable Members

        public void Dispose()
        {
            if (BackBuffer != null)
            {
                BackBuffer.Dispose();
                BackBuffer = null;
            }
            if (SelectionBuffer != null)
            {
                SelectionBuffer.Dispose();
                SelectionBuffer = null;
            }
            if (StringBuffer != null)
            {
                StringBuffer.Dispose();
                StringBuffer = null;
            }
            if (FontNormal != null)
            {
                FontNormal.Dispose();
                FontNormal = null;
            }
            if (FontBold != null)
            {
                FontBold.Dispose();
                FontBold = null;
            }
            if (FontItalic != null)
            {
                FontItalic.Dispose();
                FontItalic = null;
            }
            if (FontBoldItalic != null)
            {
                FontBoldItalic.Dispose();
                FontBoldItalic = null;
            }
            if (FontUnderline != null)
            {
                FontUnderline.Dispose();
                FontUnderline = null;
            }
            if (FontBoldUnderline != null)
            {
                FontBoldUnderline.Dispose();
                FontBoldUnderline = null;
            }
            if (FontItalicUnderline != null)
            {
                FontItalicUnderline.Dispose();
                FontItalicUnderline = null;
            }
            if (FontBoldItalicUnderline != null)
            {
                FontBoldItalicUnderline.Dispose();
                FontBoldItalicUnderline = null;
            }
            if (GutterMarginBrush != null)
            {
                GutterMarginBrush.Dispose();
                GutterMarginBrush = null;
            }
            if (GutterMarginBrush != null)
            {
                GutterMarginBrush.Dispose();
                GutterMarginBrush = null;
            }
            if (LineNumberMarginBrush != null)
            {
                LineNumberMarginBrush.Dispose();
                LineNumberMarginBrush = null;
            }
            if (LineNumberMarginBorderBrush != null)
            {
                LineNumberMarginBorderBrush.Dispose();
                LineNumberMarginBorderBrush = null;
            }
            if (BackgroundBrush != null)
            {
                BackgroundBrush.Dispose();
                BackgroundBrush = null;
            }
            if (HighLightLineBrush != null)
            {
                HighLightLineBrush.Dispose();
                HighLightLineBrush = null;
            }
            if (OutlineBrush != null)
            {
                OutlineBrush.Dispose();
                OutlineBrush = null;
            }
        }
Esempio n. 5
0
		private GDIFont GetFont(Font font)
		{
			GDIFont gf = (GDIFont) _Fonts[GetFontKey(font)];
			if (gf == null)
			{
				gf = new GDIFont(font.Name, font.Size, font.Bold, font.Italic, font.Underline, false);
				_Fonts[GetFontKey(font)] = gf;
			}
			return gf;
		}
Esempio n. 6
0
        private void LB_DrawItem(object sender, DrawItemEventArgs e)
        {
            bool selected = (e.State & DrawItemState.Selected) == DrawItemState.Selected;

            if (e.Index == -1)
            {
                return;
            }


            object li = FontListbox.Items[e.Index];
            string text = li.ToString();
            Brush  bg, fg;

            if (selected)
            {
                bg = SystemBrushes.Highlight;
                fg = SystemBrushes.HighlightText;
                //fg=Brushes.Black;
            }
            else
            {
                bg = SystemBrushes.Window;
                fg = SystemBrushes.WindowText;
            }

            //e.Graphics.FillRectangle (SystemBrushes.Window,0,e.Bounds.Top,e.Bounds.Width ,FontListbox.ItemHeight);
            if (selected)
            {
                int ofs = 37;
                e.Graphics.FillRectangle(SystemBrushes.Window, new Rectangle(ofs, e.Bounds.Top, e.Bounds.Width - ofs, FontListbox.ItemHeight));
                e.Graphics.FillRectangle(SystemBrushes.Highlight, new Rectangle(ofs + 1, e.Bounds.Top + 1, e.Bounds.Width - ofs - 2, FontListbox.ItemHeight - 2));
                System.Windows.Forms.ControlPaint.DrawFocusRectangle(e.Graphics, new Rectangle(ofs, e.Bounds.Top, e.Bounds.Width - ofs, FontListbox.ItemHeight));
            }
            else
            {
                e.Graphics.FillRectangle(SystemBrushes.Window, 0, e.Bounds.Top, e.Bounds.Width, FontListbox.ItemHeight);
            }


            e.Graphics.DrawString(text, e.Font, fg, 38, e.Bounds.Top + 4);

            e.Graphics.SetClip(new Rectangle(1, e.Bounds.Top + 2, 34, FontListbox.ItemHeight - 4));


            e.Graphics.FillRectangle(SystemBrushes.Highlight, new Rectangle(1, e.Bounds.Top + 2, 34, FontListbox.ItemHeight - 4));

            IntPtr  hdc = e.Graphics.GetHdc();
            GDIFont gf  = new GDIFont(text, 9);
            int     a   = 0;
            IntPtr  res = NativeGdi32Api.SelectObject(hdc, gf.hFont);

            NativeGdi32Api.SetTextColor(hdc, ColorTranslator.ToWin32(SystemColors.Window));
            NativeGdi32Api.SetBkMode(hdc, 0);
            NativeUser32Api.TabbedTextOut(hdc, 3, e.Bounds.Top + 5, "abc", 3, 0, ref a, 0);
            NativeGdi32Api.SelectObject(hdc, res);
            gf.Dispose();
            e.Graphics.ReleaseHdc(hdc);
            e.Graphics.DrawRectangle(Pens.Black, new Rectangle(1, e.Bounds.Top + 2, 34, FontListbox.ItemHeight - 4));
            e.Graphics.ResetClip();
        }