<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

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

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

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

          Case 1

          本文引用地址:http://www.ex-cimer.com/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

          啟動(dòng)后調(diào)用

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

          在主窗口中,通過(guò)一個(gè)定時(shí)器事件,查看串口情況

          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

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

          這是原來(lái)VB上面的一個(gè)界面。

          這個(gè)是我移植到VB.net for Mobile的版本,因?yàn)樵贛obile上面多窗口切換很麻煩,就作成分頁(yè)的顯示了。

          需要注意的是,因?yàn)镸obile上面的輸入法啟動(dòng)后會(huì)遮蓋一部分窗口,為了輸入方面最后把需要輸入的地方放到上面去,以免影響輸入。這里我把兩個(gè)顯示性Label放到了后面。

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

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

          繪制文字的時(shí)候,需要字體和畫(huà)刷,象下面這樣:

          ShowTextBrush = New SolidBrush(Color.Blue)

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

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

          繪制線的時(shí)候,需要畫(huà)筆。

          Pen1 = New Pen(Color.Red)

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

          填充圖形的時(shí)候,需要畫(huà)刷

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

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

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

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

          '繪制弧形

          '

          ' graphicsObject - Graphics 對(duì)象

          ' pen - 畫(huà)筆

          ' 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)鍵詞:

          評(píng)論


          相關(guān)推薦

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

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();