日本a√视频在线,久久青青亚洲国产,亚洲一区欧美二区,免费g片在线观看网站

        <style id="k3y6c"><u id="k3y6c"></u></style>
        <s id="k3y6c"></s>
        <mark id="k3y6c"></mark>
          
          

          <mark id="k3y6c"></mark>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 移植VB維護(hù)程序到mobile下

          移植VB維護(hù)程序到mobile下

          作者: 時間:2016-10-08 來源:網(wǎng)絡(luò) 收藏

          Case 1

          本文引用地址:http://yuyingmama.com.cn/article/201610/305854.htm

          m_SerialPort.Handshake = IO.Ports.Handshake.RequestToSend

          Case 2

          m_SerialPort.Handshake = IO.Ports.Handshake.RequestToSendXOnXOff

          Case 3

          m_SerialPort.Handshake = IO.Ports.Handshake.XOnXOff

          End Select

          m_SerialPort.PortName = COM + CStr(ComPort)

          m_SerialPort.ReadTimeout = 500

          m_SerialPort.WriteTimeout = 500

          If m_SerialPort.IsOpen = True Then

          m_SerialPort.Close()

          End If

          m_SerialPort.Open()

          If m_SerialPort.IsOpen = True Then

          bRxStatus = COMOK

          ReDim bDate(2)

          ReadData(bDate)

          bRxLock = False

          readThread.Start()

          Else

          bRxStatus = COMERROR

          End If

          ' readThread.Join()

          End Sub

          Public Function ComStatus() As Byte

          ComStatus = bRxStatus

          End Function

          Function ReadData(ByRef bDate() As Byte) As Integer

          Dim bLen As Integer

          bLen = m_SerialPort.BytesToRead

          If bLen > 0 Then

          ReDim bDate(bLen)

          m_SerialPort.Read(bDate, 0, bLen)

          ReadData = bLen

          Else

          ReadData = 0

          End If

          bRxStatus = COMFREE

          End Function

          Public Function SendDate(ByVal bDateBuff() As Byte, ByVal iLen As Integer) As Boolean

          If bRxLock = False Then

          m_SerialPort.Write(bDateBuff, 0, iLen)

          bRxLock = True

          bRxStatus = READLOCK

          SendDate = True

          Else

          SendDate = False

          End If

          End Function

          Public Shared Sub Read()

          While (1)

          Thread.Sleep(50)

          Try

          If m_SerialPort.BytesToRead > iRxLen Then

          iRxLen = m_SerialPort.BytesToRead

          iRxTime = 0

          bRxStatus = READLOCK

          Else

          If iRxLen > 0 Then

          '收到數(shù)據(jù)

          bRxStatus = READOK

          bRxLock = False

          Else

          iRxTime = iRxTime + 1

          If iRxTime > 10 Then

          bRxStatus = READOUTTIME

          End If

          bRxLock = False

          End If

          End If

          Catch ex As TimeoutException

          ' Do nothing

          End Try

          End While

          End Sub

          Public Sub Close()

          readThread.Abort()

          m_SerialPort.Close()

          End Sub

          End Class

          定義窗口變量

          Dim ComPort As New RS232TXClass

          啟動后調(diào)用

          ComPort.Init(9600,n,8,1, 0, 1)

          在主窗口中,通過一個定時器事件,查看串口情況

          Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

          Dim bDate() As Byte

          Dim iLen As Integer

          ReDim bDate(2)

          If ComPort.ComStatus = 2 Then

          iLen = ComPort.ReadData(bDate)

          If iLen > 2 Then

          ShowRevDate(bDate, iLen)

          End If

          End If

          End Sub

          下面實現(xiàn)一個windows的路燈維護(hù)程序移植到windows CE上面去的一些簡單示例。

          這是原來VB上面的一個界面。

          這個是我移植到VB.net for Mobile的版本,因為在Mobile上面多窗口切換很麻煩,就作成分頁的顯示了。

          需要注意的是,因為Mobile上面的輸入法啟動后會遮蓋一部分窗口,為了輸入方面最后把需要輸入的地方放到上面去,以免影響輸入。這里我把兩個顯示性Label放到了后面。

          VB.NET的繪圖和VB不是很一樣,更加接近C++的繪圖方式,但是只要不一些概念弄清楚,你會發(fā)現(xiàn)這種繪圖方式使用更加方便,更加方便你對于GDI+的理解。

          VB.NET中可以使用 Dim bm As New Bitmap(238, 214) 直接建立一個位圖,然后把繪制好的位圖覆蓋回去。

          繪制文字的時候,需要字體和畫刷,象下面這樣:

          ShowTextBrush = New SolidBrush(Color.Blue)

          mFont = New Font(FontFamily.GenericSansSerif, 8, FontStyle.Regular)

          g.DrawString(HELLO, mFont, ShowTextBrush, 12, 82)

          繪制線的時候,需要畫筆。

          Pen1 = New Pen(Color.Red)

          g.DrawLine(Pen1, OldX, OldY, NewX, NewY)

          填充圖形的時候,需要畫刷

          tempbrush = New SolidBrush(Color.FromArgb(192, 192, 255))

          g.FillRectangle(tempbrush, 0, 0, 238, 214)

          繪制扇形和弧形,VB.NET沒有提供,但是我從網(wǎng)上找到了實現(xiàn)方法,用聯(lián)系線和連續(xù)填充實現(xiàn)弧形和棒圖的繪制。函數(shù)如下

          '=====================================================

          '繪制弧形

          '

          ' graphicsObject - Graphics 對象

          ' pen - 畫筆

          ' x,y - 弧的圓心

          ' width - 寬度 (X直徑)

          ' height - 高度 (Y直徑)

          ' startAngle - 起始角度

          ' sweepAngle - 結(jié)束角度

          '

          Private Sub drawPie(ByVal graphicsObject As Graphics, ByVal pen As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal startAngle As Single, ByVal sweepAngle As Single)

          Dim xAngle(12) As Single

          Dim yAngle(12) As Single



          關(guān)鍵詞:

          評論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉