'//----------------------------------------------------------------------
'//【レンダリング・クオリティのデモ】- QualityTest
'//
'//
'//                                                       by Masato Hirai         
'//----------------------------------------------------------------------
Imports System
Imports System.Drawing
Imports System.Drawing.Text
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Imports System.ComponentModel
Imports Microsoft.VisualBasic
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 PictureBox1 As System.Windows.Forms.PictureBox
  Friend WithEvents Button1 As GeniusHirai.ColorfulControls.OvalButton
  Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
  Friend WithEvents ComboBox2 As System.Windows.Forms.ComboBox
  Friend WithEvents Button2 As GeniusHirai.ColorfulControls.OvalButton
  Friend WithEvents NumericLabel1 As GeniusHirai.ColorfulControls.NumericLabel
  Friend WithEvents Label1 As GeniusHirai.ColorfulControls.RichLabel
  Friend WithEvents NumericUpDown1 As System.Windows.Forms.NumericUpDown
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.PictureBox1 = New System.Windows.Forms.PictureBox
Me.Button1 = New GeniusHirai.ColorfulControls.OvalButton
Me.ComboBox1 = New System.Windows.Forms.ComboBox
Me.ComboBox2 = New System.Windows.Forms.ComboBox
Me.Button2 = New GeniusHirai.ColorfulControls.OvalButton
Me.NumericLabel1 = New GeniusHirai.ColorfulControls.NumericLabel
Me.Label1 = New GeniusHirai.ColorfulControls.RichLabel
Me.NumericUpDown1 = New System.Windows.Forms.NumericUpDown
CType(Me.NumericUpDown1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'PictureBox1
'
Me.PictureBox1.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.PictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.PictureBox1.Location = New System.Drawing.Point(8, 96)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(768, 304)
Me.PictureBox1.TabIndex = 0
Me.PictureBox1.TabStop = False
'
'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.Green
Me.Button1.Font = New System.Drawing.Font("MS UI Gothic", 24.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
Me.Button1.Location = New System.Drawing.Point(256, 408)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(112, 56)
Me.Button1.TabIndex = 1
Me.Button1.Text = "円"
'
'ComboBox1
'
Me.ComboBox1.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
Me.ComboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.ComboBox1.Font = New System.Drawing.Font("MS UI Gothic", 24.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
Me.ComboBox1.Location = New System.Drawing.Point(8, 416)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(232, 41)
Me.ComboBox1.TabIndex = 2
'
'ComboBox2
'
Me.ComboBox2.Anchor = CType(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.ComboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.ComboBox2.Font = New System.Drawing.Font("MS UI Gothic", 24.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
Me.ComboBox2.Location = New System.Drawing.Point(424, 416)
Me.ComboBox2.Name = "ComboBox2"
Me.ComboBox2.Size = New System.Drawing.Size(224, 41)
Me.ComboBox2.TabIndex = 3
'
'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.Green
Me.Button2.Font = New System.Drawing.Font("MS UI Gothic", 24.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
Me.Button2.Location = New System.Drawing.Point(656, 408)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(112, 56)
Me.Button2.TabIndex = 4
Me.Button2.Text = "文字"
'
'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(568, 8)
Me.NumericLabel1.Name = "NumericLabel1"
Me.NumericLabel1.Size = New System.Drawing.Size(204, 63)
Me.NumericLabel1.TabIndex = 5
Me.NumericLabel1.ZoomMode = GeniusHirai.ColorfulControls.NumericLabel.ZoomModes.Mini
'
'Label1
'
Me.Label1.BackColor = System.Drawing.Color.FromArgb(CType(192, Byte), CType(192, Byte), CType(255, 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", 27.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
Me.Label1.Location = New System.Drawing.Point(0, 0)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(784, 80)
Me.Label1.TabIndex = 6
Me.Label1.Text = "レンダリング クオリティのデモ"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'NumericUpDown1
'
Me.NumericUpDown1.Font = New System.Drawing.Font("MS UI Gothic", 27.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
Me.NumericUpDown1.Increment = New Decimal(New Integer() {1000, 0, 0, 0})
Me.NumericUpDown1.Location = New System.Drawing.Point(432, 16)
Me.NumericUpDown1.Maximum = New Decimal(New Integer() {10000, 0, 0, 0})
Me.NumericUpDown1.Minimum = New Decimal(New Integer() {1, 0, 0, 0})
Me.NumericUpDown1.Name = "NumericUpDown1"
Me.NumericUpDown1.TabIndex = 7
Me.NumericUpDown1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
Me.NumericUpDown1.Value = New Decimal(New Integer() {5000, 0, 0, 0})
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(44, 96)
Me.ClientSize = New System.Drawing.Size(784, 478)
Me.Controls.Add(Me.NumericUpDown1)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.ComboBox2)
Me.Controls.Add(Me.ComboBox1)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.PictureBox1)
Me.Controls.Add(Me.NumericLabel1)
Me.Controls.Add(Me.Label1)
Me.Font = New System.Drawing.Font("MS UI Gothic", 72.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
Me.Name = "Form1"
Me.Text = "レンダリング クオリティのデモ"
Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
CType(Me.NumericUpDown1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)

    End Sub

#End Region

  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me.ComboBox1.Items.AddRange([Enum].GetNames(GetType(System.Drawing.Drawing2D.SmoothingMode)))
    Me.ComboBox1.SelectedIndex = 0
    Me.ComboBox2.Items.AddRange([Enum].GetNames(GetType(System.Drawing.Text.TextRenderingHint)))
    Me.ComboBox2.SelectedIndex = 0
  End Sub

Private RainbowBrushs() As Brush = _
  {Brushes.Red, Brushes.Orange, Brushes.Yellow, _
   Brushes.Lime, Brushes.Cyan, Brushes.CornflowerBlue, Brushes.Violet}

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Const BOX As Integer = 200
    Dim rnd As New System.Random
    Dim g As Graphics = PictureBox1.CreateGraphics
    g.SmoothingMode = [Enum].Parse(GetType(System.Drawing.Drawing2D.SmoothingMode), ComboBox1.SelectedItem)
    g.Clear(PictureBox1.BackColor)
    Dim t As Integer = Environment.TickCount
    For k As Integer = 1 To Me.NumericUpDown1.Value
      g.FillEllipse(RainbowBrushs(rnd.Next(0, 6)), rnd.Next(-BOX, PictureBox1.Width + BOX), rnd.Next(-BOX, PictureBox1.Height + BOX), BOX, BOX)
    Next
    g.Dispose()
    Me.NumericLabel1.Value = Environment.TickCount - t
  End Sub

  Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    Const BOX As Integer = 100
    Dim rnd As New System.Random
    Dim g As Graphics = PictureBox1.CreateGraphics
    g.TextRenderingHint = [Enum].Parse(GetType(System.Drawing.Text.TextRenderingHint), ComboBox2.SelectedItem)
    g.Clear(PictureBox1.BackColor)
    Dim t As Integer = Environment.TickCount
    For k As Integer = 1 To Me.NumericUpDown1.Value
      Dim s As String = ChrW(rnd.Next(39770, 40164))
      g.DrawString(s, Me.Font, RainbowBrushs(rnd.Next(0, 6)), rnd.Next(-BOX, PictureBox1.Width + BOX), rnd.Next(-BOX, PictureBox1.Height + BOX))
    Next
    g.Dispose()
    Me.NumericLabel1.Value = Environment.TickCount - t
  End Sub
End Class
