GrapeCity.Win.Components 名前空間 : GcApplicationResize クラス |
Public Class GcApplicationResize Inherits System.ComponentModel.Component
public class GcApplicationResize : System.ComponentModel.Component
GcApplicationResize は現在のアプリケーションのすべてのフォームを検出し、見つかったフォームに GcResize コンポーネントをアタッチします。アタッチする前に、GcApplicationResize はその固有の設定によって GcResize の設定を初期化します。その後で、GcResizeAttaching イベントと GcResizeAttached イベントを発生させます。ユーザーはこのイベントのイベントハンドラで初期設定を変更できます。また、GcResizeAttaching イベントで GcResizeAttachingEventArgs の GcResizeAttachingEventArgs.Cancel プロパティを true に設定することにより、アタッチをキャンセルすることもできます。
フォームにすでに GcResize がアタッチされている場合、GcResize は再びアタッチされません。
GcApplicationResize では、ツールチップ、コンテキストメニュー、およびコモンダイアログにジェスチャによるサイズ変更機能を与えることはできません。
次のサンプルコードは、GcApplicationResize コンポーネントの使用方法を示します。
このコードを既存の Windows Forms アプリケーションにコピーし、サンプルコードを含むフォームを開始フォームとして設定します。
このコードの実行時にライセンスエラーが発生した場合は、ツールボックスから任意のフォームに GcApplicationResize コンポーネントをドラッグしてみてください。そうすると、このプロジェクトにライセンス情報が生成されます。
using System; using System.Drawing; using System.Windows.Forms; using GrapeCity.Win.Components; namespace GrapeCity.Win.MultiTouch.SampleCode { public class GcApplicationResizeDemo : Form { private Button _showFormButton; private Button _showForm2Button; private GcApplicationResize _gcApplicationResize; public GcApplicationResizeDemo() { InitializeComponent(); _showFormButton.Click += _showFormButton_Click; _showForm2Button.Click += _showForm2Button_Click; _gcApplicationResize.GcResizeAttaching += _gcApplicationResize_GcResizeAttaching; _gcApplicationResize.GcResizeAttached += _gcApplicationResize_GcResizeAttached; _gcApplicationResize.GcResizeDetached += _gcApplicationResize_GcResizeDetached; } void _gcApplicationResize_GcResizeAttaching(object sender, GcResizeAttachingEventArgs e) { // May be some forms should not be Resize. if (e.Form is NormalForm) { e.Cancel = true; } } void _gcApplicationResize_GcResizeAttached(object sender, GcResizeAttachedEventArgs e) { // If you want specific GcResize's setting different from GcApplicationResize, You can change it in // GcResizeAttaching or GcResizeAttached event. e.GcResize.MinimumFactor = 0.8f; if (e.Form is ResizeForm) { e.GcResize.ControlResizing += (e.Form as ResizeForm).ControlResizingProc; } } void _gcApplicationResize_GcResizeDetached(object sender, GcResizeDetachedEventArgs e) { if (e.Form is ResizeForm) { e.GcResize.ControlResizing -= (e.Form as ResizeForm).ControlResizingProc; } } void _showFormButton_Click(object sender, EventArgs e) { Form form = new ResizeForm(); form.Show(); } void _showForm2Button_Click(object sender, EventArgs e) { Form form = new NormalForm(); form.Show(); } private void InitializeComponent() { _gcApplicationResize = new GcApplicationResize(); _showFormButton = new Button(); _showFormButton.Text = "Click to open ResizeForm"; _showFormButton.Location = new Point(20, 20); _showFormButton.Size = new Size(200, 40); _showForm2Button = new Button(); _showForm2Button.Text = "Click to open NormalForm"; _showForm2Button.Location = new Point(20, 80); _showForm2Button.Size = new Size(200, 40); this.Controls.Add(_showFormButton); this.Controls.Add(_showForm2Button); this.Text = "GcApplicationResizeDemo"; this.Size = new Size(400, 300); } } internal class ResizeForm : Form { private Button _showFormButton; public ResizeForm() { InitializeComponent(); _showFormButton.Click += _showFormButton_Click; } public void ControlResizingProc(object sender, EventArgs e) { Console.WriteLine(GcApplicationResize.GetGcResize(this).ToString()); } private void _showFormButton_Click(object sender, EventArgs e) { Form form = new ResizeForm(); form.Show(); } private void InitializeComponent() { _showFormButton = new Button(); _showFormButton.Text = "Click to open a new form"; _showFormButton.Location = new Point(20, 20); _showFormButton.Size = new Size(200, 40); this.Controls.Add(_showFormButton); this.Text = "ResizeForm"; } } internal class NormalForm : Form { private Button _showFormButton; public NormalForm() { InitializeComponent(); _showFormButton.Click += _showFormButton_Click; } void _showFormButton_Click(object sender, EventArgs e) { Form form = new NormalForm(); form.Show(); } private void InitializeComponent() { _showFormButton = new Button(); _showFormButton.Text = "Click to open a new form"; _showFormButton.Location = new Point(20, 20); _showFormButton.Size = new Size(200, 40); this.Controls.Add(_showFormButton); this.Text = "NormalForm"; } } }
Imports System Imports System.Drawing Imports System.Windows.Forms Imports GrapeCity.Win.Components Namespace GrapeCity.Win.MultiTouch.SampleCode Public Class GcApplicationResizeDemo Inherits Form Private _showFormButton As Button Private _showForm2Button As Button Private _gcApplicationResize As GcApplicationResize Public Sub New() InitializeComponent() AddHandler _showFormButton.Click, AddressOf _showFormButton_Click AddHandler _showForm2Button.Click, AddressOf _showForm2Button_Click AddHandler _gcApplicationResize.GcResizeAttaching, AddressOf _gcApplicationResize_GcResizeAttaching AddHandler _gcApplicationResize.GcResizeAttached, AddressOf _gcApplicationResize_GcResizeAttached AddHandler _gcApplicationResize.GcResizeDetached, AddressOf _gcApplicationResize_GcResizeDetached End Sub Private Sub _gcApplicationResize_GcResizeAttaching(sender As Object, e As GcResizeAttachingEventArgs) ' May be some forms should not be Resize. If TypeOf e.Form Is NormalForm Then e.Cancel = True End If End Sub Private Sub _gcApplicationResize_GcResizeAttached(sender As Object, e As GcResizeAttachedEventArgs) ' If you want specific GcResize's setting different from GcApplicationResize, You can change it in ' GcResizeAttaching or GcResizeAttached event. e.GcResize.MinimumFactor = 0.8F Dim resizeForm = TryCast(e.Form, ResizeForm) If (resizeForm IsNot Nothing) Then AddHandler e.GcResize.ControlResizing, AddressOf resizeForm.ControlResizingProc End If End Sub Private Sub _gcApplicationResize_GcResizeDetached(sender As Object, e As GcResizeDetachedEventArgs) Dim resizeForm = TryCast(e.Form, ResizeForm) If (resizeForm IsNot Nothing) Then RemoveHandler e.GcResize.ControlResizing, AddressOf resizeForm.ControlResizingProc End If End Sub Private Sub _showFormButton_Click(sender As Object, e As EventArgs) Dim form As Form = New ResizeForm() form.Show() End Sub Private Sub _showForm2Button_Click(sender As Object, e As EventArgs) Dim form As Form = New NormalForm() form.Show() End Sub Private Sub InitializeComponent() _gcApplicationResize = New GcApplicationResize() _showFormButton = New Button() _showFormButton.Text = "Click to open ResizeForm" _showFormButton.Location = New Point(20, 20) _showFormButton.Size = New Size(200, 40) _showForm2Button = New Button() _showForm2Button.Text = "Click to open NormalForm" _showForm2Button.Location = New Point(20, 80) _showForm2Button.Size = New Size(200, 40) Controls.Add(_showFormButton) Controls.Add(_showForm2Button) Text = "GcApplicationResizeDemo" Size = New Size(400, 300) End Sub End Class Friend Class ResizeForm Inherits Form Private _showFormButton As Button Public Sub New() InitializeComponent() AddHandler _showFormButton.Click, AddressOf _showFormButton_Click End Sub Public Sub ControlResizingProc(sender As Object, e As EventArgs) Console.WriteLine(GcApplicationResize.GetGcResize(Me).ToString()) End Sub Private Sub _showFormButton_Click(sender As Object, e As EventArgs) Dim form As Form = New ResizeForm() form.Show() End Sub Private Sub InitializeComponent() _showFormButton = New Button() _showFormButton.Text = "Click to open a new form" _showFormButton.Location = New Point(20, 20) _showFormButton.Size = New Size(200, 40) Controls.Add(_showFormButton) Text = "ResizeForm" End Sub End Class Friend Class NormalForm Inherits Form Private _showFormButton As Button Public Sub New() InitializeComponent() AddHandler _showFormButton.Click, AddressOf _showFormButton_Click End Sub Private Sub _showFormButton_Click(sender As Object, e As EventArgs) Dim form As Form = New NormalForm() form.Show() End Sub Private Sub InitializeComponent() _showFormButton = New Button() _showFormButton.Text = "Click to open a new form" _showFormButton.Location = New Point(20, 20) _showFormButton.Size = New Size(200, 40) Controls.Add(_showFormButton) Text = "NormalForm" End Sub End Class End Namespace
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
GrapeCity.Win.Components.GcApplicationResize
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2