コード例 #1
0
ファイル: TiledDrawer.cs プロジェクト: gleroi/WallPaperSeven
        public void Draw(System.Drawing.Graphics gs, ScreenConfiguration conf)
        {
            using (Image image = Image.FromFile(conf.ImagePath))
            {
                Rectangle tile = new Rectangle(conf.Bounds.X, conf.Bounds.Y,
                    image.Size.Width, image.Size.Height);
                int xtiles = (int)Math.Ceiling((double)conf.Bounds.Width / (double)tile.Width);
                int ytiles = (int)Math.Ceiling((double)conf.Bounds.Height / (double)tile.Height);
                for (int x = 0; x < xtiles; x++)
                    for (int y = 0; y < ytiles; y++)
                    {
                        tile.Width = image.Size.Width;
                        tile.Height = image.Size.Height;
                        tile.X = conf.Bounds.X + x * tile.Width;
                        tile.Y = conf.Bounds.Y + y * tile.Height;

                        // if the tile a part of the tile is out of the screen, clip it
                        int xclip = (tile.X + tile.Width) - (conf.Bounds.X + conf.Bounds.Width);
                        if (xclip > 0)
                            tile.Width -= xclip;
                        int yclip = (tile.Y + tile.Height) - (conf.Bounds.Y + conf.Bounds.Height);
                        if (yclip > 0)
                            tile.Height -= yclip;

                        gs.DrawImageUnscaledAndClipped(image, tile);
                    }
            }
        }
コード例 #2
0
 public void Draw(System.Drawing.Graphics gs, ScreenConfiguration conf)
 {
     using (Image image = Image.FromFile(conf.ImagePath))
     {
         Point screenCenter = new Point(conf.Bounds.Width / 2, conf.Bounds.Height / 2);
         Size imageSize = image.Size;
         Point imageOrigin = new Point(
             conf.Bounds.X + screenCenter.X - (imageSize.Width / 2),
             conf.Bounds.Y + screenCenter.Y - (imageSize.Height / 2));
         gs.DrawImageUnscaledAndClipped(image, new Rectangle(
             imageOrigin, image.Size));
     }
 }
コード例 #3
0
			protected override void RenderProgressBar(float progress, System.Drawing.Graphics g)
			{
				g.DrawImageUnscaledAndClipped(_tray, new Rectangle(Point.Empty, _tray.Size));
				using (Bitmap bar = new Bitmap(_bar))
				{
					int cols = _bar.Size.Width;
					int rows = _bar.Size.Height;
					int size = rows*cols;
					int max = (int) (progress*cols);
					for (int i = 0; i < size; i++)
					{
						if (i%cols > max)
							bar.SetPixel(i%cols, i/cols, Color.Transparent);
					}
					DrawImageCentered(g, bar);
				}
				DrawImageCentered(g, _border);
			}
コード例 #4
0
			protected override void RenderProgressBar(float progress, System.Drawing.Graphics g)
			{
				g.DrawImageUnscaledAndClipped(_tray, new Rectangle(Point.Empty, _tray.Size));

				if (progress <= 0f)
				{
					// paint nothing
				}
				else if (progress >= 1f)
				{
					// paint the full bar
					DrawImageCentered(g, _bar);
				}
				else
				{
					// paint a portion of the bar using the alpha channel of the marquee mask
					using (Bitmap bar = new Bitmap(_bar))
					{
						int cols = _bar.Size.Width;
						int rows = _bar.Size.Height;
						int size = rows*cols;

						for (int i = 0; i < size; i++)
						{
							int x = i%cols;
							int offsetX = x - _offset;
							int y = i/cols;
							if (offsetX >= 0 && offsetX < _mask.Width)
							{
								var c = bar.GetPixel(x, y);
								bar.SetPixel(x, y, Color.FromArgb(_mask.GetPixel(offsetX, y).A*c.A/255, c));
							}
							else
							{
								bar.SetPixel(x, y, Color.Transparent);
							}
						}

						DrawImageCentered(g, bar);
					}
				}
				DrawImageCentered(g, _border);
			}