[]
        
(Showing Draft Content)

C1.Win.TouchToolKit.C1ZoomCommandProvider

C1ZoomCommandProvider Class

Represents the component which can be attached to any existing UserControl, and made all IButtonControl on current Usercontrol can be execute the ZoomCommands.

Inheritance
C1ZoomCommandProvider
Namespace: C1.Win.TouchToolKit
Assembly: C1.Win.TouchToolKit.8.dll
Syntax
[ToolboxBitmap(typeof(C1ZoomCommandProvider), "ControlBarCommands.png")]
public class C1ZoomCommandProvider : Component, IComponent, IDisposable, IExtenderProvider
Remarks

When attach C1ZoomCommandProvider to current UserControl, all of IButtonControl control will add a smarttag, the smartag contain a ZoomCommands item.

A UserControl can't attach two or more C1ZoomCommandProvider component.

Examples

The following code example shows how to use the C1ZoomCommandProvider component.

public class ControlBarDemo : Form
{
	private Button _controlBarButton;
	private MyUserControl _userControl = new MyUserControl();
	private GcZoom _gcZoom1 = new GcZoom();

	public ControlBarDemo()
	{
		InitializeComponent();

		_gcZoom1.Target = this;

		// Create ControlBar
		AddControlBar();
	}

	private void AddControlBar()
	{
		ControlBar controlBar = new ControlBar();

		// Content should is a Type of UserControl.
		controlBar.Content = _userControl.GetType();

		controlBar.PositionMode = PositionMode.Floating;

		// Only take effect when Position Mode is Dock.
		// controlBar.DockPosition = ContentAlignment.MiddleCenter;
		// controlBar.Margin = new System.Windows.Forms.Padding();

		// Only take effect when PositionMode is Fix or Flowing.
		controlBar.Position = new Point(20, 20);

		controlBar.Opacity = 1d;
		controlBar.TransparentBackground = true;

		_gcZoom1.ControlBars.Add(controlBar);
	}

	private void InitializeComponent()
	{
		_controlBarButton = new Button();
		_controlBarButton.Text = "This is a Button";
		_controlBarButton.Location = new Point(100, 100);
		_controlBarButton.Size = new Size(120, 30);
		this.Controls.Add(_controlBarButton);
	}
}

public class MyUserControl : UserControl
{
	private GcZoomCommandProvider commands = new GcZoomCommandProvider();
	private Button _zoomInButton;
	private Button _zoomOutButton;
	private Button _getButton;

	public MyUserControl()
	{
		InitializeComponent();

		commands.Target = this;
		commands.SetZoomCommands(_zoomInButton, ZoomCommands.ZoomIn);
		Console.WriteLine(commands.GetZoomCommands(_zoomInButton).ToString());

		commands.SetZoomCommands(_zoomOutButton, ZoomCommands.ZoomOut);
		Console.WriteLine(commands.GetZoomCommands(_zoomOutButton).ToString());

		_getButton.Click += _getButton_Click;
	}

	void _getButton_Click(object sender, EventArgs e)
	{
		Console.WriteLine(commands.OwnerForm.ToString());
		Console.WriteLine(commands.OwnerGcZoom.ToString());
	}

	private void InitializeComponent()
	{
		_zoomInButton = new Button();
		_zoomInButton.Text = "+";
		_zoomInButton.Size = new Size(40, 40);
		_zoomInButton.Location = new Point(10, 10);

		_zoomOutButton = new Button();
		_zoomOutButton.Text = "_";
		_zoomOutButton.Size = new Size(40, 40);
		_zoomOutButton.Location = new Point(60, 10);

		_getButton = new Button();
		_getButton.Text = "Get";
		_getButton.Size = new Size(40, 40);
		_getButton.Location = new Point(110, 10);

		this.Size = new Size(160, 60);
		this.Controls.Add(_zoomInButton);
		this.Controls.Add(_zoomOutButton);
		this.Controls.Add(_getButton);
	}
}
Public Class ControlBarDemo
	Inherits Form
	Private _controlBarButton As Button
	Private _userControl As New MyUserControl()
	Private _gcZoom1 As New GcZoom()

	Public Sub New()
		InitializeComponent()

		_gcZoom1.Target = Me

		' Create ControlBar
		AddControlBar()
	End Sub

	Private Sub AddControlBar()
		Dim controlBar As New ControlBar()

		' Content should is a Type of UserControl.
		controlBar.Content = _userControl.[GetType]()
		controlBar.PositionMode = PositionMode.Floating

		' Only take effect when Position Mode is Dock.
		' controlBar.DockPosition = ContentAlignment.MiddleCenter;
		' controlBar.Margin = new System.Windows.Forms.Padding();

		' Only take effect when PositionMode is Fix or Flowing.
		controlBar.Position = New Point(20, 20)

		controlBar.Opacity = 1.0
		controlBar.TransparentBackground = True

		_gcZoom1.ControlBars.Add(controlBar)
	End Sub

	Private Sub InitializeComponent()
		_controlBarButton = New Button()
		_controlBarButton.Text = "This is a Button"
		_controlBarButton.Location = New Point(100, 100)
		_controlBarButton.Size = New Size(120, 30)
		Me.Controls.Add(_controlBarButton)
	End Sub
End Class

Public Class MyUserControl
	Inherits UserControl
	Private commands As New GcZoomCommandProvider()
	Private _zoomInButton As Button
	Private _zoomOutButton As Button
	Private _getButton As Button

	Public Sub New()
 		InitializeComponent()

		commands.Target = Me
		commands.SetZoomCommands(_zoomInButton, ZoomCommands.ZoomIn)
		Console.WriteLine(commands.GetZoomCommands(_zoomInButton).ToString())

		commands.SetZoomCommands(_zoomOutButton, ZoomCommands.ZoomOut)
		Console.WriteLine(commands.GetZoomCommands(_zoomOutButton).ToString())

		AddHandler _getButton.Click, AddressOf _getButton_Click
	End Sub

	Private Sub _getButton_Click(sender As Object, e As EventArgs)
		Console.WriteLine(commands.OwnerForm.ToString())
		Console.WriteLine(commands.OwnerGcZoom.ToString())
	End Sub

	Private Sub InitializeComponent()
 		_zoomInButton = New Button()
 		_zoomInButton.Text = "+"
 		_zoomInButton.Size = New Size(40, 40)
 		_zoomInButton.Location = New Point(10, 10)

 		_zoomOutButton = New Button()
 		_zoomOutButton.Text = "_"
 		_zoomOutButton.Size = New Size(40, 40)
 		_zoomOutButton.Location = New Point(60, 10)

 		_getButton = New Button()
 		_getButton.Text = "Get"
 		_getButton.Size = New Size(40, 40)
 		_getButton.Location = New Point(110, 10)

 		Me.Size = New Size(160, 60)
 		Me.Controls.Add(_zoomInButton)
 		Me.Controls.Add(_zoomOutButton)
 		Me.Controls.Add(_getButton)
	End Sub
End Class

Constructors

Name Description
C1ZoomCommandProvider()

Initializes a new instance of the C1ZoomCommandProvider class.

C1ZoomCommandProvider(IContainer)

Initializes a new instance of the C1ZoomCommandProvider class.

Properties

Name Description
OwnerForm

Gets the form that owns this ControlBar.

OwnerGcZoom

Gets the C1Zoom that owns this C1ZoomCommandProvider.

Site

Gets or sets the ISite of the Component.

Methods

Name Description
AboutBox()

Shows the product information window.

CanExtend(object)

Specifies whether this object can provide its extender properties to the specified object.

Dispose(bool)

Releases the unmanaged resources used by the Component and optionally releases the managed resources.

GetZoomCommands(IButtonControl)

Retrieves the C1ZoomCommandProvider associated with the specified IButtonControl or not.

SetZoomCommands(IButtonControl, ZoomCommands)

Associates C1ZoomCommandProvider with the specified IButtonControl.