Option Strict Off
Option Explicit On
Imports System.Text
Friend Class Form1
	Inherits System.Windows.Forms.Form
#Region "Windows tH[ fUCiɂĐꂽR[h"
	Public Sub New()
		MyBase.New()
		'̌ĂяóAWindows tH[ fUCiŕKvłB
		InitializeComponent()
	End Sub
	'Form ́AR|[lgꗗɌ㏈s邽߂ dispose I[o[Ch܂B
	Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)
		If Disposing Then
			If Not components Is Nothing Then
				components.Dispose()
			End If
		End If
		MyBase.Dispose(Disposing)
	End Sub
	'Windows tH[ fUCiŕKvłB
	Private components As System.ComponentModel.IContainer
	Public WithEvents CommandLoad As System.Windows.Forms.Button
	Public WithEvents Graph As System.Windows.Forms.PictureBox
	Public WithEvents TextDeviceInfo As System.Windows.Forms.TextBox
	Public WithEvents TextDevice As System.Windows.Forms.TextBox
	Public WithEvents CommandInit As System.Windows.Forms.Button
	Public WithEvents CommandStart As System.Windows.Forms.Button
	Public WithEvents CommandInfo As System.Windows.Forms.Button
	Public WithEvents CommandStop As System.Windows.Forms.Button
	Public WithEvents CommandExit As System.Windows.Forms.Button
	Public WithEvents TextInfo As System.Windows.Forms.TextBox
	Public WithEvents LabelStatus As System.Windows.Forms.Label
	Public WithEvents Label2 As System.Windows.Forms.Label
	Public WithEvents Label1 As System.Windows.Forms.Label
	' : ȉ̃vV[W Windows tH[ fUCiŕKvłB
	'Windows tH[ fUCigĕύXł܂B
	'R[hGfB^gďCȂłB


	<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
		Me.CommandLoad = New System.Windows.Forms.Button()
		Me.Graph = New System.Windows.Forms.PictureBox()
		Me.TextDeviceInfo = New System.Windows.Forms.TextBox()
		Me.TextDevice = New System.Windows.Forms.TextBox()
		Me.CommandInit = New System.Windows.Forms.Button()
		Me.CommandStart = New System.Windows.Forms.Button()
		Me.CommandInfo = New System.Windows.Forms.Button()
		Me.CommandStop = New System.Windows.Forms.Button()
		Me.CommandExit = New System.Windows.Forms.Button()
		Me.TextInfo = New System.Windows.Forms.TextBox()
		Me.LabelStatus = New System.Windows.Forms.Label()
		Me.Label2 = New System.Windows.Forms.Label()
		Me.Label1 = New System.Windows.Forms.Label()
		Me.SuspendLayout()
		'
		'CommandLoad
		'
		Me.CommandLoad.BackColor = System.Drawing.SystemColors.Control
		Me.CommandLoad.Cursor = System.Windows.Forms.Cursors.Default
		Me.CommandLoad.ForeColor = System.Drawing.SystemColors.ControlText
		Me.CommandLoad.Location = New System.Drawing.Point(8, 88)
		Me.CommandLoad.Name = "CommandLoad"
		Me.CommandLoad.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.CommandLoad.Size = New System.Drawing.Size(81, 33)
		Me.CommandLoad.TabIndex = 12
		Me.CommandLoad.Text = "ݒt@Cǂݍ"
		'
		'Graph
		'
		Me.Graph.BackColor = System.Drawing.SystemColors.Window
		Me.Graph.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
		Me.Graph.Cursor = System.Windows.Forms.Cursors.Default
		Me.Graph.ForeColor = System.Drawing.SystemColors.WindowText
		Me.Graph.Location = New System.Drawing.Point(96, 16)
		Me.Graph.Name = "Graph"
		Me.Graph.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.Graph.Size = New System.Drawing.Size(289, 201)
		Me.Graph.TabIndex = 9
		'
		'TextDeviceInfo
		'
		Me.TextDeviceInfo.AcceptsReturn = True
		Me.TextDeviceInfo.AutoSize = False
		Me.TextDeviceInfo.BackColor = System.Drawing.SystemColors.Window
		Me.TextDeviceInfo.Cursor = System.Windows.Forms.Cursors.IBeam
		Me.TextDeviceInfo.ForeColor = System.Drawing.SystemColors.WindowText
		Me.TextDeviceInfo.Location = New System.Drawing.Point(192, 256)
		Me.TextDeviceInfo.MaxLength = 0
		Me.TextDeviceInfo.Multiline = True
		Me.TextDeviceInfo.Name = "TextDeviceInfo"
		Me.TextDeviceInfo.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.TextDeviceInfo.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
		Me.TextDeviceInfo.Size = New System.Drawing.Size(193, 65)
		Me.TextDeviceInfo.TabIndex = 8
		Me.TextDeviceInfo.Text = ""
		'
		'TextDevice
		'
		Me.TextDevice.AcceptsReturn = True
		Me.TextDevice.AutoSize = False
		Me.TextDevice.BackColor = System.Drawing.SystemColors.Window
		Me.TextDevice.Cursor = System.Windows.Forms.Cursors.IBeam
		Me.TextDevice.ForeColor = System.Drawing.SystemColors.WindowText
		Me.TextDevice.Location = New System.Drawing.Point(8, 32)
		Me.TextDevice.MaxLength = 0
		Me.TextDevice.Name = "TextDevice"
		Me.TextDevice.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.TextDevice.Size = New System.Drawing.Size(81, 18)
		Me.TextDevice.TabIndex = 6
		Me.TextDevice.Text = "DIG000"
		'
		'CommandInit
		'
		Me.CommandInit.BackColor = System.Drawing.SystemColors.Control
		Me.CommandInit.Cursor = System.Windows.Forms.Cursors.Default
		Me.CommandInit.ForeColor = System.Drawing.SystemColors.ControlText
		Me.CommandInit.Location = New System.Drawing.Point(8, 56)
		Me.CommandInit.Name = "CommandInit"
		Me.CommandInit.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.CommandInit.Size = New System.Drawing.Size(81, 25)
		Me.CommandInit.TabIndex = 5
		Me.CommandInit.Text = ""
		'
		'CommandStart
		'
		Me.CommandStart.BackColor = System.Drawing.SystemColors.Control
		Me.CommandStart.Cursor = System.Windows.Forms.Cursors.Default
		Me.CommandStart.ForeColor = System.Drawing.SystemColors.ControlText
		Me.CommandStart.Location = New System.Drawing.Point(8, 128)
		Me.CommandStart.Name = "CommandStart"
		Me.CommandStart.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.CommandStart.Size = New System.Drawing.Size(81, 25)
		Me.CommandStart.TabIndex = 4
		Me.CommandStart.Text = "WJn"
		'
		'CommandInfo
		'
		Me.CommandInfo.BackColor = System.Drawing.SystemColors.Control
		Me.CommandInfo.Cursor = System.Windows.Forms.Cursors.Default
		Me.CommandInfo.ForeColor = System.Drawing.SystemColors.ControlText
		Me.CommandInfo.Location = New System.Drawing.Point(8, 160)
		Me.CommandInfo.Name = "CommandInfo"
		Me.CommandInfo.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.CommandInfo.Size = New System.Drawing.Size(81, 25)
		Me.CommandInfo.TabIndex = 3
		Me.CommandInfo.Text = "擾"
		'
		'CommandStop
		'
		Me.CommandStop.BackColor = System.Drawing.SystemColors.Control
		Me.CommandStop.Cursor = System.Windows.Forms.Cursors.Default
		Me.CommandStop.ForeColor = System.Drawing.SystemColors.ControlText
		Me.CommandStop.Location = New System.Drawing.Point(8, 192)
		Me.CommandStop.Name = "CommandStop"
		Me.CommandStop.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.CommandStop.Size = New System.Drawing.Size(81, 25)
		Me.CommandStop.TabIndex = 2
		Me.CommandStop.Text = "W~"
		'
		'CommandExit
		'
		Me.CommandExit.BackColor = System.Drawing.SystemColors.Control
		Me.CommandExit.Cursor = System.Windows.Forms.Cursors.Default
		Me.CommandExit.ForeColor = System.Drawing.SystemColors.ControlText
		Me.CommandExit.Location = New System.Drawing.Point(8, 224)
		Me.CommandExit.Name = "CommandExit"
		Me.CommandExit.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.CommandExit.Size = New System.Drawing.Size(81, 25)
		Me.CommandExit.TabIndex = 1
		Me.CommandExit.Text = "I"
		'
		'TextInfo
		'
		Me.TextInfo.AcceptsReturn = True
		Me.TextInfo.AutoSize = False
		Me.TextInfo.BackColor = System.Drawing.SystemColors.Window
		Me.TextInfo.Cursor = System.Windows.Forms.Cursors.IBeam
		Me.TextInfo.ForeColor = System.Drawing.SystemColors.WindowText
		Me.TextInfo.Location = New System.Drawing.Point(8, 256)
		Me.TextInfo.MaxLength = 0
		Me.TextInfo.Multiline = True
		Me.TextInfo.Name = "TextInfo"
		Me.TextInfo.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.TextInfo.Size = New System.Drawing.Size(185, 65)
		Me.TextInfo.TabIndex = 0
		Me.TextInfo.Text = ""
		'
		'LabelStatus
		'
		Me.LabelStatus.BackColor = System.Drawing.SystemColors.Control
		Me.LabelStatus.Cursor = System.Windows.Forms.Cursors.Default
		Me.LabelStatus.ForeColor = System.Drawing.SystemColors.ControlText
		Me.LabelStatus.Location = New System.Drawing.Point(280, 232)
		Me.LabelStatus.Name = "LabelStatus"
		Me.LabelStatus.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.LabelStatus.Size = New System.Drawing.Size(105, 17)
		Me.LabelStatus.TabIndex = 11
		Me.LabelStatus.Text = "0H"
		'
		'Label2
		'
		Me.Label2.BackColor = System.Drawing.SystemColors.Control
		Me.Label2.Cursor = System.Windows.Forms.Cursors.Default
		Me.Label2.ForeColor = System.Drawing.SystemColors.ControlText
		Me.Label2.Location = New System.Drawing.Point(208, 232)
		Me.Label2.Name = "Label2"
		Me.Label2.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.Label2.Size = New System.Drawing.Size(57, 17)
		Me.Label2.TabIndex = 10
		Me.Label2.Text = "Xe[^X"
		'
		'Label1
		'
		Me.Label1.BackColor = System.Drawing.SystemColors.Control
		Me.Label1.Cursor = System.Windows.Forms.Cursors.Default
		Me.Label1.ForeColor = System.Drawing.SystemColors.ControlText
		Me.Label1.Location = New System.Drawing.Point(8, 8)
		Me.Label1.Name = "Label1"
		Me.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.Label1.Size = New System.Drawing.Size(65, 17)
		Me.Label1.TabIndex = 7
		Me.Label1.Text = "foCX"
		'
		'Form1
		'
		Me.AutoScaleBaseSize = New System.Drawing.Size(5, 12)
		Me.ClientSize = New System.Drawing.Size(395, 327)
		Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.CommandLoad, Me.Graph, Me.TextDeviceInfo, Me.TextDevice, Me.CommandInit, Me.CommandStart, Me.CommandInfo, Me.CommandStop, Me.CommandExit, Me.TextInfo, Me.LabelStatus, Me.Label2, Me.Label1})
		Me.Location = New System.Drawing.Point(4, 30)
		Me.MaximizeBox = False
		Me.Name = "Form1"
		Me.Text = "ݒt@C̓ǂݍ"
		Me.ResumeLayout(False)

	End Sub
#End Region 

	Dim Id As Short	' foCXID
	Const MAX_SAMPLES As Short = 1024	' őTvO
	Dim Data(MAX_SAMPLES) As Single	 ' 擾f[^̔z
	Dim Records As Integer	   ' 擾R[h
	Dim RecordLength As Integer	   ' R[h
	Dim Channels As Short	  ' `l
	Dim TriggerChannel As Short		 ' gK\[X`l
	Dim Range As Single	  ' ̓W
	Dim bmp As Bitmap	' rbg}bv

	Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
		bmp = New Bitmap(Graph.Size.Width, Graph.Size.Height)		  ' OtƓTCỸrbg}bv𐶐
	End Sub

	'==================================
	' 
	'==================================
	Private Sub CommandInit_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CommandInit.Click
		Dim Ret As Integer	   ' ߂l
		Dim Ret2 As Integer	   ' ߂l2
        Dim ErrorString As New StringBuilder("", 256)     ' G[

		'----------------------------------
		' 
		'----------------------------------
		Ret = DigInit(TextDevice.Text, Id)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
            TextInfo.Text = "DigInit = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If

		'----------------------------------
		' foCX̃Zbg
		'----------------------------------
		Ret = DigResetDevice(Id)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
            TextInfo.Text = "DigResetDevice = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If

		TextInfo.Text = " : I"
	End Sub

	'==================================
	' ݒt@Cǂݍ
	'==================================
	Private Sub CommandLoad_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CommandLoad.Click
		Dim Ret As Integer		  ' ߂l
		Dim Ret2 As Integer		  ' ߂l2
        Dim ErrorString As New StringBuilder("", 256)     ' G[
		Dim FilePath As String		  ' ݒt@CpX

		'----------------------------------
		' t@CI[v_CAO\܂B
		'----------------------------------
		Dim LoadDialog As New OpenFileDialog()
		' [t@C̎] {bNXɕ\Iݒ肷
		LoadDialog.Filter = "xml files (*.xml)|*.xml"
		If LoadDialog.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
			FilePath = LoadDialog.FileName			 ' Iꂽt@CpX̎擾
			'---------------------------------
			' ݒt@Cǂݍ
			'---------------------------------
			Ret = DigLoadConfig(Id, FilePath)
			If Ret <> 0 Then
				Ret2 = DigGetErrorString(Ret, ErrorString)
                TextInfo.Text = "DigLoadConfig = " & Ret & " : " & ErrorString.ToString()
				Exit Sub
			End If
			TextInfo.Text = "ݒt@Cǂݍ݁FI"
		End If
	End Sub

	'==================================
	' WJn
	'==================================
	Private Sub CommandStart_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CommandStart.Click
		Dim Ret As Integer		  ' ߂l
		Dim Ret2 As Integer		  ' ߂l2
        Dim ErrorString As New StringBuilder("", 256)     ' G[

		'----------------------------------
		' ZbgAbv擾/\
		'----------------------------------
		CommandInfo_Click(CommandInfo, New System.EventArgs())

		'----------------------------------
		' Jn
		'----------------------------------
		Ret = DigStart(Id)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
            TextInfo.Text = "DigStart = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If
		TextInfo.Text = "WJn : I"

		'----------------------------------
		' 쒆Xe[^XOFFɂȂ܂Ń|[O
		'----------------------------------
		Dim Status As Integer

		Do
			System.Windows.Forms.Application.DoEvents()			 ' _CAOLɂ邽߂̏
			'----------------------------------
			' hCoR[h擾
			'----------------------------------
			Ret = DigGetDriverMemoryRecords(Id, Records)
			If Ret <> 0 Then
				Ret2 = DigGetErrorString(Ret, ErrorString)
                TextInfo.Text = "DigGetDriverMemoryRecords = " & Ret & " : " & ErrorString.ToString()
				Exit Sub
			End If

			'----------------------------------
			' hCoɃR[h݂΁AVf[^擾
			'----------------------------------
			If Records > 0 Or Records = -1 Then
                Ret = DigReadLatestRecords(Id, DIG_RECORD_DATA, 1, Data, Nothing, Nothing)
				If Ret <> 0 Then
					Ret2 = DigGetErrorString(Ret, ErrorString)
                    TextInfo.Text = "DigReadLatestRecords = " & Ret & " : " & ErrorString.ToString()
					Exit Sub
				End If
				'----------------------------------
				' Ot̕`
				'----------------------------------
				DrawGraph()
			End If
			'----------------------------------
			' Xe[^X̎擾
			'----------------------------------
			Ret = DigGetStatus(Id, Status)
			If Ret <> 0 Then
				Ret2 = DigGetErrorString(Ret, ErrorString)
                TextInfo.Text = "DigGetStatus = " & Ret & " : " & ErrorString.ToString()
				Exit Sub
			End If
			LabelStatus.Text = Hex(Status) & "H"
		Loop While (Status And DIG_STATUS_BUSY) = DIG_STATUS_BUSY

		'----------------------------------
		' ~hCoɎcĂ郌R[h擾
		'----------------------------------
		Ret = DigGetDriverMemoryRecords(Id, Records)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
            TextInfo.Text = "DigGetDriverMemoryRecords = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If

		'----------------------------------
		' hCoɃR[h݂΁AVf[^擾
		'----------------------------------
		If Records > 0 Or Records = -1 Then
            Ret = DigReadLatestRecords(Id, DIG_RECORD_DATA, 1, Data, Nothing, Nothing)
			If Ret <> 0 Then
				Ret2 = DigGetErrorString(Ret, ErrorString)
                TextInfo.Text = "DigReadLatestRecords = " & Ret & " : " & ErrorString.ToString()
				Exit Sub
			End If
			'----------------------------------
			' Ot̕`
			'----------------------------------
			DrawGraph()
		End If

	End Sub

	'==================================
	' 擾
	'==================================
	Private Sub CommandInfo_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CommandInfo.Click
		Dim Status As Integer
		Dim Ret As Integer		  ' ߂l
		Dim Ret2 As Integer		  ' ߂l2
        Dim ErrorString As New StringBuilder("", 256)     ' G[
		Dim SampleRate As Single		  ' Tv[g
		Dim Duty As Single		  ' f[eB
		Dim Level As Single		  ' gKx
		Dim Slope As Short		  ' gK
		Dim Count As Integer		  ' gK

		'----------------------------------
		' Xe[^X̎擾
		'----------------------------------
		Ret = DigGetStatus(Id, Status)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
            TextInfo.Text = "DigGetStatus = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If
		LabelStatus.Text = Hex(Status) & "H"

		'-------------------------------------
		' DigLoadConfig֐ŎIɐݒ肳ɂĎ擾
		'-------------------------------------
		'-------------------------------
		' Tv[g̎擾
		'-------------------------------
		Ret = DigGetSampleRate(Id, SampleRate)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
            TextInfo.Text = "DigGetSampleRate = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If
		TextDeviceInfo.Text = "Tv[gF" & SampleRate & "Hz" & vbCrLf
		'-------------------------------
		' R[h̎擾
		'-------------------------------
		Ret = DigGetRecordLength(Id, RecordLength)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
            TextInfo.Text = "DigGetSampleRate = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If
		TextDeviceInfo.Text = TextDeviceInfo.Text & "R[hF" & RecordLength & vbCrLf
		'-------------------------------
		' f[eB̎擾
		'-------------------------------
		Ret = DigGetDutyCycle(Id, Duty)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
            TextInfo.Text = "DigGetDutyCycle = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If
		TextDeviceInfo.Text = TextDeviceInfo.Text & "f[eBF" & Duty & "%" & vbCrLf
		'-------------------------------
		' Lȃ`l̎擾
		'-------------------------------
		Ret = DigGetChannels(Id, Channels)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
            TextInfo.Text = "DigGetChannels = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If
		TextDeviceInfo.Text = TextDeviceInfo.Text & "L`lF" & Channels & vbCrLf
		'-------------------------------
		' gK̎擾
		'-------------------------------
		Ret = DigGetPostTriggerAiEdge(Id, TriggerChannel, Level, Slope, Count)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
            TextInfo.Text = "DigGetPostTriggerAiEdge = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If
		TextDeviceInfo.Text = TextDeviceInfo.Text & "`lF" & TriggerChannel & vbCrLf
		TextDeviceInfo.Text = TextDeviceInfo.Text & "gKxF" & Level & "V" & vbCrLf
		'-------------------------------
		' W̎擾
		'-------------------------------
		Ret = DigGetRange(Id, TriggerChannel, Range)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
            TextInfo.Text = "DigGetRange = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If
		TextDeviceInfo.Text = TextDeviceInfo.Text & "̓WF" & Range & "VPP" & vbCrLf

		TextInfo.Text = "擾 : I"
	End Sub

	'==================================
	' W~
	'==================================
	Private Sub CommandStop_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CommandStop.Click
		Dim Ret As Integer		  ' ߂l
		Dim Ret2 As Integer		  ' ߂l2
        Dim ErrorString As New StringBuilder("", 256)     ' G[

		Ret = DigStop(Id)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
            TextInfo.Text = "DigExit = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If

		TextInfo.Text = "W~ : I"
	End Sub


	'==================================
	' I
	'==================================
	Private Sub CommandExit_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CommandExit.Click
		Dim Ret As Integer		  ' ߂l
		Dim Ret2 As Integer		  ' ߂l2
        Dim ErrorString As New StringBuilder("", 256)     ' G[

		Ret = DigExit(Id)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
            TextInfo.Text = "DigExit = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If

		TextInfo.Text = "I : I"
	End Sub

	'==================================
	' tH[̃A[h
	'==================================
	Private Sub Form1_Closed(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Closed
		Dim Ret As Integer		  ' ߂l
		Ret = DigExit(Id)
	End Sub

	'==================================
	' Ot`
	'==================================
	Private Sub DrawGraph()
		Dim XUnit As Single		  ' X`C^[o
		Dim PosX As Single		  ' X`ʒu
		Dim PosY As Single		  ' Y`ʒu
		Dim OldX As Single		  ' XWޔp
		Dim OldY As Single		  ' YWޔp
		Dim pen As Pen		 ' Ot`py
		Dim i As Integer
		Dim j As Integer

		' ݂̓dOtɕ`悵܂B
		Graph.Image = bmp
		Dim grp As Graphics = Graphics.FromImage(Graph.Image)		' rbg}bv`ΏۃIuWFNg𐶐
		grp.Clear(Graph.BackColor)									' OtNA

		'----------------------------------------------------
		' Wf[^A`揈JԂ܂B
		'----------------------------------------------------
		XUnit = Graph.Size.Width() / CSng(RecordLength)		' 1f[^̉ړsNZvZ
		For i = 0 To Channels - 1
			If i = 0 Then
				pen = New Pen(System.Drawing.Color.Red, 1)				 ' ԐFy̍쐬
			Else
				pen = New Pen(System.Drawing.Color.Blue, 1)				 ' Fy̍쐬
			End If

			OldY = Graph.Height * ((Range / 2) - Data(i)) / Range			  ' Y̏lvZ
			If OldY >= Graph.Height Then
				OldY = Graph.Height - 1				  ' Y̏lOt̕`̈𒴂ꍇAʒuC
			End If
			If OldY < 0 Then
				OldY = 0				 ' Y̏lOt̕`̈ꍇAʒuC
			End If
			OldX = 0
			For j = i To RecordLength * Channels Step Channels
				PosX = OldX + XUnit				  ' X̍WvZ
				PosY = Graph.Height() * ((Range / 2) - Data(j)) / Range				   ' Y̍WvZ
				If PosY >= Graph.Height() Then
					' Y̍W`̈𒴂ꍇ
					PosY = Graph.Height() - 1					  ' `ʒȕC

				ElseIf PosY < 0 Then
					' Y̍W`̈ꍇ
					PosY = 0					  ' `ʒȕC
				End If
				grp.DrawLine(pen, OldX, OldY, PosX, PosY)				 ' `

				OldX = PosX				  ' X̍W`pɕێ
				OldY = PosY				  ' Y̍W`pɕێ
			Next j
			pen.Dispose()			' \[X̉
		Next i
		grp.Dispose()		 ' \[X̉
	End Sub
End Class