public void Redraw()
{
if (g == null)
return;
g.Clear(Color.White);
g.InterpolationMode = InterpolationMode.NearestNeighbor;
ColorMatrix cm = new ColorMatrix();
ImageAttributes ia = new ImageAttributes();
Rectangle dest = new Rectangle(0, 0, this.Width, this.Height);
Rectangle source = new Rectangle(OffsetX, OffsetY, (int)Math.Round(((double)this.Width) / ((double)Magnification)), (int)Math.Round(((double)this.Height) / ((double)Magnification)));
for (int i = Layers.Count - 1; i >= 0; i--)
{
if (!Layers[i].Visible)
continue;
cm.Matrix33 = Layers[i].Opacity;
ia.SetColorMatrix(cm);
g.DrawImage(Layers[i].Image, dest, source.X, source.Y, source.Width, source.Height, GraphicsUnit.Pixel, ia);
}
if (scrollHorizontal.Visible && scrollVertical.Visible)
{
//draw over the corner between the scrollbars
dest = new Rectangle(scrollVertical.Location.X, scrollHorizontal.Location.Y, scrollVertical.Width, scrollHorizontal.Height);
Brush b = new SolidBrush(SystemColors.Control);
g.FillRectangle(b, dest);
b.Dispose();
}
this.Refresh();
}