[]
        
(Showing Draft Content)

C1.Win.TouchToolKit.ListViewZoomPolicy

ListViewZoomPolicy Class

Represents a zoom policy for ListView type control.

Inheritance
ListViewZoomPolicy
Namespace: C1.Win.TouchToolKit
Assembly: C1.Win.C1TouchToolKit.4.8.dll
Syntax
public class ListViewZoomPolicy : ZoomPolicy
Remarks

This zoom policy zoom the column width of ListView and change the font of all items.

Examples

The following code example shows how to use ListViewZoomPolicy class.

You can copy the code to a exsit Windows Forms appliction. And set the form in the sample code as start form.

If you find a licenses error when run this code. Try to drag a C1Zoom component to a any Form from tool box can generate the licenses information to this project.

public class ListViewZoomPolicyDemo : Form
{
	private ListView _listView;
	private CheckBox _enableCheckBox;
	private CheckBox _zoomColumnWidthCheckBox;
	private CheckBox _zoomItemFont;
	private TextBox _targetTypeTextBox;
	private ListViewZoomPolicy _listViewZoomPolicy = new ListViewZoomPolicy();
	private GcZoom _gcZoom1 = new GcZoom();

	public ListViewZoomPolicyDemo()
	{
		InitializeComponent();

		_gcZoom1.Target = this;

		// Set ListView's ZoomPolicy object
		_gcZoom1.ZoomPolicies.Add(_listViewZoomPolicy);

		// ListView control should to change default font
		foreach (ListViewItem item in _listView.Items)
		{
			item.Font = new Font(this.Font.FontFamily, this.Font.Size);
		}

		GetTargetType();

		_enableCheckBox.CheckedChanged += _enableCheckBox_CheckedChanged;
		_zoomColumnWidthCheckBox.CheckedChanged += _zoomColumnWidthCheckBox_CheckedChanged;
		_zoomItemFont.CheckedChanged += _zoomItemFont_CheckedChanged;
	}

	void GetTargetType()
	{
		_targetTypeTextBox.Text = _listViewZoomPolicy.TargetType.Name;
	}

	void _enableCheckBox_CheckedChanged(object sender, EventArgs e)
	{
		_gcZoom1.ZoomFactor = 1f;
		_listViewZoomPolicy.Enabled = _enableCheckBox.Checked;

		_zoomColumnWidthCheckBox.Enabled = _enableCheckBox.Checked;
		_zoomItemFont.Enabled = _enableCheckBox.Checked;
	}

	void _zoomColumnWidthCheckBox_CheckedChanged(object sender, EventArgs e)
	{
		_gcZoom1.ZoomFactor = 1f;
		_listViewZoomPolicy.ZoomColumnWidth = _zoomColumnWidthCheckBox.Checked;
	}

	void _zoomItemFont_CheckedChanged(object sender, EventArgs e)
	{
		_gcZoom1.ZoomFactor = 1f;
		_listViewZoomPolicy.ZoomItemFont = _zoomItemFont.Checked;
	}

	private void InitializeComponent()
	{
		_listView = new ListView();
		_listView.Location = new Point(20, 20);
		_listView.Size = new Size(400, 300);
		_listView.GridLines = true;

		_listView.View = View.Details;
		_listView.Columns.Add("", 100, HorizontalAlignment.Center);
		_listView.Columns.Add("", 100, HorizontalAlignment.Center);
		_listView.Columns.Add("", 100, HorizontalAlignment.Center);

		ListViewItem item1 = new ListViewItem(new string[] { "Item 1", "Item 2", "Item 3" });
		ListViewItem item2 = new ListViewItem(new string[] { "Item 4", "Item 5", "Item 6" });
		_listView.Items.Add(item1);
		_listView.Items.Add(item2);

		_enableCheckBox = new CheckBox();
		_enableCheckBox.Text = "Enabled";
		_enableCheckBox.Size = new Size(120, 20);
		_enableCheckBox.Location = new Point(450, 20);
		_enableCheckBox.Checked = true;

		_zoomColumnWidthCheckBox = new CheckBox();
		_zoomColumnWidthCheckBox.Text = "ZoomColumnWidth";
		_zoomColumnWidthCheckBox.Size = new Size(120, 20);
		_zoomColumnWidthCheckBox.Location = new Point(450, 50);
		_zoomColumnWidthCheckBox.Checked = true;

		_zoomItemFont = new CheckBox();
		_zoomItemFont.Text = "ZoomItemFont";
		_zoomItemFont.Size = new Size(120, 20);
		_zoomItemFont.Location = new Point(450, 80);
		_zoomItemFont.Checked = true;

		_targetTypeTextBox = new TextBox();
		_targetTypeTextBox.ReadOnly = true;
		_targetTypeTextBox.Size = new Size(120, 20);
		_targetTypeTextBox.Location = new Point(450, 110);

		this.Controls.Add(_listView);
		this.Controls.Add(_enableCheckBox);
		this.Controls.Add(_zoomColumnWidthCheckBox);
		this.Controls.Add(_zoomItemFont);
		this.Controls.Add(_targetTypeTextBox);
		this.Size = new Size(600, 450);
	}
}
Public Class ListViewZoomPolicyDemo
	Inherits Form
	Private _listView As ListView
	Private _enableCheckBox As CheckBox
	Private _zoomColumnWidthCheckBox As CheckBox
	Private _zoomItemFont As CheckBox
	Private _targetTypeTextBox As TextBox
	Private _listViewZoomPolicy As New ListViewZoomPolicy()
	Private _gcZoom1 As New GcZoom()

	Public Sub New()
		InitializeComponent()

		_gcZoom1.Target = Me

		' Set ListView's ZoomPolicy object
		_gcZoom1.ZoomPolicies.Add(_listViewZoomPolicy)

		' ListView control should to change default font
		For Each item As ListViewItem In _listView.Items
			item.Font = New Font(Me.Font.FontFamily, Me.Font.Size)
		Next

		GetTargetType()

		AddHandler _enableCheckBox.CheckedChanged, AddressOf _enableCheckBox_CheckedChanged
		AddHandler _zoomColumnWidthCheckBox.CheckedChanged, AddressOf _zoomColumnWidthCheckBox_CheckedChanged
		AddHandler _zoomItemFont.CheckedChanged, AddressOf _zoomItemFont_CheckedChanged
	End Sub

	Private Sub GetTargetType()
		_targetTypeTextBox.Text = _listViewZoomPolicy.TargetType.Name
	End Sub

	Private Sub _enableCheckBox_CheckedChanged(sender As Object, e As EventArgs)
		_gcZoom1.ZoomFactor = 1.0F
		_listViewZoomPolicy.Enabled = _enableCheckBox.Checked

		_zoomColumnWidthCheckBox.Enabled = _enableCheckBox.Checked
		_zoomItemFont.Enabled = _enableCheckBox.Checked
	End Sub

	Private Sub _zoomColumnWidthCheckBox_CheckedChanged(sender As Object, e As EventArgs)
		_gcZoom1.ZoomFactor = 1.0F
		_listViewZoomPolicy.ZoomColumnWidth = _zoomColumnWidthCheckBox.Checked
	End Sub

	Private Sub _zoomItemFont_CheckedChanged(sender As Object, e As EventArgs)
		_gcZoom1.ZoomFactor = 1.0F
		_listViewZoomPolicy.ZoomItemFont = _zoomItemFont.Checked
	End Sub

	Private Sub InitializeComponent()
		_listView = New ListView()
		_listView.Location = New Point(20, 20)
		_listView.Size = New Size(400, 300)
		_listView.GridLines = True

		_listView.View = View.Details
		_listView.Columns.Add("", 100, HorizontalAlignment.Center)
		_listView.Columns.Add("", 100, HorizontalAlignment.Center)
		_listView.Columns.Add("", 100, HorizontalAlignment.Center)

		Dim item1 As New ListViewItem(New String() { "Item 1", "Item 2", "Item 3"})
		Dim item2 As New ListViewItem(New String() { "Item 4", "Item 5", "Item 6"})
		_listView.Items.Add(item1)
		_listView.Items.Add(item2)

		_enableCheckBox = New CheckBox()
		_enableCheckBox.Text = "Enabled"
		_enableCheckBox.Size = New Size(120, 20)
		_enableCheckBox.Location = New Point(450, 20)
		_enableCheckBox.Checked = True

		_zoomColumnWidthCheckBox = New CheckBox()
		_zoomColumnWidthCheckBox.Text = "ZoomColumnWidth"
		_zoomColumnWidthCheckBox.Size = New Size(120, 20)
		_zoomColumnWidthCheckBox.Location = New Point(450, 50)
		_zoomColumnWidthCheckBox.Checked = True

		_zoomItemFont = New CheckBox()
		_zoomItemFont.Text = "ZoomItemFont"
		_zoomItemFont.Size = New Size(120, 20)
		_zoomItemFont.Location = New Point(450, 80)
		_zoomItemFont.Checked = True

		_targetTypeTextBox = New TextBox()
		_targetTypeTextBox.[ReadOnly] = True
		_targetTypeTextBox.Size = New Size(120, 20)
		_targetTypeTextBox.Location = New Point(450, 110)

		Me.Controls.Add(_listView)
		Me.Controls.Add(_enableCheckBox)
		Me.Controls.Add(_zoomColumnWidthCheckBox)
		Me.Controls.Add(_zoomItemFont)
		Me.Controls.Add(_targetTypeTextBox)
		Me.Size = New Size(600, 450)
	End Sub
End Class

Constructors

Name Description
ListViewZoomPolicy()

Properties

Name Description
TargetType

Gets the type indicates which control type can use this policy.

ZoomColumnWidth

Gets or sets a value indicating whether zoom column's width.

ZoomIcon

Gets or sets a value indicating whether zoom item's icon.

ZoomItemFont

Gets or sets a value indicating whether zoom item's font.

Methods

Name Description
ZoomBounds(Control, ZoomBoundsInfo)

Zoom the control bounds.

ZoomFont(Control, ZoomFontInfo)

Zoom the control font.

See Also