'//----------------------------------------------------------------------
'//【アイテムの追加 - Add vs. AddRange】- AddRangeDemo
'//
'//
'//                                                       by Masato Hirai
'//----------------------------------------------------------------------
Imports System
Imports System.Collections
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Imports System.Reflection
Imports GeniusHirai.ColorfulControls

Public Class Form1 : Inherits 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 ListBox1 As System.Windows.Forms.ListBox
  Friend WithEvents Label1 As System.Windows.Forms.Label
  Friend WithEvents NumericUpDown1 As System.Windows.Forms.NumericUpDown
  Friend WithEvents RichLabel1 As GeniusHirai.ColorfulControls.RichLabel
  Friend WithEvents NumericLabel1 As GeniusHirai.ColorfulControls.NumericLabel
  Friend WithEvents Button1 As GeniusHirai.ColorfulControls.OvalButton
  Friend WithEvents Button2 As GeniusHirai.ColorfulControls.OvalButton
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.Button2 = New GeniusHirai.ColorfulControls.OvalButton
Me.Button1 = New GeniusHirai.ColorfulControls.OvalButton
Me.NumericUpDown1 = New System.Windows.Forms.NumericUpDown
Me.Label1 = New System.Windows.Forms.Label
Me.ListBox1 = New System.Windows.Forms.ListBox
Me.RichLabel1 = New GeniusHirai.ColorfulControls.RichLabel
Me.NumericLabel1 = New GeniusHirai.ColorfulControls.NumericLabel
CType(Me.NumericUpDown1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'Button2
'
Me.Button2.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Button2.FaceColor = GeniusHirai.ColorfulControls.OvalButton.FaceColorConstant.Magenta
Me.Button2.Location = New System.Drawing.Point(128, 456)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(184, 56)
Me.Button2.TabIndex = 10
Me.Button2.Text = "AddRange"
'
'Button1
'
Me.Button1.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
Me.Button1.FaceColor = GeniusHirai.ColorfulControls.OvalButton.FaceColorConstant.Magenta
Me.Button1.Location = New System.Drawing.Point(16, 456)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(96, 56)
Me.Button1.TabIndex = 9
Me.Button1.Text = "Add"
'
'NumericUpDown1
'
Me.NumericUpDown1.Increment = New Decimal(New Integer() {1000, 0, 0, 0})
Me.NumericUpDown1.Location = New System.Drawing.Point(16, 112)
Me.NumericUpDown1.Maximum = New Decimal(New Integer() {100000, 0, 0, 0})
Me.NumericUpDown1.Name = "NumericUpDown1"
Me.NumericUpDown1.Size = New System.Drawing.Size(104, 39)
Me.NumericUpDown1.TabIndex = 7
Me.NumericUpDown1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
Me.NumericUpDown1.Value = New Decimal(New Integer() {2000, 0, 0, 0})
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.BackColor = System.Drawing.Color.Transparent
Me.Label1.Font = New System.Drawing.Font("MS UI Gothic", 18.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
Me.Label1.Location = New System.Drawing.Point(8, 80)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(112, 27)
Me.Label1.TabIndex = 5
Me.Label1.Text = "試行回数:"
'
'ListBox1
'
Me.ListBox1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
            Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.ListBox1.Font = New System.Drawing.Font("MS UI Gothic", 24.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
Me.ListBox1.ItemHeight = 33
Me.ListBox1.Location = New System.Drawing.Point(8, 168)
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.Size = New System.Drawing.Size(304, 268)
Me.ListBox1.TabIndex = 0
'
'RichLabel1
'
Me.RichLabel1.BackColor = System.Drawing.Color.FromArgb(CType(192, Byte), CType(192, Byte), CType(255, Byte))
Me.RichLabel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.RichLabel1.Dock = System.Windows.Forms.DockStyle.Top
Me.RichLabel1.Font = New System.Drawing.Font("MS UI Gothic", 27.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
Me.RichLabel1.ForeColor = System.Drawing.Color.Blue
Me.RichLabel1.Location = New System.Drawing.Point(0, 0)
Me.RichLabel1.Name = "RichLabel1"
Me.RichLabel1.Size = New System.Drawing.Size(320, 66)
Me.RichLabel1.TabIndex = 7
Me.RichLabel1.Text = "Add vs. AddRange"
Me.RichLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'NumericLabel1
'
Me.NumericLabel1.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.NumericLabel1.BackColor = System.Drawing.Color.Black
Me.NumericLabel1.ForeColor = System.Drawing.Color.Yellow
Me.NumericLabel1.Location = New System.Drawing.Point(136, 80)
Me.NumericLabel1.Name = "NumericLabel1"
Me.NumericLabel1.Size = New System.Drawing.Size(172, 63)
Me.NumericLabel1.TabIndex = 8
Me.NumericLabel1.Text = "NumericLabel1"
Me.NumericLabel1.UpperPoint = 5
Me.NumericLabel1.ZoomMode = GeniusHirai.ColorfulControls.NumericLabel.ZoomModes.Mini
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(15, 32)
Me.BackgroundImage = CType(resources.GetObject("$this.BackgroundImage"), System.Drawing.Image)
Me.ClientSize = New System.Drawing.Size(320, 526)
Me.Controls.Add(Me.NumericLabel1)
Me.Controls.Add(Me.RichLabel1)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.NumericUpDown1)
Me.Controls.Add(Me.ListBox1)
Me.Controls.Add(Me.Button2)
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.Name = "Form1"
Me.Text = "アイテムの追加"
CType(Me.NumericUpDown1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)

    End Sub

#End Region

'//
'// Addメソッド
'//
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  Dim LOOPS As Integer = NumericUpDown1.Value
  ListBox1.Items.Clear()
  Dim t As Integer = Environment.TickCount

  For k As Integer = 1 To LOOPS
    'Addメソッドで追加
    For Each s As String _
          In [Enum].GetNames(GetType(FormBorderStyle))
      ListBox1.Items.Add(s)
    Next
  Next

  NumericLabel1.Value = Environment.TickCount - t
End Sub

'//
'// AddRangeメソッド
'//
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  Dim LOOPS As Integer = NumericUpDown1.Value
  ListBox1.Items.Clear()
  Dim t As Integer = Environment.TickCount

  For k As Integer = 1 To LOOPS
    'AddRangeメソッドで追加
    ListBox1.Items.AddRange( _
      [Enum].GetNames(GetType(FormBorderStyle)))
  Next

  NumericLabel1.Value = Environment.TickCount - t
End Sub

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
  Me.FormBorderStyle = [Enum].Parse(GetType(FormBorderStyle), ListBox1.SelectedItem)
End Sub

End Class
