C# Class SANTA.UI.ZPImageBox

A zoom-able, pan-able image box for displaying and navigating around images.
Inheritance: System.Windows.Forms.ScrollableControl
Exibir arquivo Open project: siegleal/iSanta

Protected Properties

Property Type Description
_dragging bool
_image Image
_imageFocus Point
_mode Mode
_multipleFiles bool
_zoom float
grabCursor System.Windows.Forms.Cursor
grabbingCursor System.Windows.Forms.Cursor

Public Methods

Method Description
SetImage ( Bitmap image ) : void

Change the currently displayed image.

SetImage ( Bitmap image, bool reset ) : void

Change the currently displayed image

SetMultipleFileMode ( bool multipleFiles ) : void

Change if multiple files are selected or not. Multiple images cannot be displayed if this is set to true.

ZPImageBox ( ) : System

Construct a ZPImageBox

Protected Methods

Method Description
Box2ImageCoord ( Point boxCoord ) : Point

Convert a point from mouse coordinates to image coordinates.

Near ( Point a, Point b, float dist ) : bool

Determine if two points are within a certain distance of each other.

ResetImage ( bool moveToBoxCenter ) : void

Change the zoom level so the image is entirely viewable.

Private Methods

Method Description
DrawImage ( object sender, PaintEventArgs e ) : void

Paint the image to the box.

SetEventHandlers ( ) : void
ZPImageBox_KeyDown ( object sender, KeyEventArgs e ) : void

If the Control key was pressed, put the image into Manipulate mode.

ZPImageBox_KeyUp ( object sender, KeyEventArgs e ) : void

If the Control key was released, put the image into Navigate mode.

ZPImageBox_MouseDown ( object sender, MouseEventArgs e ) : void

Handle navigation interaction

ZPImageBox_MouseEnter ( object sender, EventArgs e ) : void

This needs to grab focus when the mouse enters so that input can be handled.

ZPImageBox_MouseMove ( object sender, MouseEventArgs e ) : void

Move the image around.

ZPImageBox_MouseUp ( object sender, MouseEventArgs e ) : void

Disable dragging mode.

ZPImageBox_MouseWheel ( object sender, MouseEventArgs e ) : void

Zoom in or out of the image.

Method Details

Box2ImageCoord() protected method

Convert a point from mouse coordinates to image coordinates.
protected Box2ImageCoord ( Point boxCoord ) : Point
boxCoord Point Coordinate in the box's coordinate system.
return Point

Near() protected static method

Determine if two points are within a certain distance of each other.
protected static Near ( Point a, Point b, float dist ) : bool
a Point First point.
b Point Second Point.
dist float The
return bool

ResetImage() protected method

Change the zoom level so the image is entirely viewable.
protected ResetImage ( bool moveToBoxCenter ) : void
moveToBoxCenter bool Should the image be moved back to the center of the box
return void

SetImage() public method

Change the currently displayed image.
public SetImage ( Bitmap image ) : void
image System.Drawing.Bitmap The new image to display.
return void

SetImage() public method

Change the currently displayed image
public SetImage ( Bitmap image, bool reset ) : void
image System.Drawing.Bitmap The new image to display
reset bool Whether to reset the zoom level and focal point
return void

SetMultipleFileMode() public method

Change if multiple files are selected or not. Multiple images cannot be displayed if this is set to true.
public SetMultipleFileMode ( bool multipleFiles ) : void
multipleFiles bool Are multiple files selected
return void

ZPImageBox() public method

Construct a ZPImageBox
public ZPImageBox ( ) : System
return System

Property Details

_dragging protected_oe property

Is the _image being dragged/moved around.
protected bool _dragging
return bool

_image protected_oe property

Image to display
protected Image _image
return Image

_imageFocus protected_oe property

_imageFocus is the point in the image's coordinate system that corresponds to the _boxFocus, which is the point in the ZPImageBox coordinate system where the user last clicked when moving the image.
protected Point _imageFocus
return Point

_mode protected_oe property

The current method of interaction with the ZPImageBox.
protected Mode _mode
return Mode

_multipleFiles protected_oe property

Have multiple files been selected.
protected bool _multipleFiles
return bool

_zoom protected_oe property

These specify the range of scaling factors for the image.
protected float _zoom
return float

grabCursor protected_oe static_oe property

Cursor to use when the mouse button is depressed. It looks like an opened hand.
protected static Cursor,System.Windows.Forms grabCursor
return System.Windows.Forms.Cursor

grabbingCursor protected_oe static_oe property

Cursor to use when the mouse button is not depressed. It looks like a hand grabbing.
protected static Cursor,System.Windows.Forms grabbingCursor
return System.Windows.Forms.Cursor