AutoScrollingMinSize is setup in device coordinates. If you are using a world coordinate system other than pixels this means that you have to translate between world and device coordinates before you set this value. You can use the Graphics.TransformPoints method to do this as shown below.
g.TransformPoints( CoordinateSpace.Device, CoordinateSpace.World, ptScrollSize );
All this does is convert from the GraphicsUnit that you are using to pixels. For example, if your GraphicsUnit is Inch, then with a Graphics object that represents a monitor screen you will have translated values that come to about 100 pixels for every logical inch. Using this method ensures that you are insulated from the underlying device. The values will be much higher for printers. Another important point to remember is that your Transform in the painting code will have to be in logical coordinates and will hence have to translate between logical and device coordinates.
protected void OnHandlePaint(object sender, PaintEventArgs args)
{
Graphics g = args.Graphics;
g.PageUnit = GraphicsUnit.Inch;
// this will always be in pixels
Point[] ptAutoScrollPos = new Point[] { AutoScrollPosition };
// We have to convert the pixel value (device) to inches (logical..world)
g.TransformPoints( CoordinateSpace.World, CoordinateSpace.Device, ptAutoScrollPos );
// set up a simple translation so that we draw with respect to the doc bounds
// and not the physical bounds
g.TranslateTransform( ptAutoScrollPos[ 0 ].X, ptAutoScrollPos[ 0 ].Y );
g.DrawEllipse( pen, rectEllipse );
}
Play around with the sample and all should be clear. When you run the sample nothing will be seen on the screen. Scroll around. Remember the logical units are in inches. You will be looking at a huge ellipse!
Syncfusion Staff