'//----------------------------------------------------------------------
'//【ネイティブイメージ(NGEN)デモ】- NGenDemo
'//
'//
'//                                                       by Masato Hirai
'//----------------------------------------------------------------------
Imports System
Imports System.Collections
Imports System.Drawing
Imports System.Windows.Forms
Imports System.ComponentModel
Imports Microsoft.VisualBasic

Public Class MainForm
    Inherits System.Windows.Forms.Form

#Region " Windows フォーム デザイナで生成されたコード "

    Public Sub New()
      MyBase.New()
      ' この呼び出しは Windows フォーム デザイナで必要です。
      InitializeComponent()
      ' InitializeComponent() 呼び出しの後に初期化を追加します。
    End Sub

    ' Form は、コンポーネント一覧に後処理を実行するために dispose をオーバーライドします。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    ' Windows フォーム デザイナで必要です。
    Private components As System.ComponentModel.IContainer

    ' メモ : 以下のプロシージャは、Windows フォーム デザイナで必要です。
    'Windows フォーム デザイナを使って変更してください。  
    ' コード エディタを使って変更しないでください。
  Friend WithEvents Button1 As System.Windows.Forms.Button
  Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
  Friend WithEvents Button2 As System.Windows.Forms.Button
  Friend WithEvents Label1 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Button2 = New System.Windows.Forms.Button
Me.Label1 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.Button1.Location = New System.Drawing.Point(16, 160)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(312, 48)
Me.Button1.TabIndex = 0
Me.Button1.Text = "ToUpperメソッド"
'
'TextBox1
'
Me.TextBox1.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.TextBox1.Location = New System.Drawing.Point(16, 104)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(312, 39)
Me.TextBox1.TabIndex = 1
Me.TextBox1.Text = "Hello World."
'
'Button2
'
Me.Button2.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Button2.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.Button2.Location = New System.Drawing.Point(16, 224)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(312, 48)
Me.Button2.TabIndex = 2
Me.Button2.Text = "LCase$関数"
'
'Label1
'
Me.Label1.BackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(128, Byte), CType(128, Byte))
Me.Label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.Label1.Dock = System.Windows.Forms.DockStyle.Top
Me.Label1.Font = New System.Drawing.Font("MS UI Gothic", 36.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
Me.Label1.ForeColor = System.Drawing.Color.White
Me.Label1.Location = New System.Drawing.Point(0, 0)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(344, 80)
Me.Label1.TabIndex = 3
Me.Label1.Text = "NGENデモ"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'MainForm
'
Me.AutoScaleBaseSize = New System.Drawing.Size(15, 32)
Me.ClientSize = New System.Drawing.Size(344, 294)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Button1)
Me.Font = New System.Drawing.Font("MS UI Gothic", 24.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "MainForm"
Me.StartPosition = System.Windows.Forms.FormStartPosition.Manual
Me.Text = "ネイティブイメージ パフォーマンス デモ"
Me.ResumeLayout(False)

    End Sub

#End Region

  Dim oArr1 As New ArrayList
  Dim oArr2 As New ArrayList

  Public Shared Sub Main()
    Application.EnableVisualStyles()
    Application.Run(New MainForm)
  End Sub

  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    '//
    '// 20個のクラスをインスタンス化
    '//
    oArr1.Add(New ManyMethodClass01)
    oArr1.Add(New ManyMethodClass02)
    oArr1.Add(New ManyMethodClass03)
    oArr1.Add(New ManyMethodClass04)
    oArr1.Add(New ManyMethodClass05)
    oArr1.Add(New ManyMethodClass06)
    oArr1.Add(New ManyMethodClass07)
    oArr1.Add(New ManyMethodClass08)
    oArr1.Add(New ManyMethodClass09)
    oArr1.Add(New ManyMethodClass10)
    oArr1.Add(New ManyMethodClass11)
    oArr1.Add(New ManyMethodClass12)
    oArr1.Add(New ManyMethodClass13)
    oArr1.Add(New ManyMethodClass14)
    oArr1.Add(New ManyMethodClass15)
    oArr1.Add(New ManyMethodClass16)
    oArr1.Add(New ManyMethodClass17)
    oArr1.Add(New ManyMethodClass18)
    oArr1.Add(New ManyMethodClass19)
    oArr1.Add(New ManyMethodClass20)
    '//
    '// メソッドとプロパティの呼び出し（計200回）
    '//
    For n As Integer = 0 To oArr1.Count - 1
      For k As Integer = 1 To 50
        oArr1(n).GetType().InvokeMember("iMethod" & k.ToString("00"), Reflection.BindingFlags.InvokeMethod, Nothing, oArr1(n), Nothing)
        oArr1(n).GetType().InvokeMember("iProp" & k.ToString("00"), Reflection.BindingFlags.SetProperty, Nothing, oArr1(n), New Object() {k})
        oArr1(n).GetType().InvokeMember("sMethod" & k.ToString("00"), Reflection.BindingFlags.InvokeMethod, Nothing, oArr1(n), Nothing)
        oArr1(n).GetType().InvokeMember("sProp" & k.ToString("00"), Reflection.BindingFlags.SetProperty, Nothing, oArr1(n), New Object() {k})
      Next
    Next
    '//
    '// 20個のクラスをインスタンス化
    '//
    oArr2.Add(New ManyMethodClass01)
    oArr2.Add(New ManyMethodClass02)
    oArr2.Add(New ManyMethodClass03)
    oArr2.Add(New ManyMethodClass04)
    oArr2.Add(New ManyMethodClass05)
    oArr2.Add(New ManyMethodClass06)
    oArr2.Add(New ManyMethodClass07)
    oArr2.Add(New ManyMethodClass08)
    oArr2.Add(New ManyMethodClass09)
    oArr2.Add(New ManyMethodClass10)
    oArr2.Add(New ManyMethodClass11)
    oArr2.Add(New ManyMethodClass12)
    oArr2.Add(New ManyMethodClass13)
    oArr2.Add(New ManyMethodClass14)
    oArr2.Add(New ManyMethodClass15)
    oArr2.Add(New ManyMethodClass16)
    oArr2.Add(New ManyMethodClass17)
    oArr2.Add(New ManyMethodClass18)
    oArr2.Add(New ManyMethodClass19)
    oArr2.Add(New ManyMethodClass20)
  End Sub

  '//
  '// StringクラスのToUpperメソッドで大文字へ変換
  '//
  Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
    Dim s As String = TextBox1.Text
    TextBox1.Text = s.ToUpper()
  End Sub

  '//
  '// VB.NETのUCase$関数で大文字へ変換
  '//
  Private Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
    Dim s As String = TextBox1.Text
    TextBox1.Text = UCase$(s)
  End Sub

End Class
