Exemplo n.º 1
0
        private void UpdateSurface()
        {
            mBackground.Fill(mBackColor);
            if (base.IsColorTransparent(mBackColor))
            {
                mBackground.Transparent      = true;
                mBackground.TransparentColor = mBackColor;
            }
            else
            {
                mBackground.Transparent = false;
            }
            decimal newWidth = (decimal)base.Width * ((decimal)mPercent / (decimal)100);
            Size    barSize  = new Size(System.Math.Max(0, (int)newWidth - 2), System.Math.Max(0, base.Height - 2));

            Gfx.Surface barSurface = new SdlDotNet.Graphics.Surface(barSize);
            barSurface.Fill(mBarColor);
            mBackground.Blit(barSurface, new Point(1, 1));
            barSurface.Close();
            barSurface.Dispose();
            if (mText != "" && mFont != null)
            {
                Gfx.Surface fontSurf = mFont.Render(mText, Color.Black, false);
                mBackground.Blit(fontSurf, GetCenter(mBackground, fontSurf.Size), new Rectangle(0, 0, this.Width, this.Height));
            }
            Draw3dBorder();

            base.Buffer.Blit(mBackground, new Point(0, 0));
        }
Exemplo n.º 2
0
 private void UpdateBackground()
 {
     mBackground = new SdlDotNet.Graphics.Surface(base.Size);
     base.Buffer.Fill(mBackColor);
     if (mBackColor.A != 0)
     {
         mBackground.Fill(mBackColor);
     }
     else
     {
         mBackground.Transparent      = true;
         mBackground.TransparentColor = Color.Transparent;
         mBackground.Fill(Color.Transparent);
     }
     mCheckedBoxBounds = new Rectangle(new Point(2, 2), new Size(this.Height - 4, this.Height - 4));
     Gfx.Primitives.Box box = new SdlDotNet.Graphics.Primitives.Box(mCheckedBoxBounds.Location, mCheckedBoxBounds.Size);
     mBackground.Draw(box, Color.Black);
     if (mChecked)
     {
         Gfx.Surface filled = new SdlDotNet.Graphics.Surface(box.Size);
         filled.Fill(Color.Black);
         mBackground.Blit(filled, box.Location);
         filled.Close();
         filled.Dispose();
     }
     if (mText != "")
     {
         Gfx.Font font = new Gfx.Font(IO.IO.CreateOSPath("Fonts\\PMU.ttf"), this.Height);
         mBackground.Blit(font.Render(mText, mForeColor, mAntiAlias), new Point(20, -4));
         font.Close();
     }
     base.Buffer.Blit(mBackground, new Point(0, 0));
 }
Exemplo n.º 3
0
 protected void ReinitBuffer()
 {
     if (mBuffer != null)
     {
         mBuffer.Close();
         mBuffer.Dispose();
     }
     mBuffer                  = new Surface(this.Size);
     mBuffer.Transparent      = true;
     mBuffer.TransparentColor = Color.Transparent;
     mBuffer.Fill(Color.Transparent);
 }
Exemplo n.º 4
0
 private void Redraw()
 {
     try {
         base.Buffer.Fill(mBackColor);
         if (mBackground != null)
         {
             mBackground.Close();
             mBackground.Dispose();
         }
         mBackground = new SdlDotNet.Graphics.Surface(this.Size);
         mBackground.TransparentColor = Color.Transparent;
         mBackground.Transparent      = true;
         mBackground.Fill(mBackColor);
         int lastY = 2;
         // Draw each line
         for (int i = mVisibleY; i < mVisibleY + mMaxY; i++)
         {
             if (mLines.Count > i)
             {
                 SdlDotNet.Graphics.Surface lineSurf;
                 if (mPasswordChar == '\0')
                 {
                     lineSurf = mLines[i].Render();
                 }
                 else
                 {
                     lineSurf = mLines[i].RenderPassword(mPasswordChar);
                 }
                 mBackground.Blit(lineSurf, new Point(2, lastY));
                 lineSurf.Close();
                 lastY += mFont.Height;
             }
             else
             {
                 break;
             }
         }
         base.Buffer.Blit(mBackground);
         mBackground.Close();
         //if (mDoLineDraw) {
         //    Gfx.IPrimitive line = new Gfx.Primitives.Line(new Point((((mCursorLocX - mVisibleX) * (mLetterSize.Width))), (((((mCursorLocY) - mVisibleY) * mLetterSize.Height)) - 2)), new Point(((mCursorLocX - mVisibleX) * (mLetterSize.Width)), (((mCursorLocY) - mVisibleY) * mLetterSize.Height + mLetterSize.Height)));
         //    base.Buffer.Draw(line, Color.Blue);
         //}
     } catch (Exception ex) {
         Console.WriteLine(ex.ToString());
     }
 }
Exemplo n.º 5
0
 public static Surface GetSurface(byte[] imgBytes, Size boxSize)
 {
     Surface boxSurf = new Surface(boxSize);
     boxSurf.Fill(Color.White);  //Fill background to white color
     //Get and resize image
     if (imgBytes != null)
     {
         Surface imgSurf = new Surface(imgBytes);
         double scale = Ratio.CalculateScale(imgSurf.Size,
                                             new Size(boxSize.Width, boxSize.Height),
                                             Ratio.RatioType.FitImage); //Calculate ratio
         Surface scaledSurf = imgSurf.CreateScaledSurface(scale, true);
         imgSurf.Dispose();
         Point pt = new Point((boxSize.Width - scaledSurf.Width) / 2,      //Left point
                              (boxSize.Height - scaledSurf.Height) / 2);   //Top point
         boxSurf.Blit(scaledSurf, pt);
         scaledSurf.Dispose();  //Clear imgSurf memory
     }
     //Draw border
     for(int i = 0; i < BORDER; i++)
         boxSurf.Draw(new Box(new Point(i, i), new Point(boxSize.Width - i - 1, boxSize.Height - i - 1)), Color.Gray);
     return boxSurf;
 }
Exemplo n.º 6
0
 private void UpdateBackground()
 {
     mBackground = new SdlDotNet.Graphics.Surface(base.Size);
     base.Buffer.Fill(mBackColor);
     if (mBackColor.A != 0) {
         mBackground.Fill(mBackColor);
     } else {
         mBackground.Transparent = true;
         mBackground.TransparentColor = Color.Transparent;
         mBackground.Fill(Color.Transparent);
     }
     mCheckedBoxBounds = new Rectangle(new Point(2, 2), new Size(this.Height - 4, this.Height - 4));
     Gfx.Primitives.Box box = new SdlDotNet.Graphics.Primitives.Box(mCheckedBoxBounds.Location, mCheckedBoxBounds.Size);
     mBackground.Draw(box, Color.Black);
     if (mChecked) {
         Gfx.Surface filled = new SdlDotNet.Graphics.Surface(box.Size);
         filled.Fill(Color.Black);
         mBackground.Blit(filled, box.Location);
         filled.Close();
         filled.Dispose();
     }
     if (mText != "") {
         Gfx.Font font = new Gfx.Font(IO.IO.CreateOSPath("Fonts\\PMU.ttf"), this.Height);
         mBackground.Blit(font.Render(mText, mForeColor, mAntiAlias), new Point(20, -4));
         font.Close();
     }
     base.Buffer.Blit(mBackground, new Point(0, 0));
 }
Exemplo n.º 7
0
		protected override Surface CreateSurface ()
		{
			if (player == null || player.Surface == null)
				return null;
			
			Console.WriteLine ("MovieElement: Creating new surface");
			Surface surf;

			surf = new Surface (player.Surface);

			if (scale
			    && (player.Width != Width
				|| player.Height != Height)) {
				double horiz_zoom = (double)Width / player.Width;
				double vert_zoom = (double)Height / player.Height;
				double zoom;

				if (horiz_zoom < vert_zoom)
					zoom = horiz_zoom;
				else
					zoom = vert_zoom;

				// FIXME: NewSDL
				// surf.Scale (zoom);
			}

			if (dim != 0) {
				Surface dim_surf = new Surface (surf.Size);
				dim_surf.Alpha = dim;
				dim_surf.AlphaBlending = true;
				dim_surf.Blit (surf);
				surf.Dispose ();
				surf = dim_surf;
			}

			return surf;
		}
Exemplo n.º 8
0
        private void UpdateSurface()
        {
            mBackground.Fill(mBackColor);
            if (base.IsColorTransparent(mBackColor)) {
                mBackground.Transparent = true;
                mBackground.TransparentColor = mBackColor;
            } else {
                mBackground.Transparent = false;
            }
            decimal newWidth = (decimal)base.Width * ((decimal)mPercent / (decimal)100);
            Size barSize = new Size(System.Math.Max(0, (int)newWidth - 2), System.Math.Max(0, base.Height - 2));
            Gfx.Surface barSurface = new SdlDotNet.Graphics.Surface(barSize);
            barSurface.Fill(mBarColor);
            mBackground.Blit(barSurface, new Point(1, 1));
            barSurface.Close();
            barSurface.Dispose();
            if (mText != "" && mFont != null) {
                Gfx.Surface fontSurf = mFont.Render(mText, Color.Black, false);
                mBackground.Blit(fontSurf, GetCenter(mBackground, fontSurf.Size), new Rectangle(0, 0, this.Width, this.Height));
            }
            Draw3dBorder();

            base.Buffer.Blit(mBackground, new Point(0, 0));
        }