예제 #1
0
        /// <inheritdoc />
        public override IDisposable BeginShape(Color color)
        {
            var localPath = new GraphicsPath(FillMode.Alternate);

            this.path = localPath;

            return(new ActionDisposable(() =>
            {
                Interlocked.CompareExchange(ref this.path, null, localPath);

                var state = graphics.Save();
                try
                {
                    graphics.SmoothingMode = SmoothingMode.AntiAlias;
                    graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;

                    using (var brush = new SolidBrush(color.ToGdi()))
                    {
                        graphics.FillPath(brush, localPath);
                    }
                }
                finally
                {
                    graphics.Restore(state);
                    localPath.Dispose();
                }
            }));
        }
예제 #2
0
 /// <inheritdoc />
 public override void SetBackground(Color color, Rectangle iconBounds)
 {
     using (var brush = new SolidBrush(color.ToGdi()))
     {
         graphics.FillRectangle(brush, iconBounds.X, iconBounds.Y, iconBounds.Width, iconBounds.Height);
     }
 }
예제 #3
0
 /// <inheritdoc />
 public override void SetBackground(Color color)
 {
     graphics.Clear(color.ToGdi());
 }