Example #1
0
        private Bitmap GetStackIcon(BitmapCreatorDelegate creator)
        {
            Bitmap icon      = new Bitmap(_iconSize.Width, _iconSize.Height);
            int    subWidth  = _iconSize.Width - (_stackSize - 1) * Math.Abs(_stackOffset.Width);
            int    subHeight = _iconSize.Height - (_stackSize - 1) * Math.Abs(_stackOffset.Height);

            int offsetH = 0;

            if (_stackOffset.Width < 0)
            {
                offsetH = (_stackSize - 1) * Math.Abs(_stackOffset.Width);
            }

            int offsetV = 0;

            if (_stackOffset.Height < 0)
            {
                offsetV = (_stackSize - 1) * Math.Abs(_stackOffset.Height);
            }

            using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(icon))
            {
                using (Bitmap bmp = creator(subWidth, subHeight))
                {
                    for (int n = _stackSize - 1; n >= 0; n--)
                    {
                        Point point = new Point(n * _stackOffset.Width + offsetH, n * _stackOffset.Height + offsetV);
                        if (bmp != null)
                        {
                            g.DrawImage(bmp, point);
                        }
                        else
                        {
                            g.FillRectangle(new SolidBrush(_backgroundColor), point.X, point.Y, subWidth, subHeight);
                        }
                        DrawBorder(icon, new Rectangle(point, new Size(subWidth, subHeight)), _borderColor, _borderWidth);
                    }
                }
            }
            return(icon);
        }
Example #2
0
        private Bitmap GetImageIcon(BitmapCreatorDelegate creator)
        {
            Bitmap icon = new Bitmap(_iconSize.Width, _iconSize.Height);

            using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(icon))
            {
                using (Bitmap bmp = creator(_iconSize.Width, _iconSize.Height))
                {
                    if (bmp != null)
                    {
                        g.DrawImage(bmp, Point.Empty);
                    }
                    else
                    {
                        g.FillRectangle(new SolidBrush(_backgroundColor), new Rectangle(Point.Empty, icon.Size));
                    }
                    DrawBorder(icon, _borderColor, _borderWidth);
                }
            }
            return(icon);
        }
Example #3
0
		private Bitmap GetStackIcon(BitmapCreatorDelegate creator)
		{
			Bitmap icon = new Bitmap(_iconSize.Width, _iconSize.Height);
			int subWidth = _iconSize.Width - (_stackSize - 1)*Math.Abs(_stackOffset.Width);
			int subHeight = _iconSize.Height - (_stackSize - 1)*Math.Abs(_stackOffset.Height);

			int offsetH = 0;
			if (_stackOffset.Width < 0)
			{
				offsetH = (_stackSize - 1)*Math.Abs(_stackOffset.Width);
			}

			int offsetV = 0;
			if (_stackOffset.Height < 0)
			{
				offsetV = (_stackSize - 1)*Math.Abs(_stackOffset.Height);
			}

			using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(icon))
			{
				using (Bitmap bmp = creator(subWidth, subHeight))
				{
					for (int n = _stackSize - 1; n >= 0; n--)
					{
						Point point = new Point(n*_stackOffset.Width + offsetH, n*_stackOffset.Height + offsetV);
						if (bmp != null)
							g.DrawImage(bmp, point);
						else
							g.FillRectangle(new SolidBrush(_backgroundColor), point.X, point.Y, subWidth, subHeight);
						DrawBorder(icon, new Rectangle(point, new Size(subWidth, subHeight)), _borderColor, _borderWidth);
					}
				}
			}
			return icon;
		}
Example #4
0
		private Bitmap GetImageIcon(BitmapCreatorDelegate creator)
		{
			Bitmap icon = new Bitmap(_iconSize.Width, _iconSize.Height);
			using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(icon))
			{
				using (Bitmap bmp = creator(_iconSize.Width, _iconSize.Height))
				{
					if (bmp != null)
						g.DrawImage(bmp, Point.Empty);
					else
						g.FillRectangle(new SolidBrush(_backgroundColor), new Rectangle(Point.Empty, icon.Size));
					DrawBorder(icon, _borderColor, _borderWidth);
				}
			}
			return icon;
		}