Imports System.IO
Imports Microsoft.VisualBasic.CompilerServices
Imports ProgramAlarmClock.My
Imports ProgramAlarmClock.My.Resources
Imports System
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Drawing
Imports System.Runtime.CompilerServices
Imports System.Windows.Forms
Public Class main
Dim player As New MediaPlayer.MediaPlayer
Private Sub main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.LoadProgram()
End Sub
Private Sub btexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btexit.Click
Dim chkexit As Integer
chkexit = MsgBox("คุณต้องการออกจากโปรแกรมหรือไม่", MsgBoxStyle.OkCancel, "ยืนยันการออกโปรแกรม")
If (chkexit = 1) Then
End
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Try
If (Me.numDemo < 600) Then
Me.numDemo += 1
Else
Me.Close()
End If
Me.lbcurrenttime.Text = New DateTime(DateTime.Now.Ticks).ToLongTimeString
Me.lbdate.Text = DateTime.Now.ToLongDateString()
Me.CheckDay()
Me.lbday.Text = Now.Date.ToString("dddd")
Catch
End Try
End Sub
Private Sub btsetting_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsetting.Click
setting.Show()
End Sub
Private Sub btsaveprogram_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsaveprogram.Click
Try
Dim text As String = String.Concat(New String() {Me.nudmon.Value.ToString, ",", Me.nudtue.Value.ToString, ",", Me.nudwed.Value.ToString, ",", Me.nudthu.Value.ToString, ",", Me.nudfri.Value.ToString, ",", Me.nudsat.Value.ToString, ",", Me.nudsun.Value.ToString, ","})
Dim file As String = "C:\ProgramAlarmClock\program.txt"
MyProject.Computer.FileSystem.WriteAllText(file, [text], False)
LoadProgram()
Catch exception1 As Exception
ProjectData.SetProjectError(exception1)
MessageBox.Show("โปรดตรวจสอบที่อยู่ของโฟลเดอร์ 'Alarm Data' ให้ถูกต้อง")
ProjectData.ClearProjectError()
End Try
End Sub
Private Sub CheckDay()
Dim time As New DateTime(DateTime.Now.Ticks)
Select Case time.DayOfWeek
Case DayOfWeek.Sunday
Me.textDay = "อาทิตย์"
Me.numFile = Convert.ToInt32(Me.nudsun.Value)
Exit Select
Case DayOfWeek.Monday
Me.textDay = "จันทร์"
Me.numFile = Convert.ToInt32(Me.nudmon.Value)
Exit Select
Case DayOfWeek.Tuesday
Me.textDay = "อังคาร"
Me.numFile = Convert.ToInt32(Me.nudtue.Value)
Exit Select
Case DayOfWeek.Wednesday
Me.textDay = "พุธ"
Me.numFile = Convert.ToInt32(Me.nudwed.Value)
Exit Select
Case DayOfWeek.Thursday
Me.textDay = "พฤหัสบดี"
Me.numFile = Convert.ToInt32(Me.nudthu.Value)
Exit Select
Case DayOfWeek.Friday
Me.textDay = "ศุกร์"
Me.numFile = Convert.ToInt32(Me.nudfri.Value)
Exit Select
Case DayOfWeek.Saturday
Me.textDay = "เสาร์"
Me.numFile = Convert.ToInt32(Me.nudsat.Value)
Exit Select
End Select
End Sub
Private Sub LoadProgram()
Try
Dim file As String = "C:\ProgramAlarmClock\program.txt"
Dim strArray As String() = MyProject.Computer.FileSystem.ReadAllText(file).Split(New Char() {","c})
nudmon.Value = Conversions.ToDecimal(strArray(0))
nudtue.Value = Conversions.ToDecimal(strArray(1))
nudwed.Value = Conversions.ToDecimal(strArray(2))
nudthu.Value = Conversions.ToDecimal(strArray(3))
nudfri.Value = Conversions.ToDecimal(strArray(4))
nudsat.Value = Conversions.ToDecimal(strArray(5))
nudsun.Value = Conversions.ToDecimal(strArray(6))
Me.CheckDay()
Me.lbcurrenttime.Text = Me.textDay
If (Me.numFile <> Conversions.ToDouble("0")) Then
Me.lbuseprogram.Text = Me.numFile.ToString
Else
Me.lbuseprogram.Text = "ไม่ได้กำหนด"
End If
Catch exception1 As Exception
ProjectData.SetProjectError(exception1)
MessageBox.Show("โปรดตรวจสอบที่อยู่ของโฟลเดอร์ 'Alarm Data' ให้ถูกต้อง")
ProjectData.ClearProjectError()
End Try
End Sub
Private buffcheckTime As Object
Private checkStart As Object
Private checkTime As Object
Private checkWorking As Object
Private i As Object
Private j As Object
Private Const KEYEVENTF_KEYUP As Long = 2
Private numDemo As Integer
Private numFile As Integer
Private startTime As Object
Private textDay As String
End Class
อันนี้หน้าต่างโปรแปรมสำรอง Code (VB.NET)
Imports System.IO
Imports Microsoft.VisualBasic.CompilerServices
Imports ProgramAlarmClock.My
Imports ProgramAlarmClock.My.Resources
Imports System
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Drawing
Imports System.Runtime.CompilerServices
Imports System.Windows.Forms
Public Class setting
Public player As New MediaPlayer.MediaPlayer
Private Sub btcancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btcancel.Click
Me.Close()
End Sub
Private Sub btclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btclear.Click
Me.ClearProgram()
End Sub
Private Sub btsound1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsound1.Click
OpenFileDialog1.Filter = "wav (*.wav)|*.wav|mp3 (*.mp3)*|.mp3"
If (OpenFileDialog1.ShowDialog = DialogResult.OK) Then
TextBox1.Text = OpenFileDialog1.FileName
End If
End Sub
Private Sub btsound2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsound2.Click
OpenFileDialog1.Filter = "wav (*.wav)|*.wav|mp3 (*.mp3)*|.mp3"
If (OpenFileDialog1.ShowDialog = DialogResult.OK) Then
TextBox2.Text = OpenFileDialog1.FileName
End If
End Sub
Private Sub btsound3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsound3.Click
OpenFileDialog1.Filter = "wav (*.wav)|*.wav|mp3 (*.mp3)*|.mp3"
If (OpenFileDialog1.ShowDialog = DialogResult.OK) Then
TextBox3.Text = OpenFileDialog1.FileName
End If
End Sub
Private Sub btsound4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsound4.Click
OpenFileDialog1.Filter = "wav (*.wav)|*.wav|mp3 (*.mp3)*|.mp3"
If (OpenFileDialog1.ShowDialog = DialogResult.OK) Then
TextBox4.Text = OpenFileDialog1.FileName
End If
End Sub
Private Sub btsound5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsound5.Click
OpenFileDialog1.Filter = "wav (*.wav)|*.wav|mp3 (*.mp3)*|.mp3"
If (OpenFileDialog1.ShowDialog = DialogResult.OK) Then
TextBox5.Text = OpenFileDialog1.FileName
End If
End Sub
Private Sub btsound6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsound6.Click
OpenFileDialog1.Filter = "wav (*.wav)|*.wav|mp3 (*.mp3)*|.mp3"
If (OpenFileDialog1.ShowDialog = DialogResult.OK) Then
TextBox6.Text = OpenFileDialog1.FileName
End If
End Sub
Private Sub btsound7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsound7.Click
OpenFileDialog1.Filter = "wav (*.wav)|*.wav|mp3 (*.mp3)*|.mp3"
If (OpenFileDialog1.ShowDialog = DialogResult.OK) Then
TextBox7.Text = OpenFileDialog1.FileName
End If
End Sub
Private Sub btsound8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsound8.Click
OpenFileDialog1.Filter = "wav (*.wav)|*.wav|mp3 (*.mp3)*|.mp3"
If (OpenFileDialog1.ShowDialog = DialogResult.OK) Then
TextBox8.Text = OpenFileDialog1.FileName
End If
End Sub
Private Sub btsound9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsound9.Click
OpenFileDialog1.Filter = "wav (*.wav)|*.wav|mp3 (*.mp3)*|.mp3"
If (OpenFileDialog1.ShowDialog = DialogResult.OK) Then
TextBox9.Text = OpenFileDialog1.FileName
End If
End Sub
Private Sub btsound10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsound10.Click
OpenFileDialog1.Filter = "wav (*.wav)|*.wav|mp3 (*.mp3)*|.mp3"
If (OpenFileDialog1.ShowDialog = DialogResult.OK) Then
TextBox10.Text = OpenFileDialog1.FileName
End If
End Sub
Private Sub btsound11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsound11.Click
OpenFileDialog1.Filter = "wav (*.wav)|*.wav|mp3 (*.mp3)*|.mp3"
If (OpenFileDialog1.ShowDialog = DialogResult.OK) Then
TextBox11.Text = OpenFileDialog1.FileName
End If
End Sub
Private Sub btsound12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsound12.Click
OpenFileDialog1.Filter = "wav (*.wav)|*.wav|mp3 (*.mp3)*|.mp3"
If (OpenFileDialog1.ShowDialog = DialogResult.OK) Then
TextBox12.Text = OpenFileDialog1.FileName
End If
End Sub
Private Sub btsound13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsound13.Click
OpenFileDialog1.Filter = "wav (*.wav)|*.wav|mp3 (*.mp3)*|.mp3"
If (OpenFileDialog1.ShowDialog = DialogResult.OK) Then
TextBox13.Text = OpenFileDialog1.FileName
End If
End Sub
Private Sub btsound14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsound14.Click
OpenFileDialog1.Filter = "wav (*.wav)|*.wav|mp3 (*.mp3)*|.mp3"
If (OpenFileDialog1.ShowDialog = DialogResult.OK) Then
TextBox14.Text = OpenFileDialog1.FileName
End If
End Sub
Private Sub btsound15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsound15.Click
OpenFileDialog1.Filter = "wav (*.wav)|*.wav|mp3 (*.mp3)*|.mp3"
If (OpenFileDialog1.ShowDialog = DialogResult.OK) Then
TextBox15.Text = OpenFileDialog1.FileName
End If
End Sub
Private Sub btsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsave.Click
Try
Dim text As String = String.Concat(New String() {Me.TextBox1.Text, ",", Me.TextBox2.Text, ",", Me.TextBox3.Text, ",", Me.TextBox4.Text, ",", Me.TextBox5.Text, ",", Me.TextBox6.Text, ",", Me.TextBox7.Text, ",", Me.TextBox8.Text, ",", Me.TextBox9.Text, ",", Me.TextBox10.Text, ",", Me.TextBox11.Text, ",", Me.TextBox12.Text, ",", Me.TextBox13.Text, ",", Me.TextBox14.Text, ",", Me.TextBox15.Text, ","})
Dim file As String = "C:\ProgramAlarmClock\setup" & Me.NumericUpDown1.Value & ".txt"
MyProject.Computer.FileSystem.WriteAllText(file, [text], False)
Dim text1 As String = String.Concat(New String() {Me.ComboBox1.Text, ",", Me.ComboBox2.Text, ",", Me.ComboBox3.Text, ",", Me.ComboBox4.Text, ",", Me.ComboBox5.Text, ",", Me.ComboBox6.Text, ",", Me.ComboBox7.Text, ",", Me.ComboBox8.Text, ",", Me.ComboBox9.Text, ",", Me.ComboBox10.Text, ",", Me.ComboBox11.Text, ",", Me.ComboBox12.Text, ",", Me.ComboBox13.Text, ",", Me.ComboBox14.Text, ",", Me.ComboBox15.Text, ",", Me.ComboBox16.Text, ",", Me.ComboBox17.Text, ",", Me.ComboBox18.Text, ",", Me.ComboBox19.Text, ",", Me.ComboBox20.Text, ",", Me.ComboBox21.Text, ",", Me.ComboBox22.Text, ",", Me.ComboBox23.Text, ",", Me.ComboBox24.Text, ",", Me.ComboBox25.Text, ",", Me.ComboBox26.Text, ",", Me.ComboBox27.Text, ",", Me.ComboBox28.Text, ",", Me.ComboBox29.Text, ",", Me.ComboBox30.Text, ",", Me.ComboBox31.Text, ",", Me.ComboBox32.Text, ",", Me.ComboBox33.Text, ",", Me.ComboBox34.Text, ",", Me.ComboBox35.Text, ",", Me.ComboBox36.Text, ",", Me.ComboBox37.Text, ",", Me.ComboBox38.Text, ",", Me.ComboBox39.Text, ",", Me.ComboBox40.Text, ",", Me.ComboBox41.Text, ",", Me.ComboBox42.Text, ",", Me.ComboBox43.Text, ",", Me.ComboBox44.Text, ",", Me.ComboBox45.Text, ","})
Dim file1 As String = "C:\ProgramAlarmClock\songtime" & Me.NumericUpDown1.Value & ".txt"
MyProject.Computer.FileSystem.WriteAllText(file1, [text1], False)
Dim text2 As String = String.Concat(New String() {Me.CheckBox1.Checked, ",", Me.CheckBox2.Checked, ",", Me.CheckBox3.Checked, ",", Me.CheckBox4.Checked, ",", Me.CheckBox5.Checked, ",", Me.CheckBox6.Checked, ",", Me.CheckBox7.Checked, ",", Me.CheckBox8.Checked, ",", Me.CheckBox9.Checked, ",", Me.CheckBox10.Checked, ",", Me.CheckBox11.Checked, ",", Me.CheckBox12.Checked, ",", Me.CheckBox13.Checked, ",", Me.CheckBox14.Checked, ",", Me.CheckBox15.Checked, ","})
Dim file2 As String = "C:\ProgramAlarmClock\usesong" & Me.NumericUpDown1.Value & ".txt"
MyProject.Computer.FileSystem.WriteAllText(file2, [text2], False)
Catch exception1 As Exception
ProjectData.SetProjectError(exception1)
MessageBox.Show("โปรดตรวจสอบที่อยู่ของโฟลเดอร์ 'Alarm Data' ให้ถูกต้อง")
ProjectData.ClearProjectError()
End Try
End Sub
Private Sub NumericUpDown1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles NumericUpDown1.Click
Me.LoadProgram()
End Sub
Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
If NumericUpDown1.Value > 9 Then
NumericUpDown1.Value = 1
End If
If NumericUpDown1.Value < 1 Then
NumericUpDown1.Value = 1
End If
End Sub
Private Sub setting_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.LoadProgram
End Sub
Private Sub LoadProgram()
Me.ClearProgram()
Try
Dim file As String = "C:\ProgramAlarmClock\setup" & Me.NumericUpDown1.Value & ".txt"
Dim strArray As String() = MyProject.Computer.FileSystem.ReadAllText(file).Split(New Char() {","c})
Me.TextBox1.Text = strArray(0)
Me.TextBox2.Text = strArray(1)
Me.TextBox3.Text = strArray(2)
Me.TextBox4.Text = strArray(3)
Me.TextBox5.Text = strArray(4)
Me.TextBox6.Text = strArray(5)
Me.TextBox7.Text = strArray(6)
Me.TextBox8.Text = strArray(7)
Me.TextBox9.Text = strArray(8)
Me.TextBox10.Text = strArray(9)
Me.TextBox11.Text = strArray(10)
Me.TextBox12.Text = strArray(11)
Me.TextBox13.Text = strArray(12)
Me.TextBox14.Text = strArray(13)
Me.TextBox15.Text = strArray(14)
Dim file1 As String = "C:\ProgramAlarmClock\songtime" & Me.NumericUpDown1.Value & ".txt"
Dim strArray1 As String() = MyProject.Computer.FileSystem.ReadAllText(file1).Split(New Char() {","c})
Me.ComboBox1.Text = strArray1(0)
Me.ComboBox2.Text = strArray1(1)
Me.ComboBox3.Text = strArray1(2)
Me.ComboBox4.Text = strArray1(3)
Me.ComboBox5.Text = strArray1(4)
Me.ComboBox6.Text = strArray1(5)
Me.ComboBox7.Text = strArray1(6)
Me.ComboBox8.Text = strArray1(7)
Me.ComboBox9.Text = strArray1(8)
Me.ComboBox10.Text = strArray1(9)
Me.ComboBox11.Text = strArray1(10)
Me.ComboBox12.Text = strArray1(11)
Me.ComboBox13.Text = strArray1(12)
Me.ComboBox14.Text = strArray1(13)
Me.ComboBox15.Text = strArray1(14)
Me.ComboBox16.Text = strArray1(15)
Me.ComboBox17.Text = strArray1(&H10)
Me.ComboBox18.Text = strArray1(&H11)
Me.ComboBox19.Text = strArray1(&H12)
Me.ComboBox20.Text = strArray1(20)
Me.ComboBox21.Text = strArray1(&H14)
Me.ComboBox22.Text = strArray1(&H15)
Me.ComboBox23.Text = strArray1(&H16)
Me.ComboBox24.Text = strArray1(&H17)
Me.ComboBox25.Text = strArray1(&H18)
Me.ComboBox26.Text = strArray1(&H19)
Me.ComboBox27.Text = strArray1(&H1A)
Me.ComboBox28.Text = strArray1(&H1B)
Me.ComboBox29.Text = strArray1(&H1C)
Me.ComboBox30.Text = strArray1(&H1D)
Me.ComboBox31.Text = strArray1(30)
Me.ComboBox32.Text = strArray1(&H1F)
Me.ComboBox33.Text = strArray1(&H20)
Me.ComboBox34.Text = strArray1(&H21)
Me.ComboBox35.Text = strArray1(&H22)
Me.ComboBox36.Text = strArray1(&H23)
Me.ComboBox37.Text = strArray1(&H24)
Me.ComboBox38.Text = strArray1(&H25)
Me.ComboBox39.Text = strArray1(&H26)
Me.ComboBox40.Text = strArray1(&H27)
Me.ComboBox41.Text = strArray1(40)
Me.ComboBox42.Text = strArray1(&H29)
Me.ComboBox43.Text = strArray1(&H2A)
Me.ComboBox44.Text = strArray1(&H2B)
Me.ComboBox45.Text = strArray1(&H2C)
Dim file2 As String = "C:\ProgramAlarmClock\usesong" & Me.NumericUpDown1.Value & ".txt"
Dim strArray2 As String() = MyProject.Computer.FileSystem.ReadAllText(file2).Split(New Char() {","c})
Me.CheckBox1.Checked = strArray2(0)
Me.CheckBox2.Checked = strArray2(1)
Me.CheckBox3.Checked = strArray2(2)
Me.CheckBox4.Checked = strArray2(3)
Me.CheckBox5.Checked = strArray2(4)
Me.CheckBox6.Checked = strArray2(5)
Me.CheckBox7.Checked = strArray2(6)
Me.CheckBox8.Checked = strArray2(7)
Me.CheckBox9.Checked = strArray2(8)
Me.CheckBox10.Checked = strArray2(9)
Me.CheckBox11.Checked = strArray2(10)
Me.CheckBox12.Checked = strArray2(11)
Me.CheckBox13.Checked = strArray2(12)
Me.CheckBox14.Checked = strArray2(13)
Me.CheckBox15.Checked = strArray2(14)
Catch exception1 As Exception
ProjectData.SetProjectError(exception1)
MessageBox.Show("โปรดตรวจสอบที่อยู่ของโฟลเดอร์ 'Alarm Data' ให้ถูกต้อง")
ProjectData.ClearProjectError()
End Try
End Sub
Private Sub ClearProgram()
Me.ComboBox1.Text = "0"
Me.ComboBox2.Text = "0"
Me.ComboBox3.Text = "0"
Me.ComboBox4.Text = "0"
Me.ComboBox7.Text = "0"
Me.ComboBox6.Text = "0"
Me.ComboBox5.Text = "0"
Me.ComboBox9.Text = "0"
Me.ComboBox8.Text = "0"
Me.ComboBox12.Text = "0"
Me.ComboBox11.Text = "0"
Me.ComboBox15.Text = "0"
Me.ComboBox14.Text = "0"
Me.ComboBox18.Text = "0"
Me.ComboBox17.Text = "0"
Me.ComboBox21.Text = "0"
Me.ComboBox20.Text = "0"
Me.ComboBox24.Text = "0"
Me.ComboBox23.Text = "0"
Me.ComboBox27.Text = "0"
Me.ComboBox26.Text = "0"
Me.ComboBox30.Text = "0"
Me.ComboBox29.Text = "0"
Me.ComboBox33.Text = "0"
Me.ComboBox32.Text = "0"
Me.ComboBox36.Text = "0"
Me.ComboBox35.Text = "0"
Me.ComboBox39.Text = "0"
Me.ComboBox38.Text = "0"
Me.ComboBox42.Text = "0"
Me.ComboBox41.Text = "0"
Me.ComboBox45.Text = "0"
Me.ComboBox44.Text = "0"
Me.ComboBox10.Text = "0"
Me.ComboBox13.Text = "0"
Me.ComboBox16.Text = "0"
Me.ComboBox19.Text = "0"
Me.ComboBox22.Text = "0"
Me.ComboBox25.Text = "0"
Me.ComboBox28.Text = "0"
Me.ComboBox31.Text = "0"
Me.ComboBox34.Text = "0"
Me.ComboBox37.Text = "0"
Me.ComboBox40.Text = "0"
Me.ComboBox43.Text = "0"
Me.CheckBox1.Checked = False
Me.CheckBox2.Checked = False
Me.CheckBox3.Checked = False
Me.CheckBox4.Checked = False
Me.CheckBox5.Checked = False
Me.CheckBox6.Checked = False
Me.CheckBox7.Checked = False
Me.CheckBox8.Checked = False
Me.CheckBox9.Checked = False
Me.CheckBox10.Checked = False
Me.CheckBox11.Checked = False
Me.CheckBox12.Checked = False
Me.CheckBox13.Checked = False
Me.CheckBox14.Checked = False
Me.CheckBox15.Checked = False
Me.TextBox1.Text = ""
Me.TextBox2.Text = ""
Me.TextBox3.Text = ""
Me.TextBox4.Text = ""
Me.TextBox5.Text = ""
Me.TextBox6.Text = ""
Me.TextBox7.Text = ""
Me.TextBox8.Text = ""
Me.TextBox9.Text = ""
Me.TextBox10.Text = ""
Me.TextBox11.Text = ""
Me.TextBox12.Text = ""
Me.TextBox13.Text = ""
Me.TextBox14.Text = ""
Me.TextBox15.Text = ""
End Sub
End Class