public override void Draw(IDrawingGraphics drawingGraphics) { var dg = drawingGraphics; if (this.clipBitmap == null) { this.clipBitmap = new Bitmap(this.Size.Width.ToPixels(), this.Size.Height.ToPixels()-1); // TODO roundup errors! } if (CachePanning && panInProgress && this.clipBitmap != null) { drawingGraphics.Graphics.DrawImage(this.clipBitmap, drawingGraphics.CalculateX(this.HorizontalOffset - this.panH), drawingGraphics.CalculateY(this.VerticalOffset - this.panV)); }else { using (var clipBitmap = drawingGraphics.GetClipBuffer(new Rectangle(0, 0, this.Size.Width, this.Size.Height), this.clipBitmap)) { /* Do shadows */ if (this.DrawShadows) { if (TopShadow == null) { TopShadow = new Bitmap(this.Size.Width.ToPixels(), drawingGraphics.CalculateHeight(ShadowHeight)); BottomShadow = new Bitmap(this.Size.Width.ToPixels(), drawingGraphics.CalculateHeight(ShadowHeight)); } if (this.VerticalOffset < 0) { drawingGraphics.GetOpaqueClipBuffer(new Rectangle(0, 0, this.Size.Width, this.ShadowHeight), TopShadow).Dispose(); } if (this.VerticalOffset > Math.Min(0, -this.Content.Size.Height + this.Size.Height)) { drawingGraphics.GetOpaqueClipBuffer(new Rectangle(0, this.Size.Height + 1 - ShadowHeight, this.Size.Width, ShadowHeight), BottomShadow).Dispose(); } } this.Content.Draw(clipBitmap.DrawingGr.CreateChild(new Point(this.HorizontalOffset, this.VerticalOffset), this.content.TransformationScaling, this.content.TransformationCenter)); if (this.ShowScrollbars) { this.DrawScrollBar(clipBitmap.DrawingGr); } } } if (this.DrawShadows) { if (this.VerticalOffset < 0) { int cheight = 0; for(int s = 0; s < ShadowSteps; s++) { drawingGraphics.Graphics.AlphaBlend(TopShadow, new Rectangle(dg.CalculateX(0), dg.CalculateY(0)+cheight, TopShadow.Width, TopShadow.Height/ShadowSteps), new Rectangle(0, cheight, TopShadow.Width, TopShadow.Height/ShadowSteps), 0.95f - 1f/(ShadowSteps+2)*s); cheight += TopShadow.Height/ShadowSteps; } } if (this.VerticalOffset > Math.Min(0, -this.Content.Size.Height + this.Size.Height)) { int cheight = 0; for(int s = 0; s < ShadowSteps; s++) { drawingGraphics.Graphics.AlphaBlend(BottomShadow, new Rectangle(dg.CalculateX(0), dg.CalculateY(this.Size.Height-ShadowHeight)+cheight, BottomShadow.Width, BottomShadow.Height/ShadowSteps), new Rectangle(0, cheight, BottomShadow.Width, BottomShadow.Height/ShadowSteps), 1f/(ShadowSteps+2)*(s+2)); cheight += BottomShadow.Height/ShadowSteps; } } } }
public override void Draw(IDrawingGraphics drawingGraphics) { var dg = drawingGraphics; if (this.clipBitmap == null) { this.clipBitmap = new Bitmap(this.Size.Width.ToPixels(), this.Size.Height.ToPixels() - 1); // TODO roundup errors! } if (CachePanning && panInProgress && this.clipBitmap != null) { drawingGraphics.Graphics.DrawImage(this.clipBitmap, drawingGraphics.CalculateX(this.HorizontalOffset - this.panH), drawingGraphics.CalculateY(this.VerticalOffset - this.panV)); } else { using (var clipBitmap = drawingGraphics.GetClipBuffer(new Rectangle(0, 0, this.Size.Width, this.Size.Height), this.clipBitmap)) { /* Do shadows */ if (this.DrawShadows) { if (TopShadow == null) { TopShadow = new Bitmap(this.Size.Width.ToPixels(), drawingGraphics.CalculateHeight(ShadowHeight)); BottomShadow = new Bitmap(this.Size.Width.ToPixels(), drawingGraphics.CalculateHeight(ShadowHeight)); } if (this.VerticalOffset < 0) { drawingGraphics.GetOpaqueClipBuffer(new Rectangle(0, 0, this.Size.Width, this.ShadowHeight), TopShadow).Dispose(); } if (this.VerticalOffset > Math.Min(0, -this.Content.Size.Height + this.Size.Height)) { drawingGraphics.GetOpaqueClipBuffer(new Rectangle(0, this.Size.Height + 1 - ShadowHeight, this.Size.Width, ShadowHeight), BottomShadow).Dispose(); } } this.Content.Draw(clipBitmap.DrawingGr.CreateChild(new Point(this.HorizontalOffset, this.VerticalOffset), this.content.TransformationScaling, this.content.TransformationCenter)); if (this.ShowScrollbars) { this.DrawScrollBar(clipBitmap.DrawingGr); } } } if (this.DrawShadows) { if (this.VerticalOffset < 0) { int cheight = 0; for (int s = 0; s < ShadowSteps; s++) { drawingGraphics.Graphics.AlphaBlend(TopShadow, new Rectangle(dg.CalculateX(0), dg.CalculateY(0) + cheight, TopShadow.Width, TopShadow.Height / ShadowSteps), new Rectangle(0, cheight, TopShadow.Width, TopShadow.Height / ShadowSteps), 0.95f - 1f / (ShadowSteps + 2) * s); cheight += TopShadow.Height / ShadowSteps; } } if (this.VerticalOffset > Math.Min(0, -this.Content.Size.Height + this.Size.Height)) { int cheight = 0; for (int s = 0; s < ShadowSteps; s++) { drawingGraphics.Graphics.AlphaBlend(BottomShadow, new Rectangle(dg.CalculateX(0), dg.CalculateY(this.Size.Height - ShadowHeight) + cheight, BottomShadow.Width, BottomShadow.Height / ShadowSteps), new Rectangle(0, cheight, BottomShadow.Width, BottomShadow.Height / ShadowSteps), 1f / (ShadowSteps + 2) * (s + 2)); cheight += BottomShadow.Height / ShadowSteps; } } } }