九月 23

感謝保哥無私的分享

在此分流 Subversion 繁體中文線上電子書

有需要的人可以連結使用,或於小站的右邊連結進入





九月 19

昨天農曆7/30,民間習俗鬼月的最後一天,俗稱鬼門關

很神奇的,架在家裡的Server發生了很奇怪的事

昨天回到家順手把Server裡的作業系統 Server 2003 x64 給更新了一下

重開後,啥!!架在Server裡的VMWare Linux 作業系統,PPPOE撥接浮動IP上去後

我自已的NB卻連不到那個PPPOE上去的IP,可是卻Ping的到。我想你一定不知道我在說什麼

簡單的說就是這2台電腦可以互相Ping到對方的PPPOE IP,可是卻連不上對方的任何port

最神奇的是,外面的IP完全可以正常的存取這2個電腦的PPPOE IP.......

試過把Server 2003 x64還原、重灌VMWare、移除防火牆、重開數據機、換線路

完全沒效..........就這樣我在上面花了12小時以上,這是傳說中的鬼擋牆嗎

今天玩不下去了,打給中華電信,說星期一來我家測試一下數據機.....

好吧,反正都要來測了,我就惡搞一下數據機吧,丫不是啦,我是說研究一下

先更新個軔體玩玩,我是刷這個版本ZyXEL P-870HA N3 韌體,刷的過程有點小久,刷完數據機會自已重開機

刷成功後,耶....正常了。這就是所謂的卡到陰嗎........那我昨天弄到早上4點不就是弄心酸的..冏

這邊附上更新的教學,此教學來自ZyXEL P-870HA N3 韌體更新- essoduke's blog,感謝

更新步驟如下:

1. 下載 N3 版韌體(檔案來源:本站提供)
2. 將本機 IP 改成和 VDSL 相同的網段(192.168.1.2 – 192.168.1.254)
3. 有使用分享器者,先將網路線直接連接至 MODEM 再進行下列操作。
4. 開啟瀏覽器執行:http://192.168.1.1/,帳號密碼如下:

* 北部 帳號 cht 密碼 chtnvdsl
* 中部 帳號 cht 密碼 chtcvdsl
* 南部 帳號 cht 密碼chtsvdsl

5. 登入後點選左側選單「Management」->「Update Software」進行更新
6. 過程中會先斷線,完成後會要求重新登入,更新後請使用上述帳密中的「北區」進行登入
7. 檢查 Device Info 看是否更新完成





九月 16

PropertyGrid 這個元件在市面上 .net  的書很少看到

這幾天摸了一下,感覺上是個還不錯用的元件

尤其對於在開發"編輯環境"的特別好用

簡單的說,這是一個可以幫你把Class變成設定介面的元件

把Class丟進元件後,元件就會幫你處理傳值與顯示值的問題

看圖或許比較好理解

有沒有一種很熟悉的感覺,沒錯,跟 Visual Studio .Net 的的屬性設定是一樣的

而這個介面只要把寫好的Class放進去就可以自動產生了,真的超方便

完整的程式碼可以到這邊下載

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles MyBase.Load
        '把Class丟進去PropertyGrid
        PropertyGrid1.SelectedObject = New SampleClass
    End Sub

SampleClass.vb

Imports System.ComponentModel

Public Class SampleClass

    <FlagsAttribute()> _
   Public Enum Permissions
        <Description("未設定")> _
        None = 0

        <Description("建立")> _
        Create = 1

        <Description("讀取")> _
        Read = 2

        <Description("更新")> _
        Update = 4

        <Description("刪除")> _
        Delete = 8

        <Description("所有功能")> _
        All = Create Or Read Or Update Or Delete

    End Enum

    Private _P1 As String
    Public Property P1_String() As String
        Get
            Return _P1
        End Get
        Set(ByVal value As String)
            _P1 = value
        End Set
    End Property

    Private _P2 As Integer
    Public Property P2_Integer() As Integer
        Get
            Return _P2
        End Get
        Set(ByVal value As Integer)
            _P2 = value
        End Set
    End Property

    Private _P3 As Boolean
    Public Property P3_Boolen() As Boolean
        Get
            Return _P3
        End Get
        Set(ByVal value As Boolean)
            _P3 = value
        End Set
    End Property

    Private _P4 As DateTime
    Public Property P4_DateTime() As DateTime
        Get
            Return _P4
        End Get
        Set(ByVal value As DateTime)
            _P4 = value
        End Set
    End Property

    Private _P5 As Permissions
    Public Property P5_Enum() As Permissions
        Get
            Return _P5
        End Get
        Set(ByVal value As Permissions)
            _P5 = value
        End Set
    End Property

    Private _P6 As New PropertyTreeClass.AddressType
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
    <Description("住址")> _
    Public Property P6_Tree() As PropertyTreeClass.AddressType
        Get
            Return _P6
        End Get
        Set(ByVal value As PropertyTreeClass.AddressType)
            _P6 = value
        End Set
    End Property

    Private _P7 As Color = Color.White
    Public Property P7_Color() As Color
        Get
            Return _P7
        End Get
        Set(ByVal value As Color)
            _P7 = value
        End Set
    End Property

    Private _P8 As Color = System.Drawing.Color.FromArgb(123, 123, 123)
    <Description("於自訂項目的下面空格中按下滑鼠右鍵,可自訂RGB")> _
    Public Property P8_Color() As Color
        Get
            Return _P8
        End Get
        Set(ByVal value As Color)
            _P8 = value
        End Set
    End Property

#Region "可分類的屬性"
    Private _C1 As String
    <Category("分類")> _
    <Description("相同類型的屬性C1")> _
    Public Property C1() As String
        Get
            Return _C1
        End Get
        Set(ByVal value As String)
            _C1 = value
        End Set
    End Property

    Private _C2 As String
    <Category("分類")> _
    <Description("相同類型的屬性C2")> _
    Public Property C2() As String
        Get
            Return _C2
        End Get
        Set(ByVal value As String)
            _C2 = value
        End Set
    End Property
#End Region

End Class

PropertyTreeClass.vb

Imports System.ComponentModel
Imports System.Globalization

'The namespace referenced from
'http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/f81b6caa-5fae-45c4-ad46-2240e84a5d7a

Namespace PropertyTreeClass

    <TypeConverter(GetType(AddressTypeTypeConverter))> _
    Public Class AddressType

        Private m_country As String
        <NotifyParentProperty(True), Description("國家"), RefreshProperties(RefreshProperties.Repaint)> _
        Public Property Country() As String
            Get
                Return m_country
            End Get

            Set(ByVal value As String)
                m_country = value
            End Set
        End Property

        Private m_city As String
        <NotifyParentProperty(True), Description("城市"), RefreshProperties(RefreshProperties.Repaint)> _
        Public Property City() As String
            Get
                Return m_city
            End Get

            Set(ByVal value As String)
                m_city = value
            End Set
        End Property
    End Class

    Public Class Person

        Public Sub New()
            homeAddressField = New AddressType()
        End Sub

        Private homeAddressField As AddressType

        <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
        Public Property HomeAddress() As AddressType
            Get
                Return Me.homeAddressField
            End Get

            Set(ByVal value As AddressType)
                Me.homeAddressField = value
            End Set
        End Property
    End Class

    Public Class AddressTypeTypeConverter
        Inherits TypeConverter

        Public Overrides Function ConvertTo(ByVal context As ITypeDescriptorContext, ByVal culture As System.Globalization.CultureInfo, ByVal value As Object, ByVal destinationType As Type) As Object
            'This method is used to shown information in the PropertyGrid.
            If destinationType Is GetType(String) Then
                Return (DirectCast(value, AddressType).Country & ",") + DirectCast(value, AddressType).City
            End If

            Return MyBase.ConvertTo(context, culture, value, destinationType)
        End Function

        Public Overrides Function GetProperties(ByVal context As ITypeDescriptorContext, ByVal value As Object, ByVal attributes As Attribute()) As PropertyDescriptorCollection
            Return TypeDescriptor.GetProperties(GetType(AddressType), attributes).Sort(New String() {"Country", "City"})
        End Function

        Public Overrides Function GetPropertiesSupported(ByVal context As ITypeDescriptorContext) As Boolean
            Return True
        End Function

    End Class

End Namespace




九月 15

先import 下面這2個namespace
Imports System.ComponentModel
Imports System.Reflection


<FlagsAttribute()> _
Public Enum Permissions

<Description("未設定")> _
None = 0

<Description("建立")> _
Create = 1

<Description("讀取")> _
Read = 2

<Description("更新")> _
Update = 4

<Description("刪除")> _
Delete = 8

<Description("所有功能")> _
All = Create Or Read Or Update Or Delete

End Enum

'要取得描述時使用下面的程式碼

Dim fi As FieldInfo = _
Permissions.Create.GetType().GetField(Permissions.Create.ToString())

Dim attributes As DescriptionAttribute() = _
CType(fi.GetCustomAttributes(GetType(DescriptionAttribute), False),  _
DescriptionAttribute())

'顯示取得的描述
Response.Write(attributes(0).Description)




九月 08

之前有個網友問說,要怎麼樣批次解壓縮某個目錄下的壓縮檔

所以就有這篇文章出現了。使用前請先確定你有裝winrar~

如果不是裝在預設路徑的話,要修改WINRAR_PATH這個參數


@ECHO OFF
REM AFTER_UNRAR_DELETE_FILE=YES 解壓後刪除原始的壓縮檔
REM AFTER_UNRAR_DELETE_FILE=NO 解壓後保留原始的壓縮檔

REM 在此設定要不要刪原始檔(大小寫有分別)
SET AFTER_UNRAR_DELETE_FILE=NO
REM 在此設定WINRAR的路徑
SET WINRAR_PATH=C:\PROGRA~1\WinRAR\WinRAR.exe

FOR %%F IN (*.rar) DO (
ECHO "解壓 %%F..."
MKDIR "Unrar_%%F"
%WINRAR_PATH% x "%%F" * "Unrar_%%F"\
IF %AFTER_UNRAR_DELETE_FILE%==YES (Del "%%F")
)

延伸閱讀:WinRAR於指令模式自動化壓縮