⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ve-9e.tmp

📁 这是我自己用VB.NET编写的一款监护仪的电脑软件
💻 TMP
📖 第 1 页 / 共 3 页
字号:



Imports System.IO
Imports System.Drawing
Imports System.Text
Public Class MainForm
    Public PortID As Integer = 0  '用于选择端口号,默认为COM1
    Public MyPath As String = Application.StartupPath & "Data.dat"
    Public Exp_Bytes As Integer   '测试数据还剩多少字节,判断COM口是否正确连接
    Public PrintBMP As New Bitmap(1200, 900)  '打印栅格
    Public BuffData(3) As Byte
    Public Err_Count As Integer = 0
    Public Point_Count As Integer = 0 '总点数
    '以下是子窗口打开事件
    Private Sub Sys_Set_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Sys_Set.Click
        SystemSet.ShowDialog()
    End Sub

    Private Sub Pra_File_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Pra_File.Click
        DangAn.ShowDialog()
    End Sub

    Private Sub Print_set_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Print_set.Click
        PrintF.Begin_Print.Enabled = False
        PrintF.GroupBox3.Enabled = True
        PrintF.CheckBox1.Enabled = True
        PrintF.CheckBox1.Checked = True
        PrintF.ShowDialog()
    End Sub

    Private Sub Sys_quit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Sys_quit.Click
        If Me.Start_Obv.Text <> "开始监护" Then
            MessageBox.Show("请先停止监护后再退出系统!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            Exit Sub
        End If
        On Error Resume Next
        File.Delete(MyPath)  '删除文件
        Close()
        Login.Close() '关闭登陆窗口
    End Sub

    Private Sub Data_Man_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Data_Man.Click
        If Me.Data_Man.Text = "数据库管理" Then
            FormDatabase.ShowDialog()
        Else   'show帮助文档
        End If
    End Sub
    Private Sub Aboout_us_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles Aboout_us.LinkClicked
        AboutBox1.ShowDialog()
    End Sub

    Private Sub Start_Obv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Start_Obv.Click
        If Me.Print_rate.Text = "未设置" Then     '用户第一次登陆
            PrintF.Begin_Print.Enabled = False
            PrintF.GroupBox3.Enabled = True
            PrintF.Print_ComboBox.Enabled = True
            PrintF.CheckBox1.Enabled = True
            PrintF.ShowDialog()                                        '*************这里设置走纸速度
            Exit Sub
        ElseIf Me.Print_rate.Text = "3厘米/分钟" Then                  '*******************************
            DataTimer.Interval = 50
        ElseIf Me.Print_rate.Text = "2厘米/分钟" Then                   '*******************************
            DataTimer.Interval = 100
        Else
            DataTimer.Interval = 150
        End If

        If Me.Button1.Text = "增加栅格" Then
            Me.Button1_Click(Nothing, Nothing)
        End If

        Print_Image.Enabled = False
        Print_Image.BackColor = Color.LightGray
        Stop_obv.Enabled = True  '停止按钮可用
        Stop_obv.BackColor = Color.Red


        If Me.Start_Obv.Text = "开始监护" Then
            '以下清除数据记录

            Point_Count = 0
            Pause_Count = 0
            Page_Count = 0
            Arr_Count = 0
            FHR1(1) = 0
            FHR2(1) = 0
            UC(1) = 0
            X_Pos = 0
            Using MyDraw1 As Graphics = Graphics.FromImage(bmp)
                MyDraw1.Clear(Color.White)
            End Using
            Using MyDraw2 As Graphics = Graphics.FromImage(MyBmp)
                MyDraw2.Clear(Color.White)
            End Using
            Me.PictureBox1.Image = bmp
            '************************测试用数据,以下程序仅供测试
            Timer_Ceshi.Start()
            '**************************************************

            Try
                SPort.PortName = My.Computer.Ports.SerialPortNames(PortID)  '打开端口,可选
                If Not SPort.IsOpen Then
                    SPort.Open()
                    SPort.DiscardInBuffer()
                    SPort.DiscardInBuffer()
                End If

            Catch ex As Exception
                Me.Stop_obv_Click(Nothing, Nothing)
                Exit Sub
            End Try

            If Exp_Bytes < 10 Then
                ' Me.Stop_obv_Click(Nothing, Nothing)
                MessageBox.Show("端口无效,请检查设备是否正确连接,或通过系统设置选择其它端口!", "连接失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
                If SPort.IsOpen Then
                    SPort.Close()
                End If
                ' Exit Sub
            End If

            If Me.DisPlayAll.Text <> "恢复正常视图" Then
                Me.DisPlayAll_Click(Nothing, Nothing)
            End If

        End If


        If Start_Obv.Text = "开始监护" Or Start_Obv.Text = "恢复" Then
            Start_Obv.Text = "暂停"
            Start_Obv.BackColor = Color.Yellow
            ToolStripStatusLabel3.Text = "监护状态:正在监护"
            Me.Obv_status.Text = "正在监护"

        ElseIf Start_Obv.Text = "暂停" Then
            Start_Obv.Text = "恢复"
            Start_Obv.BackColor = Color.LimeGreen
            ToolStripStatusLabel3.Text = "监护状态:监护暂停"
            Me.Obv_status.Text = "监护暂停"
            '以下代码用于记录暂停数据
            Pause_Count += 1  '记录暂停次数
        End If
        Me.DisPlayAll.Visible = False  '显示全部
        Obv_Timer.Start()     '开始监护

    End Sub

    Private Sub Stop_obv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Stop_obv.Click
        Dim MyFS2 As FileStream = File.Open(MyPath, FileMode.Create, FileAccess.Write)
        Dim MySR2 As New BinaryWriter(MyFS2)
        MySR2.Write(WriteBuffer)
        MySR2.Close()
        MyFS2.Close()
        Obv_Timer.Stop()
        DataTimer.Stop()
        Time_Tick = 0
        Print_Image.Enabled = True
        Print_Image.BackColor = Color.LimeGreen

        Start_Obv.Text = "开始监护"
        Start_Obv.BackColor = Color.LimeGreen
        If Point_Count > 560 Then
            Me.DisPlayAll.Visible = True    '满屏,换页
        End If

        Me.Obv_status.Text = "已停止"
        ToolStripStatusLabel3.Text = "监护状态:未开始"
        DataTimer.Stop()  '停止处理数据



        If SPort.IsOpen = True Then
            SPort.Close()
        End If

        Stop_obv.Enabled = False
        Stop_obv.BackColor = Color.LightGray

        '************************测试用数据,以下程序仅供测试
        Timer_Ceshi.Stop()
        Me.RichTextBox1.Text = ""
        '******************************************************
        Draw_PrintImage(PrintBMP)    '绘制栅格,供打印

        If Me.Obv_Left.Text = "0分0秒" Then
            MessageBox.Show("监护时间到,谢谢使用!", "监护完成", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End If

    End Sub


    Private Sub MoreInform_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles MoreInform.LinkClicked
        DangAn.ShowDialog()
    End Sub

    Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        SystemSet.ShowDialog()
    End Sub

    Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
        On Error GoTo err
        If Me.PictureBox1.Width < 2 Then  '不满一屏
            Exit Sub
        End If

        Me.PictureBox1.BackgroundImage = Nothing   '这句用来清除栅格,不能使用Clear语句
        '以下绘制栅格
        Dim MyRect1(Me.PictureBox1.Width / 90 - 1) As Rectangle  'FHR1  栅格示意
        Dim MyRect2(Me.PictureBox1.Width / 90 - 1) As Rectangle  'FHR2
        Dim MyRect3(Me.PictureBox1.Width / 90 - 1) As Rectangle  'UC
        Dim MyPen As New Pen(Color.Black, 1)
        Dim MyColor As Color = System.Drawing.Color.FromArgb(130, 200, 200, 200)
        Dim Mybrush As New SolidBrush(MyColor)

        If Me.Button1.Text = "取消栅格" Then
            e.Graphics.FillRectangle(Mybrush, 2, 82, Me.PictureBox1.Width - 2, 50)    '画正常区,激发报警
            e.Graphics.FillRectangle(Mybrush, 2, 82 + 210, Me.PictureBox1.Width - 2, 50)
            e.Graphics.FillRectangle(Mybrush, 2, 17 + 435, Me.PictureBox1.Width - 2, 85)
            MyPen.DashStyle = Drawing2D.DashStyle.Dash
            For i As Integer = 0 To Me.PictureBox1.Width / 90 - 1
                MyRect1(i).X = 2 + i * 90
                MyRect1(i).Y = 2
                MyRect1(i).Width = 90
                MyRect1(i).Height = 190

                MyRect2(i).X = 2 + i * 90
                MyRect2(i).Y = 212
                MyRect2(i).Width = 90
                MyRect2(i).Height = 190

                MyRect3(i).X = 2 + i * 90
                MyRect3(i).Y = 437
                MyRect3(i).Width = 90
                MyRect3(i).Height = 100

                For j As Integer = 1 To 2
                    e.Graphics.DrawLine(MyPen, 90 * i + 30 * j, 2, 90 * i + 30 * j, 192)
                    e.Graphics.DrawLine(MyPen, 90 * i + 30 * j, 212, 90 * i + 30 * j, 402)
                    e.Graphics.DrawLine(MyPen, 90 * i + 30 * j, 437, 90 * i + 30 * j, 537)
                Next
            Next

            e.Graphics.DrawRectangles(Pens.Black, MyRect1)
            e.Graphics.DrawRectangles(Pens.Black, MyRect2)
            e.Graphics.DrawRectangles(Pens.Black, MyRect3)
            For i As Integer = 1 To 18
                e.Graphics.DrawLine(MyPen, 2, i * 10 + 2, Me.PictureBox1.Width, i * 10 + 2)
                e.Graphics.DrawLine(MyPen, 2, i * 10 + 212, Me.PictureBox1.Width, i * 10 + 212)
                If i < 10 Then
                    e.Graphics.DrawLine(MyPen, 2, i * 10 + 437, Me.PictureBox1.Width, i * 10 + 437)
                End If
            Next

            '标注坐标
            Dim Pos_Value As Integer = 240
            For i As Integer = 0 To 6
                For j As Integer = 0 To PictureBox1.Width / 700
                    e.Graphics.DrawString(Pos_Value, New Font("黑体", 8, FontStyle.Italic), Brushes.Red, 240 + 700 * j, -2 + i * 30)
                    e.Graphics.DrawString(Pos_Value, New Font("黑体", 8, FontStyle.Italic), Brushes.Red, 240 + 700 * j, 207 + i * 30)
                Next
                Pos_Value -= 30
            Next
            Pos_Value = 100
            For i As Integer = 0 To 5
                For j As Integer = 0 To PictureBox1.Width / 700
                    e.Graphics.DrawString(Pos_Value, New Font("黑体", 8, FontStyle.Italic), Brushes.Red, 240 + 700 * j, 433 + i * 20)
                Next
                Pos_Value -= 20
            Next

            e.Graphics.DrawString(50, New Font("黑体", 8, FontStyle.Italic), Brushes.DarkBlue, 240, 192)
            e.Graphics.DrawString(50, New Font("黑体", 8, FontStyle.Italic), Brushes.DarkBlue, 240, 402)

            e.Graphics.DrawString("胎心音1", New Font("宋体", 9), Brushes.Red, 5, 189)
            e.Graphics.DrawString("胎心音2", New Font("宋体", 9), Brushes.Red, 5, 401)
            e.Graphics.DrawString("宫压", New Font("宋体", 9), Brushes.Red, 5, 536)


        Else   '这里删除栅格
            Me.PictureBox1.BackgroundImage = Nothing   '这句用来清除栅格,不能使用Clear语句
            e.Graphics.DrawString("胎心音1", New Font("宋体", 9), Brushes.Red, 5, 189)
            e.Graphics.DrawString("胎心音2", New Font("宋体", 9), Brushes.Red, 5, 401)
            e.Graphics.DrawString("宫压", New Font("宋体", 9), Brushes.Red, 5, 536)
            e.Graphics.FillRectangle(Mybrush, 2, 82, Me.PictureBox1.Width, 50)    '画正常区,激发报警
            e.Graphics.FillRectangle(Mybrush, 2, 82 + 210, Me.PictureBox1.Width, 50)
            e.Graphics.FillRectangle(Mybrush, 2, 17 + 435, Me.PictureBox1.Width, 85)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -