2008年6月15日 星期日

SourceCodePublishingHelper [2008_06_15_PM_05_39_04]

' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
' ' ' ' ' ' ' ' ' ' ' ' '  [2008_06_15_PM_05_39_04]  ' ' ' ' ' ' ' ' ' ' ' ' ' '
' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
'     SourceCodePublishingHelper_VBY2008M06 [2008-06-10-PM-09-56-52]
'     Version: 1.00.02
'     Last Updated: (2008 06 15 PM 05 36 04)
'     Version: 1.00.01
'     Last Updated: (2008 06 10 PM 09 56 14)

Imports System.Windows.Forms

Public Class SourceCodePublishingHelper_VBY2008M06

    Public Sub TreatClipboardContentAsVBSourceCodeAndMakeItReadyForPostingToBlogSpot()
        ' OK

        Dim T As String
        T = Me.Do_GetStringInClipboard()

        Dim SB As New System.Text.StringBuilder
        Dim T2 As String = "' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '"
        Dim T3 As String = "' ' ' ' ' ' ' ' ' ' ' ' '  "
        Dim T4 As String = "  ' ' ' ' ' ' ' ' ' ' ' ' ' '"

        Dim TS As String
        TS = Me.Do_GetStandardTimeType02

        With SB
            .Append(T2)
            .Append(vbNewLine)
            .Append(T2)
            .Append(vbNewLine)
            .Append(T3 & TS & T4)
            .Append(vbNewLine)
            .Append(T2)
            .Append(vbNewLine)

            .Append(T)

            .Append(vbNewLine)
            .Append(T2)
            .Append(vbNewLine)
            .Append(T3 & TS & T4)
            .Append(vbNewLine)
            .Append(T2)
            .Append(vbNewLine)
            .Append(T2)
            .Append(vbNewLine)
        End With

        Me.Do_PasteStringToClipboard(SB.ToString)

    End Sub ' TreatClipboardContentAsVBSourceCodeAndMakeItReadyForPostingToBlogSpot

    Private Function Do_GetStringInClipboard() As String
        ' (本段程式之目的) Purpose:
        '     Get the text content currently stored in system's clipboard.
        ' (本段程式是否已經在被使用中) In use: Yes
        ' (重要等級) Importance rating:  85%
        ' (再利用的可能性) Chances of reuse:  90%
        ' (程式撰寫的進度) Developing: 100% (Mandatory)
        ' (程式堪用的程度) Workable: 80% (Threshold at 80%)
        ' (程式的測試程度) Code tested: 80% (max 99%)
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        ' (修改程式的日期) Revision Date: (2005 09 01 PM 01 50 25)
        ' (修改程式的人員) Revised by: WeiJin Tang (湯偉晉)
        '     OK
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        Dim myDataObject As System.Windows.Forms.IDataObject
        Dim T As String
        myDataObject = System.Windows.Forms.Clipboard.GetDataObject()

        ' Try to return Unicode Text first, if failed, then try to return ANSI Text
        If myDataObject.GetDataPresent(System.Windows.Forms.DataFormats.UnicodeText) Then
            T = myDataObject.GetData(System.Windows.Forms.DataFormats.UnicodeText)
        Else
            If myDataObject.GetDataPresent(System.Windows.Forms.DataFormats.Text) Then
                T = myDataObject.GetData(System.Windows.Forms.DataFormats.Text)
            Else
                T = String.Empty
            End If
        End If

        Return T

        ' Begin: Reusable code block (2005 09 01 PM 10 26 20)
        If myDataObject.GetDataPresent(System.Windows.Forms.DataFormats.Text) Then
            MsgBox("Clipboard content is compatible with data type [System.Windows.Forms.DataFormats.Text]")
        Else
            MsgBox("Clipboard content is    NOT      compatible with data type  [System.Windows.Forms.DataFormats.Text]")
        End If

        If myDataObject.GetDataPresent(System.Windows.Forms.DataFormats.UnicodeText) Then
            MsgBox("Clipboard content is compatible with data type [System.Windows.Forms.DataFormats.UnicodeText]")
        Else
            MsgBox("Clipboard content is    NOT      compatible with data type  [System.Windows.Forms.DataFormats.UnicodeText]")
        End If

        If myDataObject.GetDataPresent(System.Windows.Forms.DataFormats.WaveAudio) Then
            MsgBox("Clipboard content is compatible with data type [System.Windows.Forms.DataFormats.WaveAudio]")
        Else
            MsgBox("Clipboard content is    NOT      compatible with data type  [System.Windows.Forms.DataFormats.WaveAudio]")
        End If

        If myDataObject.GetDataPresent(System.Windows.Forms.DataFormats.Html) Then
            MsgBox("Clipboard content is compatible with data type [System.Windows.Forms.DataFormats.Html]")
        Else
            MsgBox("Clipboard content is    NOT      compatible with data type  [System.Windows.Forms.DataFormats.Html]")
        End If

        If myDataObject.GetDataPresent(System.Windows.Forms.DataFormats.Rtf) Then
            MsgBox("Clipboard content is compatible with data type [System.Windows.Forms.DataFormats.Rtf]")
        Else
            MsgBox("Clipboard content is    NOT      compatible with data type  [System.Windows.Forms.DataFormats.Rtf]")
        End If

        If myDataObject.GetDataPresent(System.Windows.Forms.DataFormats.Bitmap) Then
            MsgBox("Clipboard content is compatible with data type [System.Windows.Forms.DataFormats.Bitmap]")
        Else
            MsgBox("Clipboard content is    NOT      compatible with data type  [System.Windows.Forms.DataFormats.Bitmap]")
        End If

        If myDataObject.GetDataPresent(System.Windows.Forms.DataFormats.PenData) Then
            MsgBox("Clipboard content is compatible with data type [System.Windows.Forms.DataFormats.PenData]")
        Else
            MsgBox("Clipboard content is    NOT      compatible with data type  [System.Windows.Forms.DataFormats.PenData]")
        End If

        If myDataObject.GetDataPresent(System.Windows.Forms.DataFormats.StringFormat) Then
            MsgBox("Clipboard content is compatible with data type [System.Windows.Forms.DataFormats.StringFormat]")
        Else
            MsgBox("Clipboard content is    NOT      compatible with data type  [System.Windows.Forms.DataFormats.StringFormat]")
        End If

        If myDataObject.GetDataPresent(System.Windows.Forms.DataFormats.Serializable) Then
            MsgBox("Clipboard content is compatible with data type [System.Windows.Forms.DataFormats.Serializable]")
        Else
            MsgBox("Clipboard content is    NOT      compatible with data type  [System.Windows.Forms.DataFormats.Serializable]")
        End If

        If myDataObject.GetDataPresent(System.Windows.Forms.DataFormats.Riff) Then
            MsgBox("Clipboard content is compatible with data type [System.Windows.Forms.DataFormats.Riff]")
        Else
            MsgBox("Clipboard content is    NOT      compatible with data type  [System.Windows.Forms.DataFormats.Riff]")
        End If
        ' End:    Reusable code block (2005 09 01 PM 10 26 20)

    End Function ' Do_GetStringInClipboard
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    Private Function Do_GetStandardTimeStampWithYearMonthDayAndTime() As String
        ' (本段程式之目的) Purpose:
        '     Return a standard time stamp like the followings:
        '
        '           "(2003 07 28 AM 01 51 56)"
        '           "(2003 07 28 MM 12 51 56)"
        '           "(2003 07 28 PM 01 51 56)"
        '
        ' (本段程式是否已經在被使用中) In use: Yes
        ' (重要等級) Importance rating:  90%
        ' (再利用的可能性) Chances of reuse:  80%
        ' (程式撰寫的進度) Developing: 100%
        ' (程式堪用的程度) Workable: 80%
        ' (程式的測試程度) Code tested: 80%
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        ' (修改程式的日期) Revision Date: (2003 07 28 PM 01 49 20)
        ' (修改程式的人員) Revised by: WeiJin Tang (湯偉晉)
        '     OK
        '     Version: 1.00.02
        '     Last Updated: (2006 01 13 AM 01 39 50)
        '     Version: 1.00.01
        '     Last Updated: (2003 07 28 PM 01 49 20)
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        ' Begin: 1.00.02 (2006 01 13 AM 01 40 03)

        Dim TimeStampWithYearMonthDayAndTime As String
        Dim ValueOfHour As Long

        Dim ThisMoment As Date
        ThisMoment = Now

        ValueOfHour = Hour(ThisMoment)

        Dim AM_MM_or_PM As String

        If ValueOfHour >= 0 And ValueOfHour < 12 Then
            AM_MM_or_PM = "AM"
        ElseIf ValueOfHour = 12 Then
            AM_MM_or_PM = "MM"
        Else
            AM_MM_or_PM = "PM"
            If ValueOfHour <> 12 Then
                ValueOfHour = ValueOfHour - 12
            End If
        End If

        Dim YearAsString As String
        YearAsString = ThisMoment.Year.ToString.PadLeft(4, Convert.ToChar("0"))
        Dim MonthAsString As String
        MonthAsString = ThisMoment.Month.ToString.PadLeft(2, Convert.ToChar("0"))
        Dim DayAsString As String
        DayAsString = ThisMoment.Day.ToString.PadLeft(2, Convert.ToChar("0"))

        Dim HourAsString As String
        HourAsString = ValueOfHour.ToString.PadLeft(2, Convert.ToChar("0"))

        Dim MinuteAsString As String
        MinuteAsString = ThisMoment.Minute.ToString.PadLeft(2, Convert.ToChar("0"))
        Dim SecondAsString As String
        SecondAsString = ThisMoment.Second.ToString.PadLeft(2, Convert.ToChar("0"))

        Dim SpaceChar As String = " "

        TimeStampWithYearMonthDayAndTime = "(" & YearAsString & SpaceChar & MonthAsString & SpaceChar & DayAsString & SpaceChar & AM_MM_or_PM & SpaceChar & HourAsString & SpaceChar & MinuteAsString & SpaceChar & SecondAsString & ")"

        Return TimeStampWithYearMonthDayAndTime

        ' End:    1.00.02 (2006 01 13 AM 01 40 03)

    End Function ' Do_GetStandardTimeStampWithYearMonthDayAndTime
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    Private Function Do_GetStandardTimeType02() As String
        ' (本段程式之目的) Purpose:
        '     Return a standard time stamp like the followings:
        '
        '           "[2008_06_10_PM_09_28_21]"
        '
        ' (本段程式是否已經在被使用中) In use: Yes
        ' (重要等級) Importance rating:  90%
        ' (再利用的可能性) Chances of reuse:  80%
        ' (程式撰寫的進度) Developing: 100%
        ' (程式堪用的程度) Workable: 80%
        ' (程式的測試程度) Code tested: 80%
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        ' (修改程式的日期) Revision Date: (2008 06 10 PM 09 30 16)
        ' (修改程式的人員) Revised by: WeiJin Tang (湯偉晉)
        '     OK
        '     Version: 1.00.01
        '     Last Updated: (2008 06 10 PM 09 30 16)
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        Dim T As String
        T = Me.Do_GetStandardTimeStampWithYearMonthDayAndTime
        T = T.Replace("(", "[")
        'T = T.Replace("-", "_")
        T = T.Replace(" ", "_")
        T = T.Replace(")", "]")

        Return T
    End Function
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    Private Sub Do_PasteStringToClipboard(ByVal AnyString As String)
        ' (本段程式之目的) Purpose:
        '     Paste string to Clipboard.
        ' (本段程式是否已經在被使用中) In use: Yes
        ' (重要等級) Importance rating:  80%
        ' (再利用的可能性) Chances of reuse:  90%
        ' (程式撰寫的進度) Developing: 100% (Mandatory)
        ' (程式堪用的程度) Workable: 80% (Threshold at 80%)
        ' (程式的測試程度) Code tested: 80% (max 99%)
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        ' (修改程式的日期) Revision Date: (2004 12 06 PM 03 17 30)
        ' (修改程式的人員) Revised by: WeiJin Tang (湯偉晉)
        '     ok
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        Clipboard.SetDataObject(AnyString, True)

    End Sub ' Do_PasteStringToClipboard
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
End Class ' SourceCodePublishingHelper_VBY2008M06

' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
' ' ' ' ' ' ' ' ' ' ' ' '  [2008_06_15_PM_05_39_04]  ' ' ' ' ' ' ' ' ' ' ' ' ' '
' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '

沒有留言: