[]
Represents the component which can be attached to any existing form, and made the form can be zoom by two finger touch.
[ToolboxBitmap(typeof(C1Zoom), "Zoom.png")]
public class C1Zoom : Component, IComponent, IDisposable
When form load, GcZoom will change all form's children control to a inner panel. So after form loaded, you can't access children controls by Form.Controls property. You should use GcZoom.Controls property instead.
If the form contains a C1ZoomPanel, C1Zoom can't attach to the form.
A form can't attach two or more GcZoom component.
The C1Zoom can't change the tooltip, contextMenu, common dialog's font and size.
The following code example shows how to configure C1Zoom component to get different zoom effect.
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 GcZoomDemo : Form
{
private Label _label1;
private ComboBox _previewModeComboBox;
private Label _label2;
private ComboBox _boundaryFeedbackModeComboBox;
private Label _label3;
private TextBox _maxZoomFactorTextBox;
private Label _label4;
private TextBox _zoomFactorTextBox;
private TextBox _zoomFactor2TextBox;
private GcZoom _gcZoom1 = new GcZoom();
public GcZoomDemo()
{
InitializeComponent();
SetGcZoomTarget();
_previewModeComboBox.SelectedIndexChanged += previewModeComboBox_SelectedIndexChanged;
_boundaryFeedbackModeComboBox.SelectedIndexChanged += boundaryFeedbackModeComboBox_SelectedIndexChanged;
_maxZoomFactorTextBox.TextChanged += maxZoomFactorTextBox_TextChanged;
_zoomFactorTextBox.TextChanged += zoomFactorTextBox_TextChanged;
// GcZoom's ZoomFactor changed event
_gcZoom1.ZoomFactorChanged += gcZoom1_ZoomFactorChanged;
}
void boundaryFeedbackModeComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
switch (_boundaryFeedbackModeComboBox.Text)
{
case "Split":
_gcZoom1.BoundaryFeedbackMode = BoundaryFeedbackMode.Split;
break;
case "Standard":
_gcZoom1.BoundaryFeedbackMode = BoundaryFeedbackMode.Standard;
break;
default:
break;
}
}
void previewModeComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
switch (_previewModeComboBox.Text)
{
case "Bitmap":
_gcZoom1.ZoomPreviewMode = ZoomPreviewMode.Bitmap;
break;
case "AlternativeContent":
_gcZoom1.ZoomPreviewMode = ZoomPreviewMode.AlternativeContent;
_gcZoom1.AlternativeContentSettings.ForeColor = SystemColors.ControlDarkDark;
_gcZoom1.AlternativeContentSettings.Format = "Zooming {Percentage}%";
break;
case "NoPreview":
_gcZoom1.ZoomPreviewMode = ZoomPreviewMode.NoPreview;
break;
default:
break;
}
}
void SetGcZoomTarget()
{
_gcZoom1.Target = this;
}
void maxZoomFactorTextBox_TextChanged(object sender, EventArgs e)
{
string value = _maxZoomFactorTextBox.Text.Trim();
try
{
float maxFactor = (float)Convert.ToDouble(value);
_gcZoom1.MaxZoomFactor = maxFactor;
}
catch
{
_gcZoom1.MaxZoomFactor = 2f;
}
}
void zoomFactorTextBox_TextChanged(object sender, EventArgs e)
{
string value = _zoomFactorTextBox.Text.Trim();
try
{
float zoomFactor = (float)Convert.ToDouble(value);
_gcZoom1.ZoomFactor = zoomFactor;
}
catch
{
Console.WriteLine(e.ToString());
_gcZoom1.ZoomFactor = 1f;
}
}
void gcZoom1_ZoomFactorChanged(object sender, EventArgs e)
{
_zoomFactor2TextBox.Text = _gcZoom1.ZoomFactor.ToString();
}
private void InitializeComponent()
{
_label1 = new Label();
_label1.Text = "ZoomPreviewMode";
_label1.Location = new Point(20, 20);
_label1.Size = new Size(140, 20);
_previewModeComboBox = new ComboBox();
_previewModeComboBox.Items.AddRange(new object[] { "Bitmap", "AlternativeContent", "NoPreview" });
_previewModeComboBox.Location = new Point(160, 20);
_label2 = new Label();
_label2.Text = "BoundaryFeedbackMode";
_label2.Location = new Point(20, 50);
_label2.Size = new Size(140, 20);
_boundaryFeedbackModeComboBox = new ComboBox();
_boundaryFeedbackModeComboBox.Items.AddRange(new object[] { "Split", "Standard"});
_boundaryFeedbackModeComboBox.Location = new Point(160, 50);
_label3 = new Label();
_label3.Text = "MaxZoomFactor";
_label3.Location = new Point(20, 80);
_label3.Size = new Size(140, 20);
_maxZoomFactorTextBox = new TextBox();
_maxZoomFactorTextBox.Location = new Point(160, 80);
_label4 = new Label();
_label4.Text = "ZoomFactor";
_label4.Location = new Point(20, 110);
_label4.Size = new Size(140, 20);
_zoomFactorTextBox = new TextBox();
_zoomFactorTextBox.Location = new Point(160, 110);
_zoomFactor2TextBox = new TextBox();
_zoomFactor2TextBox.Text = "1";
_zoomFactor2TextBox.ReadOnly = true;
_zoomFactor2TextBox.Location = new Point(160, 135);
this.Controls.Add(_label1);
this.Controls.Add(_previewModeComboBox);
this.Controls.Add(_label2);
this.Controls.Add(_boundaryFeedbackModeComboBox);
this.Controls.Add(_label3);
this.Controls.Add(_maxZoomFactorTextBox);
this.Controls.Add(_label4);
this.Controls.Add(_zoomFactorTextBox);
this.Controls.Add(_zoomFactor2TextBox);
}
}
Public Class GcZoomDemo
Inherits Form
Private _label1 As Label
Private _previewModeComboBox As ComboBox
Private _label2 As Label
Private _boundaryFeedbackModeComboBox As ComboBox
Private _label3 As Label
Private _maxZoomFactorTextBox As TextBox
Private _label4 As Label
Private _zoomFactorTextBox As TextBox
Private _zoomFactor2TextBox As TextBox
Private _gcZoom1 As New GcZoom()
Public Sub New()
InitializeComponent()
SetGcZoomTarget()
AddHandler _previewModeComboBox.SelectedIndexChanged, AddressOf previewModeComboBox_SelectedIndexChanged
AddHandler _boundaryFeedbackModeComboBox.SelectedIndexChanged, AddressOf boundaryFeedbackModeComboBox_SelectedIndexChanged
AddHandler _maxZoomFactorTextBox.TextChanged, AddressOf maxZoomFactorTextBox_TextChanged
AddHandler _zoomFactorTextBox.TextChanged, AddressOf zoomFactorTextBox_TextChanged
' GcZoom's ZoomFactor changed event
AddHandler _gcZoom1.ZoomFactorChanged, AddressOf gcZoom1_ZoomFactorChanged
End Sub
Private Sub boundaryFeedbackModeComboBox_SelectedIndexChanged(sender As Object, e As EventArgs)
Select Case _boundaryFeedbackModeComboBox.Text
Case "Split"
_gcZoom1.BoundaryFeedbackMode = BoundaryFeedbackMode.Split
Exit Select
Case "Standard"
_gcZoom1.BoundaryFeedbackMode = BoundaryFeedbackMode.Standard
Exit Select
Case Else
Exit Select
End Select
End Sub
Private Sub previewModeComboBox_SelectedIndexChanged(sender As Object, e As EventArgs)
Select Case _previewModeComboBox.Text
Case "Bitmap"
_gcZoom1.ZoomPreviewMode = ZoomPreviewMode.Bitmap
Exit Select
Case "AlternativeContent"
_gcZoom1.ZoomPreviewMode = ZoomPreviewMode.AlternativeContent
_gcZoom1.AlternativeContentSettings.ForeColor = SystemColors.ControlDarkDark
_gcZoom1.AlternativeContentSettings.Format = "Zooming {Percentage}%"
Exit Select
Case "NoPreview"
_gcZoom1.ZoomPreviewMode = ZoomPreviewMode.NoPreview
Exit Select
Case Else
Exit Select
End Select
End Sub
Private Sub SetGcZoomTarget()
_gcZoom1.Target = Me
End Sub
Private Sub maxZoomFactorTextBox_TextChanged(sender As Object, e As EventArgs)
Dim value As String = _maxZoomFactorTextBox.Text.Trim()
Try
Dim maxFactor As Single = CSng(Convert.ToDouble(value))
_gcZoom1.MaxZoomFactor = maxFactor
Catch
_gcZoom1.MaxZoomFactor = 2.0F
End Try
End Sub
Private Sub zoomFactorTextBox_TextChanged(sender As Object, e As EventArgs)
Dim value As String = _zoomFactorTextBox.Text.Trim()
Try
Dim zoomFactor As Single = CSng(Convert.ToDouble(value))
_gcZoom1.ZoomFactor = zoomFactor
Catch
Console.WriteLine(e.ToString())
_gcZoom1.ZoomFactor = 1.0F
End Try
End Sub
Private Sub gcZoom1_ZoomFactorChanged(sender As Object, e As EventArgs)
_zoomFactor2TextBox.Text = _gcZoom1.ZoomFactor.ToString()
End Sub
Private Sub InitializeComponent()
_label1 = New Label()
_label1.Text = "ZoomPreviewMode"
_label1.Location = New Point(20, 20)
_label1.Size = New Size(140, 20)
_previewModeComboBox = New ComboBox()
_previewModeComboBox.Items.AddRange(New Object() {"Bitmap", "AlternativeContent", "NoPreview"})
_previewModeComboBox.Location = New Point(160, 20)
_label2 = New Label()
_label2.Text = "BoundaryFeedbackMode"
_label2.Location = New Point(20, 50)
_label2.Size = New Size(140, 20)
_boundaryFeedbackModeComboBox = New ComboBox()
_boundaryFeedbackModeComboBox.Items.AddRange(New Object() {"Split", "Standard"})
_boundaryFeedbackModeComboBox.Location = New Point(160, 50)
_label3 = New Label()
_label3.Text = "MaxZoomFactor"
_label3.Location = New Point(20, 80)
_label3.Size = New Size(140, 20)
_maxZoomFactorTextBox = New TextBox()
_maxZoomFactorTextBox.Location = New Point(160, 80)
_label4 = New Label()
_label4.Text = "ZoomFactor"
_label4.Location = New Point(20, 110)
_label4.Size = New Size(140, 20)
_zoomFactorTextBox = New TextBox()
_zoomFactorTextBox.Location = New Point(160, 110)
_zoomFactor2TextBox = New TextBox()
_zoomFactor2TextBox.Text = "1"
_zoomFactor2TextBox.[ReadOnly] = True
_zoomFactor2TextBox.Location = New Point(160, 135)
Me.Controls.Add(_label1)
Me.Controls.Add(_previewModeComboBox)
Me.Controls.Add(_label2)
Me.Controls.Add(_boundaryFeedbackModeComboBox)
Me.Controls.Add(_label3)
Me.Controls.Add(_maxZoomFactorTextBox)
Me.Controls.Add(_label4)
Me.Controls.Add(_zoomFactorTextBox)
Me.Controls.Add(_zoomFactor2TextBox)
End Sub
End Class
Name | Description |
---|---|
C1Zoom() | Initializes a new instance of the C1Zoom class. |
C1Zoom(IContainer) | Initializes a new instance of the C1Zoom class with the specified container. |
Name | Description |
---|---|
AllowDoubleTapZoom | Gets or sets a value indicating whether allow double tap to zoom. ZoomFactor will change to 2f or MaxZoomFactor if it is less than 2f before double tap; otherwise, it will change to 1f. |
AllowMouseWheelScroll | Gets or sets which types of MouseWheel scroll are possible. |
AllowMouseWheelZoom | Gets or sets a value indicating whether allow zoom by control + mouse wheel. |
AllowPanScroll | Gets or sets a value indicating whether allow scroll the form by pan gesture. |
AllowPinchZoom | Gets or sets a value indicating whether the form can perform gesture zoom. |
AllowResizeByZoom | Gets or sets a value that indicates whether resize form when zooming form. |
AllowZoomByResize | Gets or sets a value that indicates whether zoom form when resizing form. |
AlternativeContentSettings | Gets the settings indicating how to display zoom factor when gesture zooming. |
AutoShowControl | Gets or sets a value that indicates whether the control auto show when get focus or touch keyboard popup. |
BackColor | Gets or sets the background color of blank areas in Form when to zoom and scroll. |
BackgroundImage | Gets or sets the background image displayed in the blank areas of Form when to zoom and scroll. |
BackgroundImageLayout | Gets or sets the background image layout as defined in the ImageLayout enumeration. |
BoundaryFeedbackMode | Gets or sets a value indicating how to show visual feedback when scroll reach end point. |
ControlBars | Gets the collection of ControlBar contained within the C1Zoom. |
Controls | Gets the child controls of the owner form. |
DefaultZoomPolicies | Gets the default zoom policies. |
FullScreenMode | Gets or sets the full screen mode used by owner form. |
InnerPanel | Gets the inner panel that contains the target form's child controls. |
InnerPanelLayoutMode | Gets or sets the layout of InnerPanel after enlarge form. |
IsHorizontalRailEnabled | Gets or sets a value that indicates whether the scroll rail is enabled for the horizontal axis. |
IsPanWindowShown | Gets a value indicating whether the pan window is shown. |
IsVerticalRailEnabled | Gets or sets a value that indicates whether the scroll rail is enabled for the vertical axis. |
KeepAspectRatio | Gets or sets a value indicating whether to keep aspect ratio when resize the form. |
MaxZoomFactor | Gets or sets the maximum zoom factor of the form. |
ScrollIndicatorMode | Gets or sets a value indicating which mode to indicate current scroll location. |
ScrollLocation | Gets or sets the scroll location of the form. |
Site | |
ZoomFactor | Gets or sets the zoom factor of the form. |
ZoomPolicies | Gets the custom zoom policies. C1Zoom will look for zoom policies in this list. |
ZoomPreviewMode | Gets or sets a value indicating how to preview the form when gesture zooming. |
ZoomSnapDistance | Gets or sets a value indicate the minimum distance that can cause current zoom factor snap to a zoom factor in ZoomSnapPoints. |
ZoomSnapPoints | Gets a group of zoom factor, when zoom ending, the result zoom factor will try to snap to a zoom factor in this group. |
ZoomTargets | Gets the collection of controls that can receive the zoom gesture message. |
Name | Description |
---|---|
AboutBox() | Shows the product information window. |
BeginAddControls() | Call this method before change child control collection. |
ClosePanWindow() | Closes the pan window. |
Dispose(bool) | Releases the unmanaged resources used by the Component and optionally releases the managed resources. |
EndAddControls() | Call this method after change child control collection. |
GetDisplayRectangle(Control) | Get control visibility rectangle. |
OnAnimationCompleted(EventArgs) | Raises the AnimationCompleted event. |
OnAnimationStarting(AnimationStartingEventArgs) | Raises the AnimationStarting event. |
OnControlAutoShowing(ControlAutoShowingEventArgs) | Raises the ControlAutoShowing event. |
OnControlBoundsZooming(ControlBoundsZoomingEventArgs) | Raises the ControlBoundsZooming event. |
OnControlFontZooming(ControlFontZoomingEventArgs) | Raises the ControlFontZooming event. |
OnManipulationStarting(ZoomManipulationStartingEventArgs) | Raises the ManipulationStarting event. |
OnZoomFactorChanged(EventArgs) | Raises the ZoomFactorChanged event. |
SetScrollLocation(Point, bool) | Sets the ScrollLocation and determines whether use animation when change ScrollLocation. |
SetZoomFactor(float, bool) | Sets the ZoomFactor and determines whether use animation when change ZoomFactor. |
ShowPanWindow() | Shows the pan window. |
ShowPanWindow(Point) | Shows the pan window with the specified location. |
ShowPanWindow(Point, Size) | Shows the pan window with the specified location and size. |
ShowPanWindow(FormStartPosition) | Shows the pan window with the specified start position. |
ShowPanWindow(FormStartPosition, Size) | Shows the pan window with the specified start position and size. |
Name | Description |
---|---|
AnimationCompleted | Occurs when animation is completed. |
AnimationStarting | Occurs before C1Zoom start animation. |
ControlAutoShowing | Occurs before C1Zoom start show the target control. |
ControlBoundsZooming | Occurs before C1Zoom start zoom the target control's bounds. |
ControlFontZooming | Occurs before C1Zoom start zoom the target control's font. |
ManipulationStarting | Occurs when the manipulation processor is first created. |
ZoomFactorChanged | Occurs when ZoomFactor changed. |