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

📄 mainform.vb

📁 这是我自己用VB.NET编写的一款监护仪的电脑软件
💻 VB
📖 第 1 页 / 共 3 页
字号:
            '****************************************************画栅格
            Using GridDraw As Graphics = Graphics.FromImage(bmp(Page_Count))
                GridDraw.Clear(Color.White)
                Dim MyRect1(Me.PictureBox1.Width / 120 - 1) As Rectangle  'FHR1/2  栅格示意
                Dim MyRect2(Me.PictureBox1.Width / 120 - 1) As Rectangle  'UC
                Dim MyPen As New Pen(Color.YellowGreen, 1)
                Dim MyColor As Color = System.Drawing.Color.FromArgb(180, Me.Shadow_ForeColor.R, Shadow_ForeColor.G, Shadow_ForeColor.B)
                Dim Mybrush As New SolidBrush(MyColor)

                Dim myp As New Pen(Me.FHR1_ForeColor, 2)
                Dim myp1 As New Pen(Me.FHR2_ForeColor, 1)
                Dim myp2 As New Pen(Me.UC_ForeColor, 1)
                Dim RecColor As New Pen(Color.Gray, 1)

                GridDraw.FillRectangle(Mybrush, 5, 120 + 50, 1085, 60)    '画正常区,激发报警

                '画标记
                GridDraw.DrawLine(myp, 11, 77, 29, 77)
                GridDraw.DrawLine(myp1, 11, 92, 29, 92)
                GridDraw.DrawLine(myp2, 11, 456, 29, 456)
                GridDraw.DrawString("FHR1", New Font("Times New Roman", 8, FontStyle.Regular), Brushes.Black, 34, 69)
                If SystemSet.CheckBox4.Checked = False Then
                    GridDraw.DrawString("Non-Used", New Font("Times New Roman", 10, FontStyle.Regular), Brushes.DarkRed, 65, 69)
                End If

                GridDraw.DrawString("FHR2", New Font("Times New Roman", 8, FontStyle.Regular), Brushes.Black, 34, 83)
                If SystemSet.CheckBox5.Checked = False Then
                    GridDraw.DrawString("Non-Used", New Font("Times New Roman", 10, FontStyle.Regular), Brushes.DarkRed, 65, 83)
                Else
                    GridDraw.DrawString("Twin Offset:( " & Me.Twin_Offset & ")", New Font("Times New Roman", 10, FontStyle.Bold), Brushes.DarkRed, 65, 83)
                End If
                GridDraw.DrawString("UC", New Font("Times New Roman", 8, FontStyle.Regular), Brushes.Black, 34, 451)
                If SystemSet.CheckBox6.Checked = False Then
                    GridDraw.DrawString("Non-Used", New Font("Times New Roman", 10, FontStyle.Regular), Brushes.DarkRed, 65, 450)
                End If
                MyPen.DashStyle = Drawing2D.DashStyle.Dash

                For i As Integer = 0 To Me.PictureBox1.Width / 120 - 1
                    MyRect1(i).X = i * 120 + 5
                    MyRect1(i).Y = 50
                    MyRect1(i).Width = 120
                    MyRect1(i).Height = 315
                    MyRect2(i).X = i * 120 + 5
                    MyRect2(i).Y = 450
                    MyRect2(i).Width = 120
                    MyRect2(i).Height = 150


                    For j As Integer = 1 To 2
                        GridDraw.DrawLine(MyPen, 5 + 120 * i + 40 * j, 50, 5 + 120 * i + 40 * j, 365)
                        GridDraw.DrawLine(MyPen, 5 + 120 * i + 40 * j, 450, 5 + 120 * i + 40 * j, 600)
                    Next
                Next

                GridDraw.DrawRectangles(RecColor, MyRect1)
                GridDraw.DrawRectangles(RecColor, MyRect2)
                For i As Integer = 0 To 21
                    If i Mod 3 = 0 Then
                        GridDraw.DrawLine(Pens.LightSteelBlue, 5, i * 15 + 50, 1085, i * 15 + 50)
                    Else
                        GridDraw.DrawLine(MyPen, 5, i * 15 + 50, 1085, i * 15 + 50)
                    End If
                Next
                For i As Integer = 0 To 10
                    If i Mod 2 = 0 Then
                        GridDraw.DrawLine(Pens.LightSteelBlue, 5, i * 15 + 450, 1085, i * 15 + 450)
                    Else
                        GridDraw.DrawLine(MyPen, 5, i * 15 + 450, 1085, i * 15 + 450)
                    End If
                Next

                Dim YGrid As Integer = 240
                For i As Integer = 0 To 7
                    GridDraw.DrawString(YGrid - i * 30, New Font("Arial", 8), Brushes.DarkGreen, 267, i * 45 + 45)
                Next
                YGrid = 100
                For i As Integer = 0 To 5
                    GridDraw.DrawString(YGrid - i * 20, New Font("Arial", 8), Brushes.DarkGreen, 270, 445 + i * 30)
                Next
                '*********************************************
            End Using
        End If

        '&&&&&&&&&&&&&&&&&****************************&&&&&&&&&&&&&&&&&
        '&&&&&&&&&&&&&&&&&&&&&&&*********************&&&&&&&&&&&&&&&&&&&&&&&&&&


        If Point_Count Mod 120 = 0 Then
            ReDim Preserve MyTime(Time_Count)
            MyTime(Time_Count) = Format(Now, "H:mm:ss")
        End If

        FHR1(Arr_Count) = BuffData(1)
        FHR2(Arr_Count) = BuffData(2)
        UC(Arr_Count) = BuffData(3)
        Using timeDraw As Graphics = Graphics.FromImage(bmp(Page_Count))
            If X_Pos Mod 120 = 0 Then
                timeDraw.DrawString(MyTime(Time_Count), New Font("Arial", 8), Brushes.Blue, X_Pos, 600)
            End If
        End Using
        If Me.Start_Obv.Text = "Pause" Then
            Using MyDraw As Graphics = Graphics.FromImage(bmp(Page_Count))
                MyDraw.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
                MyDraw.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality
                Dim myp As New Pen(Me.FHR1_ForeColor, 2)
                Dim myp1 As New Pen(Me.FHR2_ForeColor, 1)
                Dim myp2 As New Pen(Me.UC_ForeColor, 1)
                If FHR1(Arr_Count) >= 50 And FHR1(Arr_Count) <= 240 Then
                    If FHR1(1 - Arr_Count) >= 50 And FHR1(1 - Arr_Count) <= 240 Then
                        If FHR1(1 - Arr_Count) - FHR1(Arr_Count) <= 30 And FHR1(1 - Arr_Count) - FHR1(Arr_Count) >= -30 Then
                            If SystemSet.CheckBox4.Checked Then
                                MyDraw.DrawLine(myp, X_Pos + 5, CInt((240 - FHR1(1 - Arr_Count)) * 1.5) + 50, X_Pos + 6, CInt((240 - FHR1(Arr_Count)) * 1.5) + 50)
                            End If
                        End If
                    End If
                End If
                If FHR2(Arr_Count) >= 50 And FHR2(Arr_Count) <= 240 Then
                    If FHR2(1 - Arr_Count) >= 50 And FHR2(1 - Arr_Count) <= 240 Then
                        If FHR2(1 - Arr_Count) - FHR2(Arr_Count) <= 30 And FHR2(1 - Arr_Count) - FHR2(Arr_Count) >= -30 Then
                            '此处涉及到偏移
                            If SystemSet.CheckBox5.Checked Then
                                MyDraw.DrawLine(myp1, X_Pos + 5, CInt((-Me.Twin_Offset + 240 - FHR2(1 - Arr_Count)) * 1.5) + 50, X_Pos + 6, CInt((-Me.Twin_Offset + 240 - FHR2(Arr_Count)) * 1.5) + 50)
                            End If
                        End If
                    End If
                End If
                If SystemSet.CheckBox6.Checked Then
                    If UC(1 - Arr_Count) > 100 Or UC(Arr_Count) > 100 Then
                        Exit Sub
                    End If
                    MyDraw.DrawLine(myp2, X_Pos + 5, 449 + CInt((100 - UC(1 - Arr_Count)) * 1.5), X_Pos + 6, 449 + CInt((100 - UC(Arr_Count)) * 1.5))
                End If
            End Using

            If Arr_Count = 0 Then
                Arr_Count = 1
            Else
                Arr_Count = 0
            End If
        End If

        Point_Count += 1
        X_Pos += 1

        If X_Pos >= 1080 Then
            X_Pos = 0
        End If

        Me.PictureBox1.Image = bmp(Page_Count)

        '***************************暂存数
        '   For i As Integer = 0 To 3
        ' Me.RichTextBox1.Text += Hex(BuffData(i)) + " "
        '   Next
        ' Me.RichTextBox1.Text += "   "

        '******
        '***************************************
    End Sub


    Private Sub ToolStripStatusLabel6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripStatusLabel6.Click
        Me.TopMost = False
        System.Diagnostics.Process.Start("http://www.szbestman.com")
    End Sub

    Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        With Me.PrintDocument1
            .DefaultPageSettings.Margins.Left = 10
            .DefaultPageSettings.Margins.Right = 10
            .DefaultPageSettings.Margins.Bottom = 10
            .DefaultPageSettings.Margins.Top = 10
            .DefaultPageSettings.PrinterResolution.Kind = Printing.PrinterResolutionKind.High
            .DefaultPageSettings.Landscape = True '横向打印
        End With
        e.Graphics.PageUnit = GraphicsUnit.Display
        e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
        Static Page_C As Integer = 0  '页码
        e.Graphics.DrawImage(bmp(Page_C), 25, 80, 1064, 640)
        Dim MyLogo As Bitmap = New Bitmap(Me.ImageLogo.Image, 120, 50)
        e.Graphics.DrawImage(MyLogo, 100, 10)
        e.Graphics.DrawString("Computer Aided Fetal Monitor Images", New Font("Arial", 28), Brushes.Black, 225, 12)
        If Me.Prag_HosID.Text = "" Or Me.Prag_HosID.Text = "Not Set" Then
            e.Graphics.DrawString("File Number:" & "                ", New Font("Arial", 14, FontStyle.Bold), Brushes.Black, 170, 70)
        Else
            e.Graphics.DrawString("File Number:" & Me.Prag_HosID.Text, New Font("Arial", 14, FontStyle.Bold), Brushes.Black, 170, 70)
        End If

        e.Graphics.DrawString("Page " & Page_C + 1 & "/" & bmp.Length & " Page total", New Font("Times New Roman", 14), Brushes.Black, 350, 105)
        If Me.Prag_Name.Text = "" Or Me.Prag_Name.Text = "Not set" Then
            e.Graphics.DrawString("Patient Name: " & "         ", New Font("Arial", 14, FontStyle.Bold), Brushes.Black, 440, 70)
        Else
            e.Graphics.DrawString("Patient Name: " & Me.Prag_Name.Text, New Font("Arial", 14, FontStyle.Bold), Brushes.Black, 440, 70)
        End If

        If SystemSet.yiyuanming.Text <> "" Then
            e.Graphics.DrawString("Hospital:" & SystemSet.yiyuanming.Text & "   Address: " & SystemSet.yiyuandizhi.Text & "   Tel: " & SystemSet.yiyuandianhua.Text, New Font("黑体", 14), Brushes.Black, 250, 770)
        End If
        e.Graphics.DrawString("Printing Speed:  " & Me.Print_rate.Text & "    Printing Time:  " & Format(Now, "yyyy.M.d  H:mm:ss"), New Font("Arial", 14), Brushes.Black, 200, 740)
        e.Graphics.DrawString("Monitor Time:" & Me.Obv_Left.Text, New Font("Arial", 14), Brushes.Black, 450, 710)
        e.Graphics.DrawString("Physician's Signature:", New Font("Arial", 20, FontStyle.Italic), Brushes.DarkSalmon, 650, 75)
        e.Graphics.DrawLine(Pens.Black, 925, 100, 1120, 100)

        If Page_C + 1 - bmp.Length < 0 Then
            e.HasMorePages = True
            Page_C += 1
        Else
            e.HasMorePages = False
            Page_C = 0
        End If
    End Sub


    Private Sub Print_Image_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Print_Image.Click
        If Point_Count = 0 Then
            MessageBox.Show("No image for printing!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            Exit Sub
        End If
        Dim MyPrintResult As MsgBoxResult = Me.PrintDialog1.ShowDialog()
        If MyPrintResult = MsgBoxResult.Ok Then
            Me.PrintDocument1.PrinterSettings.PrinterName = Me.PrintDialog1.PrinterSettings.PrinterName
            Try
                Me.PrintPreviewDialog1.ShowDialog()
            Catch ex As Exception
                MessageBox.Show("Printing failed !You printer is not accessible!")
            End Try
        End If
    End Sub



    Private Sub Obv_Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Obv_Timer.Tick
        If Me.Start_Obv.Text <> "Start" Then
            Me.Obv_Left.Text = Math.Floor(Time_Tick / 60) & "min" & Time_Tick Mod 60 & "sec"
            Time_Tick += 1
        End If
        Try
            Dim ceshi(15) As Byte
            If Not SPort.IsOpen Then
                SPort.Open()
            End If
            SPort.Read(ceshi, 0, 10)
        Catch
            Me.Stop_obv_Click(Nothing, Nothing)
            MessageBox.Show("The serial port is interrupted!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            Exit Sub
        End Try
        If Time_Tick = Monitor_Time * 60 + 1 Then
            Me.Stop_obv_Click(Nothing, Nothing)
            MessageBox.Show("Time is up for monitoring !Thank you!", "Monitoring finished", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End If
    End Sub

    Private Sub PrintPreviewDialog1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintPreviewDialog1.Load
        Me.PrintPreviewDialog1.Document = Me.PrintDocument1
        Me.PrintPreviewDialog1.Document.DocumentName = bmp.Length  '共几页
        Me.PrintPreviewDialog1.Document.DefaultPageSettings.Landscape = True
    End Sub

    Private Sub File_Op_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles File_Op.Click
        If Me.Stop_obv.Enabled <> False Then
            MessageBox.Show("You must use this function under non-monitoring condition!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            Exit Sub
        End If
        Me.OpenFileDialog1.Filter = "File Info files(ImageInfo.bstm)|ImageInfo.bstm"
        Me.OpenFileDialog1.InitialDirectory = Application.StartupPath & "\Data\"
        Me.OpenFileDialog1.ShowDialog()
    End Sub

    Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
        Dim FN As String = Me.OpenFileDialog1.FileName
        '以下处理文本信息
        Try
            Dim MyTextInfo() As String = File.ReadAllLines(FN, System.Text.Encoding.UTF8)
            Me.Prag_Name.Text = MyTextInfo(0)
            Me.Prag_HosID.Text = MyTextInfo(1)
            Me.Prag_BedID.Text = MyTextInfo(2)
            Me.Prag_week.Text = MyTextInfo(3)
            Me.Print_rate.Text = MyTextInfo(4)
            Me.Obv_Left.Text = MyTextInfo(5)
            Me.RichTextBox1.Text = ""
            For i As Integer = 6 To MyTextInfo.Length - 1
                Me.RichTextBox1.Text += MyTextInfo(i)
            Next

            FN = IO.Directory.GetParent(FN).ToString '用来保存父路径

            Dim i_Count As Integer = 0
            While (1)
                ReDim Preserve bmp(i_Count)
                bmp(i_Count) = Image.FromFile(FN & "\ImageIndex(" & i_Count + 1 & ").gif")
                i_Count += 1
                If Not File.Exists(FN & "\ImageIndex(" & i_Count + 1 & ").gif") Then
                    Exit While
                End If
            End While
            Me.ComboBox1.Items.Clear()
            For i As Integer = 1 To bmp.Length
                Me.ComboBox1.Items.Add(i)
            Next
            Me.ComboBox1.Text = 1
            Me.Total_Page.Text = bmp.Length & " Page Total"
            Me.PictureBox1.Image = bmp(0)
            Me.HScrollBar1.Value = 0
            File_Flag = 1 '防止重复保存文件
            Point_Count = -1
            Print_Image.Enabled = True
            Print_Image.BackColor = Color.LimeGreen
        Catch ex As Exception
            MessageBox.Show("Failure of reading the image!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            Exit Try
        End Try

    End Sub

    Private Sub Data_Man_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Data_Man.Click
        If Me.Data_Man.Text = "Database" Then
            DataManger.ShowDialog()
        Else
            Me.TopMost = False
            'show帮助文档
            System.Diagnostics.Process.Start(Application.StartupPath & "\Help.chm")
        End If
    End Sub


⌨️ 快捷键说明

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