2009年3月22日 星期日

SHColorPicker_2009-0322.frmMainUI [2009-03-22-PM-04-39-39]


'  Code Name of this Visual Basic 2003 Windows Form Application:
'  SHColorPicker_2009-0322.frmMainUI
'
'  Version 1.00.01; Last Updated on [2009-03-22-MM-12-25-58]
'
Public Class frmMainUI
    Inherits System.Windows.Forms.Form
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    Private Const pc_FriendlyApplicationName As String = "SoftHuman Color Picker (善解科技_顏色選擇器)"
    Private m_PictureBoxHelper_WJ As WJPictureBoxHelper_Y2009M03D22

    Private m_ReportMouseTipCoordinates_Delegate As WJPictureBoxHelper_Y2009M03D22.ReportMouseTipCoordinates_Delegate
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
#Region " Windows Form 設計工具產生的程式碼 "

    Public Sub New()
        MyBase.New()

        '此為 Windows Form 設計工具所需的呼叫。
        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 Form 設計工具的必要項
    Private components As System.ComponentModel.IContainer

    '注意: 以下為 Windows Form 設計工具所需的程序
    '您可以使用 Windows Form 設計工具進行修改。
    '請勿使用程式碼編輯器來修改這些程序。
    Friend WithEvents StatusBar1 As System.Windows.Forms.StatusBar
    Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
    Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
    Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
    Friend WithEvents miTest01 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem3 As System.Windows.Forms.MenuItem
    Friend WithEvents miLoadNewImageFile As System.Windows.Forms.MenuItem
    Friend WithEvents Panel1 As System.Windows.Forms.Panel
    Friend WithEvents RichTextBox1 As System.Windows.Forms.RichTextBox
    Friend WithEvents Splitter1 As System.Windows.Forms.Splitter
    Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmMainUI))
        Me.StatusBar1 = New System.Windows.Forms.StatusBar
        Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog
        Me.MainMenu1 = New System.Windows.Forms.MainMenu
        Me.MenuItem1 = New System.Windows.Forms.MenuItem
        Me.miTest01 = New System.Windows.Forms.MenuItem
        Me.MenuItem2 = New System.Windows.Forms.MenuItem
        Me.MenuItem3 = New System.Windows.Forms.MenuItem
        Me.miLoadNewImageFile = New System.Windows.Forms.MenuItem
        Me.Panel1 = New System.Windows.Forms.Panel
        Me.RichTextBox1 = New System.Windows.Forms.RichTextBox
        Me.Splitter1 = New System.Windows.Forms.Splitter
        Me.PictureBox1 = New System.Windows.Forms.PictureBox
        Me.Panel1.SuspendLayout()
        Me.SuspendLayout()
        '
        'StatusBar1
        '
        Me.StatusBar1.Location = New System.Drawing.Point(0, 384)
        Me.StatusBar1.Name = "StatusBar1"
        Me.StatusBar1.Size = New System.Drawing.Size(672, 22)
        Me.StatusBar1.TabIndex = 0
        Me.StatusBar1.Text = "StatusBar1"
        '
        'MainMenu1
        '
        Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem3, Me.MenuItem2, Me.MenuItem1})
        '
        'MenuItem1
        '
        Me.MenuItem1.Index = 2
        Me.MenuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.miTest01})
        Me.MenuItem1.Text = "Test"
        '
        'miTest01
        '
        Me.miTest01.Index = 0
        Me.miTest01.Shortcut = System.Windows.Forms.Shortcut.F5
        Me.miTest01.Text = "Test 01"
        '
        'MenuItem2
        '
        Me.MenuItem2.Index = 1
        Me.MenuItem2.Text = "Tools"
        '
        'MenuItem3
        '
        Me.MenuItem3.Index = 0
        Me.MenuItem3.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.miLoadNewImageFile})
        Me.MenuItem3.Text = "File"
        '
        'miLoadNewImageFile
        '
        Me.miLoadNewImageFile.Index = 0
        Me.miLoadNewImageFile.Text = "Load New Image File"
        '
        'Panel1
        '
        Me.Panel1.Controls.Add(Me.RichTextBox1)
        Me.Panel1.Dock = System.Windows.Forms.DockStyle.Top
        Me.Panel1.Location = New System.Drawing.Point(0, 0)
        Me.Panel1.Name = "Panel1"
        Me.Panel1.Size = New System.Drawing.Size(672, 200)
        Me.Panel1.TabIndex = 1
        '
        'RichTextBox1
        '
        Me.RichTextBox1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.RichTextBox1.Location = New System.Drawing.Point(0, 0)
        Me.RichTextBox1.Name = "RichTextBox1"
        Me.RichTextBox1.Size = New System.Drawing.Size(672, 200)
        Me.RichTextBox1.TabIndex = 0
        Me.RichTextBox1.Text = "RichTextBox1"
        '
        'Splitter1
        '
        Me.Splitter1.Dock = System.Windows.Forms.DockStyle.Top
        Me.Splitter1.Location = New System.Drawing.Point(0, 200)
        Me.Splitter1.Name = "Splitter1"
        Me.Splitter1.Size = New System.Drawing.Size(672, 3)
        Me.Splitter1.TabIndex = 2
        Me.Splitter1.TabStop = False
        '
        'PictureBox1
        '
        Me.PictureBox1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)
        Me.PictureBox1.Location = New System.Drawing.Point(0, 203)
        Me.PictureBox1.Name = "PictureBox1"
        Me.PictureBox1.Size = New System.Drawing.Size(672, 181)
        Me.PictureBox1.TabIndex = 3
        Me.PictureBox1.TabStop = False
        '
        'frmMainUI
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 15)
        Me.ClientSize = New System.Drawing.Size(672, 406)
        Me.Controls.Add(Me.PictureBox1)
        Me.Controls.Add(Me.Splitter1)
        Me.Controls.Add(Me.Panel1)
        Me.Controls.Add(Me.StatusBar1)
        Me.Menu = Me.MainMenu1
        Me.Name = "frmMainUI"
        Me.Text = "SoftHuman Color Picker"
        Me.Panel1.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    Private Sub frmMainUI_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim myFriendlyApplicationNameWithVersionInfo As String

        'myFriendlyApplicationNameWithVersionInfo = pc_FriendlyApplicationName & " - " & Application.ProductVersion
        myFriendlyApplicationNameWithVersionInfo = _
            pc_FriendlyApplicationName & " - " & Application.ProductVersion & " " & "[2009-03-22]"

        Me.Do_InitializeMemberVariables()

        With Me
            .Text = myFriendlyApplicationNameWithVersionInfo

            .Font = New System.Drawing.Font("Times New Roman", 13)

            .StartPosition = FormStartPosition.CenterScreen
        End With

        With Me.RichTextBox1
            .Font = New System.Drawing.Font("Times New Roman", 13)
            '.ZoomFactor = 1.5
            '.ZoomFactor = 1.4
            .ZoomFactor = 1.3
            '.ZoomFactor = 1.2

            .ShowSelectionMargin = True

            .SelectAll()
            '.SelectionFont = New System.Drawing.Font("Times New Roman", 13, FontStyle.Regular)
            .SelectionColor = System.Drawing.Color.Blue

            .Dock = DockStyle.Fill

            ' initial setup, for info only
            .Text = myFriendlyApplicationNameWithVersionInfo

        End With

        Dim FPFN As String
        'FPFN = "C:\Documents and Settings\806\My Documents\My Pictures\Data 02.PNG"

        With Me.PictureBox1
            '            .Dock = DockStyle.Fill

            If IO.File.Exists(FPFN) Then
                'MsgBox("FPFN = " & FPFN)

                .Image = System.Drawing.Image.FromFile(FPFN)
            Else
            End If

            .BringToFront()
        End With

        With Me.RichTextBox1
            '           .BringToFront()
        End With

        With Me.StatusBar1
            .Text = myFriendlyApplicationNameWithVersionInfo
        End With
    End Sub
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    Private Sub Do_InitializeMemberVariables()
        ' OK

        Me.m_ReportMouseTipCoordinates_Delegate = New WJPictureBoxHelper_Y2009M03D22.ReportMouseTipCoordinates_Delegate(AddressOf Me.Do_ReportMouseTipCoordinates_Delegate)

        Me.m_PictureBoxHelper_WJ = New WJPictureBoxHelper_Y2009M03D22(Me.PictureBox1, Me.m_ReportMouseTipCoordinates_Delegate)

    End Sub
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    Private Sub Do_ReportMouseTipCoordinates_Delegate(ByVal X As Integer, ByVal Y As Integer)
        ' OK

        Dim SB As New System.Text.StringBuilder

        With SB
            '.Append(vbNewLine)
            '.Append(vbNewLine)
            .Append("X = ")
            '            .Append(vbNewLine)
            .Append(X)
            '.Append(vbNewLine)
            .Append(vbNewLine)
            .Append("Y = ")
            '            .Append(vbNewLine)
            .Append(Y)
            .Append(vbNewLine)

            '.Append("Me.m_PictureBoxHelper_WJ.RValueGValueAndBValueOfThePixelPointedByMouseTip")
            .Append(vbNewLine)
            .Append(Me.m_PictureBoxHelper_WJ.RValueGValueAndBValueOfThePixelPointedByMouseTip)
            .Append(vbNewLine)
            .Append(vbNewLine)
            '.Append(vbNewLine)

        End With

        Me.RichTextBox1.Text = SB.ToString

    End Sub ' Do_ReportMouseTipCoordinates_Delegate
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    Private Sub miLoadNewImageFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miLoadNewImageFile.Click
        ' (本段程式之目的) Purpose:
        '     Explanation
        ' (本段程式是否已經在被使用中) In use: Yes
        ' (程式撰寫的進度) Developing: 100% (Mandatory)
        ' (程式堪用的程度) Workable: 80% (Threshold at 80%)
        ' (程式的測試程度) Code tested: 60% (max 99%)
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        ' (修改程式的日期) Revision Date: (2009 03 22 PM 03 20 08)
        ' (修改程式的人員) Revised by: WeiJin Tang (湯偉晉)
        '     OK
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        ' Most recently used folder path
        Static MRUFolderPath As String = Nothing

        Dim FP As String

        ' Try to set the initial folder to the most recently used folder
        If MRUFolderPath Is Nothing Or IO.Directory.Exists(MRUFolderPath) = False Then
            FP = System.Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)
        Else
            FP = MRUFolderPath
        End If

        Dim FPFN As String

        With Me.OpenFileDialog1
            If IO.File.Exists(FP) Then
                .InitialDirectory = FP
            Else
                ' use default folder path
                .InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal)
            End If

            If Me.OpenFileDialog1.ShowDialog = DialogResult.OK Then
                FPFN = Me.OpenFileDialog1.FileName
            Else
                Exit Sub
            End If
        End With

        If IO.File.Exists(FPFN) Then
        Else
            Exit Sub
        End If

        Try
            With Me.PictureBox1
                .Image = System.Drawing.Bitmap.FromFile(FPFN)
                .Width = .Image.Width
                .Height = .Image.Height
            End With

            ' save ...
            MRUFolderPath = IO.Path.GetFullPath(FPFN)
            'MsgBox("MRUFolderPath = " & MRUFolderPath)
        Catch ex As Exception

        End Try
    End Sub
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
End Class ' frmMainUI

沒有留言: