コード例 #1
0
ファイル: Painter_GDI.cs プロジェクト: itsbth/GLuaR
 private void SetFont(bool Bold, bool Italic, bool Underline, GDISurface
     bbuff)
 {
     if (Bold)
         if (Italic)
             if (Underline)
                 bbuff.Font = GFX.FontBoldItalicUnderline;
             else
                 bbuff.Font = GFX.FontBoldItalic;
         else if (Underline)
             bbuff.Font = GFX.FontBoldUnderline;
         else
             bbuff.Font = GFX.FontBold;
     else if (Italic)
         if (Underline)
             bbuff.Font = GFX.FontItalicUnderline;
         else
             bbuff.Font = GFX.FontItalic;
     else if (Underline)
         bbuff.Font = GFX.FontUnderline;
     else
         bbuff.Font = GFX.FontNormal;
 }
コード例 #2
0
ファイル: GDISurface.cs プロジェクト: ummerland/FireBall
 public void RenderTo(GDISurface target, int x, int y)
 {
     RenderTo(target.hDC, x, y);
 }
コード例 #3
0
ファイル: GDISurface.cs プロジェクト: ummerland/FireBall
 public void RenderTo(GDISurface target, int SourceX, int SourceY, int Width, int Height, int DestX, int DestY)
 {
     NativeGdi32Api.BitBlt(target.hDC, DestX, DestY, Width, Height, this.hDC, SourceX, SourceY, (int)GDIRop.SrcCopy);
 }
コード例 #4
0
ファイル: Structs.cs プロジェクト: viticm/pap2
		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;
            }
        }
コード例 #5
0
ファイル: GDISurface.cs プロジェクト: ummerland/FireBall
 public GDISurface(int width, int height, GDISurface surface)
 {
     Init(width, height, surface.hDC);
     Create();
 }
コード例 #6
0
		private void CreateWords(FormatLabelElement[] Elements)
		{
			GDISurface bbuff = new GDISurface(1, 1, this, false);

			_HasImageError = false;
			foreach (FormatLabelElement Element in Elements)
			{
				if (Element.TagName == "img")
				{
					Element.words = new FormatLabelWord[1];

					Element.words[0] = new FormatLabelWord();

					Image img = null;

					try
					{
						string SRC = GetAttrib("img", Element.Tag).ToLower();
						if (IsIndex(SRC))
						{
							int index = int.Parse(SRC);
							img = this.ImageList.Images[index];
						}
						else if (SRC.StartsWith("http://")) //from url
						{
						}
						else if (SRC.StartsWith("file://")) // from file
						{
							img = Image.FromFile(SRC.Substring(7));
						}
						else //from file
						{
							img = Image.FromFile(SRC);
						}
					}
					catch
					{
						img = new Bitmap(20, 20);
						_HasImageError = true;
					}

					Element.words[0].Image = img;


					Element.words[0].Element = Element;


					if (img != null)
					{
						Element.words[0].Height = img.Height;
						Element.words[0].Width = img.Width;
                        Element.words[0].ScreenArea = new Rectangle(Element.words[0].ScreenArea.Location,
                            new Size(img.Width, img.Height));
					}
				}
				else
				{
					string[] words = Element.Text.Split(' ');
					Element.words = new FormatLabelWord[words.Length];
					int i = 0;
					foreach (string word in words)
					{
						Element.words[i] = new FormatLabelWord();
						string tmp = "";
						Element.words[i].Element = Element;
						if (i == words.Length - 1)
						{
							Element.words[i].Text = word;
							tmp = word;
						}
						else
						{
							Element.words[i].Text = word + " ";
							tmp = word + " "; //last space cant be measured , lets measure an "," instead
						}
						//SizeF size=g.MeasureString (tmp,Element.Font);
						bbuff.Font = GetFont(Element.Font);
						Size s = bbuff.MeasureTabbedString(tmp, 0);
						Element.words[i].Height = s.Height;
						Element.words[i].Width = s.Width - 0;
                        Element.words[i].ScreenArea = new Rectangle(Element.words[i].ScreenArea.Location, 
                            new Size(Element.words[i].Width, Element.words[i].Height));
						//	Element.words[i].Link =Element.Link ;

						i++;
					}
				}
			}

			bbuff.Dispose();
		}
コード例 #7
0
        private void RedrawBuffer()
        {
            if (_bufferSurface != null)
                _bufferSurface.Dispose();

            _bufferSurface = new GDISurface(this.Width, this.Height, this, true);

            using (Graphics gfx = Graphics.FromHdc(_bufferSurface.hDC))
            {
                //try
                //{
                _bufferSurface.FontTransparent = true;

                if (this.BackgroundImage != null)
                {
                    gfx.DrawImage(this.BackgroundImage, 0, 0, this.Width, this.Height);
                }
                else
                {
                    _bufferSurface.Clear(this.BackColor);
                }
                int x = LabelMargin;
                int y = LabelMargin;
                for (int i = vScroll.Value; i < _Rows.Count; i++)
                {
                    FormatLabelRow r = (FormatLabelRow)_Rows[i];
                    x = LabelMargin;
                    r.Visible = true;
                    r.Top = y;
                    if (r.RenderSeparator)
                    {
                        Color c1 = Color.FromArgb(120, 0, 0, 0);
                        Brush b1 = new SolidBrush(c1);
                        gfx.FillRectangle(b1, 0, y, this.Width, 1);

                        Color c2 = Color.FromArgb(120, 255, 255, 255);
                        Brush b2 = new SolidBrush(c2);
                        gfx.FillRectangle(b2, 0, y + 1, this.Width, 1);

                        b1.Dispose();
                        b2.Dispose();


                        //bbuff.DrawLine (this.ForeColor,new Point (0,y),new Point (this.Width,y));
                    }

                    foreach (FormatLabelWord w in r.Words)
                    {
                        int ypos = r.Height - w.Height + y;

                        if (w.Image != null)
                        {
                            gfx.DrawImage(w.Image, x, y);
                            //bbuff.FillRect (Color.Red ,x,ypos,w.Width ,w.Height);
                        }
                        else
                        {
                            GDIFont gf = null;
                            if (w.Element.Link != null)
                            {
                                Font f = null;

                                FontStyle fs = w.Element.Font.Style;
                                if (w.Element.Link == _ActiveElement)
                                {
                                    if (_Link_UnderLine_Hover)
                                        fs |= FontStyle.Underline;

                                    f = new Font(w.Element.Font, fs);
                                }
                                else
                                {
                                    if (_Link_UnderLine)
                                        fs |= FontStyle.Underline;

                                    f = new Font(w.Element.Font, fs);
                                }

                                gf = GetFont(f);
                            }
                            else
                            {
                                gf = GetFont(w.Element.Font);
                            }

                            _bufferSurface.Font = gf;
                            if (w.Element.Effect != TextEffect.None)
                            {
                                _bufferSurface.TextForeColor = w.Element.EffectColor;

                                if (w.Element.Effect == TextEffect.Outline)
                                {
                                    for (int xx = -1; xx <= 1; xx++)
                                        for (int yy = -1; yy <= 1; yy++)
                                            _bufferSurface.DrawTabbedString(w.Text, x + xx, ypos + yy, 0, 0);


                                }
                                else if (w.Element.Effect != TextEffect.None)
                                {
                                    _bufferSurface.DrawTabbedString(w.Text, x + 1, ypos + 1, 0, 0);
                                }
                            }


                            if (w.Element.Link != null)
                            {
                                if (w.Element.Link == _ActiveElement)
                                {
                                    _bufferSurface.TextForeColor = Link_Color_Hover;
                                }
                                else
                                {
                                    _bufferSurface.TextForeColor = Link_Color;
                                }
                            }
                            else
                                _bufferSurface.TextForeColor = w.Element.ForeColor;

                            _bufferSurface.TextBackColor = w.Element.BackColor;
                            _bufferSurface.DrawTabbedString(w.Text, x, ypos, 0, 0);
                        }

                        w.ScreenArea =new Rectangle(new Point(x, ypos), w.ScreenArea.Size);
                        //w.ScreenArea.Y = ypos;
                        x += w.Width;
                    }

                    y += r.Height + r.BottomPadd;
                    if (y > this.Height)
                        break;
                }

                //}
                //catch (Exception x)
                //{
                //    Console.WriteLine(x.Message);
                //}
            }
        }
コード例 #8
0
ファイル: GDISurface.cs プロジェクト: westybsa/MP.LSharp
		public GDISurface(int width, int height, GDISurface surface)
		{
			Init(width, height, surface.hDC);
			Create();
		}
コード例 #9
0
ファイル: GDISurface.cs プロジェクト: westybsa/MP.LSharp
		public void RenderTo(GDISurface target, int SourceX, int SourceY, int Width, int Height, int DestX, int DestY)
		{
            NativeGdi32Api.BitBlt(target.hDC, DestX, DestY, Width, Height, this.hDC, SourceX, SourceY, (int)GDIRop.SrcCopy);
		}
コード例 #10
0
ファイル: GDISurface.cs プロジェクト: westybsa/MP.LSharp
		public void RenderTo(GDISurface target, int x, int y)
		{
			RenderTo(target.hDC, x, y);
		}