[]
        
(Showing Draft Content)

C1.Win.TouchToolKit.C1ApplicationZoom.GetC1Zoom

GetC1Zoom Method

GetC1Zoom(Form)

Gets the associated C1Zoom by a specific form.

Declaration
public static C1Zoom GetC1Zoom(Form form)
Parameters
Type Name Description
Form form

The form.

Returns
Type Description
C1Zoom

A C1Zoom value that associated to specific form.

Examples

The following code example shows how to use this method.

This code example is part of a larger example provided for the C1ApplicationZoom class.

public class GcApplicationZoomDemo : Form
{
	private Button _showFormButton;
	private GcApplicationZoom _gcApplicationZoom;

	public GcApplicationZoomDemo()
	{
		InitializeComponent();

		_showFormButton.Click += _showFormButton_Click;
		_gcApplicationZoom.GcZoomAttached += _gcApplicationZoom_GcZoomAttached;
		_gcApplicationZoom.GcZoomDetached += _gcApplicationZoom_GcZoomDetached;
	}

	void _gcApplicationZoom_GcZoomAttached(object sender, GcZoomAttachedEventArgs e)
	{
		// If you want specific GcZoom's setting different from GcApplicationZoom, You can change it in
		// GcZoomAttaching or GcZoomAttached event.
		e.GcZoom.MaxZoomFactor = 4f;

		if (e.Form is ZoomForm)
		{
			e.GcZoom.ZoomFactorChanged += (e.Form as ZoomForm).ZoomFactorChangeProc;
		}
	}

	void _gcApplicationZoom_GcZoomDetached(object sender, GcZoomDetachedEventArgs e)
	{
		if (e.Form is ZoomForm)
		{
			e.GcZoom.ZoomFactorChanged -= (e.Form as ZoomForm).ZoomFactorChangeProc;
		}
	}

	void _showFormButton_Click(object sender, EventArgs e)
	{
		Form form = new ZoomForm();
		form.Show();
	}

	private void InitializeComponent()
	{
		_gcApplicationZoom = new GcApplicationZoom();
		_showFormButton = new Button();
		_showFormButton.Text = "Click to open ZoomForm";
		_showFormButton.Location = new Point(20, 20);
		_showFormButton.Size = new Size(200, 40);
		this.Controls.Add(_showFormButton);
	}
}

internal class ZoomForm : Form 
{
	public ZoomForm()
	{
	}

	public void ZoomFactorChangeProc(object sender, EventArgs e)
	{
		Console.WriteLine(GcApplicationZoom.GetGcZoom(this).ZoomFactor.ToString());
	}
}
Public Class GcApplicationZoomDemo
	Inherits Form
	Private _showFormButton As Button
	Private _gcApplicationZoom As GcApplicationZoom

	Public Sub New()
		InitializeComponent()

		AddHandler _showFormButton.Click, AddressOf _showFormButton_Click
		AddHandler _gcApplicationZoom.GcZoomAttached, AddressOf _gcApplicationZoom_GcZoomAttached
		AddHandler _gcApplicationZoom.GcZoomDetached, AddressOf _gcApplicationZoom_GcZoomDetached
	End Sub

	Private Sub _gcApplicationZoom_GcZoomAttached(sender As Object, e As GcZoomAttachedEventArgs)
		' If you want specific GcZoom's setting different from GcApplicationZoom, You can change it in
		' GcZoomAttaching or GcZoomAttached event.
		e.GcZoom.MaxZoomFactor = 4.0F

		If TypeOf e.Form Is ZoomForm Then
			AddHandler e.GcZoom.ZoomFactorChanged, AddressOf TryCast(e.Form, ZoomForm).ZoomFactorChangeProc
		End If
	End Sub

	Private Sub _gcApplicationZoom_GcZoomDetached(sender As Object, e As GcZoomDetachedEventArgs)
		If TypeOf e.Form Is ZoomForm Then
			RemoveHandler e.GcZoom.ZoomFactorChanged, AddressOf TryCast(e.Form, ZoomForm).ZoomFactorChangeProc
		End If
	End Sub

	Private Sub _showFormButton_Click(sender As Object, e As EventArgs)
		Dim form As Form = New ZoomForm()
		form.Show()
	End Sub

	Private Sub InitializeComponent()
		_gcApplicationZoom = New GcApplicationZoom()

		_showFormButton = New Button()
		_showFormButton.Text = "Click to open ZoomForm"
		_showFormButton.Location = New Point(20, 20)
		_showFormButton.Size = New Size(200, 40)
		Me.Controls.Add(_showFormButton)
	End Sub
End Class

Friend Class ZoomForm
	Inherits Form

	Public Sub New()
	End Sub

	Public Sub ZoomFactorChangeProc(sender As Object, e As EventArgs)
		Console.WriteLine(GcApplicationZoom.GetGcZoom(Me).ZoomFactor.ToString())
	End Sub
End Class