[]
Sets the ZoomFactor and determines whether use animation when change ZoomFactor.
public void SetZoomFactor(float zoomFactor, bool useAnimation = false)
Type | Name | Description |
---|---|---|
float | zoomFactor | The new zoom factor. |
bool | useAnimation | true to use animation; otherwise, false. |
The following code example shows how to use this method.
This code example is part of a larger example provided for the AnimationStartingEventArgs class.
class GcZoomAnimationDemo : Form
{
private Button _zoomInBtn = new Button();
private Button _zoomOutBtn = new Button();
private GcZoom _gcZoom1 = new GcZoom();
public GcZoomAnimationDemo()
{
InitializeComponent();
_gcZoom1.Target = this;
_zoomInBtn.Click += _zoomInBtn_Click;
_zoomOutBtn.Click += _zoomOutBtn_Click;
}
void _zoomOutBtn_Click(object sender, EventArgs e)
{
_gcZoom1.SetZoomFactor(1, true);
}
void _zoomInBtn_Click(object sender, EventArgs e)
{
_gcZoom1.SetZoomFactor(2, true);
}
private void InitializeComponent()
{
this._zoomInBtn.Location = new System.Drawing.Point(12, 150);
this._zoomInBtn.Size = new System.Drawing.Size(260, 30);
this._zoomInBtn.Text = "Zoom In";
this._zoomOutBtn.Location = new System.Drawing.Point(12, 200);
this._zoomOutBtn.Size = new System.Drawing.Size(260, 30);
this._zoomOutBtn.Text = "Zoom Out";
this.Controls.Add(this._zoomOutBtn);
this.Controls.Add(this._zoomInBtn);
}
}
Class GcZoomAnimationDemo
Inherits Form
Private _zoomInBtn As New Button()
Private _zoomOutBtn As New Button()
Private _gcZoom1 As New GcZoom()
Public Sub New()
InitializeComponent()
_gcZoom1.Target = Me
AddHandler _zoomInBtn.Click, AddressOf _zoomInBtn_Click
AddHandler _zoomOutBtn.Click, AddressOf _zoomOutBtn_Click
End Sub
Private Sub _zoomOutBtn_Click(sender As Object, e As EventArgs)
_gcZoom1.SetZoomFactor(1, True)
End Sub
Private Sub _zoomInBtn_Click(sender As Object, e As EventArgs)
_gcZoom1.SetZoomFactor(2, True)
End Sub
Private Sub InitializeComponent()
Me._zoomInBtn.Location = New System.Drawing.Point(12, 150)
Me._zoomInBtn.Size = New System.Drawing.Size(260, 30)
Me._zoomInBtn.Text = "Zoom In"
Me._zoomOutBtn.Location = New System.Drawing.Point(12, 200)
Me._zoomOutBtn.Size = New System.Drawing.Size(260, 30)
Me._zoomOutBtn.Text = "Zoom Out"
Me.Controls.Add(Me._zoomOutBtn)
Me.Controls.Add(Me._zoomInBtn)
End Sub
End Class
Type | Condition |
---|---|
ArgumentOutOfRangeException | The assigned value is greater than MaxZoomFactor or less than 1. |