/// <summary>
 /// Initializes a new instance of the <see cref="ImageBoxExtendedZoomEventArgs"/> class.
 /// </summary>
 /// <param name="actions">The zoom operation being performed.</param>
 /// <param name="source">The source of the operation.</param>
 /// <param name="oldZoom">The old zoom level.</param>
 /// <param name="newZoom">The new zoom level.</param>
 public ImageBoxExtendedZoomEventArgs(ImageBoxZoomActions actions, ImageBoxActionSources source, int oldZoom, int newZoom)
     : this()
 {
     this.Actions = actions;
     this.Source  = source;
     this.OldZoom = oldZoom;
     this.NewZoom = newZoom;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ImageBoxZoomEventArgs"/> class.
 /// </summary>
 /// <param name="actions">The zoom operation being performed.</param>
 /// <param name="source">The source of the operation.</param>
 /// <param name="oldZoom">The old zoom level.</param>
 /// <param name="newZoom">The new zoom level.</param>
 public ImageBoxZoomEventArgs(ImageBoxZoomActions actions, ImageBoxActionSources source, int oldZoom, int newZoom)
     : this()
 {
     Actions = actions;
     Source  = source;
     OldZoom = oldZoom;
     NewZoom = newZoom;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ImageBoxZoomEventArgs"/> class.
 /// </summary>
 /// <param name="actions">The zoom operation being performed.</param>
 /// <param name="source">The source of the operation.</param>
 /// <param name="oldZoom">The old zoom level.</param>
 /// <param name="newZoom">The new zoom level.</param>
 public ImageBoxZoomEventArgs(ImageBoxZoomActions actions, ImageBoxActionSources source, int oldZoom, int newZoom)
   : this()
 {
   this.Actions = actions;
   this.Source = source;
   this.OldZoom = oldZoom;
   this.NewZoom = newZoom;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Updates the current zoom.
        /// </summary>
        /// <param name="value">The new zoom value.</param>
        /// <param name="actions">The zoom actions that caused the value to be updated.</param>
        /// <param name="source">The source of the zoom operation.</param>
        private void SetZoom(int value, ImageBoxZoomActions actions, ImageBoxActionSources source)
        {
            int previousZoom;

            previousZoom = this.Zoom;

            if (value < MinZoom)
            {
                value = MinZoom;
            }
            else if (value > MaxZoom)
            {
                value = MaxZoom;
            }

            if (_zoom != value)
            {
                _zoom = value;

                this.OnZoomChanged(EventArgs.Empty);

                this.OnZoomed(new ImageBoxZoomEventArgs(actions, source, previousZoom, this.Zoom));
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Zooms out of the image
 /// </summary>
 /// <param name="source">The source that initiated the action.</param>
 private void PerformZoomOut(ImageBoxActionSources source)
 {
     this.RestoreSizeMode();
     this.SetZoom(this.ZoomLevels.PreviousZoom(this.Zoom), ImageBoxZoomActions.ZoomOut, source);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Zooms into the image
 /// </summary>
 /// <param name="source">The source that initiated the action.</param>
 private void PerformZoomIn(ImageBoxActionSources source)
 {
     this.RestoreSizeMode();
     this.SetZoom(this.ZoomLevels.NextZoom(this.Zoom), ImageBoxZoomActions.ZoomIn, source);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Resets the zoom to 100%.
 /// </summary>
 /// <param name="source">The source that initiated the action.</param>
 private void PerformActualSize(ImageBoxActionSources source)
 {
     this.SizeMode = ImageBoxSizeMode.Normal;
     this.SetZoom(100, ImageBoxZoomActions.ActualSize | (this.Zoom < 100 ? ImageBoxZoomActions.ZoomIn : ImageBoxZoomActions.ZoomOut), source);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Zooms out of the image
 /// </summary>
 /// <param name="source">The source that initiated the action.</param>
 /// <param name="preservePosition"><c>true</c> if the current scrolling position should be preserved relative to the new zoom level, <c>false</c> to reset.</param>
 private void PerformZoomOut(ImageBoxActionSources source, bool preservePosition)
 {
     this.PerformZoom(ImageBoxZoomActions.ZoomOut, source, preservePosition);
 }
Exemplo n.º 9
0
        /// <summary>
        /// Performs a zoom action.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <param name="source">The source that initiated the action.</param>
        /// <param name="preservePosition"><c>true</c> if the current scrolling position should be preserved relative to the new zoom level, <c>false</c> to reset.</param>
        /// <param name="relativePoint">A <see cref="Point"/> describing the current center of the control.</param>
        private void PerformZoom(ImageBoxZoomActions action, ImageBoxActionSources source, bool preservePosition, Point relativePoint)
        {
            Point currentPixel;
            int currentZoom;
            int newZoom;

            currentPixel = this.PointToImage(relativePoint);
            currentZoom = this.Zoom;
            newZoom = this.GetZoomLevel(action);

            this.RestoreSizeMode();
            this.SetZoom(newZoom, action, source);

            if (preservePosition && this.Zoom != currentZoom)
            {
                this.ScrollTo(currentPixel, relativePoint);
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// Performs a zoom action.
 /// </summary>
 /// <param name="action">The action to perform.</param>
 /// <param name="source">The source that initiated the action.</param>
 /// <param name="preservePosition"><c>true</c> if the current scrolling position should be preserved relative to the new zoom level, <c>false</c> to reset.</param>
 private void PerformZoom(ImageBoxZoomActions action, ImageBoxActionSources source, bool preservePosition)
 {
     this.PerformZoom(action, source, preservePosition, this.CenterPoint);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Zooms into the image
 /// </summary>
 /// <param name="source">The source that initiated the action.</param>
 /// <param name="preservePosition"><c>true</c> if the current scrolling position should be preserved relative to the new zoom level, <c>false</c> to reset.</param>
 private void PerformZoomIn(ImageBoxActionSources source, bool preservePosition)
 {
     PerformZoom(ImageBoxZoomActions.ZoomIn, source, preservePosition);
 }