diff --git a/3321.pdf b/3321.pdf new file mode 100644 index 0000000..4f882d3 Binary files /dev/null and b/3321.pdf differ diff --git a/9781590597903.jpg b/9781590597903.jpg new file mode 100644 index 0000000..96bf669 Binary files /dev/null and b/9781590597903.jpg differ diff --git a/Chapter01(Socket)/Part 0/Client/Client.sln b/Chapter01(Socket)/Part 0/Client/Client.sln new file mode 100644 index 0000000..3c74f80 --- /dev/null +++ b/Chapter01(Socket)/Part 0/Client/Client.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Client", "Client\Client.vbproj", "{9952804B-B7AD-4FEF-9A02-AC6CFF879333}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9952804B-B7AD-4FEF-9A02-AC6CFF879333}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9952804B-B7AD-4FEF-9A02-AC6CFF879333}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9952804B-B7AD-4FEF-9A02-AC6CFF879333}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9952804B-B7AD-4FEF-9A02-AC6CFF879333}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter01(Socket)/Part 0/Client/Client.suo b/Chapter01(Socket)/Part 0/Client/Client.suo new file mode 100644 index 0000000..001d835 Binary files /dev/null and b/Chapter01(Socket)/Part 0/Client/Client.suo differ diff --git a/Chapter01(Socket)/Part 0/Client/Client/Client.vbproj b/Chapter01(Socket)/Part 0/Client/Client/Client.vbproj new file mode 100644 index 0000000..c366f35 --- /dev/null +++ b/Chapter01(Socket)/Part 0/Client/Client/Client.vbproj @@ -0,0 +1,92 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {9952804B-B7AD-4FEF-9A02-AC6CFF879333} + Exe + Client.Module1 + Client + Client + Console + + + true + full + true + true + bin\Debug\ + Client.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + Client.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 0/Client/Client/Module1.vb b/Chapter01(Socket)/Part 0/Client/Client/Module1.vb new file mode 100644 index 0000000..958a45a --- /dev/null +++ b/Chapter01(Socket)/Part 0/Client/Client/Module1.vb @@ -0,0 +1,18 @@ +Imports System.Net.Sockets +Imports System.Text + +Module Module1 + Const portNo As Integer = 500 + Sub Main() + Dim tcpclient As New TcpClient + '---connect to the server--- + tcpclient.Connect("127.0.0.1", portNo) + + '---use a NetworkStream object to send and receive data--- + Dim ns As NetworkStream = tcpclient.GetStream + Dim data As Byte() = Encoding.ASCII.GetBytes("Hello") + + '---send the text--- + ns.Write(data, 0, data.Length) + End Sub +End Module diff --git a/Chapter01(Socket)/Part 0/Client/Client/My Project/Application.Designer.vb b/Chapter01(Socket)/Part 0/Client/Client/My Project/Application.Designer.vb new file mode 100644 index 0000000..8a621ae --- /dev/null +++ b/Chapter01(Socket)/Part 0/Client/Client/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/Chapter01(Socket)/Part 0/Client/Client/My Project/Application.myapp b/Chapter01(Socket)/Part 0/Client/Client/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Chapter01(Socket)/Part 0/Client/Client/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Chapter01(Socket)/Part 0/Client/Client/My Project/AssemblyInfo.vb b/Chapter01(Socket)/Part 0/Client/Client/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..1f97c44 --- /dev/null +++ b/Chapter01(Socket)/Part 0/Client/Client/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + + diff --git a/Chapter01(Socket)/Part 0/Client/Client/My Project/Resources.Designer.vb b/Chapter01(Socket)/Part 0/Client/Client/My Project/Resources.Designer.vb new file mode 100644 index 0000000..5b2f1e1 --- /dev/null +++ b/Chapter01(Socket)/Part 0/Client/Client/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ' + ' A strongly-typed resource class, for looking up localized strings, etc. + ' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ' + ' Returns the cached ResourceManager instance used by this class. + ' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Client.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ' + ' Overrides the current thread's CurrentUICulture property for all + ' resource lookups using this strongly typed resource class. + ' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Chapter01(Socket)/Part 0/Client/Client/My Project/Resources.resx b/Chapter01(Socket)/Part 0/Client/Client/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Chapter01(Socket)/Part 0/Client/Client/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 0/Client/Client/My Project/Settings.Designer.vb b/Chapter01(Socket)/Part 0/Client/Client/My Project/Settings.Designer.vb new file mode 100644 index 0000000..fa3ba1d --- /dev/null +++ b/Chapter01(Socket)/Part 0/Client/Client/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.Client.My.MySettings + Get + Return Global.Client.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Chapter01(Socket)/Part 0/Client/Client/My Project/Settings.settings b/Chapter01(Socket)/Part 0/Client/Client/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Chapter01(Socket)/Part 0/Client/Client/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Chapter01(Socket)/Part 0/Client/Client/bin/Debug/Client.exe b/Chapter01(Socket)/Part 0/Client/Client/bin/Debug/Client.exe new file mode 100644 index 0000000..fd5e013 Binary files /dev/null and b/Chapter01(Socket)/Part 0/Client/Client/bin/Debug/Client.exe differ diff --git a/Chapter01(Socket)/Part 0/Client/Client/bin/Debug/Client.pdb b/Chapter01(Socket)/Part 0/Client/Client/bin/Debug/Client.pdb new file mode 100644 index 0000000..ca0401b Binary files /dev/null and b/Chapter01(Socket)/Part 0/Client/Client/bin/Debug/Client.pdb differ diff --git a/Chapter01(Socket)/Part 0/Client/Client/bin/Debug/Client.vshost.exe b/Chapter01(Socket)/Part 0/Client/Client/bin/Debug/Client.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter01(Socket)/Part 0/Client/Client/bin/Debug/Client.vshost.exe differ diff --git a/Chapter01(Socket)/Part 0/Client/Client/bin/Debug/Client.xml b/Chapter01(Socket)/Part 0/Client/Client/bin/Debug/Client.xml new file mode 100644 index 0000000..1f8c2ee --- /dev/null +++ b/Chapter01(Socket)/Part 0/Client/Client/bin/Debug/Client.xml @@ -0,0 +1,11 @@ + + + + +Client + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 0/Client/Client/obj/Client.vbproj.FileList.txt b/Chapter01(Socket)/Part 0/Client/Client/obj/Client.vbproj.FileList.txt new file mode 100644 index 0000000..1c8be69 --- /dev/null +++ b/Chapter01(Socket)/Part 0/Client/Client/obj/Client.vbproj.FileList.txt @@ -0,0 +1,9 @@ +bin\Debug\Client.exe +bin\Debug\Client.pdb +bin\Debug\Client.xml +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\Client.Resources.resources +obj\Debug\Client.vbproj.GenerateResource.Cache +obj\Debug\Client.exe +obj\Debug\Client.xml +obj\Debug\Client.pdb diff --git a/Chapter01(Socket)/Part 0/Client/Client/obj/Debug/Client.Resources.resources b/Chapter01(Socket)/Part 0/Client/Client/obj/Debug/Client.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter01(Socket)/Part 0/Client/Client/obj/Debug/Client.Resources.resources differ diff --git a/Chapter01(Socket)/Part 0/Client/Client/obj/Debug/Client.exe b/Chapter01(Socket)/Part 0/Client/Client/obj/Debug/Client.exe new file mode 100644 index 0000000..fd5e013 Binary files /dev/null and b/Chapter01(Socket)/Part 0/Client/Client/obj/Debug/Client.exe differ diff --git a/Chapter01(Socket)/Part 0/Client/Client/obj/Debug/Client.pdb b/Chapter01(Socket)/Part 0/Client/Client/obj/Debug/Client.pdb new file mode 100644 index 0000000..ca0401b Binary files /dev/null and b/Chapter01(Socket)/Part 0/Client/Client/obj/Debug/Client.pdb differ diff --git a/Chapter01(Socket)/Part 0/Client/Client/obj/Debug/Client.vbproj.GenerateResource.Cache b/Chapter01(Socket)/Part 0/Client/Client/obj/Debug/Client.vbproj.GenerateResource.Cache new file mode 100644 index 0000000..35a36ca Binary files /dev/null and b/Chapter01(Socket)/Part 0/Client/Client/obj/Debug/Client.vbproj.GenerateResource.Cache differ diff --git a/Chapter01(Socket)/Part 0/Client/Client/obj/Debug/Client.xml b/Chapter01(Socket)/Part 0/Client/Client/obj/Debug/Client.xml new file mode 100644 index 0000000..1f8c2ee --- /dev/null +++ b/Chapter01(Socket)/Part 0/Client/Client/obj/Debug/Client.xml @@ -0,0 +1,11 @@ + + + + +Client + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 0/Client_CS/Client_CS.sln b/Chapter01(Socket)/Part 0/Client_CS/Client_CS.sln new file mode 100644 index 0000000..d416de9 --- /dev/null +++ b/Chapter01(Socket)/Part 0/Client_CS/Client_CS.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client_CS", "Client_CS\Client_CS.csproj", "{C141460D-C554-422F-8D82-CBD5B6BE746B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C141460D-C554-422F-8D82-CBD5B6BE746B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C141460D-C554-422F-8D82-CBD5B6BE746B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C141460D-C554-422F-8D82-CBD5B6BE746B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C141460D-C554-422F-8D82-CBD5B6BE746B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter01(Socket)/Part 0/Client_CS/Client_CS.suo b/Chapter01(Socket)/Part 0/Client_CS/Client_CS.suo new file mode 100644 index 0000000..a2c667e Binary files /dev/null and b/Chapter01(Socket)/Part 0/Client_CS/Client_CS.suo differ diff --git a/Chapter01(Socket)/Part 0/Client_CS/Client_CS/Client_CS.csproj b/Chapter01(Socket)/Part 0/Client_CS/Client_CS/Client_CS.csproj new file mode 100644 index 0000000..0a56da8 --- /dev/null +++ b/Chapter01(Socket)/Part 0/Client_CS/Client_CS/Client_CS.csproj @@ -0,0 +1,47 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {C141460D-C554-422F-8D82-CBD5B6BE746B} + Exe + Properties + Client_CS + Client_CS + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 0/Client_CS/Client_CS/Program.cs b/Chapter01(Socket)/Part 0/Client_CS/Client_CS/Program.cs new file mode 100644 index 0000000..9d52d67 --- /dev/null +++ b/Chapter01(Socket)/Part 0/Client_CS/Client_CS/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Net.Sockets; + +namespace Client_CS +{ + class Program + { + const int portNo = 500; + static void Main(string[] args) + { + TcpClient tcpclient = new TcpClient(); + tcpclient.Connect("127.0.0.1", portNo); + NetworkStream ns = tcpclient.GetStream(); + byte[] data = Encoding.ASCII.GetBytes("Hello"); + ns.Write(data, 0, data.Length); + } + } +} diff --git a/Chapter01(Socket)/Part 0/Client_CS/Client_CS/Properties/AssemblyInfo.cs b/Chapter01(Socket)/Part 0/Client_CS/Client_CS/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..4d466fe --- /dev/null +++ b/Chapter01(Socket)/Part 0/Client_CS/Client_CS/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Client_CS")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Client_CS")] +[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("b8c7757f-6e5a-4e0d-817a-382fc96d83b1")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Chapter01(Socket)/Part 0/Client_CS/Client_CS/bin/Debug/Client_CS.exe b/Chapter01(Socket)/Part 0/Client_CS/Client_CS/bin/Debug/Client_CS.exe new file mode 100644 index 0000000..17a4658 Binary files /dev/null and b/Chapter01(Socket)/Part 0/Client_CS/Client_CS/bin/Debug/Client_CS.exe differ diff --git a/Chapter01(Socket)/Part 0/Client_CS/Client_CS/bin/Debug/Client_CS.pdb b/Chapter01(Socket)/Part 0/Client_CS/Client_CS/bin/Debug/Client_CS.pdb new file mode 100644 index 0000000..91dd500 Binary files /dev/null and b/Chapter01(Socket)/Part 0/Client_CS/Client_CS/bin/Debug/Client_CS.pdb differ diff --git a/Chapter01(Socket)/Part 0/Client_CS/Client_CS/bin/Debug/Client_CS.vshost.exe b/Chapter01(Socket)/Part 0/Client_CS/Client_CS/bin/Debug/Client_CS.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter01(Socket)/Part 0/Client_CS/Client_CS/bin/Debug/Client_CS.vshost.exe differ diff --git a/Chapter01(Socket)/Part 0/Client_CS/Client_CS/obj/Client_CS.csproj.FileList.txt b/Chapter01(Socket)/Part 0/Client_CS/Client_CS/obj/Client_CS.csproj.FileList.txt new file mode 100644 index 0000000..83c5149 --- /dev/null +++ b/Chapter01(Socket)/Part 0/Client_CS/Client_CS/obj/Client_CS.csproj.FileList.txt @@ -0,0 +1,5 @@ +obj\Debug\ResolveAssemblyReference.cache +bin\Debug\Client_CS.exe +bin\Debug\Client_CS.pdb +obj\Debug\Client_CS.exe +obj\Debug\Client_CS.pdb diff --git a/Chapter01(Socket)/Part 0/Client_CS/Client_CS/obj/Debug/Client_CS.exe b/Chapter01(Socket)/Part 0/Client_CS/Client_CS/obj/Debug/Client_CS.exe new file mode 100644 index 0000000..17a4658 Binary files /dev/null and b/Chapter01(Socket)/Part 0/Client_CS/Client_CS/obj/Debug/Client_CS.exe differ diff --git a/Chapter01(Socket)/Part 0/Client_CS/Client_CS/obj/Debug/Client_CS.pdb b/Chapter01(Socket)/Part 0/Client_CS/Client_CS/obj/Debug/Client_CS.pdb new file mode 100644 index 0000000..91dd500 Binary files /dev/null and b/Chapter01(Socket)/Part 0/Client_CS/Client_CS/obj/Debug/Client_CS.pdb differ diff --git a/Chapter01(Socket)/Part 0/Server/Server.sln b/Chapter01(Socket)/Part 0/Server/Server.sln new file mode 100644 index 0000000..70c9e73 --- /dev/null +++ b/Chapter01(Socket)/Part 0/Server/Server.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Server", "Server\Server.vbproj", "{20D9DA33-6F44-4B3D-BC0C-549AC897E62A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {20D9DA33-6F44-4B3D-BC0C-549AC897E62A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {20D9DA33-6F44-4B3D-BC0C-549AC897E62A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {20D9DA33-6F44-4B3D-BC0C-549AC897E62A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {20D9DA33-6F44-4B3D-BC0C-549AC897E62A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter01(Socket)/Part 0/Server/Server.suo b/Chapter01(Socket)/Part 0/Server/Server.suo new file mode 100644 index 0000000..4c45cba Binary files /dev/null and b/Chapter01(Socket)/Part 0/Server/Server.suo differ diff --git a/Chapter01(Socket)/Part 0/Server/Server/Module1.vb b/Chapter01(Socket)/Part 0/Server/Server/Module1.vb new file mode 100644 index 0000000..083bce2 --- /dev/null +++ b/Chapter01(Socket)/Part 0/Server/Server/Module1.vb @@ -0,0 +1,35 @@ +Imports System.Net.Sockets +Imports System.Text + +Module Module1 + '---port number to use for listening--- + Const portNo As Integer = 500 + + Sub Main() + Dim localAdd As System.Net.IPAddress = _ + System.Net.IPAddress.Parse("127.0.0.1") + + '---listen at the local address--- + Dim listener As New TcpListener(localAdd, portNo) + listener.Start() + + '---Accepts a pending connection request--- + Dim tcpClient As TcpClient = listener.AcceptTcpClient() + + '---use a NetworkStream object to send and receive data--- + Dim ns As NetworkStream = tcpClient.GetStream + Dim data(tcpClient.ReceiveBufferSize) As Byte + + '---read incoming stream; Read() is a blocking call--- + Dim numBytesRead As Integer = ns.Read(data, 0, _ + CInt(tcpClient.ReceiveBufferSize)) + + '---display data received--- + Console.WriteLine("Received :" & _ + Encoding.ASCII.GetString(data, 0, numBytesRead)) + + '---prevent the console window from closing immediately--- + Console.ReadLine() + End Sub + +End Module diff --git a/Chapter01(Socket)/Part 0/Server/Server/My Project/Application.Designer.vb b/Chapter01(Socket)/Part 0/Server/Server/My Project/Application.Designer.vb new file mode 100644 index 0000000..8a621ae --- /dev/null +++ b/Chapter01(Socket)/Part 0/Server/Server/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/Chapter01(Socket)/Part 0/Server/Server/My Project/Application.myapp b/Chapter01(Socket)/Part 0/Server/Server/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Chapter01(Socket)/Part 0/Server/Server/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Chapter01(Socket)/Part 0/Server/Server/My Project/AssemblyInfo.vb b/Chapter01(Socket)/Part 0/Server/Server/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..bfa3634 --- /dev/null +++ b/Chapter01(Socket)/Part 0/Server/Server/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + + diff --git a/Chapter01(Socket)/Part 0/Server/Server/My Project/Resources.Designer.vb b/Chapter01(Socket)/Part 0/Server/Server/My Project/Resources.Designer.vb new file mode 100644 index 0000000..a4f144f --- /dev/null +++ b/Chapter01(Socket)/Part 0/Server/Server/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ' + ' A strongly-typed resource class, for looking up localized strings, etc. + ' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ' + ' Returns the cached ResourceManager instance used by this class. + ' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Server.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ' + ' Overrides the current thread's CurrentUICulture property for all + ' resource lookups using this strongly typed resource class. + ' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Chapter01(Socket)/Part 0/Server/Server/My Project/Resources.resx b/Chapter01(Socket)/Part 0/Server/Server/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Chapter01(Socket)/Part 0/Server/Server/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 0/Server/Server/My Project/Settings.Designer.vb b/Chapter01(Socket)/Part 0/Server/Server/My Project/Settings.Designer.vb new file mode 100644 index 0000000..585b2af --- /dev/null +++ b/Chapter01(Socket)/Part 0/Server/Server/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.Server.My.MySettings + Get + Return Global.Server.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Chapter01(Socket)/Part 0/Server/Server/My Project/Settings.settings b/Chapter01(Socket)/Part 0/Server/Server/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Chapter01(Socket)/Part 0/Server/Server/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Chapter01(Socket)/Part 0/Server/Server/Server.vbproj b/Chapter01(Socket)/Part 0/Server/Server/Server.vbproj new file mode 100644 index 0000000..72be8b8 --- /dev/null +++ b/Chapter01(Socket)/Part 0/Server/Server/Server.vbproj @@ -0,0 +1,92 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {20D9DA33-6F44-4B3D-BC0C-549AC897E62A} + Exe + Server.Module1 + Server + Server + Console + + + true + full + true + true + bin\Debug\ + Server.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + Server.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 0/Server/Server/bin/Debug/Server.exe b/Chapter01(Socket)/Part 0/Server/Server/bin/Debug/Server.exe new file mode 100644 index 0000000..af4c69b Binary files /dev/null and b/Chapter01(Socket)/Part 0/Server/Server/bin/Debug/Server.exe differ diff --git a/Chapter01(Socket)/Part 0/Server/Server/bin/Debug/Server.pdb b/Chapter01(Socket)/Part 0/Server/Server/bin/Debug/Server.pdb new file mode 100644 index 0000000..a3e070f Binary files /dev/null and b/Chapter01(Socket)/Part 0/Server/Server/bin/Debug/Server.pdb differ diff --git a/Chapter01(Socket)/Part 0/Server/Server/bin/Debug/Server.vshost.exe b/Chapter01(Socket)/Part 0/Server/Server/bin/Debug/Server.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter01(Socket)/Part 0/Server/Server/bin/Debug/Server.vshost.exe differ diff --git a/Chapter01(Socket)/Part 0/Server/Server/bin/Debug/Server.xml b/Chapter01(Socket)/Part 0/Server/Server/bin/Debug/Server.xml new file mode 100644 index 0000000..6f3a531 --- /dev/null +++ b/Chapter01(Socket)/Part 0/Server/Server/bin/Debug/Server.xml @@ -0,0 +1,11 @@ + + + + +Server + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 0/Server/Server/obj/Debug/Server.Resources.resources b/Chapter01(Socket)/Part 0/Server/Server/obj/Debug/Server.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter01(Socket)/Part 0/Server/Server/obj/Debug/Server.Resources.resources differ diff --git a/Chapter01(Socket)/Part 0/Server/Server/obj/Debug/Server.exe b/Chapter01(Socket)/Part 0/Server/Server/obj/Debug/Server.exe new file mode 100644 index 0000000..af4c69b Binary files /dev/null and b/Chapter01(Socket)/Part 0/Server/Server/obj/Debug/Server.exe differ diff --git a/Chapter01(Socket)/Part 0/Server/Server/obj/Debug/Server.pdb b/Chapter01(Socket)/Part 0/Server/Server/obj/Debug/Server.pdb new file mode 100644 index 0000000..a3e070f Binary files /dev/null and b/Chapter01(Socket)/Part 0/Server/Server/obj/Debug/Server.pdb differ diff --git a/Chapter01(Socket)/Part 0/Server/Server/obj/Debug/Server.vbproj.GenerateResource.Cache b/Chapter01(Socket)/Part 0/Server/Server/obj/Debug/Server.vbproj.GenerateResource.Cache new file mode 100644 index 0000000..fa1f3d3 Binary files /dev/null and b/Chapter01(Socket)/Part 0/Server/Server/obj/Debug/Server.vbproj.GenerateResource.Cache differ diff --git a/Chapter01(Socket)/Part 0/Server/Server/obj/Debug/Server.xml b/Chapter01(Socket)/Part 0/Server/Server/obj/Debug/Server.xml new file mode 100644 index 0000000..6f3a531 --- /dev/null +++ b/Chapter01(Socket)/Part 0/Server/Server/obj/Debug/Server.xml @@ -0,0 +1,11 @@ + + + + +Server + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 0/Server/Server/obj/Server.vbproj.FileList.txt b/Chapter01(Socket)/Part 0/Server/Server/obj/Server.vbproj.FileList.txt new file mode 100644 index 0000000..d722a49 --- /dev/null +++ b/Chapter01(Socket)/Part 0/Server/Server/obj/Server.vbproj.FileList.txt @@ -0,0 +1,9 @@ +bin\Debug\Server.exe +bin\Debug\Server.pdb +bin\Debug\Server.xml +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\Server.Resources.resources +obj\Debug\Server.vbproj.GenerateResource.Cache +obj\Debug\Server.exe +obj\Debug\Server.xml +obj\Debug\Server.pdb diff --git a/Chapter01(Socket)/Part 0/Server_CS/Server_CS.sln b/Chapter01(Socket)/Part 0/Server_CS/Server_CS.sln new file mode 100644 index 0000000..097cafb --- /dev/null +++ b/Chapter01(Socket)/Part 0/Server_CS/Server_CS.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server_CS", "Server_CS\Server_CS.csproj", "{D2C9F0C0-8C52-4E44-AA28-749E15CBBA08}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D2C9F0C0-8C52-4E44-AA28-749E15CBBA08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D2C9F0C0-8C52-4E44-AA28-749E15CBBA08}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D2C9F0C0-8C52-4E44-AA28-749E15CBBA08}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D2C9F0C0-8C52-4E44-AA28-749E15CBBA08}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter01(Socket)/Part 0/Server_CS/Server_CS.suo b/Chapter01(Socket)/Part 0/Server_CS/Server_CS.suo new file mode 100644 index 0000000..7aaf323 Binary files /dev/null and b/Chapter01(Socket)/Part 0/Server_CS/Server_CS.suo differ diff --git a/Chapter01(Socket)/Part 0/Server_CS/Server_CS/Program.cs b/Chapter01(Socket)/Part 0/Server_CS/Server_CS/Program.cs new file mode 100644 index 0000000..e9901da --- /dev/null +++ b/Chapter01(Socket)/Part 0/Server_CS/Server_CS/Program.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Net.Sockets; + +namespace Server_CS +{ + class Program + { + const int portNo = 500; + static void Main(string[] args) + { + System.Net.IPAddress localAdd = System.Net.IPAddress.Parse("127.0.0.1"); + TcpListener listener = new TcpListener(localAdd, portNo); + listener.Start(); + TcpClient tcpClient = listener.AcceptTcpClient(); + NetworkStream ns = tcpClient.GetStream(); + byte[] data = new byte[tcpClient.ReceiveBufferSize]; + int numBytesRead = ns.Read(data, 0, System.Convert.ToInt32(tcpClient.ReceiveBufferSize)); + Console.WriteLine("Received :" + Encoding.ASCII.GetString(data, 0, numBytesRead)); + Console.ReadLine(); + } + } +} diff --git a/Chapter01(Socket)/Part 0/Server_CS/Server_CS/Properties/AssemblyInfo.cs b/Chapter01(Socket)/Part 0/Server_CS/Server_CS/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..02bbb8f --- /dev/null +++ b/Chapter01(Socket)/Part 0/Server_CS/Server_CS/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Server_CS")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Server_CS")] +[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("7f30b172-07de-49af-bccc-99f6855def60")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Chapter01(Socket)/Part 0/Server_CS/Server_CS/Server_CS.csproj b/Chapter01(Socket)/Part 0/Server_CS/Server_CS/Server_CS.csproj new file mode 100644 index 0000000..42a0626 --- /dev/null +++ b/Chapter01(Socket)/Part 0/Server_CS/Server_CS/Server_CS.csproj @@ -0,0 +1,47 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {D2C9F0C0-8C52-4E44-AA28-749E15CBBA08} + Exe + Properties + Server_CS + Server_CS + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 0/Server_CS/Server_CS/bin/Debug/Server_CS.exe b/Chapter01(Socket)/Part 0/Server_CS/Server_CS/bin/Debug/Server_CS.exe new file mode 100644 index 0000000..55492ac Binary files /dev/null and b/Chapter01(Socket)/Part 0/Server_CS/Server_CS/bin/Debug/Server_CS.exe differ diff --git a/Chapter01(Socket)/Part 0/Server_CS/Server_CS/bin/Debug/Server_CS.pdb b/Chapter01(Socket)/Part 0/Server_CS/Server_CS/bin/Debug/Server_CS.pdb new file mode 100644 index 0000000..2da0005 Binary files /dev/null and b/Chapter01(Socket)/Part 0/Server_CS/Server_CS/bin/Debug/Server_CS.pdb differ diff --git a/Chapter01(Socket)/Part 0/Server_CS/Server_CS/bin/Debug/Server_CS.vshost.exe b/Chapter01(Socket)/Part 0/Server_CS/Server_CS/bin/Debug/Server_CS.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter01(Socket)/Part 0/Server_CS/Server_CS/bin/Debug/Server_CS.vshost.exe differ diff --git a/Chapter01(Socket)/Part 0/Server_CS/Server_CS/obj/Debug/Server_CS.exe b/Chapter01(Socket)/Part 0/Server_CS/Server_CS/obj/Debug/Server_CS.exe new file mode 100644 index 0000000..55492ac Binary files /dev/null and b/Chapter01(Socket)/Part 0/Server_CS/Server_CS/obj/Debug/Server_CS.exe differ diff --git a/Chapter01(Socket)/Part 0/Server_CS/Server_CS/obj/Debug/Server_CS.pdb b/Chapter01(Socket)/Part 0/Server_CS/Server_CS/obj/Debug/Server_CS.pdb new file mode 100644 index 0000000..2da0005 Binary files /dev/null and b/Chapter01(Socket)/Part 0/Server_CS/Server_CS/obj/Debug/Server_CS.pdb differ diff --git a/Chapter01(Socket)/Part 0/Server_CS/Server_CS/obj/Server_CS.csproj.FileList.txt b/Chapter01(Socket)/Part 0/Server_CS/Server_CS/obj/Server_CS.csproj.FileList.txt new file mode 100644 index 0000000..b020531 --- /dev/null +++ b/Chapter01(Socket)/Part 0/Server_CS/Server_CS/obj/Server_CS.csproj.FileList.txt @@ -0,0 +1,5 @@ +obj\Debug\ResolveAssemblyReference.cache +bin\Debug\Server_CS.exe +bin\Debug\Server_CS.pdb +obj\Debug\Server_CS.exe +obj\Debug\Server_CS.pdb diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient.sln b/Chapter01(Socket)/Part 1/WinClient/WinClient.sln new file mode 100644 index 0000000..05b6717 --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient/WinClient.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "WinClient", "WinClient\WinClient.vbproj", "{18BAFD43-9363-4F34-80A2-F5CB6DE70617}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {18BAFD43-9363-4F34-80A2-F5CB6DE70617}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {18BAFD43-9363-4F34-80A2-F5CB6DE70617}.Debug|Any CPU.Build.0 = Debug|Any CPU + {18BAFD43-9363-4F34-80A2-F5CB6DE70617}.Release|Any CPU.ActiveCfg = Release|Any CPU + {18BAFD43-9363-4F34-80A2-F5CB6DE70617}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient.suo b/Chapter01(Socket)/Part 1/WinClient/WinClient.suo new file mode 100644 index 0000000..c5b5fa4 Binary files /dev/null and b/Chapter01(Socket)/Part 1/WinClient/WinClient.suo differ diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/Form1.Designer.vb b/Chapter01(Socket)/Part 1/WinClient/WinClient/Form1.Designer.vb new file mode 100644 index 0000000..27cd2d5 --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient/WinClient/Form1.Designer.vb @@ -0,0 +1,113 @@ +Partial Public Class Form1 + Inherits System.Windows.Forms.Form + + _ + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + End Sub + + 'Form overrides dispose to clean up the component list. + _ + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.txtMessageHistory = New System.Windows.Forms.TextBox + Me.txtMessage = New System.Windows.Forms.TextBox + Me.btnSend = New System.Windows.Forms.Button + Me.btnSignIn = New System.Windows.Forms.Button + Me.txtNick = New System.Windows.Forms.TextBox + Me.Label1 = New System.Windows.Forms.Label + Me.SuspendLayout() + ' + 'txtMessageHistory + ' + Me.txtMessageHistory.BackColor = System.Drawing.SystemColors.ControlLightLight + Me.txtMessageHistory.Location = New System.Drawing.Point(2, 39) + Me.txtMessageHistory.Multiline = True + Me.txtMessageHistory.Name = "txtMessageHistory" + Me.txtMessageHistory.ReadOnly = True + Me.txtMessageHistory.ScrollBars = System.Windows.Forms.ScrollBars.Vertical + Me.txtMessageHistory.Size = New System.Drawing.Size(268, 285) + Me.txtMessageHistory.TabIndex = 0 + ' + 'txtMessage + ' + Me.txtMessage.Location = New System.Drawing.Point(2, 331) + Me.txtMessage.Name = "txtMessage" + Me.txtMessage.Size = New System.Drawing.Size(186, 20) + Me.txtMessage.TabIndex = 1 + ' + 'btnSend + ' + Me.btnSend.Enabled = False + Me.btnSend.Location = New System.Drawing.Point(194, 329) + Me.btnSend.Name = "btnSend" + Me.btnSend.Size = New System.Drawing.Size(75, 23) + Me.btnSend.TabIndex = 2 + Me.btnSend.Text = "Send" + ' + 'btnSignIn + ' + Me.btnSignIn.Location = New System.Drawing.Point(194, 10) + Me.btnSignIn.Name = "btnSignIn" + Me.btnSignIn.Size = New System.Drawing.Size(75, 23) + Me.btnSignIn.TabIndex = 3 + Me.btnSignIn.Text = "Sign In" + ' + 'txtNick + ' + Me.txtNick.Location = New System.Drawing.Point(44, 12) + Me.txtNick.Name = "txtNick" + Me.txtNick.Size = New System.Drawing.Size(144, 20) + Me.txtNick.TabIndex = 4 + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(12, 15) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(29, 13) + Me.Label1.TabIndex = 5 + Me.Label1.Text = "Nick" + ' + 'Form1 + ' + Me.AcceptButton = Me.btnSend + Me.BackColor = System.Drawing.SystemColors.Control + Me.ClientSize = New System.Drawing.Size(272, 355) + Me.Controls.Add(Me.Label1) + Me.Controls.Add(Me.txtNick) + Me.Controls.Add(Me.btnSignIn) + Me.Controls.Add(Me.btnSend) + Me.Controls.Add(Me.txtMessage) + Me.Controls.Add(Me.txtMessageHistory) + Me.Name = "Form1" + Me.Text = "Chat Client" + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents txtMessageHistory As System.Windows.Forms.TextBox + Friend WithEvents txtMessage As System.Windows.Forms.TextBox + Friend WithEvents btnSend As System.Windows.Forms.Button + Friend WithEvents btnSignIn As System.Windows.Forms.Button + Friend WithEvents txtNick As System.Windows.Forms.TextBox + Friend WithEvents Label1 As System.Windows.Forms.Label + +End Class diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/Form1.resx b/Chapter01(Socket)/Part 1/WinClient/WinClient/Form1.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient/WinClient/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/Form1.vb b/Chapter01(Socket)/Part 1/WinClient/WinClient/Form1.vb new file mode 100644 index 0000000..88ea112 --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient/WinClient/Form1.vb @@ -0,0 +1,101 @@ +Imports System.Net.Sockets + +Public Class Form1 + Const portNo As Integer = 500 + Dim client As TcpClient + Dim data() As Byte + + Private Sub btnSend_Click( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles btnSend.Click + SendMessage(txtMessage.Text) + txtMessage.Clear() + End Sub + + Public Sub SendMessage(ByVal message As String) + Try + '---send a message to the server + Dim ns As NetworkStream = client.GetStream + Dim data As Byte() = _ + System.Text.Encoding.ASCII.GetBytes(message) + '---send the text--- + ns.Write(data, 0, data.Length) + ns.Flush() + Catch ex As Exception + MsgBox(ex.ToString) + End Try + End Sub + + Public Sub ReceiveMessage(ByVal ar As IAsyncResult) + Try + Dim bytesRead As Integer + bytesRead = client.GetStream.EndRead(ar) + If bytesRead < 1 Then + Exit Sub + Else + Dim para() As Object = _ + {System.Text.Encoding.ASCII.GetString( _ + data, 0, bytesRead)} + Me.Invoke(New delUpdateHistory( _ + AddressOf Me.UpdateHistory), para) + End If + client.GetStream.BeginRead( _ + data, 0, CInt(client.ReceiveBufferSize), _ + AddressOf ReceiveMessage, Nothing) + Catch ex As Exception + End Try + End Sub + + Private Sub btnSignIn_Click( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles btnSignIn.Click + If btnSignIn.Text = "Sign In" Then + Try + '---connect to server + client = New TcpClient + client.Connect("127.0.0.1", portNo) + ReDim data(client.ReceiveBufferSize) + SendMessage(txtNick.Text) + '---read from server + client.GetStream.BeginRead( _ + data, 0, CInt(client.ReceiveBufferSize), _ + AddressOf ReceiveMessage, Nothing) + btnSignIn.Text = "Sign Out" + btnSend.Enabled = True + Catch ex As Exception + MsgBox(ex.ToString) + End Try + Else + '---disconnect from server + Disconnect() + btnSignIn.Text = "Sign In" + btnSend.Enabled = False + End If + End Sub + + Public Sub Disconnect() + '---Disconnect from server + Try + client.GetStream.Close() + client.Close() + Catch ex As Exception + MsgBox(ex.ToString) + End Try + End Sub + + '---delegate and subroutine to update the TextBox control + Public Delegate Sub delUpdateHistory(ByVal str As String) + Public Sub UpdateHistory(ByVal str As String) + txtMessageHistory.AppendText(str) + End Sub + + Private Sub Form1_FormClosing( _ + ByVal sender As Object, _ + ByVal e As System.Windows.Forms.FormClosingEventArgs) _ + Handles Me.FormClosing + Disconnect() + End Sub +End Class + diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/My Project/AssemblyInfo.vb b/Chapter01(Socket)/Part 1/WinClient/WinClient/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..76041b3 --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient/WinClient/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + + diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/My Project/MyApplication.myapp b/Chapter01(Socket)/Part 1/WinClient/WinClient/My Project/MyApplication.myapp new file mode 100644 index 0000000..17c28e4 --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient/WinClient/My Project/MyApplication.myapp @@ -0,0 +1,10 @@ + + + true + WinClient.Form1 + false + 0 + true + 0 + 0 + diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/My Project/MyApplication.vb b/Chapter01(Socket)/Part 1/WinClient/WinClient/My Project/MyApplication.vb new file mode 100644 index 0000000..e9ad238 --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient/WinClient/My Project/MyApplication.vb @@ -0,0 +1,23 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + Partial Class MyApplication + + + Protected Overrides Sub OnCreateMainForm() + Me.MainForm = My.Forms.Form1 + End Sub + End Class +End Namespace diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/My Project/MyEvents.vb b/Chapter01(Socket)/Part 1/WinClient/WinClient/My Project/MyEvents.vb new file mode 100644 index 0000000..d67825f --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient/WinClient/My Project/MyEvents.vb @@ -0,0 +1,15 @@ +Namespace My + + 'Use the editor window dropdowns in the Application pane of the Project Designer to handle MyApplication Events + ' + 'Startup: Raised when the application starts, before the startup form is created. + 'Shutdown: Raised after all application forms are closed. This event is not raised if the application is terminating abnormally. + 'UnhandledException: Raised if the application encounters an unhandled exception. + 'StartupNextInstance: Raised when launching a single-instance application and the application is already active. + 'NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected. + + Partial Friend Class MyApplication + + End Class + +End Namespace diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/My Project/MyResources.resx b/Chapter01(Socket)/Part 1/WinClient/WinClient/My Project/MyResources.resx new file mode 100644 index 0000000..3e18af9 --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient/WinClient/My Project/MyResources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/My Project/MyResources.vb b/Chapter01(Socket)/Part 1/WinClient/WinClient/My Project/MyResources.vb new file mode 100644 index 0000000..250357e --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient/WinClient/My Project/MyResources.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict Off +Option Explicit On + +Imports System +Imports System.IO +Imports System.Resources + +Namespace My.Resources + + ' + ' A strongly-typed resource class, for looking up localized strings, etc. + ' + 'This class was auto-generated by the Strongly Typed Resource Builder + 'class via a tool like ResGen or Visual Studio.NET. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + _ + Module MyResources + + Private _resMgr As System.Resources.ResourceManager + + Private _resCulture As System.Globalization.CultureInfo + + ' + ' Returns the cached ResourceManager instance used by this class. + ' + _ + Public ReadOnly Property ResourceManager() As System.Resources.ResourceManager + Get + If (_resMgr Is Nothing) Then + Dim temp As System.Resources.ResourceManager = New System.Resources.ResourceManager("WinClient.MyResources", GetType(MyResources).Assembly) + System.Threading.Thread.MemoryBarrier + _resMgr = temp + End If + Return _resMgr + End Get + End Property + + ' + ' Overrides the current thread's CurrentUICulture property for all + ' resource lookups using this strongly typed resource class. + ' + _ + Public Property Culture() As System.Globalization.CultureInfo + Get + Return _resCulture + End Get + Set + _resCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/My Project/MySettings.settings b/Chapter01(Socket)/Part 1/WinClient/WinClient/My Project/MySettings.settings new file mode 100644 index 0000000..0bcb11d --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient/WinClient/My Project/MySettings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/My Project/MySettings.vb b/Chapter01(Socket)/Part 1/WinClient/WinClient/My Project/MySettings.vb new file mode 100644 index 0000000..3d12c6f --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient/WinClient/My Project/MySettings.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict Off +Option Explicit On + + + +Partial Friend NotInheritable Class MySettings + Inherits System.Configuration.ApplicationSettingsBase + + Private Shared m_Value As MySettings + + Private Shared m_SyncObject As Object = New Object + + _ + Public Shared ReadOnly Property Value() As MySettings + Get + If (MySettings.m_Value Is Nothing) Then + System.Threading.Monitor.Enter(MySettings.m_SyncObject) + If (MySettings.m_Value Is Nothing) Then + Try + MySettings.m_Value = New MySettings + Finally + System.Threading.Monitor.Exit(MySettings.m_SyncObject) + End Try + End If + End If + Return MySettings.m_Value + End Get + End Property +End Class diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/WinClient.vbproj b/Chapter01(Socket)/Part 1/WinClient/WinClient/WinClient.vbproj new file mode 100644 index 0000000..e1343bc --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient/WinClient/WinClient.vbproj @@ -0,0 +1,94 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {18BAFD43-9363-4F34-80A2-F5CB6DE70617} + WinExe + WinClient.My.MyApplication + WinClient + WinClient + WindowsForms + + + true + full + true + true + bin\ + WinClient.xml + 42016,42017,42018,42019,42032 + + + pdbonly + false + true + true + bin\ + WinClient.xml + 42016,42017,42018,42019,42032 + + + + + + + + + + + + + + + + + + Form + + + Form1.vb + Form + + + + True + MyApplication.myapp + + + True + True + MyResources.resx + + + True + MySettings.settings + True + + + + + + Form1.vb + Designer + + + VbMyResourcesResXFileCodeGenerator + MyResources.vb + My.Resources + + + + + + MyApplicationCodeGenerator + MyApplication.vb + + + SettingsSingleFileGenerator + MySettings.vb + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/WinClient.vbproj.user b/Chapter01(Socket)/Part 1/WinClient/WinClient/WinClient.vbproj.user new file mode 100644 index 0000000..e1d33e3 --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient/WinClient/WinClient.vbproj.user @@ -0,0 +1,7 @@ + + + 8.0.41115 + ProjectFiles + 0 + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/app.config b/Chapter01(Socket)/Part 1/WinClient/WinClient/app.config new file mode 100644 index 0000000..f636923 --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient/WinClient/app.config @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/bin/WinClient.exe b/Chapter01(Socket)/Part 1/WinClient/WinClient/bin/WinClient.exe new file mode 100644 index 0000000..f66a27d Binary files /dev/null and b/Chapter01(Socket)/Part 1/WinClient/WinClient/bin/WinClient.exe differ diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/bin/WinClient.exe.config b/Chapter01(Socket)/Part 1/WinClient/WinClient/bin/WinClient.exe.config new file mode 100644 index 0000000..f636923 --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient/WinClient/bin/WinClient.exe.config @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/bin/WinClient.pdb b/Chapter01(Socket)/Part 1/WinClient/WinClient/bin/WinClient.pdb new file mode 100644 index 0000000..acd6000 Binary files /dev/null and b/Chapter01(Socket)/Part 1/WinClient/WinClient/bin/WinClient.pdb differ diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/bin/WinClient.vshost.exe b/Chapter01(Socket)/Part 1/WinClient/WinClient/bin/WinClient.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter01(Socket)/Part 1/WinClient/WinClient/bin/WinClient.vshost.exe differ diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/bin/WinClient.vshost.exe.config b/Chapter01(Socket)/Part 1/WinClient/WinClient/bin/WinClient.vshost.exe.config new file mode 100644 index 0000000..f636923 --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient/WinClient/bin/WinClient.vshost.exe.config @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/bin/WinClient.xml b/Chapter01(Socket)/Part 1/WinClient/WinClient/bin/WinClient.xml new file mode 100644 index 0000000..3a4f94d --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient/WinClient/bin/WinClient.xml @@ -0,0 +1,11 @@ + + + + +WinClient + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/obj/Release/TempPE/My Project.MyResources.vb.dll b/Chapter01(Socket)/Part 1/WinClient/WinClient/obj/Release/TempPE/My Project.MyResources.vb.dll new file mode 100644 index 0000000..4d2d751 Binary files /dev/null and b/Chapter01(Socket)/Part 1/WinClient/WinClient/obj/Release/TempPE/My Project.MyResources.vb.dll differ diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/obj/Release/WinClient.Form1.resources b/Chapter01(Socket)/Part 1/WinClient/WinClient/obj/Release/WinClient.Form1.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter01(Socket)/Part 1/WinClient/WinClient/obj/Release/WinClient.Form1.resources differ diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/obj/Release/WinClient.MyResources.resources b/Chapter01(Socket)/Part 1/WinClient/WinClient/obj/Release/WinClient.MyResources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter01(Socket)/Part 1/WinClient/WinClient/obj/Release/WinClient.MyResources.resources differ diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/obj/Release/WinClient.exe b/Chapter01(Socket)/Part 1/WinClient/WinClient/obj/Release/WinClient.exe new file mode 100644 index 0000000..f66a27d Binary files /dev/null and b/Chapter01(Socket)/Part 1/WinClient/WinClient/obj/Release/WinClient.exe differ diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/obj/Release/WinClient.pdb b/Chapter01(Socket)/Part 1/WinClient/WinClient/obj/Release/WinClient.pdb new file mode 100644 index 0000000..acd6000 Binary files /dev/null and b/Chapter01(Socket)/Part 1/WinClient/WinClient/obj/Release/WinClient.pdb differ diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/obj/Release/WinClient.vbproj.GenerateResource.Cache b/Chapter01(Socket)/Part 1/WinClient/WinClient/obj/Release/WinClient.vbproj.GenerateResource.Cache new file mode 100644 index 0000000..f9c1da7 Binary files /dev/null and b/Chapter01(Socket)/Part 1/WinClient/WinClient/obj/Release/WinClient.vbproj.GenerateResource.Cache differ diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/obj/Release/WinClient.xml b/Chapter01(Socket)/Part 1/WinClient/WinClient/obj/Release/WinClient.xml new file mode 100644 index 0000000..3a4f94d --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient/WinClient/obj/Release/WinClient.xml @@ -0,0 +1,11 @@ + + + + +WinClient + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/WinClient/WinClient/obj/WinClient.vbproj.FileList.txt b/Chapter01(Socket)/Part 1/WinClient/WinClient/obj/WinClient.vbproj.FileList.txt new file mode 100644 index 0000000..5707253 --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient/WinClient/obj/WinClient.vbproj.FileList.txt @@ -0,0 +1,11 @@ +bin\WinClient.exe.config +bin\WinClient.exe +bin\WinClient.pdb +bin\WinClient.xml +obj\Release\ResolveAssemblyReference.cache +obj\Release\WinClient.Form1.resources +obj\Release\WinClient.MyResources.resources +obj\Release\WinClient.vbproj.GenerateResource.Cache +obj\Release\WinClient.exe +obj\Release\WinClient.xml +obj\Release\WinClient.pdb diff --git a/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS.sln b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS.sln new file mode 100644 index 0000000..2c877d7 --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinClient_CS", "WinClient_CS\WinClient_CS.csproj", "{5AE42AD9-0C4F-4E26-A9EE-13CDB60E9B2D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5AE42AD9-0C4F-4E26-A9EE-13CDB60E9B2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5AE42AD9-0C4F-4E26-A9EE-13CDB60E9B2D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5AE42AD9-0C4F-4E26-A9EE-13CDB60E9B2D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5AE42AD9-0C4F-4E26-A9EE-13CDB60E9B2D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS.suo b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS.suo new file mode 100644 index 0000000..c8e9ff2 Binary files /dev/null and b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS.suo differ diff --git a/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Form1.Designer.cs b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Form1.Designer.cs new file mode 100644 index 0000000..3af743d --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Form1.Designer.cs @@ -0,0 +1,121 @@ +namespace WinClient_CS +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.Label1 = new System.Windows.Forms.Label(); + this.txtNick = new System.Windows.Forms.TextBox(); + this.btnSignIn = new System.Windows.Forms.Button(); + this.btnSend = new System.Windows.Forms.Button(); + this.txtMessage = new System.Windows.Forms.TextBox(); + this.txtMessageHistory = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // Label1 + // + this.Label1.AutoSize = true; + this.Label1.Location = new System.Drawing.Point(12, 11); + this.Label1.Name = "Label1"; + this.Label1.Size = new System.Drawing.Size(29, 13); + this.Label1.TabIndex = 11; + this.Label1.Text = "Nick"; + // + // txtNick + // + this.txtNick.Location = new System.Drawing.Point(44, 8); + this.txtNick.Name = "txtNick"; + this.txtNick.Size = new System.Drawing.Size(144, 20); + this.txtNick.TabIndex = 10; + // + // btnSignIn + // + this.btnSignIn.Location = new System.Drawing.Point(194, 6); + this.btnSignIn.Name = "btnSignIn"; + this.btnSignIn.Size = new System.Drawing.Size(75, 23); + this.btnSignIn.TabIndex = 9; + this.btnSignIn.Text = "Sign In"; + this.btnSignIn.Click += new System.EventHandler(this.btnSignIn_Click); + // + // btnSend + // + this.btnSend.Enabled = false; + this.btnSend.Location = new System.Drawing.Point(194, 325); + this.btnSend.Name = "btnSend"; + this.btnSend.Size = new System.Drawing.Size(75, 23); + this.btnSend.TabIndex = 8; + this.btnSend.Text = "Send"; + this.btnSend.Click += new System.EventHandler(this.btnSend_Click); + // + // txtMessage + // + this.txtMessage.Location = new System.Drawing.Point(2, 327); + this.txtMessage.Name = "txtMessage"; + this.txtMessage.Size = new System.Drawing.Size(186, 20); + this.txtMessage.TabIndex = 7; + // + // txtMessageHistory + // + this.txtMessageHistory.BackColor = System.Drawing.SystemColors.ControlLightLight; + this.txtMessageHistory.Location = new System.Drawing.Point(2, 35); + this.txtMessageHistory.Multiline = true; + this.txtMessageHistory.Name = "txtMessageHistory"; + this.txtMessageHistory.ReadOnly = true; + this.txtMessageHistory.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.txtMessageHistory.Size = new System.Drawing.Size(268, 285); + this.txtMessageHistory.TabIndex = 6; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(272, 355); + this.Controls.Add(this.Label1); + this.Controls.Add(this.txtNick); + this.Controls.Add(this.btnSignIn); + this.Controls.Add(this.btnSend); + this.Controls.Add(this.txtMessage); + this.Controls.Add(this.txtMessageHistory); + this.Name = "Form1"; + this.Text = "Form1"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form_Closing); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + internal System.Windows.Forms.Label Label1; + internal System.Windows.Forms.TextBox txtNick; + internal System.Windows.Forms.Button btnSignIn; + internal System.Windows.Forms.Button btnSend; + internal System.Windows.Forms.TextBox txtMessage; + internal System.Windows.Forms.TextBox txtMessageHistory; + } +} + diff --git a/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Form1.cs b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Form1.cs new file mode 100644 index 0000000..7170d83 --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Form1.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + + +using System.Net.Sockets; + +namespace WinClient_CS +{ + public partial class Form1 : Form + { + const int portNo = 500; + TcpClient client; + byte[] data; + + public Form1() + { + InitializeComponent(); + } + + public void SendMessage(string message) + { + try + { + NetworkStream ns = client.GetStream(); + byte[] data = System.Text.Encoding.ASCII.GetBytes(message); + ns.Write(data, 0, data.Length); + ns.Flush(); + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + } + + + public void ReceiveMessage(IAsyncResult ar) + { + try + { + int bytesRead; + bytesRead = client.GetStream().EndRead(ar); + if (bytesRead < 1) + { + return; + } + else + { + object[] para = { System.Text.Encoding.ASCII.GetString(data, 0, bytesRead) }; + this.Invoke(new delUpdateHistory(UpdateHistory), para); + } + client.GetStream().BeginRead(data, 0, System.Convert.ToInt32(client.ReceiveBufferSize),ReceiveMessage, null); + } + catch (Exception ex) + { + } + } + + private void btnSignIn_Click(object sender, EventArgs e) + { + if (btnSignIn.Text == "Sign In") + { + try + { + client = new TcpClient(); + client.Connect("127.0.0.1", portNo); + + data = new byte[client.ReceiveBufferSize]; + + SendMessage(txtNick.Text); + client.GetStream().BeginRead(data, 0, System.Convert.ToInt32(client.ReceiveBufferSize), ReceiveMessage, null); + btnSignIn.Text = "Sign Out"; + btnSend.Enabled = true; + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + } + else + { + Disconnect(); + btnSignIn.Text = "Sign In"; + btnSend.Enabled = false; + } + } + public void Disconnect() + { + try + { + client.GetStream().Close(); + client.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + } + + public delegate void delUpdateHistory(string str); + public void UpdateHistory(string str) + { + txtMessageHistory.AppendText(str); + } + + private void Form_Closing(object sender, FormClosingEventArgs e) + { + Disconnect(); + } + + private void btnSend_Click(object sender, EventArgs e) + { + SendMessage(txtMessage.Text); + txtMessage.Clear(); + } + + } +} \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Form1.resx b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Form1.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Program.cs b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Program.cs new file mode 100644 index 0000000..f2b9ee7 --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace WinClient_CS +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Properties/AssemblyInfo.cs b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..3d6d21f --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("WinClient_CS")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("WinClient_CS")] +[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("fa365092-9344-4be4-8f05-4a7c6f02b55f")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Properties/Resources.Designer.cs b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Properties/Resources.Designer.cs new file mode 100644 index 0000000..a54b167 --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WinClient_CS.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WinClient_CS.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Properties/Resources.resx b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Properties/Settings.Designer.cs b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Properties/Settings.Designer.cs new file mode 100644 index 0000000..76414ec --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WinClient_CS.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Properties/Settings.settings b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/WinClient_CS.csproj b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/WinClient_CS.csproj new file mode 100644 index 0000000..b906046 --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/WinClient_CS.csproj @@ -0,0 +1,78 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {5AE42AD9-0C4F-4E26-A9EE-13CDB60E9B2D} + WinExe + Properties + WinClient_CS + WinClient_CS + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + Form + + + Form1.cs + + + + + Designer + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/bin/Debug/WinClient_CS.exe b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/bin/Debug/WinClient_CS.exe new file mode 100644 index 0000000..17fb48e Binary files /dev/null and b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/bin/Debug/WinClient_CS.exe differ diff --git a/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/bin/Debug/WinClient_CS.pdb b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/bin/Debug/WinClient_CS.pdb new file mode 100644 index 0000000..2df146b Binary files /dev/null and b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/bin/Debug/WinClient_CS.pdb differ diff --git a/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/bin/Debug/WinClient_CS.vshost.exe b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/bin/Debug/WinClient_CS.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/bin/Debug/WinClient_CS.vshost.exe differ diff --git a/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.Form1.resources b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.Form1.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.Form1.resources differ diff --git a/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.Properties.Resources.resources b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.Properties.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.Properties.Resources.resources differ diff --git a/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.csproj.GenerateResource.Cache b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.csproj.GenerateResource.Cache new file mode 100644 index 0000000..500b8c0 Binary files /dev/null and b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.csproj.GenerateResource.Cache differ diff --git a/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.exe b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.exe new file mode 100644 index 0000000..17fb48e Binary files /dev/null and b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.exe differ diff --git a/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.pdb b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.pdb new file mode 100644 index 0000000..2df146b Binary files /dev/null and b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.pdb differ diff --git a/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/obj/WinClient_CS.csproj.FileList.txt b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/obj/WinClient_CS.csproj.FileList.txt new file mode 100644 index 0000000..8f7db2b --- /dev/null +++ b/Chapter01(Socket)/Part 1/WinClient_CS/WinClient_CS/obj/WinClient_CS.csproj.FileList.txt @@ -0,0 +1,8 @@ +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\WinClient_CS.Form1.resources +obj\Debug\WinClient_CS.Properties.Resources.resources +obj\Debug\WinClient_CS.csproj.GenerateResource.Cache +bin\Debug\WinClient_CS.exe +bin\Debug\WinClient_CS.pdb +obj\Debug\WinClient_CS.exe +obj\Debug\WinClient_CS.pdb diff --git a/Chapter01(Socket)/Part 1/server/server.sln b/Chapter01(Socket)/Part 1/server/server.sln new file mode 100644 index 0000000..c397be3 --- /dev/null +++ b/Chapter01(Socket)/Part 1/server/server.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "server", "server\server.vbproj", "{02784E52-3E62-4C83-A989-2C63C2368170}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {02784E52-3E62-4C83-A989-2C63C2368170}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {02784E52-3E62-4C83-A989-2C63C2368170}.Debug|Any CPU.Build.0 = Debug|Any CPU + {02784E52-3E62-4C83-A989-2C63C2368170}.Release|Any CPU.ActiveCfg = Release|Any CPU + {02784E52-3E62-4C83-A989-2C63C2368170}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter01(Socket)/Part 1/server/server.suo b/Chapter01(Socket)/Part 1/server/server.suo new file mode 100644 index 0000000..aec5eb3 Binary files /dev/null and b/Chapter01(Socket)/Part 1/server/server.suo differ diff --git a/Chapter01(Socket)/Part 1/server/server/ChatClient.vb b/Chapter01(Socket)/Part 1/server/server/ChatClient.vb new file mode 100644 index 0000000..9055ed3 --- /dev/null +++ b/Chapter01(Socket)/Part 1/server/server/ChatClient.vb @@ -0,0 +1,101 @@ +Imports System.Net.Sockets + +Public Class ChatClient + '---contains a list of all the clients + Public Shared AllClients As New Hashtable + + '---information about the client + Private _client As TcpClient + Private _clientIP As String + Private _ClientNick As String + + '---used for sending/receiving data + Private data() As Byte + + '---is the nick name being sent? + Private ReceiveNick As Boolean = True + + Public Sub New(ByVal client As TcpClient) + _client = client + + '---get the client IP address + _clientIP = client.Client.RemoteEndPoint.ToString + + '---add the current client to the hash table + AllClients.Add(_clientIP, Me) + + '---start reading data from the client in a separate thread + ReDim data(_client.ReceiveBufferSize) + + _client.GetStream.BeginRead(data, 0, _ + CInt(_client.ReceiveBufferSize), _ + AddressOf ReceiveMessage, Nothing) + End Sub + + Public Sub SendMessage(ByVal message As String) + Try + '---send the text + Dim ns As System.Net.Sockets.NetworkStream + SyncLock _client.GetStream + ns = _client.GetStream + End SyncLock + Dim bytesToSend As Byte() = _ + System.Text.Encoding.ASCII.GetBytes(message) + ns.Write(bytesToSend, 0, bytesToSend.Length) + ns.Flush() + Catch ex As Exception + Console.WriteLine(ex.ToString) + End Try + End Sub + + Public Sub ReceiveMessage(ByVal ar As IAsyncResult) + '---read from client--- + Dim bytesRead As Integer + Try + SyncLock _client.GetStream + bytesRead = _client.GetStream.EndRead(ar) + End SyncLock + '---client has disconnected + If bytesRead < 1 Then + AllClients.Remove(_clientIP) + Broadcast(_ClientNick & " has left the chat.") + Exit Sub + Else + '---get the message sent + Dim messageReceived As String = _ + System.Text.Encoding.ASCII. _ + GetString(data, 0, bytesRead) + '---client is sending its nickname + If ReceiveNick Then + _ClientNick = messageReceived + + '---tell everyone client has entered the chat + Broadcast(_ClientNick & " has joined the chat.") + ReceiveNick = False + Else + '---broadcast the message to everyone + Broadcast(_ClientNick & ">" & messageReceived) + End If + End If + '---continue reading from client + SyncLock _client.GetStream + _client.GetStream.BeginRead(data, 0, _ + CInt(_client.ReceiveBufferSize), _ + AddressOf ReceiveMessage, Nothing) + End SyncLock + Catch ex As Exception + AllClients.Remove(_clientIP) + Broadcast(_ClientNick & " has left the chat.") + End Try + End Sub + + Public Sub Broadcast(ByVal message As String) + '---log it locally + Console.WriteLine(message) + Dim c As DictionaryEntry + For Each c In AllClients + '---broadcast message to all users + CType(c.Value, ChatClient).SendMessage(message & vbLf) + Next + End Sub +End Class diff --git a/Chapter01(Socket)/Part 1/server/server/Module1.vb b/Chapter01(Socket)/Part 1/server/server/Module1.vb new file mode 100644 index 0000000..f329318 --- /dev/null +++ b/Chapter01(Socket)/Part 1/server/server/Module1.vb @@ -0,0 +1,15 @@ +Imports System.Net.Sockets + +Module Module1 + Const portNo As Integer = 500 + + Sub Main() + Dim localAdd As System.Net.IPAddress = _ + System.Net.IPAddress.Parse("127.0.0.1") + Dim listener As New TcpListener(localAdd, portNo) + listener.Start() + While True + Dim user As New ChatClient(listener.AcceptTcpClient) + End While + End Sub +End Module diff --git a/Chapter01(Socket)/Part 1/server/server/My Project/AssemblyInfo.vb b/Chapter01(Socket)/Part 1/server/server/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..30e1c1e --- /dev/null +++ b/Chapter01(Socket)/Part 1/server/server/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + + diff --git a/Chapter01(Socket)/Part 1/server/server/My Project/MyApplication.myapp b/Chapter01(Socket)/Part 1/server/server/My Project/MyApplication.myapp new file mode 100644 index 0000000..76de46d --- /dev/null +++ b/Chapter01(Socket)/Part 1/server/server/My Project/MyApplication.myapp @@ -0,0 +1,9 @@ + + + false + false + 0 + true + 0 + 3 + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/server/server/My Project/MyApplication.vb b/Chapter01(Socket)/Part 1/server/server/My Project/MyApplication.vb new file mode 100644 index 0000000..0154603 --- /dev/null +++ b/Chapter01(Socket)/Part 1/server/server/My Project/MyApplication.vb @@ -0,0 +1,12 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/Chapter01(Socket)/Part 1/server/server/My Project/MyResources.resx b/Chapter01(Socket)/Part 1/server/server/My Project/MyResources.resx new file mode 100644 index 0000000..3e18af9 --- /dev/null +++ b/Chapter01(Socket)/Part 1/server/server/My Project/MyResources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/server/server/My Project/MyResources.vb b/Chapter01(Socket)/Part 1/server/server/My Project/MyResources.vb new file mode 100644 index 0000000..a8884f3 --- /dev/null +++ b/Chapter01(Socket)/Part 1/server/server/My Project/MyResources.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict Off +Option Explicit On + +Imports System +Imports System.IO +Imports System.Resources + +Namespace My.Resources + + ' + ' A strongly-typed resource class, for looking up localized strings, etc. + ' + 'This class was auto-generated by the Strongly Typed Resource Builder + 'class via a tool like ResGen or Visual Studio.NET. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + _ + Module MyResources + + Private _resMgr As System.Resources.ResourceManager + + Private _resCulture As System.Globalization.CultureInfo + + ' + ' Returns the cached ResourceManager instance used by this class. + ' + _ + Public ReadOnly Property ResourceManager() As System.Resources.ResourceManager + Get + If (_resMgr Is Nothing) Then + Dim temp As System.Resources.ResourceManager = New System.Resources.ResourceManager("$safeprojectname$.MyResources", GetType(MyResources).Assembly) + System.Threading.Thread.MemoryBarrier + _resMgr = temp + End If + Return _resMgr + End Get + End Property + + ' + ' Overrides the current thread's CurrentUICulture property for all + ' resource lookups using this strongly typed resource class. + ' + _ + Public Property Culture() As System.Globalization.CultureInfo + Get + Return _resCulture + End Get + Set + _resCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Chapter01(Socket)/Part 1/server/server/My Project/MySettings.settings b/Chapter01(Socket)/Part 1/server/server/My Project/MySettings.settings new file mode 100644 index 0000000..0bcb11d --- /dev/null +++ b/Chapter01(Socket)/Part 1/server/server/My Project/MySettings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/server/server/My Project/MySettings.vb b/Chapter01(Socket)/Part 1/server/server/My Project/MySettings.vb new file mode 100644 index 0000000..3d12c6f --- /dev/null +++ b/Chapter01(Socket)/Part 1/server/server/My Project/MySettings.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict Off +Option Explicit On + + + +Partial Friend NotInheritable Class MySettings + Inherits System.Configuration.ApplicationSettingsBase + + Private Shared m_Value As MySettings + + Private Shared m_SyncObject As Object = New Object + + _ + Public Shared ReadOnly Property Value() As MySettings + Get + If (MySettings.m_Value Is Nothing) Then + System.Threading.Monitor.Enter(MySettings.m_SyncObject) + If (MySettings.m_Value Is Nothing) Then + Try + MySettings.m_Value = New MySettings + Finally + System.Threading.Monitor.Exit(MySettings.m_SyncObject) + End Try + End If + End If + Return MySettings.m_Value + End Get + End Property +End Class diff --git a/Chapter01(Socket)/Part 1/server/server/app.config b/Chapter01(Socket)/Part 1/server/server/app.config new file mode 100644 index 0000000..f636923 --- /dev/null +++ b/Chapter01(Socket)/Part 1/server/server/app.config @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/server/server/bin/server.exe b/Chapter01(Socket)/Part 1/server/server/bin/server.exe new file mode 100644 index 0000000..abd4dd4 Binary files /dev/null and b/Chapter01(Socket)/Part 1/server/server/bin/server.exe differ diff --git a/Chapter01(Socket)/Part 1/server/server/bin/server.exe.config b/Chapter01(Socket)/Part 1/server/server/bin/server.exe.config new file mode 100644 index 0000000..f636923 --- /dev/null +++ b/Chapter01(Socket)/Part 1/server/server/bin/server.exe.config @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/server/server/bin/server.pdb b/Chapter01(Socket)/Part 1/server/server/bin/server.pdb new file mode 100644 index 0000000..fc3d4e5 Binary files /dev/null and b/Chapter01(Socket)/Part 1/server/server/bin/server.pdb differ diff --git a/Chapter01(Socket)/Part 1/server/server/bin/server.vshost.exe b/Chapter01(Socket)/Part 1/server/server/bin/server.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter01(Socket)/Part 1/server/server/bin/server.vshost.exe differ diff --git a/Chapter01(Socket)/Part 1/server/server/bin/server.vshost.exe.config b/Chapter01(Socket)/Part 1/server/server/bin/server.vshost.exe.config new file mode 100644 index 0000000..f636923 --- /dev/null +++ b/Chapter01(Socket)/Part 1/server/server/bin/server.vshost.exe.config @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/server/server/bin/server.xml b/Chapter01(Socket)/Part 1/server/server/bin/server.xml new file mode 100644 index 0000000..83af37a --- /dev/null +++ b/Chapter01(Socket)/Part 1/server/server/bin/server.xml @@ -0,0 +1,11 @@ + + + + +server + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/server/server/obj/Debug/server.MyResources.resources b/Chapter01(Socket)/Part 1/server/server/obj/Debug/server.MyResources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter01(Socket)/Part 1/server/server/obj/Debug/server.MyResources.resources differ diff --git a/Chapter01(Socket)/Part 1/server/server/obj/Debug/server.exe b/Chapter01(Socket)/Part 1/server/server/obj/Debug/server.exe new file mode 100644 index 0000000..abd4dd4 Binary files /dev/null and b/Chapter01(Socket)/Part 1/server/server/obj/Debug/server.exe differ diff --git a/Chapter01(Socket)/Part 1/server/server/obj/Debug/server.pdb b/Chapter01(Socket)/Part 1/server/server/obj/Debug/server.pdb new file mode 100644 index 0000000..fc3d4e5 Binary files /dev/null and b/Chapter01(Socket)/Part 1/server/server/obj/Debug/server.pdb differ diff --git a/Chapter01(Socket)/Part 1/server/server/obj/Debug/server.vbproj.GenerateResource.Cache b/Chapter01(Socket)/Part 1/server/server/obj/Debug/server.vbproj.GenerateResource.Cache new file mode 100644 index 0000000..625f780 Binary files /dev/null and b/Chapter01(Socket)/Part 1/server/server/obj/Debug/server.vbproj.GenerateResource.Cache differ diff --git a/Chapter01(Socket)/Part 1/server/server/obj/Debug/server.xml b/Chapter01(Socket)/Part 1/server/server/obj/Debug/server.xml new file mode 100644 index 0000000..83af37a --- /dev/null +++ b/Chapter01(Socket)/Part 1/server/server/obj/Debug/server.xml @@ -0,0 +1,11 @@ + + + + +server + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/server/server/obj/server.vbproj.FileList.txt b/Chapter01(Socket)/Part 1/server/server/obj/server.vbproj.FileList.txt new file mode 100644 index 0000000..c15a50b --- /dev/null +++ b/Chapter01(Socket)/Part 1/server/server/obj/server.vbproj.FileList.txt @@ -0,0 +1,10 @@ +bin\server.exe.config +bin\server.exe +bin\server.pdb +bin\server.xml +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\server.MyResources.resources +obj\Debug\server.vbproj.GenerateResource.Cache +obj\Debug\server.exe +obj\Debug\server.xml +obj\Debug\server.pdb diff --git a/Chapter01(Socket)/Part 1/server/server/server.vbproj b/Chapter01(Socket)/Part 1/server/server/server.vbproj new file mode 100644 index 0000000..3fb4616 --- /dev/null +++ b/Chapter01(Socket)/Part 1/server/server/server.vbproj @@ -0,0 +1,83 @@ + + + Debug + AnyCPU + 8.0.41115 + 2.0 + {02784E52-3E62-4C83-A989-2C63C2368170} + Exe + server.Module1 + server + server + Windows + + + true + full + true + true + bin\ + server.xml + 42016,42017,42018,42019,42032 + + + pdbonly + false + true + true + bin\ + server.xml + 42016,42017,42018,42019,42032 + + + + + + + + + + + + + + + + + + + + True + MyApplication.myapp + + + True + True + MyResources.resx + + + True + MySettings.settings + True + + + + + VbMyResourcesResXFileCodeGenerator + MyResources.vb + My.Resources + + + + + + MyApplicationCodeGenerator + MyApplication.vb + + + SettingsSingleFileGenerator + MySettings.vb + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/server/server/server.vbproj.user b/Chapter01(Socket)/Part 1/server/server/server.vbproj.user new file mode 100644 index 0000000..e1d33e3 --- /dev/null +++ b/Chapter01(Socket)/Part 1/server/server/server.vbproj.user @@ -0,0 +1,7 @@ + + + 8.0.41115 + ProjectFiles + 0 + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 1/server_CS/server_CS.sln b/Chapter01(Socket)/Part 1/server_CS/server_CS.sln new file mode 100644 index 0000000..ecd2d10 --- /dev/null +++ b/Chapter01(Socket)/Part 1/server_CS/server_CS.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "server_CS", "server_CS\server_CS.csproj", "{2D92EC13-47B0-44B3-9357-7C59D7AD57BB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2D92EC13-47B0-44B3-9357-7C59D7AD57BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2D92EC13-47B0-44B3-9357-7C59D7AD57BB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2D92EC13-47B0-44B3-9357-7C59D7AD57BB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2D92EC13-47B0-44B3-9357-7C59D7AD57BB}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter01(Socket)/Part 1/server_CS/server_CS.suo b/Chapter01(Socket)/Part 1/server_CS/server_CS.suo new file mode 100644 index 0000000..a96f5f1 Binary files /dev/null and b/Chapter01(Socket)/Part 1/server_CS/server_CS.suo differ diff --git a/Chapter01(Socket)/Part 1/server_CS/server_CS/ChatClient.cs b/Chapter01(Socket)/Part 1/server_CS/server_CS/ChatClient.cs new file mode 100644 index 0000000..2eb07dc --- /dev/null +++ b/Chapter01(Socket)/Part 1/server_CS/server_CS/ChatClient.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using System.Net.Sockets; +using System.Collections; + +namespace server_CS +{ + class ChatClient + { + public static Hashtable AllClients = + new Hashtable(); + private TcpClient _client; + private string _clientIP; + private string _ClientNick; + private byte[] data; + private bool ReceiveNick = true; + + public ChatClient(TcpClient client) + { + _client = client; + _clientIP = client.Client.RemoteEndPoint.ToString(); + AllClients.Add(_clientIP, this); + + data = new byte[_client.ReceiveBufferSize]; + _client.GetStream().BeginRead(data, 0, System.Convert.ToInt32(_client.ReceiveBufferSize), ReceiveMessage, null); + } + + public void SendMessage(string message) + { + try + { + System.Net.Sockets.NetworkStream ns; + lock (_client.GetStream()) + { + ns = _client.GetStream(); + } + byte[] bytesToSend = System.Text.Encoding.ASCII.GetBytes(message); + ns.Write(bytesToSend, 0, bytesToSend.Length); + ns.Flush(); + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + } + } + + public void ReceiveMessage(IAsyncResult ar) + { + int bytesRead; + try + { + lock (_client.GetStream()) + { + bytesRead = _client.GetStream().EndRead(ar); + } + if (bytesRead < 1) + { + AllClients.Remove(_clientIP); + Broadcast(_ClientNick + " has left the chat."); + return; + } + else + { + string messageReceived = System.Text.Encoding.ASCII.GetString(data, 0, bytesRead); + if (ReceiveNick) + { + _ClientNick = messageReceived; + Broadcast(_ClientNick + " has joined the chat."); + ReceiveNick = false; + } + else + { + Broadcast(_ClientNick + ">" + messageReceived); + } + } + lock (_client.GetStream()) + { + _client.GetStream().BeginRead(data, 0, System.Convert.ToInt32(_client.ReceiveBufferSize),ReceiveMessage, null); + } + } + catch (Exception ex) + { + AllClients.Remove(_clientIP); + Broadcast(_ClientNick + " has left the chat."); + } + } + public void Broadcast(string message) + { + Console.WriteLine(message); + foreach (DictionaryEntry c in AllClients) + { + ((ChatClient)(c.Value)).SendMessage(message + Environment.NewLine); + } + } + } +} diff --git a/Chapter01(Socket)/Part 1/server_CS/server_CS/Program.cs b/Chapter01(Socket)/Part 1/server_CS/server_CS/Program.cs new file mode 100644 index 0000000..75ff94f --- /dev/null +++ b/Chapter01(Socket)/Part 1/server_CS/server_CS/Program.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using System.Net.Sockets; + +namespace server_CS +{ + class Program + { + const int portNo = 500; + static void Main(string[] args) + { + System.Net.IPAddress localAdd = System.Net.IPAddress.Parse("127.0.0.1"); + TcpListener listener = new TcpListener(localAdd, portNo); + listener.Start(); + while (true) + { + ChatClient user = new ChatClient(listener.AcceptTcpClient()); + } + } + } +} diff --git a/Chapter01(Socket)/Part 1/server_CS/server_CS/Properties/AssemblyInfo.cs b/Chapter01(Socket)/Part 1/server_CS/server_CS/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c02c11d --- /dev/null +++ b/Chapter01(Socket)/Part 1/server_CS/server_CS/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("server_CS")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("server_CS")] +[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("b1825a4b-8cb0-4ac9-b622-08605a30e817")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Chapter01(Socket)/Part 1/server_CS/server_CS/bin/Debug/server_CS.exe b/Chapter01(Socket)/Part 1/server_CS/server_CS/bin/Debug/server_CS.exe new file mode 100644 index 0000000..64d9767 Binary files /dev/null and b/Chapter01(Socket)/Part 1/server_CS/server_CS/bin/Debug/server_CS.exe differ diff --git a/Chapter01(Socket)/Part 1/server_CS/server_CS/bin/Debug/server_CS.pdb b/Chapter01(Socket)/Part 1/server_CS/server_CS/bin/Debug/server_CS.pdb new file mode 100644 index 0000000..d54f376 Binary files /dev/null and b/Chapter01(Socket)/Part 1/server_CS/server_CS/bin/Debug/server_CS.pdb differ diff --git a/Chapter01(Socket)/Part 1/server_CS/server_CS/bin/Debug/server_CS.vshost.exe b/Chapter01(Socket)/Part 1/server_CS/server_CS/bin/Debug/server_CS.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter01(Socket)/Part 1/server_CS/server_CS/bin/Debug/server_CS.vshost.exe differ diff --git a/Chapter01(Socket)/Part 1/server_CS/server_CS/obj/Debug/server_CS.exe b/Chapter01(Socket)/Part 1/server_CS/server_CS/obj/Debug/server_CS.exe new file mode 100644 index 0000000..64d9767 Binary files /dev/null and b/Chapter01(Socket)/Part 1/server_CS/server_CS/obj/Debug/server_CS.exe differ diff --git a/Chapter01(Socket)/Part 1/server_CS/server_CS/obj/Debug/server_CS.pdb b/Chapter01(Socket)/Part 1/server_CS/server_CS/obj/Debug/server_CS.pdb new file mode 100644 index 0000000..d54f376 Binary files /dev/null and b/Chapter01(Socket)/Part 1/server_CS/server_CS/obj/Debug/server_CS.pdb differ diff --git a/Chapter01(Socket)/Part 1/server_CS/server_CS/obj/server_CS.csproj.FileList.txt b/Chapter01(Socket)/Part 1/server_CS/server_CS/obj/server_CS.csproj.FileList.txt new file mode 100644 index 0000000..201e435 --- /dev/null +++ b/Chapter01(Socket)/Part 1/server_CS/server_CS/obj/server_CS.csproj.FileList.txt @@ -0,0 +1,5 @@ +bin\Debug\server_CS.exe +bin\Debug\server_CS.pdb +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\server_CS.exe +obj\Debug\server_CS.pdb diff --git a/Chapter01(Socket)/Part 1/server_CS/server_CS/server_CS.csproj b/Chapter01(Socket)/Part 1/server_CS/server_CS/server_CS.csproj new file mode 100644 index 0000000..cdae1fa --- /dev/null +++ b/Chapter01(Socket)/Part 1/server_CS/server_CS/server_CS.csproj @@ -0,0 +1,48 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {2D92EC13-47B0-44B3-9357-7C59D7AD57BB} + Exe + Properties + server_CS + server_CS + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient.sln b/Chapter01(Socket)/Part 2/WinClient/WinClient.sln new file mode 100644 index 0000000..05b6717 --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient/WinClient.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "WinClient", "WinClient\WinClient.vbproj", "{18BAFD43-9363-4F34-80A2-F5CB6DE70617}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {18BAFD43-9363-4F34-80A2-F5CB6DE70617}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {18BAFD43-9363-4F34-80A2-F5CB6DE70617}.Debug|Any CPU.Build.0 = Debug|Any CPU + {18BAFD43-9363-4F34-80A2-F5CB6DE70617}.Release|Any CPU.ActiveCfg = Release|Any CPU + {18BAFD43-9363-4F34-80A2-F5CB6DE70617}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient.suo b/Chapter01(Socket)/Part 2/WinClient/WinClient.suo new file mode 100644 index 0000000..8ebcd2e Binary files /dev/null and b/Chapter01(Socket)/Part 2/WinClient/WinClient.suo differ diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/Form1.Designer.vb b/Chapter01(Socket)/Part 2/WinClient/WinClient/Form1.Designer.vb new file mode 100644 index 0000000..c82f696 --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient/WinClient/Form1.Designer.vb @@ -0,0 +1,179 @@ +Partial Public Class Form1 + Inherits System.Windows.Forms.Form + + _ + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + End Sub + + 'Form overrides dispose to clean up the component list. + _ + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.txtMessageHistory = New System.Windows.Forms.TextBox + Me.txtMessage = New System.Windows.Forms.TextBox + Me.btnSend = New System.Windows.Forms.Button + Me.btnSignIn = New System.Windows.Forms.Button + Me.txtNick = New System.Windows.Forms.TextBox + Me.Label1 = New System.Windows.Forms.Label + Me.lstUsers = New System.Windows.Forms.ListBox + Me.btnFTP = New System.Windows.Forms.Button + Me.Label2 = New System.Windows.Forms.Label + Me.StatusStrip1 = New System.Windows.Forms.StatusStrip + Me.ToolStripStatusLabel1 = New System.Windows.Forms.ToolStripStatusLabel + Me.StatusStrip1.SuspendLayout() + Me.SuspendLayout() + ' + 'txtMessageHistory + ' + Me.txtMessageHistory.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.txtMessageHistory.BackColor = System.Drawing.SystemColors.ControlLightLight + Me.txtMessageHistory.Location = New System.Drawing.Point(128, 43) + Me.txtMessageHistory.Multiline = True + Me.txtMessageHistory.Name = "txtMessageHistory" + Me.txtMessageHistory.ReadOnly = True + Me.txtMessageHistory.ScrollBars = System.Windows.Forms.ScrollBars.Vertical + Me.txtMessageHistory.Size = New System.Drawing.Size(304, 186) + Me.txtMessageHistory.TabIndex = 0 + ' + 'txtMessage + ' + Me.txtMessage.Anchor = CType(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.txtMessage.Location = New System.Drawing.Point(2, 240) + Me.txtMessage.Name = "txtMessage" + Me.txtMessage.Size = New System.Drawing.Size(271, 20) + Me.txtMessage.TabIndex = 1 + ' + 'btnSend + ' + Me.btnSend.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.btnSend.Enabled = False + Me.btnSend.Location = New System.Drawing.Point(276, 238) + Me.btnSend.Name = "btnSend" + Me.btnSend.Size = New System.Drawing.Size(75, 23) + Me.btnSend.TabIndex = 2 + Me.btnSend.Text = "Send" + ' + 'btnSignIn + ' + Me.btnSignIn.Location = New System.Drawing.Point(357, 2) + Me.btnSignIn.Name = "btnSignIn" + Me.btnSignIn.Size = New System.Drawing.Size(75, 23) + Me.btnSignIn.TabIndex = 3 + Me.btnSignIn.Text = "Sign In" + ' + 'txtNick + ' + Me.txtNick.Location = New System.Drawing.Point(34, 4) + Me.txtNick.Name = "txtNick" + Me.txtNick.Size = New System.Drawing.Size(317, 20) + Me.txtNick.TabIndex = 4 + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(-1, 7) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(29, 13) + Me.Label1.TabIndex = 5 + Me.Label1.Text = "Nick" + ' + 'lstUsers + ' + Me.lstUsers.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) + Me.lstUsers.FormattingEnabled = True + Me.lstUsers.Location = New System.Drawing.Point(2, 43) + Me.lstUsers.Name = "lstUsers" + Me.lstUsers.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended + Me.lstUsers.Size = New System.Drawing.Size(120, 186) + Me.lstUsers.TabIndex = 6 + ' + 'btnFTP + ' + Me.btnFTP.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.btnFTP.Location = New System.Drawing.Point(357, 238) + Me.btnFTP.Name = "btnFTP" + Me.btnFTP.Size = New System.Drawing.Size(75, 23) + Me.btnFTP.TabIndex = 7 + Me.btnFTP.Text = "Send File" + ' + 'Label2 + ' + Me.Label2.AutoSize = True + Me.Label2.Location = New System.Drawing.Point(-1, 27) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(65, 13) + Me.Label2.TabIndex = 8 + Me.Label2.Text = "Online users" + ' + 'StatusStrip1 + ' + Me.StatusStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripStatusLabel1}) + Me.StatusStrip1.Location = New System.Drawing.Point(0, 263) + Me.StatusStrip1.Name = "StatusStrip1" + Me.StatusStrip1.Size = New System.Drawing.Size(436, 22) + Me.StatusStrip1.TabIndex = 9 + Me.StatusStrip1.Text = "StatusStrip1" + ' + 'ToolStripStatusLabel1 + ' + Me.ToolStripStatusLabel1.Name = "ToolStripStatusLabel1" + Me.ToolStripStatusLabel1.Size = New System.Drawing.Size(111, 17) + Me.ToolStripStatusLabel1.Text = "ToolStripStatusLabel1" + ' + 'Form1 + ' + Me.AcceptButton = Me.btnSend + Me.ClientSize = New System.Drawing.Size(436, 285) + Me.Controls.Add(Me.StatusStrip1) + Me.Controls.Add(Me.Label2) + Me.Controls.Add(Me.btnFTP) + Me.Controls.Add(Me.lstUsers) + Me.Controls.Add(Me.Label1) + Me.Controls.Add(Me.txtNick) + Me.Controls.Add(Me.btnSignIn) + Me.Controls.Add(Me.btnSend) + Me.Controls.Add(Me.txtMessage) + Me.Controls.Add(Me.txtMessageHistory) + Me.Name = "Form1" + Me.Text = "Chat Client" + Me.StatusStrip1.ResumeLayout(False) + Me.StatusStrip1.PerformLayout() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents txtMessageHistory As System.Windows.Forms.TextBox + Friend WithEvents txtMessage As System.Windows.Forms.TextBox + Friend WithEvents btnSend As System.Windows.Forms.Button + Friend WithEvents btnSignIn As System.Windows.Forms.Button + Friend WithEvents txtNick As System.Windows.Forms.TextBox + Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents lstUsers As System.Windows.Forms.ListBox + Friend WithEvents btnFTP As System.Windows.Forms.Button + Friend WithEvents Label2 As System.Windows.Forms.Label + Friend WithEvents StatusStrip1 As System.Windows.Forms.StatusStrip + Friend WithEvents ToolStripStatusLabel1 As System.Windows.Forms.ToolStripStatusLabel + +End Class diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/Form1.resx b/Chapter01(Socket)/Part 2/WinClient/WinClient/Form1.resx new file mode 100644 index 0000000..faac01d --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient/WinClient/Form1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/Form1.vb b/Chapter01(Socket)/Part 2/WinClient/WinClient/Form1.vb new file mode 100644 index 0000000..ec490ac --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient/WinClient/Form1.vb @@ -0,0 +1,429 @@ +Imports System.Net.Sockets +Imports System.IO + +Public Class Form1 + + '*************************************************************************************************** + Private partialStr As String + '*************************************************************************************************** + + '---get own IP address + Private ips As Net.IPHostEntry = _ + Net.Dns.GetHostEntry(Net.Dns.GetHostName()) + + '---port nos and server IP address + Const PORTNO As Integer = 500 + Const FTPPORTNO As Integer = 501 + Const SERVERIP As String = "127.0.0.1" + 'Const SERVERIP As String = "10.0.1.2" + + Private client As TcpClient + '--used for sending and receiving data + Private data() As Byte + + '---for FTP use + Private fs As System.IO.FileStream + Private filename As String + Private fullfilename As String + + '---Send Button + Private Sub btnSend_Click( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles btnSend.Click + ' e.g. [Talk][User2,User3,etc]User1>Hello world! + + '---select users to chat + If lstUsers.SelectedItems.Count < 1 Then + MsgBox("You must select who to chat with.") + Exit Sub + End If + + '---formulate the message + Dim Message As String = "[Talk][" + + '---check who to chat with + Dim user As Object + For Each user In lstUsers.SelectedItems + Message += user & "," + Next + Message += "]" & txtNick.Text & ">" & txtMessage.Text + + '---update the message history + txtMessageHistory.Text += txtNick.Text & _ + ">" & txtMessage.Text & vbCrLf + + '---send message + SendMessage(Message) + txtMessage.Clear() + End Sub + + '---Sends the message to the server + Public Sub SendMessage(ByVal message As String) + '---adds a carriage return char--- + message += vbLf + Try + '---send the text + Dim ns As System.Net.Sockets.NetworkStream + SyncLock client.GetStream + ns = client.GetStream + Dim bytesToSend As Byte() = _ + System.Text.Encoding.ASCII.GetBytes(message) + + '---sends the text--- + ns.Write(bytesToSend, 0, bytesToSend.Length) + End SyncLock + Catch ex As Exception + MsgBox(ex.ToString) + End Try + End Sub + + '---Receives a message from the server + Public Sub ReceiveMessage(ByVal ar As IAsyncResult) + Try + Dim bytesRead As Integer + bytesRead = client.GetStream.EndRead(ar) + If bytesRead < 1 Then + Exit Sub + Else + '****************************************************************************** + 'Dim messageReceived As String = _ + ' System.Text.Encoding.ASCII.GetString( _ + ' data, 0, bytesRead) + ''---update the message history + 'Dim para() As Object = {messageReceived} + 'Me.Invoke(New delUpdateHistory(AddressOf Me.UpdateHistory), para) + '------------------------------------------------------------------------------ + + 'e.g. [Talk][user1,]user2>Hello*LF*[Talk][user2,]user1>Hello back*LF**0* + 'e.g. [Talk][user1,]user2>Hello*LF*[Talk]*0* + 'e.g. [user2,]user1>Hello back*LF**0* + + '*************************************************************************************************** + Dim messageReceived As String + Dim i As Integer = 0 + Dim start As Integer = 0 + '---loop until no more chars--- + While data(i) <> 0 + + '---do not scan more than what is read--- + If i + 1 > bytesRead Then Exit While + + '---if LF is detected--- + If data(i) = 10 Then + messageReceived = _ + partialStr & _ + System.Text.Encoding.ASCII.GetString(data, start, i - start) & _ + vbCrLf + '---update the message history + Dim para() As Object = {messageReceived} + Me.Invoke(New delUpdateHistory(AddressOf Me.UpdateHistory), para) + start = i + 1 + End If + i += 1 + End While + '---partial string--- + If start <> i Then + partialStr = System.Text.Encoding.ASCII.GetString(data, start, i - start) + End If + '*************************************************************************************************** + End If + + '---continue reading for more data + client.GetStream.BeginRead(data, 0, _ + CInt(client.ReceiveBufferSize), _ + AddressOf ReceiveMessage, Nothing) + Catch ex As Exception + MsgBox(ex.ToString) + End Try + End Sub + + '--Sign in to server--- + Private Sub btnSignIn_Click( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles btnSignIn.Click + If btnSignIn.Text = "Sign In" Then + + '---Sign in to the server + Try + client = New TcpClient + ' client.NoDelay = True + + '---connect to the server + client.Connect(SERVERIP, PORTNO) + ReDim data(client.ReceiveBufferSize - 1) + '---inform the server of your nick name--- + ' e.g. [Join][User1] + SendMessage("[Join][" & txtNick.Text & "]") + + '---begin reading data asynchronously from the server + client.GetStream.BeginRead( _ + data, 0, CInt(client.ReceiveBufferSize), _ + AddressOf ReceiveMessage, Nothing) + + '---change the button and textbox + btnSignIn.Text = "Sign Out" + btnSend.Enabled = True + txtNick.Enabled = False + + '---get all users connected + ' e.g. [Usrs] + System.Threading.Thread.Sleep(500) + SendMessage("[Usrs]") + + Catch ex As Exception + MsgBox(ex.ToString) + End Try + Else + '---Sign off from the server + Disconnect() + lstUsers.Items.Clear() + + '---change the button and textbox + btnSignIn.Text = "Sign In" + btnSend.Enabled = False + txtNick.Enabled = True + End If + End Sub + + '---disconnect from the server + Public Sub Disconnect() + Try + client.GetStream.Close() + client.Close() + Catch ex As Exception + MsgBox(ex.ToString) + End Try + End Sub + + '---delegate to update the textboxes in the main thread + Public Delegate Sub delUpdateHistory(ByVal str As String) + Public Sub UpdateHistory(ByVal str As String) + + If str.StartsWith("[Join]") Then + 'e.g. [Join][User1] + + '---extract user's name + Dim nameLength As Integer = str.IndexOf("]", 6) + + '---display in the ListBox + lstUsers.Items.Add(str.Substring(7, nameLength - 7)) + Exit Sub + + ElseIf str.StartsWith("[Left]") Then + 'e.g. [Left][User1] + + '---extract user's name + Dim nameLength As Integer = str.IndexOf("]", 6) + + '---remove the user from the listbox + Try + lstUsers.Items.RemoveAt( _ + lstUsers.Items.IndexOf( _ + str.Substring(7, nameLength - 7))) + Catch ex As Exception + End Try + Exit Sub + + ElseIf str.StartsWith("[Usrs]") Then + 'e.g. [Usrs][User1,User2,User3,etc] + + '---extract the user names + Dim users() As String = _ + str.Substring(7, str.Length - 8).Split(",") + + Dim user As String + lstUsers.Items.Clear() + '---add the user to ListBox + For Each user In users + lstUsers.Items.Add(user) + Next + '---remove the last empty user + lstUsers.Items.RemoveAt(lstUsers.Items.Count - 1) + Exit Sub + + ElseIf str.StartsWith("[File]") Then + 'e.g. [File][User1][Filename.ext] + + '---get user name + Dim users() As String = _ + str.Substring(7, str.IndexOf("]", 7) - 7).Split(",") + + '---extract file name + Dim index As Integer = str.IndexOf("]", 7) + 2 + Dim filename As String = str.Substring(index, str.Length - index - 3) + + '---prompt the user + Dim response As MsgBoxResult + response = MsgBox("Do you want to download the file " & filename, MsgBoxStyle.YesNo) + + '---proceed with download + If response = MsgBoxResult.Yes Then + '---tell the client that he can proceed to send the file + ' e.g. [Send_File][User1,User2] + SendMessage("[Send_File][" & users(0) & "," & txtNick.Text & "]") + + '---start the FTP process + FTP_Receive(filename) + End If + Exit Sub + + ElseIf str.StartsWith("[Send_File]") Then + 'e.g. [Send_File][1.2.3.4] + + '---extract the IP address of file recipient + Dim userIP As String = str.Substring(12, str.Length - 15) + '---start the FTP process + FTP_Send(fullfilename, userIP) + Exit Sub + + ElseIf str.StartsWith("[Talk]") Then + + ' Dim users() As String = str.Substring(7, str.IndexOf("]", 7) - 7).Split(",") + ' lstUsers.SelectedItem = lstUsers.Items.IndexOf(users(0)) + + '---display the message in the textbox + str = str.Substring(str.IndexOf("]", 7) + 1) + txtMessageHistory.AppendText(str) + End If + + End Sub + + Private Sub Form1_FormClosing( _ + ByVal sender As Object, _ + ByVal e As System.Windows.Forms.FormClosingEventArgs) _ + Handles Me.FormClosing + Disconnect() + End Sub + + '---Send File button + Private Sub btnFTP_Click( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles btnFTP.Click + + '---formulate the message + '---e.g. [FILE][User1,User2,User3,][Filename.ext] + Dim Message As String = "[File][" & txtNick.Text & "," + Dim user As Object + If lstUsers.SelectedItems.Count < 1 Then + MsgBox("You must select who to send to.") + Exit Sub + End If + + '---check who to send to + For Each user In lstUsers.SelectedItems + Message += user & "," + Next + + '---select the file to send + Dim openFileDialog1 As New OpenFileDialog() + + openFileDialog1.InitialDirectory = "c:\" + openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" + openFileDialog1.FilterIndex = 2 + openFileDialog1.RestoreDirectory = True + + If openFileDialog1.ShowDialog() = DialogResult.OK Then + fullfilename = openFileDialog1.FileName + filename = fullfilename.Substring(fullfilename.LastIndexOf("\") + 1) + + Message += "][" & filename & "]" + SendMessage(Message) + End If + '---------------------------- + End Sub + + '---FTP process - Send file + Public Sub FTP_Send( _ + ByVal filename As String, _ + ByVal recipientIP As String) + + '---connect to the recipient + Dim tcpClient As New System.Net.Sockets.TcpClient + tcpClient.Connect(recipientIP, FTPPORTNO) + Dim BufferSize As Integer = tcpClient.ReceiveBufferSize + Dim nws As NetworkStream = tcpClient.GetStream + + '---open the file + Dim fs As FileStream + fs = New FileStream(filename, FileMode.Open, _ + FileAccess.Read) + + Dim bytesToSend(fs.Length - 1) As Byte + Dim numBytesRead As Integer = fs.Read(bytesToSend, _ + 0, bytesToSend.Length) + + Dim totalBytes As Integer = 0 + For i As Integer = 0 To fs.Length \ BufferSize + '---send the file + If fs.Length - (i * BufferSize) > BufferSize Then + nws.Write(bytesToSend, i * BufferSize, BufferSize) + totalBytes += BufferSize + Else + nws.Write(bytesToSend, i * _ + BufferSize, fs.Length - (i * BufferSize)) + totalBytes += fs.Length - (i * BufferSize) + End If + '--update the status label + ToolStripStatusLabel1.Text = _ + "Sending " & totalBytes & " bytes...." + Application.DoEvents() + Next + ToolStripStatusLabel1.Text = _ + "Sending " & totalBytes & " bytes....Done." + fs.Close() + tcpClient.Close() + End Sub + + '---FTP Process = Receive Files + Public Sub FTP_Receive(ByVal filename As String) + + Try + '---get the local IP address + Dim localAdd As System.Net.IPAddress = _ + System.Net.IPAddress.Parse(ips.AddressList(0).ToString) + + '---start listening for incoming connection + Dim listener As New _ + System.Net.Sockets.TcpListener(localAdd, FTPPORTNO) + listener.Start() + + '---read incoming stream + Dim tcpClient As TcpClient = listener.AcceptTcpClient() + Dim nws As NetworkStream = tcpClient.GetStream + + '---delete the file if it exists + If File.Exists("c:\temp\" & filename) Then + File.Delete("c:\temp\" & filename) + End If + + '---create the file + fs = New System.IO.FileStream("c:\temp\" & filename, _ + FileMode.Append, FileAccess.Write) + + Dim counter As Integer = 0 + Dim totalBytes As Integer = 0 + Do + '---read the incoming data + Dim bytesRead As Integer = _ + nws.Read(data, 0, tcpClient.ReceiveBufferSize) + totalBytes += bytesRead + fs.Write(data, 0, bytesRead) + + '--update the status label + ToolStripStatusLabel1.Text = "Receiving " & totalBytes & " bytes...." + Application.DoEvents() + counter += 1 + Loop Until Not nws.DataAvailable + ToolStripStatusLabel1.Text = "Receiving " & totalBytes & " bytes....Done." + fs.Close() + tcpClient.Close() + listener.Stop() + Catch ex As Exception + MsgBox(ex.ToString) + End Try + End Sub + +End Class + diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/My Project/AssemblyInfo.vb b/Chapter01(Socket)/Part 2/WinClient/WinClient/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..76041b3 --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient/WinClient/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + + diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/My Project/MyApplication.myapp b/Chapter01(Socket)/Part 2/WinClient/WinClient/My Project/MyApplication.myapp new file mode 100644 index 0000000..17c28e4 --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient/WinClient/My Project/MyApplication.myapp @@ -0,0 +1,10 @@ + + + true + WinClient.Form1 + false + 0 + true + 0 + 0 + diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/My Project/MyApplication.vb b/Chapter01(Socket)/Part 2/WinClient/WinClient/My Project/MyApplication.vb new file mode 100644 index 0000000..e9ad238 --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient/WinClient/My Project/MyApplication.vb @@ -0,0 +1,23 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + Partial Class MyApplication + + + Protected Overrides Sub OnCreateMainForm() + Me.MainForm = My.Forms.Form1 + End Sub + End Class +End Namespace diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/My Project/MyEvents.vb b/Chapter01(Socket)/Part 2/WinClient/WinClient/My Project/MyEvents.vb new file mode 100644 index 0000000..d67825f --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient/WinClient/My Project/MyEvents.vb @@ -0,0 +1,15 @@ +Namespace My + + 'Use the editor window dropdowns in the Application pane of the Project Designer to handle MyApplication Events + ' + 'Startup: Raised when the application starts, before the startup form is created. + 'Shutdown: Raised after all application forms are closed. This event is not raised if the application is terminating abnormally. + 'UnhandledException: Raised if the application encounters an unhandled exception. + 'StartupNextInstance: Raised when launching a single-instance application and the application is already active. + 'NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected. + + Partial Friend Class MyApplication + + End Class + +End Namespace diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/My Project/MyResources.resx b/Chapter01(Socket)/Part 2/WinClient/WinClient/My Project/MyResources.resx new file mode 100644 index 0000000..3e18af9 --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient/WinClient/My Project/MyResources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/My Project/MyResources.vb b/Chapter01(Socket)/Part 2/WinClient/WinClient/My Project/MyResources.vb new file mode 100644 index 0000000..250357e --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient/WinClient/My Project/MyResources.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict Off +Option Explicit On + +Imports System +Imports System.IO +Imports System.Resources + +Namespace My.Resources + + ' + ' A strongly-typed resource class, for looking up localized strings, etc. + ' + 'This class was auto-generated by the Strongly Typed Resource Builder + 'class via a tool like ResGen or Visual Studio.NET. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + _ + Module MyResources + + Private _resMgr As System.Resources.ResourceManager + + Private _resCulture As System.Globalization.CultureInfo + + ' + ' Returns the cached ResourceManager instance used by this class. + ' + _ + Public ReadOnly Property ResourceManager() As System.Resources.ResourceManager + Get + If (_resMgr Is Nothing) Then + Dim temp As System.Resources.ResourceManager = New System.Resources.ResourceManager("WinClient.MyResources", GetType(MyResources).Assembly) + System.Threading.Thread.MemoryBarrier + _resMgr = temp + End If + Return _resMgr + End Get + End Property + + ' + ' Overrides the current thread's CurrentUICulture property for all + ' resource lookups using this strongly typed resource class. + ' + _ + Public Property Culture() As System.Globalization.CultureInfo + Get + Return _resCulture + End Get + Set + _resCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/My Project/MySettings.settings b/Chapter01(Socket)/Part 2/WinClient/WinClient/My Project/MySettings.settings new file mode 100644 index 0000000..0bcb11d --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient/WinClient/My Project/MySettings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/My Project/MySettings.vb b/Chapter01(Socket)/Part 2/WinClient/WinClient/My Project/MySettings.vb new file mode 100644 index 0000000..3d12c6f --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient/WinClient/My Project/MySettings.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict Off +Option Explicit On + + + +Partial Friend NotInheritable Class MySettings + Inherits System.Configuration.ApplicationSettingsBase + + Private Shared m_Value As MySettings + + Private Shared m_SyncObject As Object = New Object + + _ + Public Shared ReadOnly Property Value() As MySettings + Get + If (MySettings.m_Value Is Nothing) Then + System.Threading.Monitor.Enter(MySettings.m_SyncObject) + If (MySettings.m_Value Is Nothing) Then + Try + MySettings.m_Value = New MySettings + Finally + System.Threading.Monitor.Exit(MySettings.m_SyncObject) + End Try + End If + End If + Return MySettings.m_Value + End Get + End Property +End Class diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/WinClient.vbproj b/Chapter01(Socket)/Part 2/WinClient/WinClient/WinClient.vbproj new file mode 100644 index 0000000..82a36e3 --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient/WinClient/WinClient.vbproj @@ -0,0 +1,95 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {18BAFD43-9363-4F34-80A2-F5CB6DE70617} + WinExe + WinClient.My.MyApplication + WinClient + WinClient + WindowsForms + + + true + full + true + true + bin\ + WinClient.xml + 42016,42017,42018,42019,42032 + + + pdbonly + false + true + true + bin\ + WinClient.xml + 42016,42017,42018,42019,42032 + + + + + + + + + + + + + + + + + + Form + + + Form1.vb + Form + + + + True + MyApplication.myapp + + + True + True + MyResources.resx + + + True + MySettings.settings + True + + + + + + Form1.vb + Designer + + + VbMyResourcesResXFileCodeGenerator + MyResources.vb + My.Resources + Designer + + + + + + MyApplicationCodeGenerator + MyApplication.vb + + + SettingsSingleFileGenerator + MySettings.vb + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/WinClient.vbproj.user b/Chapter01(Socket)/Part 2/WinClient/WinClient/WinClient.vbproj.user new file mode 100644 index 0000000..f45750b --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient/WinClient/WinClient.vbproj.user @@ -0,0 +1,7 @@ + + + 8.0.41115 + ShowAllFiles + 0 + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/app.config b/Chapter01(Socket)/Part 2/WinClient/WinClient/app.config new file mode 100644 index 0000000..f636923 --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient/WinClient/app.config @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/bin/WinClient.exe b/Chapter01(Socket)/Part 2/WinClient/WinClient/bin/WinClient.exe new file mode 100644 index 0000000..ffbc585 Binary files /dev/null and b/Chapter01(Socket)/Part 2/WinClient/WinClient/bin/WinClient.exe differ diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/bin/WinClient.exe.config b/Chapter01(Socket)/Part 2/WinClient/WinClient/bin/WinClient.exe.config new file mode 100644 index 0000000..f636923 --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient/WinClient/bin/WinClient.exe.config @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/bin/WinClient.pdb b/Chapter01(Socket)/Part 2/WinClient/WinClient/bin/WinClient.pdb new file mode 100644 index 0000000..5941b09 Binary files /dev/null and b/Chapter01(Socket)/Part 2/WinClient/WinClient/bin/WinClient.pdb differ diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/bin/WinClient.vshost.exe b/Chapter01(Socket)/Part 2/WinClient/WinClient/bin/WinClient.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter01(Socket)/Part 2/WinClient/WinClient/bin/WinClient.vshost.exe differ diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/bin/WinClient.vshost.exe.config b/Chapter01(Socket)/Part 2/WinClient/WinClient/bin/WinClient.vshost.exe.config new file mode 100644 index 0000000..f636923 --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient/WinClient/bin/WinClient.vshost.exe.config @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/bin/WinClient.xml b/Chapter01(Socket)/Part 2/WinClient/WinClient/bin/WinClient.xml new file mode 100644 index 0000000..3a4f94d --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient/WinClient/bin/WinClient.xml @@ -0,0 +1,11 @@ + + + + +WinClient + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/obj/Debug/WinClient.Form1.resources b/Chapter01(Socket)/Part 2/WinClient/WinClient/obj/Debug/WinClient.Form1.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter01(Socket)/Part 2/WinClient/WinClient/obj/Debug/WinClient.Form1.resources differ diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/obj/Debug/WinClient.MyResources.resources b/Chapter01(Socket)/Part 2/WinClient/WinClient/obj/Debug/WinClient.MyResources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter01(Socket)/Part 2/WinClient/WinClient/obj/Debug/WinClient.MyResources.resources differ diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/obj/Debug/WinClient.exe b/Chapter01(Socket)/Part 2/WinClient/WinClient/obj/Debug/WinClient.exe new file mode 100644 index 0000000..ffbc585 Binary files /dev/null and b/Chapter01(Socket)/Part 2/WinClient/WinClient/obj/Debug/WinClient.exe differ diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/obj/Debug/WinClient.pdb b/Chapter01(Socket)/Part 2/WinClient/WinClient/obj/Debug/WinClient.pdb new file mode 100644 index 0000000..5941b09 Binary files /dev/null and b/Chapter01(Socket)/Part 2/WinClient/WinClient/obj/Debug/WinClient.pdb differ diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/obj/Debug/WinClient.vbproj.GenerateResource.Cache b/Chapter01(Socket)/Part 2/WinClient/WinClient/obj/Debug/WinClient.vbproj.GenerateResource.Cache new file mode 100644 index 0000000..8e32fa6 Binary files /dev/null and b/Chapter01(Socket)/Part 2/WinClient/WinClient/obj/Debug/WinClient.vbproj.GenerateResource.Cache differ diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/obj/Debug/WinClient.xml b/Chapter01(Socket)/Part 2/WinClient/WinClient/obj/Debug/WinClient.xml new file mode 100644 index 0000000..3a4f94d --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient/WinClient/obj/Debug/WinClient.xml @@ -0,0 +1,11 @@ + + + + +WinClient + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/WinClient/WinClient/obj/WinClient.vbproj.FileList.txt b/Chapter01(Socket)/Part 2/WinClient/WinClient/obj/WinClient.vbproj.FileList.txt new file mode 100644 index 0000000..58fdc52 --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient/WinClient/obj/WinClient.vbproj.FileList.txt @@ -0,0 +1,11 @@ +bin\WinClient.exe.config +bin\WinClient.exe +bin\WinClient.pdb +bin\WinClient.xml +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\WinClient.Form1.resources +obj\Debug\WinClient.MyResources.resources +obj\Debug\WinClient.vbproj.GenerateResource.Cache +obj\Debug\WinClient.exe +obj\Debug\WinClient.xml +obj\Debug\WinClient.pdb diff --git a/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS.sln b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS.sln new file mode 100644 index 0000000..0674a17 --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinClient_CS", "WinClient_CS\WinClient_CS.csproj", "{437052DC-F92B-4786-BCC7-ED672309B9BA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {437052DC-F92B-4786-BCC7-ED672309B9BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {437052DC-F92B-4786-BCC7-ED672309B9BA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {437052DC-F92B-4786-BCC7-ED672309B9BA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {437052DC-F92B-4786-BCC7-ED672309B9BA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS.suo b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS.suo new file mode 100644 index 0000000..a0859e5 Binary files /dev/null and b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS.suo differ diff --git a/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Form1.Designer.cs b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Form1.Designer.cs new file mode 100644 index 0000000..42b86be --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Form1.Designer.cs @@ -0,0 +1,190 @@ +namespace WinClient_CS +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.StatusStrip1 = new System.Windows.Forms.StatusStrip(); + this.ToolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); + this.Label2 = new System.Windows.Forms.Label(); + this.btnFTP = new System.Windows.Forms.Button(); + this.lstUsers = new System.Windows.Forms.ListBox(); + this.Label1 = new System.Windows.Forms.Label(); + this.txtNick = new System.Windows.Forms.TextBox(); + this.btnSignIn = new System.Windows.Forms.Button(); + this.btnSend = new System.Windows.Forms.Button(); + this.txtMessage = new System.Windows.Forms.TextBox(); + this.txtMessageHistory = new System.Windows.Forms.TextBox(); + this.StatusStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // StatusStrip1 + // + this.StatusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.ToolStripStatusLabel1}); + this.StatusStrip1.Location = new System.Drawing.Point(0, 263); + this.StatusStrip1.Name = "StatusStrip1"; + this.StatusStrip1.Size = new System.Drawing.Size(436, 22); + this.StatusStrip1.TabIndex = 19; + this.StatusStrip1.Text = "StatusStrip1"; + // + // ToolStripStatusLabel1 + // + this.ToolStripStatusLabel1.Name = "ToolStripStatusLabel1"; + this.ToolStripStatusLabel1.Size = new System.Drawing.Size(111, 17); + this.ToolStripStatusLabel1.Text = "ToolStripStatusLabel1"; + // + // Label2 + // + this.Label2.AutoSize = true; + this.Label2.Location = new System.Drawing.Point(0, 26); + this.Label2.Name = "Label2"; + this.Label2.Size = new System.Drawing.Size(65, 13); + this.Label2.TabIndex = 18; + this.Label2.Text = "Online users"; + // + // btnFTP + // + this.btnFTP.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnFTP.Location = new System.Drawing.Point(358, 237); + this.btnFTP.Name = "btnFTP"; + this.btnFTP.Size = new System.Drawing.Size(75, 23); + this.btnFTP.TabIndex = 17; + this.btnFTP.Text = "Send File"; + this.btnFTP.Click += new System.EventHandler(this.btnFTP_Click); + // + // lstUsers + // + this.lstUsers.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.lstUsers.FormattingEnabled = true; + this.lstUsers.Location = new System.Drawing.Point(3, 42); + this.lstUsers.Name = "lstUsers"; + this.lstUsers.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; + this.lstUsers.Size = new System.Drawing.Size(120, 186); + this.lstUsers.TabIndex = 16; + // + // Label1 + // + this.Label1.AutoSize = true; + this.Label1.Location = new System.Drawing.Point(0, 6); + this.Label1.Name = "Label1"; + this.Label1.Size = new System.Drawing.Size(29, 13); + this.Label1.TabIndex = 15; + this.Label1.Text = "Nick"; + // + // txtNick + // + this.txtNick.Location = new System.Drawing.Point(35, 3); + this.txtNick.Name = "txtNick"; + this.txtNick.Size = new System.Drawing.Size(317, 20); + this.txtNick.TabIndex = 14; + // + // btnSignIn + // + this.btnSignIn.Location = new System.Drawing.Point(358, 1); + this.btnSignIn.Name = "btnSignIn"; + this.btnSignIn.Size = new System.Drawing.Size(75, 23); + this.btnSignIn.TabIndex = 13; + this.btnSignIn.Text = "Sign In"; + this.btnSignIn.Click += new System.EventHandler(this.btnSignIn_Click); + // + // btnSend + // + this.btnSend.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnSend.Enabled = false; + this.btnSend.Location = new System.Drawing.Point(277, 237); + this.btnSend.Name = "btnSend"; + this.btnSend.Size = new System.Drawing.Size(75, 23); + this.btnSend.TabIndex = 12; + this.btnSend.Text = "Send"; + this.btnSend.Click += new System.EventHandler(this.btnSend_Click); + // + // txtMessage + // + this.txtMessage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtMessage.Location = new System.Drawing.Point(3, 239); + this.txtMessage.Name = "txtMessage"; + this.txtMessage.Size = new System.Drawing.Size(271, 20); + this.txtMessage.TabIndex = 11; + // + // txtMessageHistory + // + this.txtMessageHistory.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtMessageHistory.BackColor = System.Drawing.SystemColors.ControlLightLight; + this.txtMessageHistory.Location = new System.Drawing.Point(129, 42); + this.txtMessageHistory.Multiline = true; + this.txtMessageHistory.Name = "txtMessageHistory"; + this.txtMessageHistory.ReadOnly = true; + this.txtMessageHistory.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.txtMessageHistory.Size = new System.Drawing.Size(304, 186); + this.txtMessageHistory.TabIndex = 10; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(436, 285); + this.Controls.Add(this.StatusStrip1); + this.Controls.Add(this.Label2); + this.Controls.Add(this.btnFTP); + this.Controls.Add(this.lstUsers); + this.Controls.Add(this.Label1); + this.Controls.Add(this.txtNick); + this.Controls.Add(this.btnSignIn); + this.Controls.Add(this.btnSend); + this.Controls.Add(this.txtMessage); + this.Controls.Add(this.txtMessageHistory); + this.Name = "Form1"; + this.Text = "Chat Client"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form_Closing); + this.StatusStrip1.ResumeLayout(false); + this.StatusStrip1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + internal System.Windows.Forms.StatusStrip StatusStrip1; + internal System.Windows.Forms.ToolStripStatusLabel ToolStripStatusLabel1; + internal System.Windows.Forms.Label Label2; + internal System.Windows.Forms.Button btnFTP; + internal System.Windows.Forms.ListBox lstUsers; + internal System.Windows.Forms.Label Label1; + internal System.Windows.Forms.TextBox txtNick; + internal System.Windows.Forms.Button btnSignIn; + internal System.Windows.Forms.Button btnSend; + internal System.Windows.Forms.TextBox txtMessage; + internal System.Windows.Forms.TextBox txtMessageHistory; + } +} + diff --git a/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Form1.cs b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Form1.cs new file mode 100644 index 0000000..b6047c8 --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Form1.cs @@ -0,0 +1,319 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +using System.Net.Sockets; +using System.IO; + +namespace WinClient_CS +{ + public partial class Form1 : Form + { + private string partialStr; + private System.Net.IPHostEntry ips = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()); + const int PORTNO = 500; + const int FTPPORTNO = 501; + const string SERVERIP = "10.0.1.2"; + private TcpClient client; + private byte[] data; + private System.IO.FileStream fs; + private string filename; + private string fullfilename; + + public Form1() + { + InitializeComponent(); + } + + public void ReceiveMessage(IAsyncResult ar) + { + try + { + int bytesRead; + bytesRead = client.GetStream().EndRead(ar); + if (bytesRead < 1) + { + return; + } + else + { + string messageReceived; + int i = 0; + int start = 0; + while (data[i] != 0) + { + if (i + 1 > bytesRead) + { + break; + } + if (data[i] == 10) + { + messageReceived = partialStr + System.Text.Encoding.ASCII.GetString(data, start, i - start) + Environment.NewLine; + object[] para = { messageReceived }; + this.Invoke(new delUpdateHistory((this.UpdateHistory)), para); + start = i + 1; + } + i += 1; + } + + if (start != i) + { + partialStr = System.Text.Encoding.ASCII.GetString(data, start, i - start); + } + } + client.GetStream().BeginRead(data, 0, System.Convert.ToInt32(client.ReceiveBufferSize), ReceiveMessage, null); + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + } + + public void Disconnect() + { + try + { + client.GetStream().Close(); + client.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + } + + public void SendMessage(string message) + { + message += "\n"; + try + { + System.Net.Sockets.NetworkStream ns; + lock (client.GetStream()) + { + ns = client.GetStream(); + byte[] bytesToSend = System.Text.Encoding.ASCII.GetBytes(message); + ns.Write(bytesToSend, 0, bytesToSend.Length); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + } + + public delegate void delUpdateHistory(string str); + public void UpdateHistory(string str) + { + if (str.StartsWith("[Join]")) + { + int nameLength = str.IndexOf("]", 6); + lstUsers.Items.Add(str.Substring(7, nameLength - 7)); + return; + } + else if (str.StartsWith("[Left]")) + { + int nameLength = str.IndexOf("]", 6); + try + { + lstUsers.Items.RemoveAt(lstUsers.Items.IndexOf(str.Substring(7, nameLength - 7))); + } + catch (Exception ex) + { + } + return; + } + else if (str.StartsWith("[Usrs]")) + { + string[] users = str.Substring(7, str.Length - 8).Split(','); + lstUsers.Items.Clear(); + foreach (string user in users) + { + lstUsers.Items.Add(user); + } + lstUsers.Items.RemoveAt(lstUsers.Items.Count - 1); + return; + } + else if (str.StartsWith("[File]")) + { + string[] users = str.Substring(7, str.IndexOf("]", 7) - 7).Split(','); + int index = str.IndexOf("]", 7) + 2; + string filename = str.Substring(index, str.Length - index - 3); + DialogResult response; + response = MessageBox.Show("Do you want to download the file " + filename, "Download", MessageBoxButtons.YesNo); + if (response == DialogResult.Yes) + { + SendMessage("[Send_File][" + users[0] + "," + txtNick.Text + "]"); + FTP_Receive(filename); + } + return; + } + else if (str.StartsWith("[Send_File]")) + { + string userIP = str.Substring(12, str.Length - 15); + FTP_Send(fullfilename, userIP); + return; + } + else if (str.StartsWith("[Talk]")) + { + str = str.Substring(str.IndexOf("]", 7) + 1); + txtMessageHistory.AppendText(str); + } + } + + private void btnSignIn_Click(object sender, EventArgs e) + { + if (btnSignIn.Text == "Sign In") + { + try + { + client = new TcpClient(); + client.Connect(SERVERIP, PORTNO); + + data = new byte[client.ReceiveBufferSize]; + SendMessage("[Join][" + txtNick.Text + "]"); + client.GetStream().BeginRead(data, 0, System.Convert.ToInt32(client.ReceiveBufferSize), ReceiveMessage, null); + btnSignIn.Text = "Sign Out"; + btnSend.Enabled = true; + txtNick.Enabled = false; + System.Threading.Thread.Sleep(500); + SendMessage("[Usrs]"); + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + } + else + { + Disconnect(); + lstUsers.Items.Clear(); + btnSignIn.Text = "Sign In"; + btnSend.Enabled = false; + txtNick.Enabled = true; + } + } + + private void btnSend_Click(object sender, EventArgs e) + { + if (lstUsers.SelectedItems.Count < 1) + { + MessageBox.Show("You must select who to chat with."); + return; + } + string Message = "[Talk]["; + + foreach (object user in lstUsers.SelectedItems) + { + Message += user + ","; + } + Message += "]" + txtNick.Text + ">" + txtMessage.Text; + txtMessageHistory.Text += txtNick.Text + ">" + txtMessage.Text + Environment.NewLine; + SendMessage(Message); + txtMessage.Clear(); + } + + private void btnFTP_Click(object sender, EventArgs e) + { + string Message = "[File][" + txtNick.Text + ","; + + if (lstUsers.SelectedItems.Count < 1) + { + MessageBox.Show("You must select who to send to."); + return; + } + foreach (object user in lstUsers.SelectedItems) + { + Message += user + ","; + } + OpenFileDialog openFileDialog1 = new OpenFileDialog(); + openFileDialog1.InitialDirectory = "c:\\"; + openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; + openFileDialog1.FilterIndex = 2; + openFileDialog1.RestoreDirectory = true; + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + fullfilename = openFileDialog1.FileName; + filename = fullfilename.Substring(fullfilename.LastIndexOf("\\") + 1); + Message += "][" + filename + "]"; + SendMessage(Message); + } + + } + + public void FTP_Send(string filename, string recipientIP) + { + System.Net.Sockets.TcpClient tcpClient = new System.Net.Sockets.TcpClient(); + tcpClient.Connect(recipientIP, FTPPORTNO); + int BufferSize = tcpClient.ReceiveBufferSize; + NetworkStream nws = tcpClient.GetStream(); + FileStream fs; + fs = new FileStream(filename, FileMode.Open, FileAccess.Read); + byte[] bytesToSend = new byte[fs.Length]; + int numBytesRead = fs.Read(bytesToSend, 0, bytesToSend.Length); + int totalBytes = 0; + for (int i = 0; i <= fs.Length / BufferSize; i++) + { + if (fs.Length - (i * BufferSize) > BufferSize) + { + nws.Write(bytesToSend, i * BufferSize, BufferSize); + totalBytes += BufferSize; + } + else + { + nws.Write(bytesToSend, i * BufferSize, (int)fs.Length - (i * BufferSize)); + totalBytes += (int)fs.Length - (i * BufferSize); + } + ToolStripStatusLabel1.Text = "Sending " + totalBytes + " bytes...."; + Application.DoEvents(); + } + ToolStripStatusLabel1.Text = "Sending " + totalBytes + " bytes....Done."; + fs.Close(); + tcpClient.Close(); + } + + public void FTP_Receive(string filename) + { + try + { + System.Net.IPAddress localAdd = System.Net.IPAddress.Parse(ips.AddressList[0].ToString()); + System.Net.Sockets.TcpListener listener = new System.Net.Sockets.TcpListener(localAdd, FTPPORTNO); + listener.Start(); + TcpClient tcpClient = listener.AcceptTcpClient(); + NetworkStream nws = tcpClient.GetStream(); + if (File.Exists("c:\\temp\\" + filename)) + { + File.Delete("c:\\temp\\" + filename); + } + fs = new System.IO.FileStream("c:\\temp\\" + filename, FileMode.Append, FileAccess.Write); + int counter = 0; + int totalBytes = 0; + do + { + int bytesRead = nws.Read(data, 0, tcpClient.ReceiveBufferSize); + totalBytes += bytesRead; + fs.Write(data, 0, bytesRead); + ToolStripStatusLabel1.Text = "Receiving " + totalBytes + " bytes...."; + Application.DoEvents(); + counter += 1; + } while (!(!(nws.DataAvailable))); + ToolStripStatusLabel1.Text = "Receiving " + totalBytes + " bytes....Done."; + fs.Close(); + tcpClient.Close(); + listener.Stop(); + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + } + + private void Form_Closing(object sender, FormClosingEventArgs e) + { + Disconnect(); + } + } +} \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Form1.resx b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Form1.resx new file mode 100644 index 0000000..faac01d --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Form1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Program.cs b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Program.cs new file mode 100644 index 0000000..f2b9ee7 --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace WinClient_CS +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Properties/AssemblyInfo.cs b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..66feddb --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("WinClient_CS")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("WinClient_CS")] +[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("72f0bf7f-77aa-48f8-8b5f-1931b5155c4d")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Properties/Resources.Designer.cs b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Properties/Resources.Designer.cs new file mode 100644 index 0000000..a54b167 --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WinClient_CS.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WinClient_CS.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Properties/Resources.resx b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Properties/Settings.Designer.cs b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Properties/Settings.Designer.cs new file mode 100644 index 0000000..76414ec --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WinClient_CS.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Properties/Settings.settings b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/WinClient_CS.csproj b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/WinClient_CS.csproj new file mode 100644 index 0000000..d6a6450 --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/WinClient_CS.csproj @@ -0,0 +1,78 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {437052DC-F92B-4786-BCC7-ED672309B9BA} + WinExe + Properties + WinClient_CS + WinClient_CS + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + Form + + + Form1.cs + + + + + Designer + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/bin/Debug/WinClient_CS.exe b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/bin/Debug/WinClient_CS.exe new file mode 100644 index 0000000..7cfccc3 Binary files /dev/null and b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/bin/Debug/WinClient_CS.exe differ diff --git a/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/bin/Debug/WinClient_CS.pdb b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/bin/Debug/WinClient_CS.pdb new file mode 100644 index 0000000..73a1d6e Binary files /dev/null and b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/bin/Debug/WinClient_CS.pdb differ diff --git a/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/bin/Debug/WinClient_CS.vshost.exe b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/bin/Debug/WinClient_CS.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/bin/Debug/WinClient_CS.vshost.exe differ diff --git a/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.Form1.resources b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.Form1.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.Form1.resources differ diff --git a/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.Properties.Resources.resources b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.Properties.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.Properties.Resources.resources differ diff --git a/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.csproj.GenerateResource.Cache b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.csproj.GenerateResource.Cache new file mode 100644 index 0000000..48e9134 Binary files /dev/null and b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.csproj.GenerateResource.Cache differ diff --git a/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.exe b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.exe new file mode 100644 index 0000000..7cfccc3 Binary files /dev/null and b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.exe differ diff --git a/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.pdb b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.pdb new file mode 100644 index 0000000..73a1d6e Binary files /dev/null and b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/obj/Debug/WinClient_CS.pdb differ diff --git a/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/obj/WinClient_CS.csproj.FileList.txt b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/obj/WinClient_CS.csproj.FileList.txt new file mode 100644 index 0000000..8f7db2b --- /dev/null +++ b/Chapter01(Socket)/Part 2/WinClient_CS/WinClient_CS/obj/WinClient_CS.csproj.FileList.txt @@ -0,0 +1,8 @@ +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\WinClient_CS.Form1.resources +obj\Debug\WinClient_CS.Properties.Resources.resources +obj\Debug\WinClient_CS.csproj.GenerateResource.Cache +bin\Debug\WinClient_CS.exe +bin\Debug\WinClient_CS.pdb +obj\Debug\WinClient_CS.exe +obj\Debug\WinClient_CS.pdb diff --git a/Chapter01(Socket)/Part 2/server/server.sln b/Chapter01(Socket)/Part 2/server/server.sln new file mode 100644 index 0000000..c397be3 --- /dev/null +++ b/Chapter01(Socket)/Part 2/server/server.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "server", "server\server.vbproj", "{02784E52-3E62-4C83-A989-2C63C2368170}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {02784E52-3E62-4C83-A989-2C63C2368170}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {02784E52-3E62-4C83-A989-2C63C2368170}.Debug|Any CPU.Build.0 = Debug|Any CPU + {02784E52-3E62-4C83-A989-2C63C2368170}.Release|Any CPU.ActiveCfg = Release|Any CPU + {02784E52-3E62-4C83-A989-2C63C2368170}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter01(Socket)/Part 2/server/server.suo b/Chapter01(Socket)/Part 2/server/server.suo new file mode 100644 index 0000000..95dc293 Binary files /dev/null and b/Chapter01(Socket)/Part 2/server/server.suo differ diff --git a/Chapter01(Socket)/Part 2/server/server/ChatClient.vb b/Chapter01(Socket)/Part 2/server/server/ChatClient.vb new file mode 100644 index 0000000..6c63c67 --- /dev/null +++ b/Chapter01(Socket)/Part 2/server/server/ChatClient.vb @@ -0,0 +1,223 @@ +Imports System.Net.Sockets + +'---class to contain information of each client +Public Class ChatClient + + Private Const LF As Integer = 10 + + '---contains a list of all the clients + Public Shared AllClients As New Hashtable + + '---information about the client + Private _client As TcpClient + Private _clientIP As String + Private _clientNick As String + + '---used for sending/receiving data + Private data() As Byte + + '*************************************************************************************************** + Private partialStr As String + '*************************************************************************************************** + + '---when a client is connected + Public Sub New(ByVal client As TcpClient) + _client = client + + '---get the client IP address + _clientIP = client.Client.RemoteEndPoint.ToString + + '---add the current client to the hash table + AllClients.Add(_clientIP, Me) + + '---start reading data from the client in a separate thread + ReDim data(_client.ReceiveBufferSize - 1) + _client.GetStream.BeginRead(data, 0, _ + CInt(_client.ReceiveBufferSize), _ + AddressOf ReceiveMessage, Nothing) + End Sub + + '---send the message to the client + Public Sub SendMessage(ByVal message As String) + Try + '---send the text + Dim ns As System.Net.Sockets.NetworkStream + + SyncLock _client.GetStream + ns = _client.GetStream + Dim bytesToSend As Byte() = _ + System.Text.Encoding.ASCII.GetBytes(message) + ns.Write(bytesToSend, 0, bytesToSend.Length) + ns.Flush() + End SyncLock + + Catch ex As Exception + Console.WriteLine(ex.ToString) + End Try + End Sub + + '---receiving a message from the client + Public Sub ReceiveMessage(ByVal ar As IAsyncResult) + '---read from client--- + Dim bytesRead As Integer + Try + SyncLock _client.GetStream + bytesRead = _client.GetStream.EndRead(ar) + End SyncLock + '---client has disconnected + If bytesRead < 1 Then + AllClients.Remove(_clientIP) + Broadcast("[Left][" & _clientNick & _ + "] has left the chat.", Nothing) + Exit Sub + Else + '*************************************************************************************************** + Dim messageReceived As String + Dim i As Integer = 0 + Dim start As Integer = 0 + '---loop until no more chars--- + While data(i) <> 0 + + '---do not scan more than what is read--- + If i + 1 > bytesRead Then Exit While + + '---if LF is detected--- + If data(i) = LF Then + messageReceived = _ + partialStr & _ + System.Text.Encoding.ASCII.GetString(data, start, i - start) + '------------------------------------------------------------------------ + Console.WriteLine("received <----- " & messageReceived) + If messageReceived.StartsWith("[Join]") Then + '====client is sending its nickname==== + 'e.g. [Join][User1] + '---extract user's name--- + Dim nameLength As Integer = messageReceived.IndexOf("]", 6) + _clientNick = messageReceived.Substring(7, nameLength - 7) + '---tell everyone client has entered the chat--- + Broadcast(messageReceived, Nothing) + + ElseIf messageReceived.StartsWith("[Usrs]") Then + '===client is requesting for all users names=== + ' e.g. [Usrs] + '---get all the users--- + Dim allUsers As String = "[Usrs][" + Dim c As DictionaryEntry + For Each c In AllClients + '---get all the users' name--- + allUsers += _ + CType(c.Value, ChatClient)._clientNick & "," + Next + allUsers += "]" + 'e.g. [Usrs][User1,User2,etc] + Broadcast(allUsers, Nothing) + + ElseIf messageReceived.StartsWith("[Talk]") Then + '===Chatting with someone=== + 'e.g. [Talk][User2,User3]User1>Hello everyone! + '---get all users--- + Dim users() As String = _ + messageReceived.Substring(7, _ + messageReceived.IndexOf("]", 7) - 8).Split(",") + '---send to specified users--- + Broadcast(messageReceived, users) + + ElseIf messageReceived.StartsWith("[File]") Then + '===FTP request=== + 'e.g. [File][User1,User2][Filename.txt] + '---get all users--- + Dim users() As String = _ + messageReceived.Substring(7, _ + messageReceived.IndexOf("]", 7) - 8).Split(",") + Dim index As Integer = _ + messageReceived.IndexOf("]", 7) + 2 + Dim filename As String = _ + messageReceived.Substring(index, _ + messageReceived.Length - index - 1) + '---see who initiated the request--- + Dim from As String = users(0) + '---remove the first user (initiator)--- + For j As Integer = 1 To users.Length - 1 + users(j - 1) = users(j) + Next + users(users.Length - 1) = String.Empty + '---send to user--- + 'e.g. [File][User1][Filename.txt] + Broadcast("[File][" & from & "][" & filename & "]", users) + + ElseIf messageReceived.StartsWith("[Send_File]") Then + '===send file via FTP=== + ' e.g. [Send_File][User1,User2] + '---send file from User1 to User2--- + '---check send to who--- + Dim users() As String = _ + messageReceived.Substring(12, _ + messageReceived.IndexOf("]", 12) - 12).Split(",") + + Dim RecipientIP As String = String.Empty + '---find out the recipient's IP address--- + Dim c As DictionaryEntry + For Each c In AllClients + If CType(c.Value, ChatClient)._clientNick = users(1) Then + '---send message to user--- + RecipientIP = CType(c.Value, ChatClient). _ + _clientIP.Substring(0, _clientIP.IndexOf(":")) + Exit For + End If + Next + users(1) = String.Empty + 'e.g. [Send_File][1.2.3.4] + Broadcast("[Send_File][" & RecipientIP & "]", users) + End If + '------------------------------------------------------------------------ + start = i + 1 + End If + i += 1 + End While + '---partial string--- + If start <> i Then + partialStr = System.Text.Encoding.ASCII.GetString(data, start, i - start) + End If + '*************************************************************************************************** + End If + '---continue reading from client + SyncLock _client.GetStream + _client.GetStream.BeginRead(data, 0, _ + CInt(_client.ReceiveBufferSize), _ + AddressOf ReceiveMessage, Nothing) + End SyncLock + Catch ex As Exception + AllClients.Remove(_clientIP) + Broadcast("[Left][" & _clientNick & _ + "] has left the chat.", Nothing) + End Try + End Sub + + '---broadcast message to selected users + Public Sub Broadcast(ByVal message As String, ByVal users() As String) + + If users Is Nothing Then + '---broadcasting to everyone + Dim c As DictionaryEntry + For Each c In AllClients + '---broadcast message to all users + CType(c.Value, ChatClient).SendMessage(message & vbLf) + Next + Else + '---broadcasting to selected ones + Dim c As DictionaryEntry + For Each c In AllClients + Dim user As String + For Each user In users + If CType(c.Value, ChatClient)._clientNick = user Then + '---send message to user + CType(c.Value, ChatClient).SendMessage(message & vbLf) + '---log it locally + Console.WriteLine("sending -----> " & message) + Exit For + End If + Next + Next + End If + End Sub +End Class diff --git a/Chapter01(Socket)/Part 2/server/server/Module1.vb b/Chapter01(Socket)/Part 2/server/server/Module1.vb new file mode 100644 index 0000000..3a6113d --- /dev/null +++ b/Chapter01(Socket)/Part 2/server/server/Module1.vb @@ -0,0 +1,15 @@ +Imports System.Net.Sockets + +Module Module1 + Const portNo As Integer = 500 + + Sub Main() + Dim localAdd As System.Net.IPAddress = _ + System.Net.IPAddress.Parse("127.0.0.1") + Dim listener As New System.Net.Sockets.TcpListener(localAdd, portNo) + listener.Start() + While True + Dim user As New ChatClient(listener.AcceptTcpClient) + End While + End Sub +End Module diff --git a/Chapter01(Socket)/Part 2/server/server/My Project/AssemblyInfo.vb b/Chapter01(Socket)/Part 2/server/server/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..30e1c1e --- /dev/null +++ b/Chapter01(Socket)/Part 2/server/server/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + + diff --git a/Chapter01(Socket)/Part 2/server/server/My Project/MyApplication.myapp b/Chapter01(Socket)/Part 2/server/server/My Project/MyApplication.myapp new file mode 100644 index 0000000..76de46d --- /dev/null +++ b/Chapter01(Socket)/Part 2/server/server/My Project/MyApplication.myapp @@ -0,0 +1,9 @@ + + + false + false + 0 + true + 0 + 3 + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/server/server/My Project/MyApplication.vb b/Chapter01(Socket)/Part 2/server/server/My Project/MyApplication.vb new file mode 100644 index 0000000..0154603 --- /dev/null +++ b/Chapter01(Socket)/Part 2/server/server/My Project/MyApplication.vb @@ -0,0 +1,12 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/Chapter01(Socket)/Part 2/server/server/My Project/MyResources.resx b/Chapter01(Socket)/Part 2/server/server/My Project/MyResources.resx new file mode 100644 index 0000000..3e18af9 --- /dev/null +++ b/Chapter01(Socket)/Part 2/server/server/My Project/MyResources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/server/server/My Project/MyResources.vb b/Chapter01(Socket)/Part 2/server/server/My Project/MyResources.vb new file mode 100644 index 0000000..a8884f3 --- /dev/null +++ b/Chapter01(Socket)/Part 2/server/server/My Project/MyResources.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict Off +Option Explicit On + +Imports System +Imports System.IO +Imports System.Resources + +Namespace My.Resources + + ' + ' A strongly-typed resource class, for looking up localized strings, etc. + ' + 'This class was auto-generated by the Strongly Typed Resource Builder + 'class via a tool like ResGen or Visual Studio.NET. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + _ + Module MyResources + + Private _resMgr As System.Resources.ResourceManager + + Private _resCulture As System.Globalization.CultureInfo + + ' + ' Returns the cached ResourceManager instance used by this class. + ' + _ + Public ReadOnly Property ResourceManager() As System.Resources.ResourceManager + Get + If (_resMgr Is Nothing) Then + Dim temp As System.Resources.ResourceManager = New System.Resources.ResourceManager("$safeprojectname$.MyResources", GetType(MyResources).Assembly) + System.Threading.Thread.MemoryBarrier + _resMgr = temp + End If + Return _resMgr + End Get + End Property + + ' + ' Overrides the current thread's CurrentUICulture property for all + ' resource lookups using this strongly typed resource class. + ' + _ + Public Property Culture() As System.Globalization.CultureInfo + Get + Return _resCulture + End Get + Set + _resCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Chapter01(Socket)/Part 2/server/server/My Project/MySettings.settings b/Chapter01(Socket)/Part 2/server/server/My Project/MySettings.settings new file mode 100644 index 0000000..0bcb11d --- /dev/null +++ b/Chapter01(Socket)/Part 2/server/server/My Project/MySettings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/server/server/My Project/MySettings.vb b/Chapter01(Socket)/Part 2/server/server/My Project/MySettings.vb new file mode 100644 index 0000000..3d12c6f --- /dev/null +++ b/Chapter01(Socket)/Part 2/server/server/My Project/MySettings.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict Off +Option Explicit On + + + +Partial Friend NotInheritable Class MySettings + Inherits System.Configuration.ApplicationSettingsBase + + Private Shared m_Value As MySettings + + Private Shared m_SyncObject As Object = New Object + + _ + Public Shared ReadOnly Property Value() As MySettings + Get + If (MySettings.m_Value Is Nothing) Then + System.Threading.Monitor.Enter(MySettings.m_SyncObject) + If (MySettings.m_Value Is Nothing) Then + Try + MySettings.m_Value = New MySettings + Finally + System.Threading.Monitor.Exit(MySettings.m_SyncObject) + End Try + End If + End If + Return MySettings.m_Value + End Get + End Property +End Class diff --git a/Chapter01(Socket)/Part 2/server/server/app.config b/Chapter01(Socket)/Part 2/server/server/app.config new file mode 100644 index 0000000..f636923 --- /dev/null +++ b/Chapter01(Socket)/Part 2/server/server/app.config @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/server/server/bin/server.exe b/Chapter01(Socket)/Part 2/server/server/bin/server.exe new file mode 100644 index 0000000..1f61e5c Binary files /dev/null and b/Chapter01(Socket)/Part 2/server/server/bin/server.exe differ diff --git a/Chapter01(Socket)/Part 2/server/server/bin/server.exe.config b/Chapter01(Socket)/Part 2/server/server/bin/server.exe.config new file mode 100644 index 0000000..f636923 --- /dev/null +++ b/Chapter01(Socket)/Part 2/server/server/bin/server.exe.config @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/server/server/bin/server.pdb b/Chapter01(Socket)/Part 2/server/server/bin/server.pdb new file mode 100644 index 0000000..e3580ba Binary files /dev/null and b/Chapter01(Socket)/Part 2/server/server/bin/server.pdb differ diff --git a/Chapter01(Socket)/Part 2/server/server/bin/server.vshost.exe b/Chapter01(Socket)/Part 2/server/server/bin/server.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter01(Socket)/Part 2/server/server/bin/server.vshost.exe differ diff --git a/Chapter01(Socket)/Part 2/server/server/bin/server.vshost.exe.config b/Chapter01(Socket)/Part 2/server/server/bin/server.vshost.exe.config new file mode 100644 index 0000000..f636923 --- /dev/null +++ b/Chapter01(Socket)/Part 2/server/server/bin/server.vshost.exe.config @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/server/server/bin/server.xml b/Chapter01(Socket)/Part 2/server/server/bin/server.xml new file mode 100644 index 0000000..83af37a --- /dev/null +++ b/Chapter01(Socket)/Part 2/server/server/bin/server.xml @@ -0,0 +1,11 @@ + + + + +server + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/server/server/obj/Debug/server.MyResources.resources b/Chapter01(Socket)/Part 2/server/server/obj/Debug/server.MyResources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter01(Socket)/Part 2/server/server/obj/Debug/server.MyResources.resources differ diff --git a/Chapter01(Socket)/Part 2/server/server/obj/Debug/server.exe b/Chapter01(Socket)/Part 2/server/server/obj/Debug/server.exe new file mode 100644 index 0000000..1f61e5c Binary files /dev/null and b/Chapter01(Socket)/Part 2/server/server/obj/Debug/server.exe differ diff --git a/Chapter01(Socket)/Part 2/server/server/obj/Debug/server.pdb b/Chapter01(Socket)/Part 2/server/server/obj/Debug/server.pdb new file mode 100644 index 0000000..e3580ba Binary files /dev/null and b/Chapter01(Socket)/Part 2/server/server/obj/Debug/server.pdb differ diff --git a/Chapter01(Socket)/Part 2/server/server/obj/Debug/server.vbproj.GenerateResource.Cache b/Chapter01(Socket)/Part 2/server/server/obj/Debug/server.vbproj.GenerateResource.Cache new file mode 100644 index 0000000..625f780 Binary files /dev/null and b/Chapter01(Socket)/Part 2/server/server/obj/Debug/server.vbproj.GenerateResource.Cache differ diff --git a/Chapter01(Socket)/Part 2/server/server/obj/Debug/server.xml b/Chapter01(Socket)/Part 2/server/server/obj/Debug/server.xml new file mode 100644 index 0000000..83af37a --- /dev/null +++ b/Chapter01(Socket)/Part 2/server/server/obj/Debug/server.xml @@ -0,0 +1,11 @@ + + + + +server + + + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/server/server/obj/server.vbproj.FileList.txt b/Chapter01(Socket)/Part 2/server/server/obj/server.vbproj.FileList.txt new file mode 100644 index 0000000..c15a50b --- /dev/null +++ b/Chapter01(Socket)/Part 2/server/server/obj/server.vbproj.FileList.txt @@ -0,0 +1,10 @@ +bin\server.exe.config +bin\server.exe +bin\server.pdb +bin\server.xml +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\server.MyResources.resources +obj\Debug\server.vbproj.GenerateResource.Cache +obj\Debug\server.exe +obj\Debug\server.xml +obj\Debug\server.pdb diff --git a/Chapter01(Socket)/Part 2/server/server/server.vbproj b/Chapter01(Socket)/Part 2/server/server/server.vbproj new file mode 100644 index 0000000..e0d1e5e --- /dev/null +++ b/Chapter01(Socket)/Part 2/server/server/server.vbproj @@ -0,0 +1,84 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {02784E52-3E62-4C83-A989-2C63C2368170} + Exe + server.Module1 + server + server + Windows + + + true + full + true + true + bin\ + server.xml + 42016,42017,42018,42019,42032 + + + pdbonly + false + true + true + bin\ + server.xml + 42016,42017,42018,42019,42032 + + + + + + + + + + + + + + + + + + + + True + MyApplication.myapp + + + True + True + MyResources.resx + + + True + MySettings.settings + True + + + + + VbMyResourcesResXFileCodeGenerator + MyResources.vb + My.Resources + Designer + + + + + + MyApplicationCodeGenerator + MyApplication.vb + + + SettingsSingleFileGenerator + MySettings.vb + + + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/server/server/server.vbproj.user b/Chapter01(Socket)/Part 2/server/server/server.vbproj.user new file mode 100644 index 0000000..e1d33e3 --- /dev/null +++ b/Chapter01(Socket)/Part 2/server/server/server.vbproj.user @@ -0,0 +1,7 @@ + + + 8.0.41115 + ProjectFiles + 0 + + \ No newline at end of file diff --git a/Chapter01(Socket)/Part 2/server_CS/server_CS.sln b/Chapter01(Socket)/Part 2/server_CS/server_CS.sln new file mode 100644 index 0000000..d0aa25d --- /dev/null +++ b/Chapter01(Socket)/Part 2/server_CS/server_CS.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "server_CS", "server_CS\server_CS.csproj", "{CC62E1D7-8563-4AA9-A114-7D06FE082B32}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CC62E1D7-8563-4AA9-A114-7D06FE082B32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CC62E1D7-8563-4AA9-A114-7D06FE082B32}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CC62E1D7-8563-4AA9-A114-7D06FE082B32}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CC62E1D7-8563-4AA9-A114-7D06FE082B32}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter01(Socket)/Part 2/server_CS/server_CS.suo b/Chapter01(Socket)/Part 2/server_CS/server_CS.suo new file mode 100644 index 0000000..dc93316 Binary files /dev/null and b/Chapter01(Socket)/Part 2/server_CS/server_CS.suo differ diff --git a/Chapter01(Socket)/Part 2/server_CS/server_CS/ChatClient.cs b/Chapter01(Socket)/Part 2/server_CS/server_CS/ChatClient.cs new file mode 100644 index 0000000..824121c --- /dev/null +++ b/Chapter01(Socket)/Part 2/server_CS/server_CS/ChatClient.cs @@ -0,0 +1,176 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using System.Net.Sockets; +using System.Collections; + +namespace server_CS +{ + class ChatClient + { + const int LF = 10; + public static Hashtable AllClients = new Hashtable(); + private TcpClient _client; + private string _clientIP; + private string _clientNick; + private byte[] data; + private string partialStr; + + public ChatClient(TcpClient client) + { + _client = client; + _clientIP = client.Client.RemoteEndPoint.ToString(); + AllClients.Add(_clientIP, this); + data = new byte[_client.ReceiveBufferSize]; + _client.GetStream().BeginRead(data, 0, System.Convert.ToInt32(_client.ReceiveBufferSize), ReceiveMessage, null); + } + + public void SendMessage(string message) + { + try + { + System.Net.Sockets.NetworkStream ns; + lock (_client.GetStream()) + { + ns = _client.GetStream(); + byte[] bytesToSend = System.Text.Encoding.ASCII.GetBytes(message); + ns.Write(bytesToSend, 0, bytesToSend.Length); + ns.Flush(); + } + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + } + } + + public void ReceiveMessage(IAsyncResult ar) + { + int bytesRead; + try + { + lock (_client.GetStream()) + { + bytesRead = _client.GetStream().EndRead(ar); + } + if (bytesRead < 1) + { + AllClients.Remove(_clientIP); + Broadcast("[Left][" + _clientNick + "] has left the chat.", null); + return; + } + else + { + string messageReceived; + int i = 0; + int start = 0; + while (data[i] != 0) + { + if (i + 1 > bytesRead) + { + break; + } + if (data[i] == LF) + { + messageReceived = partialStr + System.Text.Encoding.ASCII.GetString(data, start, i - start); + Console.WriteLine("received <----- " + messageReceived); + if (messageReceived.StartsWith("[Join]")) + { + int nameLength = messageReceived.IndexOf("]", 6); + _clientNick = messageReceived.Substring(7, nameLength - 7); + Broadcast(messageReceived, null); + } + else if (messageReceived.StartsWith("[Usrs]")) + { + string allUsers = "[Usrs]["; + + foreach (DictionaryEntry c in AllClients) + { + allUsers += ((ChatClient)(c.Value))._clientNick + ","; + } + allUsers += "]"; + Broadcast(allUsers, null); + } + else if (messageReceived.StartsWith("[Talk]")) + { + string[] users = messageReceived.Substring(7, messageReceived.IndexOf("]", 7) - 8).Split(','); + Broadcast(messageReceived, users); + } + else if (messageReceived.StartsWith("[File]")) + { + string[] users = messageReceived.Substring(7, messageReceived.IndexOf("]", 7) - 8).Split(','); + int index = messageReceived.IndexOf("]", 7) + 2; + string filename = messageReceived.Substring(index, messageReceived.Length - index - 1); + string from = users[0]; + for (int j = 1; j <= users.Length - 1; j++) + { + users[j - 1] = users[j]; + } + users[users.Length - 1] = string.Empty; + Broadcast("[File][" + from + "][" + filename + "]", users); + } + else if (messageReceived.StartsWith("[Send_File]")) + { + string[] users = messageReceived.Substring(12, messageReceived.IndexOf("]", 12) - 12).Split(','); + string RecipientIP = string.Empty; + + foreach (DictionaryEntry c in AllClients) + { + if (((ChatClient)(c.Value))._clientNick == users[1]) + { + RecipientIP = ((ChatClient)(c.Value))._clientIP.Substring(0, _clientIP.IndexOf(":")); + break; + } + } + users[1] = string.Empty; + Broadcast("[Send_File][" + RecipientIP + "]", users); + } + start = i + 1; + } + i += 1; + } + if (start != i) + { + partialStr = System.Text.Encoding.ASCII.GetString(data, start, i - start); + } + } + lock (_client.GetStream()) + { + _client.GetStream().BeginRead(data, 0, System.Convert.ToInt32(_client.ReceiveBufferSize), ReceiveMessage, null); + } + } + catch (Exception ex) + { + AllClients.Remove(_clientIP); + Broadcast("[Left][" + _clientNick + "] has left the chat.", null); + } + } + + public void Broadcast(string message, string[] users) + { + if (users == null) + { + foreach (DictionaryEntry c in AllClients) + { + ((ChatClient)(c.Value)).SendMessage(message + "\n"); + } + } + else + { + foreach (DictionaryEntry c in AllClients) + { + foreach (string user in users) + { + if (((ChatClient)(c.Value))._clientNick == user) + { + ((ChatClient)(c.Value)).SendMessage(message + "\n"); + Console.WriteLine("sending -----> " + message ); + break; + } + } + } + } + } + } +} diff --git a/Chapter01(Socket)/Part 2/server_CS/server_CS/Program.cs b/Chapter01(Socket)/Part 2/server_CS/server_CS/Program.cs new file mode 100644 index 0000000..c965aa1 --- /dev/null +++ b/Chapter01(Socket)/Part 2/server_CS/server_CS/Program.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using System.Net.Sockets; + +namespace server_CS +{ + class Program + { + const int portNo = 500; + static void Main(string[] args) + { +// System.Net.IPAddress localAdd = System.Net.IPAddress.Parse("10.0.1.2"); + System.Net.IPAddress localAdd = System.Net.IPAddress.Parse("127.0.0.1"); + System.Net.Sockets.TcpListener listener = new System.Net.Sockets.TcpListener(localAdd, portNo); + listener.Start(); + while (true) + { + ChatClient user = new ChatClient(listener.AcceptTcpClient()); + } + } + } +} diff --git a/Chapter01(Socket)/Part 2/server_CS/server_CS/Properties/AssemblyInfo.cs b/Chapter01(Socket)/Part 2/server_CS/server_CS/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..6f75278 --- /dev/null +++ b/Chapter01(Socket)/Part 2/server_CS/server_CS/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("server_CS")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("server_CS")] +[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("e21dde01-b60c-48a4-9d81-290c349b3239")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Chapter01(Socket)/Part 2/server_CS/server_CS/bin/Debug/server_CS.exe b/Chapter01(Socket)/Part 2/server_CS/server_CS/bin/Debug/server_CS.exe new file mode 100644 index 0000000..3ab0c46 Binary files /dev/null and b/Chapter01(Socket)/Part 2/server_CS/server_CS/bin/Debug/server_CS.exe differ diff --git a/Chapter01(Socket)/Part 2/server_CS/server_CS/bin/Debug/server_CS.pdb b/Chapter01(Socket)/Part 2/server_CS/server_CS/bin/Debug/server_CS.pdb new file mode 100644 index 0000000..c51aae6 Binary files /dev/null and b/Chapter01(Socket)/Part 2/server_CS/server_CS/bin/Debug/server_CS.pdb differ diff --git a/Chapter01(Socket)/Part 2/server_CS/server_CS/bin/Debug/server_CS.vshost.exe b/Chapter01(Socket)/Part 2/server_CS/server_CS/bin/Debug/server_CS.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter01(Socket)/Part 2/server_CS/server_CS/bin/Debug/server_CS.vshost.exe differ diff --git a/Chapter01(Socket)/Part 2/server_CS/server_CS/obj/Debug/server_CS.exe b/Chapter01(Socket)/Part 2/server_CS/server_CS/obj/Debug/server_CS.exe new file mode 100644 index 0000000..3ab0c46 Binary files /dev/null and b/Chapter01(Socket)/Part 2/server_CS/server_CS/obj/Debug/server_CS.exe differ diff --git a/Chapter01(Socket)/Part 2/server_CS/server_CS/obj/Debug/server_CS.pdb b/Chapter01(Socket)/Part 2/server_CS/server_CS/obj/Debug/server_CS.pdb new file mode 100644 index 0000000..c51aae6 Binary files /dev/null and b/Chapter01(Socket)/Part 2/server_CS/server_CS/obj/Debug/server_CS.pdb differ diff --git a/Chapter01(Socket)/Part 2/server_CS/server_CS/obj/server_CS.csproj.FileList.txt b/Chapter01(Socket)/Part 2/server_CS/server_CS/obj/server_CS.csproj.FileList.txt new file mode 100644 index 0000000..b03743e --- /dev/null +++ b/Chapter01(Socket)/Part 2/server_CS/server_CS/obj/server_CS.csproj.FileList.txt @@ -0,0 +1,5 @@ +obj\Debug\ResolveAssemblyReference.cache +bin\Debug\server_CS.exe +bin\Debug\server_CS.pdb +obj\Debug\server_CS.exe +obj\Debug\server_CS.pdb diff --git a/Chapter01(Socket)/Part 2/server_CS/server_CS/server_CS.csproj b/Chapter01(Socket)/Part 2/server_CS/server_CS/server_CS.csproj new file mode 100644 index 0000000..5fa4dda --- /dev/null +++ b/Chapter01(Socket)/Part 2/server_CS/server_CS/server_CS.csproj @@ -0,0 +1,48 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {CC62E1D7-8563-4AA9-A114-7D06FE082B32} + Exe + Properties + server_CS + server_CS + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat.sln b/Chapter02(Serial)/SerialCommChat/SerialCommChat.sln new file mode 100644 index 0000000..ed60653 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat/SerialCommChat.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SerialCommChat", "SerialCommChat\SerialCommChat.vbproj", "{9E28C593-15C0-4D31-81E4-7CA1C0E39529}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9E28C593-15C0-4D31-81E4-7CA1C0E39529}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9E28C593-15C0-4D31-81E4-7CA1C0E39529}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9E28C593-15C0-4D31-81E4-7CA1C0E39529}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9E28C593-15C0-4D31-81E4-7CA1C0E39529}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat.suo b/Chapter02(Serial)/SerialCommChat/SerialCommChat.suo new file mode 100644 index 0000000..b5cbc7c Binary files /dev/null and b/Chapter02(Serial)/SerialCommChat/SerialCommChat.suo differ diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat/Form1.Designer.vb b/Chapter02(Serial)/SerialCommChat/SerialCommChat/Form1.Designer.vb new file mode 100644 index 0000000..77dfe5e --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat/SerialCommChat/Form1.Designer.vb @@ -0,0 +1,192 @@ + _ +Partial Class Form1 + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.Label1 = New System.Windows.Forms.Label + Me.cbbCOMPorts = New System.Windows.Forms.ComboBox + Me.txtDataToSend = New System.Windows.Forms.TextBox + Me.btnSend = New System.Windows.Forms.Button + Me.lblMessage = New System.Windows.Forms.Label + Me.btnConnect = New System.Windows.Forms.Button + Me.btnDisconnect = New System.Windows.Forms.Button + Me.txtDataReceived = New System.Windows.Forms.RichTextBox + Me.txtPhoneNumber = New System.Windows.Forms.TextBox + Me.Label2 = New System.Windows.Forms.Label + Me.btnDialNumber = New System.Windows.Forms.Button + Me.btnAnswerCall = New System.Windows.Forms.Button + Me.GroupBox1 = New System.Windows.Forms.GroupBox + Me.GroupBox1.SuspendLayout() + Me.SuspendLayout() + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(12, 9) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(104, 13) + Me.Label1.TabIndex = 0 + Me.Label1.Text = "Available COM Ports" + ' + 'cbbCOMPorts + ' + Me.cbbCOMPorts.FormattingEnabled = True + Me.cbbCOMPorts.Location = New System.Drawing.Point(122, 6) + Me.cbbCOMPorts.Name = "cbbCOMPorts" + Me.cbbCOMPorts.Size = New System.Drawing.Size(80, 21) + Me.cbbCOMPorts.TabIndex = 1 + ' + 'txtDataToSend + ' + Me.txtDataToSend.Location = New System.Drawing.Point(12, 236) + Me.txtDataToSend.Multiline = True + Me.txtDataToSend.Name = "txtDataToSend" + Me.txtDataToSend.Size = New System.Drawing.Size(273, 47) + Me.txtDataToSend.TabIndex = 2 + ' + 'btnSend + ' + Me.btnSend.Location = New System.Drawing.Point(289, 260) + Me.btnSend.Name = "btnSend" + Me.btnSend.Size = New System.Drawing.Size(75, 23) + Me.btnSend.TabIndex = 3 + Me.btnSend.Text = "Send" + Me.btnSend.UseVisualStyleBackColor = True + ' + 'lblMessage + ' + Me.lblMessage.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle + Me.lblMessage.Location = New System.Drawing.Point(12, 36) + Me.lblMessage.Name = "lblMessage" + Me.lblMessage.Size = New System.Drawing.Size(352, 23) + Me.lblMessage.TabIndex = 5 + ' + 'btnConnect + ' + Me.btnConnect.Location = New System.Drawing.Point(210, 4) + Me.btnConnect.Name = "btnConnect" + Me.btnConnect.Size = New System.Drawing.Size(75, 23) + Me.btnConnect.TabIndex = 6 + Me.btnConnect.Text = "Connect" + Me.btnConnect.UseVisualStyleBackColor = True + ' + 'btnDisconnect + ' + Me.btnDisconnect.Location = New System.Drawing.Point(291, 4) + Me.btnDisconnect.Name = "btnDisconnect" + Me.btnDisconnect.Size = New System.Drawing.Size(75, 23) + Me.btnDisconnect.TabIndex = 7 + Me.btnDisconnect.Text = "Disconnect" + Me.btnDisconnect.UseVisualStyleBackColor = True + ' + 'txtDataReceived + ' + Me.txtDataReceived.Location = New System.Drawing.Point(12, 62) + Me.txtDataReceived.Name = "txtDataReceived" + Me.txtDataReceived.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical + Me.txtDataReceived.Size = New System.Drawing.Size(352, 168) + Me.txtDataReceived.TabIndex = 8 + Me.txtDataReceived.Text = "" + ' + 'txtPhoneNumber + ' + Me.txtPhoneNumber.Location = New System.Drawing.Point(85, 19) + Me.txtPhoneNumber.Name = "txtPhoneNumber" + Me.txtPhoneNumber.Size = New System.Drawing.Size(99, 20) + Me.txtPhoneNumber.TabIndex = 9 + ' + 'Label2 + ' + Me.Label2.AutoSize = True + Me.Label2.Location = New System.Drawing.Point(6, 22) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(78, 13) + Me.Label2.TabIndex = 10 + Me.Label2.Text = "Phone Number" + ' + 'btnDialNumber + ' + Me.btnDialNumber.Location = New System.Drawing.Point(190, 17) + Me.btnDialNumber.Name = "btnDialNumber" + Me.btnDialNumber.Size = New System.Drawing.Size(75, 23) + Me.btnDialNumber.TabIndex = 11 + Me.btnDialNumber.Text = "Dial Number" + Me.btnDialNumber.UseVisualStyleBackColor = True + ' + 'btnAnswerCall + ' + Me.btnAnswerCall.Location = New System.Drawing.Point(271, 17) + Me.btnAnswerCall.Name = "btnAnswerCall" + Me.btnAnswerCall.Size = New System.Drawing.Size(75, 23) + Me.btnAnswerCall.TabIndex = 12 + Me.btnAnswerCall.Text = "Answer Call" + Me.btnAnswerCall.UseVisualStyleBackColor = True + ' + 'GroupBox1 + ' + Me.GroupBox1.Controls.Add(Me.Label2) + Me.GroupBox1.Controls.Add(Me.btnAnswerCall) + Me.GroupBox1.Controls.Add(Me.txtPhoneNumber) + Me.GroupBox1.Controls.Add(Me.btnDialNumber) + Me.GroupBox1.Location = New System.Drawing.Point(12, 289) + Me.GroupBox1.Name = "GroupBox1" + Me.GroupBox1.Size = New System.Drawing.Size(352, 50) + Me.GroupBox1.TabIndex = 13 + Me.GroupBox1.TabStop = False + Me.GroupBox1.Text = "Bluetooth Handset" + ' + 'Form1 + ' + Me.AcceptButton = Me.btnSend + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.BackColor = System.Drawing.SystemColors.Control + Me.ClientSize = New System.Drawing.Size(379, 351) + Me.Controls.Add(Me.GroupBox1) + Me.Controls.Add(Me.txtDataReceived) + Me.Controls.Add(Me.btnDisconnect) + Me.Controls.Add(Me.btnConnect) + Me.Controls.Add(Me.lblMessage) + Me.Controls.Add(Me.btnSend) + Me.Controls.Add(Me.txtDataToSend) + Me.Controls.Add(Me.cbbCOMPorts) + Me.Controls.Add(Me.Label1) + Me.Name = "Form1" + Me.Text = "Serial Chat" + Me.GroupBox1.ResumeLayout(False) + Me.GroupBox1.PerformLayout() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents cbbCOMPorts As System.Windows.Forms.ComboBox + Friend WithEvents txtDataToSend As System.Windows.Forms.TextBox + Friend WithEvents btnSend As System.Windows.Forms.Button + Friend WithEvents lblMessage As System.Windows.Forms.Label + Friend WithEvents btnConnect As System.Windows.Forms.Button + Friend WithEvents btnDisconnect As System.Windows.Forms.Button + Friend WithEvents txtDataReceived As System.Windows.Forms.RichTextBox + Friend WithEvents txtPhoneNumber As System.Windows.Forms.TextBox + Friend WithEvents Label2 As System.Windows.Forms.Label + Friend WithEvents btnDialNumber As System.Windows.Forms.Button + Friend WithEvents btnAnswerCall As System.Windows.Forms.Button + Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox + +End Class diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat/Form1.resx b/Chapter02(Serial)/SerialCommChat/SerialCommChat/Form1.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat/SerialCommChat/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat/Form1.vb b/Chapter02(Serial)/SerialCommChat/SerialCommChat/Form1.vb new file mode 100644 index 0000000..3870b3c --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat/SerialCommChat/Form1.vb @@ -0,0 +1,118 @@ +Public Class Form1 + Private WithEvents serialPort As New IO.Ports.SerialPort + + Private Sub Form1_Load( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles MyBase.Load + + For i As Integer = 0 To _ + My.Computer.Ports.SerialPortNames.Count - 1 + cbbCOMPorts.Items.Add( _ + My.Computer.Ports.SerialPortNames(i)) + Next + btnDisconnect.Enabled = False + End Sub + + Private Sub DataReceived( _ + ByVal sender As Object, _ + ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) _ + Handles serialPort.DataReceived + + txtDataReceived.BeginInvoke(New _ + myDelegate(AddressOf updateTextBox), _ + New Object() {}) + End Sub + + Private Sub btnSend_Click( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles btnSend.Click + Try + serialPort.Write(txtDataToSend.Text & vbCrLf) + 'serialPort.Write(txtDataToSend.Text) + + + With txtDataReceived + .AppendText(">" & txtDataToSend.Text & vbCrLf) + .ScrollToCaret() + End With + txtDataToSend.Text = String.Empty + Catch ex As Exception + MsgBox(ex.ToString) + End Try + End Sub + + Public Delegate Sub myDelegate() + Public Sub updateTextBox() + '---for receiving plan ASCII text--- + 'With txtDataReceived + ' .AppendText(serialPort.ReadExisting) + ' .ScrollToCaret() + 'End With + + '---UNICODE work-around--- + With txtDataReceived + '---find out the number of bytes to read--- + Dim bytesToRead As Integer = serialPort.BytesToRead + '---declare a char array--- + Dim ch(bytesToRead) As Char + '---read the bytes into the ch array--- + Dim bytesRead As Integer = 0 + bytesRead = serialPort.Read(ch, 0, bytesToRead) + '---convert the ch array into a string--- + Dim str As String = New String(ch, 0, bytesRead) + .AppendText(str) + .ScrollToCaret() + End With + End Sub + + Private Sub btnConnect_Click( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles btnConnect.Click + If serialPort.IsOpen Then + serialPort.Close() + End If + Try + With serialPort + .PortName = cbbCOMPorts.Text + .BaudRate = 2400 ' 9600 + .Parity = IO.Ports.Parity.None + .DataBits = 8 + .StopBits = IO.Ports.StopBits.One + .Handshake = IO.Ports.Handshake.None + ' .Encoding = System.Text.Encoding.Unicode + End With + serialPort.Open() + + lblMessage.Text = cbbCOMPorts.Text & " connected." + btnConnect.Enabled = False + btnDisconnect.Enabled = True + Catch ex As Exception + MsgBox(ex.ToString) + End Try + End Sub + + Private Sub btnDisconnect_Click( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles btnDisconnect.Click + Try + serialPort.Close() + lblMessage.Text = serialPort.PortName & " disconnected." + btnConnect.Enabled = True + btnDisconnect.Enabled = False + Catch ex As Exception + MsgBox(ex.ToString) + End Try + End Sub + + Private Sub btnDialNumber_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDialNumber.Click + serialPort.Write("ATDT " & txtPhoneNumber.Text & vbCrLf) + End Sub + + Private Sub btnAnswerCall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAnswerCall.Click + serialPort.Write("AT*EVA" & vbCrLf) + End Sub +End Class diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat/My Project/Application.Designer.vb b/Chapter02(Serial)/SerialCommChat/SerialCommChat/My Project/Application.Designer.vb new file mode 100644 index 0000000..8911b53 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat/SerialCommChat/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + 'NOTE: This file is auto-generated; do not modify it directly. To make changes, + ' or if you encounter build errors in this file, go to the Project Designer + ' (go to Project Properties or double-click the My Project node in + ' Solution Explorer), and make changes on the Application tab. + ' + Partial Friend Class MyApplication + + _ + Public Sub New() + MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) + Me.IsSingleInstance = false + Me.EnableVisualStyles = true + Me.SaveMySettingsOnExit = true + Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses + End Sub + + _ + Protected Overrides Sub OnCreateMainForm() + Me.MainForm = Global.SerialCommChat.Form1 + End Sub + End Class +End Namespace diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat/My Project/Application.myapp b/Chapter02(Serial)/SerialCommChat/SerialCommChat/My Project/Application.myapp new file mode 100644 index 0000000..0f12f32 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat/SerialCommChat/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + Form1 + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat/My Project/AssemblyInfo.vb b/Chapter02(Serial)/SerialCommChat/SerialCommChat/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..ff58fff --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat/SerialCommChat/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + + diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat/My Project/Resources.Designer.vb b/Chapter02(Serial)/SerialCommChat/SerialCommChat/My Project/Resources.Designer.vb new file mode 100644 index 0000000..7eaacf5 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat/SerialCommChat/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + +Imports System + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("SerialCommChat.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat/My Project/Resources.resx b/Chapter02(Serial)/SerialCommChat/SerialCommChat/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat/SerialCommChat/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat/My Project/Settings.Designer.vb b/Chapter02(Serial)/SerialCommChat/SerialCommChat/My Project/Settings.Designer.vb new file mode 100644 index 0000000..bb9a123 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat/SerialCommChat/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings),MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.SerialCommChat.My.MySettings + Get + Return Global.SerialCommChat.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat/My Project/Settings.settings b/Chapter02(Serial)/SerialCommChat/SerialCommChat/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat/SerialCommChat/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat/SerialCommChat.vbproj b/Chapter02(Serial)/SerialCommChat/SerialCommChat/SerialCommChat.vbproj new file mode 100644 index 0000000..e033007 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat/SerialCommChat/SerialCommChat.vbproj @@ -0,0 +1,106 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {9E28C593-15C0-4D31-81E4-7CA1C0E39529} + WinExe + SerialCommChat.My.MyApplication + SerialCommChat + SerialCommChat + WindowsForms + + + true + full + true + true + bin\Debug\ + SerialCommChat.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SerialCommChat.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + + + + + + + + + + + + + Form + + + Form1.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + Form1.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat/SerialCommChat.vbproj.user b/Chapter02(Serial)/SerialCommChat/SerialCommChat/SerialCommChat.vbproj.user new file mode 100644 index 0000000..c85bd53 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat/SerialCommChat/SerialCommChat.vbproj.user @@ -0,0 +1,18 @@ + + + + + + + + + + + + + 0 + en-US + true + ProjectFiles + + \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat/bin/Debug/SerialCommChat.exe b/Chapter02(Serial)/SerialCommChat/SerialCommChat/bin/Debug/SerialCommChat.exe new file mode 100644 index 0000000..2f388ab Binary files /dev/null and b/Chapter02(Serial)/SerialCommChat/SerialCommChat/bin/Debug/SerialCommChat.exe differ diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat/bin/Debug/SerialCommChat.pdb b/Chapter02(Serial)/SerialCommChat/SerialCommChat/bin/Debug/SerialCommChat.pdb new file mode 100644 index 0000000..41321f1 Binary files /dev/null and b/Chapter02(Serial)/SerialCommChat/SerialCommChat/bin/Debug/SerialCommChat.pdb differ diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat/bin/Debug/SerialCommChat.vshost.exe b/Chapter02(Serial)/SerialCommChat/SerialCommChat/bin/Debug/SerialCommChat.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter02(Serial)/SerialCommChat/SerialCommChat/bin/Debug/SerialCommChat.vshost.exe differ diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat/bin/Debug/SerialCommChat.xml b/Chapter02(Serial)/SerialCommChat/SerialCommChat/bin/Debug/SerialCommChat.xml new file mode 100644 index 0000000..ef21302 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat/SerialCommChat/bin/Debug/SerialCommChat.xml @@ -0,0 +1,24 @@ + + + + +SerialCommChat + + + + + + Returns the cached ResourceManager instance used by this class. + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat/obj/Debug/SerialCommChat.Form1.resources b/Chapter02(Serial)/SerialCommChat/SerialCommChat/obj/Debug/SerialCommChat.Form1.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter02(Serial)/SerialCommChat/SerialCommChat/obj/Debug/SerialCommChat.Form1.resources differ diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat/obj/Debug/SerialCommChat.Resources.resources b/Chapter02(Serial)/SerialCommChat/SerialCommChat/obj/Debug/SerialCommChat.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter02(Serial)/SerialCommChat/SerialCommChat/obj/Debug/SerialCommChat.Resources.resources differ diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat/obj/Debug/SerialCommChat.exe b/Chapter02(Serial)/SerialCommChat/SerialCommChat/obj/Debug/SerialCommChat.exe new file mode 100644 index 0000000..2f388ab Binary files /dev/null and b/Chapter02(Serial)/SerialCommChat/SerialCommChat/obj/Debug/SerialCommChat.exe differ diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat/obj/Debug/SerialCommChat.pdb b/Chapter02(Serial)/SerialCommChat/SerialCommChat/obj/Debug/SerialCommChat.pdb new file mode 100644 index 0000000..41321f1 Binary files /dev/null and b/Chapter02(Serial)/SerialCommChat/SerialCommChat/obj/Debug/SerialCommChat.pdb differ diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat/obj/Debug/SerialCommChat.vbproj.GenerateResource.Cache b/Chapter02(Serial)/SerialCommChat/SerialCommChat/obj/Debug/SerialCommChat.vbproj.GenerateResource.Cache new file mode 100644 index 0000000..66d0858 Binary files /dev/null and b/Chapter02(Serial)/SerialCommChat/SerialCommChat/obj/Debug/SerialCommChat.vbproj.GenerateResource.Cache differ diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat/obj/Debug/SerialCommChat.xml b/Chapter02(Serial)/SerialCommChat/SerialCommChat/obj/Debug/SerialCommChat.xml new file mode 100644 index 0000000..ef21302 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat/SerialCommChat/obj/Debug/SerialCommChat.xml @@ -0,0 +1,24 @@ + + + + +SerialCommChat + + + + + + Returns the cached ResourceManager instance used by this class. + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChat/SerialCommChat/obj/SerialCommChat.vbproj.FileList.txt b/Chapter02(Serial)/SerialCommChat/SerialCommChat/obj/SerialCommChat.vbproj.FileList.txt new file mode 100644 index 0000000..f2846e0 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat/SerialCommChat/obj/SerialCommChat.vbproj.FileList.txt @@ -0,0 +1,10 @@ +bin\Debug\SerialCommChat.exe +bin\Debug\SerialCommChat.pdb +bin\Debug\SerialCommChat.xml +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\SerialCommChat.Form1.resources +obj\Debug\SerialCommChat.Resources.resources +obj\Debug\SerialCommChat.vbproj.GenerateResource.Cache +obj\Debug\SerialCommChat.exe +obj\Debug\SerialCommChat.xml +obj\Debug\SerialCommChat.pdb diff --git a/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC.sln b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC.sln new file mode 100644 index 0000000..cdf1459 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SerialCommChatPocketPC", "SerialCommChatPocketPC\SerialCommChatPocketPC.vbproj", "{E9799171-4E2D-47BA-8F3D-FEDD9DA24242}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E9799171-4E2D-47BA-8F3D-FEDD9DA24242}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E9799171-4E2D-47BA-8F3D-FEDD9DA24242}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E9799171-4E2D-47BA-8F3D-FEDD9DA24242}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {E9799171-4E2D-47BA-8F3D-FEDD9DA24242}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E9799171-4E2D-47BA-8F3D-FEDD9DA24242}.Release|Any CPU.Build.0 = Release|Any CPU + {E9799171-4E2D-47BA-8F3D-FEDD9DA24242}.Release|Any CPU.Deploy.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC.suo b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC.suo new file mode 100644 index 0000000..ceb04cf Binary files /dev/null and b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC.suo differ diff --git a/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/Form1.Designer.vb b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/Form1.Designer.vb new file mode 100644 index 0000000..e318cc0 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/Form1.Designer.vb @@ -0,0 +1,131 @@ + _ +Partial Public Class Form1 + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + private mainMenu1 As System.Windows.Forms.MainMenu + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.mainMenu1 = New System.Windows.Forms.MainMenu + Me.MenuItem1 = New System.Windows.Forms.MenuItem + Me.Label2 = New System.Windows.Forms.Label + Me.Label1 = New System.Windows.Forms.Label + Me.txtMessageToSend = New System.Windows.Forms.TextBox + Me.txtReceivedMessage = New System.Windows.Forms.TextBox + Me.cbbCOMPorts = New System.Windows.Forms.ComboBox + Me.Label3 = New System.Windows.Forms.Label + Me.btnConnect = New System.Windows.Forms.Button + Me.SuspendLayout() + ' + 'mainMenu1 + ' + Me.mainMenu1.MenuItems.Add(Me.MenuItem1) + ' + 'MenuItem1 + ' + Me.MenuItem1.Text = "Send" + ' + 'Label2 + ' + Me.Label2.Location = New System.Drawing.Point(6, 49) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(135, 20) + Me.Label2.Text = "Received Message" + ' + 'Label1 + ' + Me.Label1.Location = New System.Drawing.Point(6, 2) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(100, 20) + Me.Label1.Text = "Message to send" + ' + 'txtMessageToSend + ' + Me.txtMessageToSend.Location = New System.Drawing.Point(3, 25) + Me.txtMessageToSend.Name = "txtMessageToSend" + Me.txtMessageToSend.Size = New System.Drawing.Size(234, 21) + Me.txtMessageToSend.TabIndex = 5 + ' + 'txtReceivedMessage + ' + Me.txtReceivedMessage.Location = New System.Drawing.Point(3, 72) + Me.txtReceivedMessage.Multiline = True + Me.txtReceivedMessage.Name = "txtReceivedMessage" + Me.txtReceivedMessage.ScrollBars = System.Windows.Forms.ScrollBars.Vertical + Me.txtReceivedMessage.Size = New System.Drawing.Size(234, 165) + Me.txtReceivedMessage.TabIndex = 2 + ' + 'cbbCOMPorts + ' + Me.cbbCOMPorts.Items.Add("COM1") + Me.cbbCOMPorts.Items.Add("COM2") + Me.cbbCOMPorts.Items.Add("COM3") + Me.cbbCOMPorts.Items.Add("COM4") + Me.cbbCOMPorts.Items.Add("COM5") + Me.cbbCOMPorts.Items.Add("COM6") + Me.cbbCOMPorts.Items.Add("COM7") + Me.cbbCOMPorts.Items.Add("COM8") + Me.cbbCOMPorts.Items.Add("COM9") + Me.cbbCOMPorts.Location = New System.Drawing.Point(68, 243) + Me.cbbCOMPorts.Name = "cbbCOMPorts" + Me.cbbCOMPorts.Size = New System.Drawing.Size(83, 22) + Me.cbbCOMPorts.TabIndex = 6 + ' + 'Label3 + ' + Me.Label3.Location = New System.Drawing.Point(3, 248) + Me.Label3.Name = "Label3" + Me.Label3.Size = New System.Drawing.Size(59, 20) + Me.Label3.Text = "COM Port" + ' + 'btnConnect + ' + Me.btnConnect.Location = New System.Drawing.Point(157, 243) + Me.btnConnect.Name = "btnConnect" + Me.btnConnect.Size = New System.Drawing.Size(80, 20) + Me.btnConnect.TabIndex = 9 + Me.btnConnect.Text = "Connect" + ' + 'Form1 + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi + Me.AutoScroll = True + Me.ClientSize = New System.Drawing.Size(240, 268) + Me.Controls.Add(Me.btnConnect) + Me.Controls.Add(Me.Label3) + Me.Controls.Add(Me.cbbCOMPorts) + Me.Controls.Add(Me.Label2) + Me.Controls.Add(Me.Label1) + Me.Controls.Add(Me.txtMessageToSend) + Me.Controls.Add(Me.txtReceivedMessage) + Me.Menu = Me.mainMenu1 + Me.Name = "Form1" + Me.Text = "Form1" + Me.ResumeLayout(False) + + End Sub + Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem + Friend WithEvents Label2 As System.Windows.Forms.Label + Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents txtMessageToSend As System.Windows.Forms.TextBox + Friend WithEvents txtReceivedMessage As System.Windows.Forms.TextBox + Friend WithEvents cbbCOMPorts As System.Windows.Forms.ComboBox + Friend WithEvents Label3 As System.Windows.Forms.Label + Friend WithEvents btnConnect As System.Windows.Forms.Button + +End Class diff --git a/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/Form1.resx b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/Form1.resx new file mode 100644 index 0000000..20d2efa --- /dev/null +++ b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/Form1.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + Pocket_PC + + + True + + \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/Form1.vb b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/Form1.vb new file mode 100644 index 0000000..e2b6cf6 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/Form1.vb @@ -0,0 +1,57 @@ +Public Class Form1 + Private WithEvents serialPort As New IO.Ports.SerialPort + + Private Sub DataReceived( _ + ByVal sender As Object, _ + ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) _ + Handles serialPort.DataReceived + + txtReceivedMessage.BeginInvoke(New _ + myDelegate(AddressOf updateTextBox), _ + New Object() {}) + End Sub + + Public Delegate Sub myDelegate() + Public Sub updateTextBox() + txtReceivedMessage.Text = _ + serialPort.ReadExisting & _ + txtReceivedMessage.Text + End Sub + + Private Sub MenuItem1_Click( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles MenuItem1.Click + Try + serialPort.WriteLine(txtMessageToSend.Text) + txtReceivedMessage.Text = ">" & _ + txtMessageToSend.Text & vbCrLf & _ + txtReceivedMessage.Text + txtMessageToSend.Text = String.Empty + Catch ex As Exception + MsgBox(ex.ToString) + End Try + End Sub + + Private Sub btnConnect_Click( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles btnConnect.Click + Try + If serialPort.IsOpen Then + serialPort.Close() + End If + With serialPort + .PortName = cbbCOMPorts.Text + .BaudRate = 9600 + .Parity = IO.Ports.Parity.None + .DataBits = 8 + .StopBits = IO.Ports.StopBits.One + End With + serialPort.Open() + MsgBox("Port opened successfully!") + Catch ex As Exception + MsgBox(ex.ToString) + End Try + End Sub +End Class diff --git a/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/My Project/AssemblyInfo.vb b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..9f4a354 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/My Project/AssemblyInfo.vb @@ -0,0 +1,36 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + diff --git a/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/My Project/Resources.Designer.vb b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/My Project/Resources.Designer.vb new file mode 100644 index 0000000..8acbdc4 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/My Project/Resources.Designer.vb @@ -0,0 +1,59 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict Off +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the Strongly Typed Resource Builder + 'class via a tool like ResGen or Visual Studio.NET. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Module Resources + + Private _resMgr As System.Resources.ResourceManager + + Private _resCulture As System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As System.Resources.ResourceManager + Get + If (_resMgr Is Nothing) Then + Dim temp As System.Resources.ResourceManager = New System.Resources.ResourceManager("SerialCommChatPocketPC.Resources", GetType(Resources).Assembly) + _resMgr = temp + End If + Return _resMgr + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As System.Globalization.CultureInfo + Get + Return _resCulture + End Get + Set + _resCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/My Project/Resources.resx b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/My Project/Resources.resx new file mode 100644 index 0000000..3e18af9 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/SerialCommChatPocketPC.vbproj b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/SerialCommChatPocketPC.vbproj new file mode 100644 index 0000000..006f11f --- /dev/null +++ b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/SerialCommChatPocketPC.vbproj @@ -0,0 +1,108 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {E9799171-4E2D-47BA-8F3D-FEDD9DA24242} + WinExe + SerialCommChatPocketPC.Form1 + SerialCommChatPocketPC + SerialCommChatPocketPC + {68B1623D-7FB9-47D8-8664-7ECEA3297D4F};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + PocketPC + 4118C335-430C-497f-BE48-11C3316B135E + 5.01 + WindowsForms + SerialCommChatPocketPC + v2.0 + + + + + true + full + true + true + bin\Debug\ + $(PlatformFamilyName)=TRUE + SerialCommChatPocketPC.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + 512 + Off + true + true + + + pdbonly + false + true + true + bin\Release\ + $(PlatformFamilyName)=TRUE + SerialCommChatPocketPC.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + 512 + Off + true + true + + + + + + + + + + + + + + + + + + Form + + + Form1.vb + Form + + + + True + True + Resources.resx + + + + + Designer + Form1.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/SerialCommChatPocketPC.vbproj.user b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/SerialCommChatPocketPC.vbproj.user new file mode 100644 index 0000000..76bd09e --- /dev/null +++ b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/SerialCommChatPocketPC.vbproj.user @@ -0,0 +1,5 @@ + + + 4118C335-430C-497f-BE48-11C3316B135Ed6518ffb-710f-11d3-99f2-00105a0df099 + + \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/bin/Debug/SerialCommChatPocketPC.exe b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/bin/Debug/SerialCommChatPocketPC.exe new file mode 100644 index 0000000..f08c9cd Binary files /dev/null and b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/bin/Debug/SerialCommChatPocketPC.exe differ diff --git a/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/bin/Debug/SerialCommChatPocketPC.pdb b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/bin/Debug/SerialCommChatPocketPC.pdb new file mode 100644 index 0000000..16e0fd6 Binary files /dev/null and b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/bin/Debug/SerialCommChatPocketPC.pdb differ diff --git a/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/bin/Debug/SerialCommChatPocketPC.xml b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/bin/Debug/SerialCommChatPocketPC.xml new file mode 100644 index 0000000..fda579c --- /dev/null +++ b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/bin/Debug/SerialCommChatPocketPC.xml @@ -0,0 +1,24 @@ + + + + +SerialCommChatPocketPC + + + + + + Returns the cached ResourceManager instance used by this class. + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/obj/Debug/SerialCommChatPocketPC.Form1.resources b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/obj/Debug/SerialCommChatPocketPC.Form1.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/obj/Debug/SerialCommChatPocketPC.Form1.resources differ diff --git a/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/obj/Debug/SerialCommChatPocketPC.Resources.resources b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/obj/Debug/SerialCommChatPocketPC.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/obj/Debug/SerialCommChatPocketPC.Resources.resources differ diff --git a/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/obj/Debug/SerialCommChatPocketPC.exe b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/obj/Debug/SerialCommChatPocketPC.exe new file mode 100644 index 0000000..f08c9cd Binary files /dev/null and b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/obj/Debug/SerialCommChatPocketPC.exe differ diff --git a/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/obj/Debug/SerialCommChatPocketPC.pdb b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/obj/Debug/SerialCommChatPocketPC.pdb new file mode 100644 index 0000000..16e0fd6 Binary files /dev/null and b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/obj/Debug/SerialCommChatPocketPC.pdb differ diff --git a/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/obj/Debug/SerialCommChatPocketPC.vbproj.GenerateResource.Cache b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/obj/Debug/SerialCommChatPocketPC.vbproj.GenerateResource.Cache new file mode 100644 index 0000000..3bdf6cb Binary files /dev/null and b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/obj/Debug/SerialCommChatPocketPC.vbproj.GenerateResource.Cache differ diff --git a/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/obj/Debug/SerialCommChatPocketPC.xml b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/obj/Debug/SerialCommChatPocketPC.xml new file mode 100644 index 0000000..fda579c --- /dev/null +++ b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/obj/Debug/SerialCommChatPocketPC.xml @@ -0,0 +1,24 @@ + + + + +SerialCommChatPocketPC + + + + + + Returns the cached ResourceManager instance used by this class. + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll new file mode 100644 index 0000000..47b2a8a Binary files /dev/null and b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll differ diff --git a/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/obj/SerialCommChatPocketPC.vbproj.FileList.txt b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/obj/SerialCommChatPocketPC.vbproj.FileList.txt new file mode 100644 index 0000000..b3d2359 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChatPocketPC/SerialCommChatPocketPC/obj/SerialCommChatPocketPC.vbproj.FileList.txt @@ -0,0 +1,10 @@ +bin\Debug\SerialCommChatPocketPC.exe +bin\Debug\SerialCommChatPocketPC.pdb +bin\Debug\SerialCommChatPocketPC.xml +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\SerialCommChatPocketPC.Form1.resources +obj\Debug\SerialCommChatPocketPC.Resources.resources +obj\Debug\SerialCommChatPocketPC.vbproj.GenerateResource.Cache +obj\Debug\SerialCommChatPocketPC.exe +obj\Debug\SerialCommChatPocketPC.xml +obj\Debug\SerialCommChatPocketPC.pdb diff --git a/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS.sln b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS.sln new file mode 100644 index 0000000..68877f0 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SerialCommChatPocketPC_CS", "SerialCommChatPocketPC_CS\SerialCommChatPocketPC_CS.csproj", "{B5F4CD7B-5903-488C-B6C0-A50CF1128A95}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B5F4CD7B-5903-488C-B6C0-A50CF1128A95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B5F4CD7B-5903-488C-B6C0-A50CF1128A95}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B5F4CD7B-5903-488C-B6C0-A50CF1128A95}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {B5F4CD7B-5903-488C-B6C0-A50CF1128A95}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B5F4CD7B-5903-488C-B6C0-A50CF1128A95}.Release|Any CPU.Build.0 = Release|Any CPU + {B5F4CD7B-5903-488C-B6C0-A50CF1128A95}.Release|Any CPU.Deploy.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS.suo b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS.suo new file mode 100644 index 0000000..2b5be13 Binary files /dev/null and b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS.suo differ diff --git a/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/Form1.Designer.cs b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/Form1.Designer.cs new file mode 100644 index 0000000..e64bfe7 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/Form1.Designer.cs @@ -0,0 +1,147 @@ +namespace SerialCommChatPocketPC_CS +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.btnConnect = new System.Windows.Forms.Button(); + this.Label3 = new System.Windows.Forms.Label(); + this.cbbCOMPorts = new System.Windows.Forms.ComboBox(); + this.Label2 = new System.Windows.Forms.Label(); + this.Label1 = new System.Windows.Forms.Label(); + this.mainMenu1 = new System.Windows.Forms.MainMenu(); + this.MenuItem1 = new System.Windows.Forms.MenuItem(); + this.txtMessageToSend = new System.Windows.Forms.TextBox(); + this.txtReceivedMessage = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // btnConnect + // + this.btnConnect.Location = new System.Drawing.Point(157, 242); + this.btnConnect.Name = "btnConnect"; + this.btnConnect.Size = new System.Drawing.Size(80, 20); + this.btnConnect.TabIndex = 16; + this.btnConnect.Text = "Connect"; + this.btnConnect.Click += new System.EventHandler(this.btnConnect_Click); + // + // Label3 + // + this.Label3.Location = new System.Drawing.Point(3, 247); + this.Label3.Name = "Label3"; + this.Label3.Size = new System.Drawing.Size(59, 20); + this.Label3.Text = "COM Port"; + // + // cbbCOMPorts + // + this.cbbCOMPorts.Items.Add("COM1"); + this.cbbCOMPorts.Items.Add("COM2"); + this.cbbCOMPorts.Items.Add("COM3"); + this.cbbCOMPorts.Items.Add("COM4"); + this.cbbCOMPorts.Items.Add("COM5"); + this.cbbCOMPorts.Items.Add("COM6"); + this.cbbCOMPorts.Items.Add("COM7"); + this.cbbCOMPorts.Items.Add("COM8"); + this.cbbCOMPorts.Items.Add("COM9"); + this.cbbCOMPorts.Location = new System.Drawing.Point(68, 242); + this.cbbCOMPorts.Name = "cbbCOMPorts"; + this.cbbCOMPorts.Size = new System.Drawing.Size(83, 22); + this.cbbCOMPorts.TabIndex = 15; + // + // Label2 + // + this.Label2.Location = new System.Drawing.Point(6, 48); + this.Label2.Name = "Label2"; + this.Label2.Size = new System.Drawing.Size(135, 20); + this.Label2.Text = "Received Message"; + // + // Label1 + // + this.Label1.Location = new System.Drawing.Point(6, 1); + this.Label1.Name = "Label1"; + this.Label1.Size = new System.Drawing.Size(100, 20); + this.Label1.Text = "Message to send"; + // + // mainMenu1 + // + this.mainMenu1.MenuItems.Add(this.MenuItem1); + // + // MenuItem1 + // + this.MenuItem1.Text = "Send"; + this.MenuItem1.Click += new System.EventHandler(this.MenuItem1_Click); + // + // txtMessageToSend + // + this.txtMessageToSend.Location = new System.Drawing.Point(3, 24); + this.txtMessageToSend.Name = "txtMessageToSend"; + this.txtMessageToSend.Size = new System.Drawing.Size(234, 21); + this.txtMessageToSend.TabIndex = 14; + // + // txtReceivedMessage + // + this.txtReceivedMessage.Location = new System.Drawing.Point(3, 71); + this.txtReceivedMessage.Multiline = true; + this.txtReceivedMessage.Name = "txtReceivedMessage"; + this.txtReceivedMessage.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.txtReceivedMessage.Size = new System.Drawing.Size(234, 165); + this.txtReceivedMessage.TabIndex = 13; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.AutoScroll = true; + this.ClientSize = new System.Drawing.Size(240, 268); + this.Controls.Add(this.btnConnect); + this.Controls.Add(this.Label3); + this.Controls.Add(this.cbbCOMPorts); + this.Controls.Add(this.Label2); + this.Controls.Add(this.Label1); + this.Controls.Add(this.txtMessageToSend); + this.Controls.Add(this.txtReceivedMessage); + this.Menu = this.mainMenu1; + this.Name = "Form1"; + this.Text = "Form1"; + this.Load += new System.EventHandler(this.Form1_Load); + this.ResumeLayout(false); + + } + + #endregion + + internal System.Windows.Forms.Button btnConnect; + internal System.Windows.Forms.Label Label3; + internal System.Windows.Forms.ComboBox cbbCOMPorts; + internal System.Windows.Forms.Label Label2; + internal System.Windows.Forms.Label Label1; + private System.Windows.Forms.MainMenu mainMenu1; + internal System.Windows.Forms.MenuItem MenuItem1; + internal System.Windows.Forms.TextBox txtMessageToSend; + internal System.Windows.Forms.TextBox txtReceivedMessage; + } +} + diff --git a/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/Form1.cs b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/Form1.cs new file mode 100644 index 0000000..4583fb3 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/Form1.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace SerialCommChatPocketPC_CS +{ + public partial class Form1 : Form + { + private System.IO.Ports.SerialPort serialPort = + new System.IO.Ports.SerialPort(); + + public Form1() + { + InitializeComponent(); + } + + private void DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) + { + txtReceivedMessage.BeginInvoke(new myDelegate(updateTextBox)); + } + + public delegate void myDelegate(); + public void updateTextBox() + { + //---for receiving plan ASCII text--- + txtReceivedMessage.Text = (serialPort.ReadExisting()) + txtReceivedMessage.Text; + txtReceivedMessage.ScrollToCaret(); + } + + private void Form1_Load(object sender, EventArgs e) + { + serialPort.DataReceived += + new System.IO.Ports.SerialDataReceivedEventHandler(DataReceived); + } + + private void MenuItem1_Click(object sender, EventArgs e) + { + try + { + serialPort.Write(txtMessageToSend.Text + "\r"); + txtReceivedMessage.Text = ">" + txtMessageToSend.Text + "\r" + txtReceivedMessage.Text; + txtMessageToSend.Text = string.Empty; + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + } + + private void btnConnect_Click(object sender, EventArgs e) + { + if (serialPort.IsOpen) + { + serialPort.Close(); + } + try + { + serialPort.PortName = cbbCOMPorts.Text; + serialPort.BaudRate = 9600; + serialPort.Parity = System.IO.Ports.Parity.None; + serialPort.DataBits = 8; + serialPort.StopBits = System.IO.Ports.StopBits.One; + serialPort.Open(); + MessageBox.Show("Port opened successfully!"); + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + } + } +} \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/Form1.resx b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/Form1.resx new file mode 100644 index 0000000..20d2efa --- /dev/null +++ b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/Form1.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + Pocket_PC + + + True + + \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/Program.cs b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/Program.cs new file mode 100644 index 0000000..f188fc2 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/Program.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace SerialCommChatPocketPC_CS +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [MTAThread] + static void Main() + { + Application.Run(new Form1()); + } + } +} \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/Properties/AssemblyInfo.cs b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..43a410f --- /dev/null +++ b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SerialCommChatPocketPC_CS")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SerialCommChatPocketPC_CS")] +[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("1576a5c7-0d28-4dc0-9ae3-40c2612ffee5")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] + diff --git a/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/Properties/Resources.Designer.cs b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/Properties/Resources.Designer.cs new file mode 100644 index 0000000..615f667 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/Properties/Resources.Designer.cs @@ -0,0 +1,68 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SerialCommChatPocketPC_CS.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the Strongly Typed Resource Builder + // class via a tool like ResGen or Visual Studio.NET. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + class Resources + { + + private static System.Resources.ResourceManager _resMgr; + + private static System.Globalization.CultureInfo _resCulture; + + /*FamANDAssem*/ + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + public static System.Resources.ResourceManager ResourceManager + { + get + { + if ((_resMgr == null)) + { + System.Resources.ResourceManager temp = new System.Resources.ResourceManager("SerialCommChatPocketPC_CS.Properties.Resources", typeof(Resources).Assembly); + _resMgr = temp; + } + return _resMgr; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + public static System.Globalization.CultureInfo Culture + { + get + { + return _resCulture; + } + set + { + _resCulture = value; + } + } + } +} diff --git a/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/Properties/Resources.resx b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/Properties/Resources.resx new file mode 100644 index 0000000..3e18af9 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS.csproj b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS.csproj new file mode 100644 index 0000000..33ef99e --- /dev/null +++ b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS.csproj @@ -0,0 +1,93 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {B5F4CD7B-5903-488C-B6C0-A50CF1128A95} + WinExe + Properties + SerialCommChatPocketPC_CS + SerialCommChatPocketPC_CS + {4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + PocketPC + 4118C335-430C-497f-BE48-11C3316B135E + 5.01 + SerialCommChatPocketPC_CS + v2.0 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE;$(PlatformFamilyName) + true + true + prompt + 512 + 4 + Off + + + pdbonly + true + bin\Release\ + TRACE;$(PlatformFamilyName) + true + true + prompt + 512 + 4 + Off + + + + + + + + + + + + Form + + + Form1.cs + + + + + Designer + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS.csproj.user b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS.csproj.user new file mode 100644 index 0000000..76bd09e --- /dev/null +++ b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS.csproj.user @@ -0,0 +1,5 @@ + + + 4118C335-430C-497f-BE48-11C3316B135Ed6518ffb-710f-11d3-99f2-00105a0df099 + + \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/bin/Debug/SerialCommChatPocketPC_CS.exe b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/bin/Debug/SerialCommChatPocketPC_CS.exe new file mode 100644 index 0000000..530bfdc Binary files /dev/null and b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/bin/Debug/SerialCommChatPocketPC_CS.exe differ diff --git a/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/bin/Debug/SerialCommChatPocketPC_CS.pdb b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/bin/Debug/SerialCommChatPocketPC_CS.pdb new file mode 100644 index 0000000..0081b71 Binary files /dev/null and b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/bin/Debug/SerialCommChatPocketPC_CS.pdb differ diff --git a/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/obj/Debug/SerialCommChatPocketPC_CS.Form1.resources b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/obj/Debug/SerialCommChatPocketPC_CS.Form1.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/obj/Debug/SerialCommChatPocketPC_CS.Form1.resources differ diff --git a/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/obj/Debug/SerialCommChatPocketPC_CS.Properties.Resources.resources b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/obj/Debug/SerialCommChatPocketPC_CS.Properties.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/obj/Debug/SerialCommChatPocketPC_CS.Properties.Resources.resources differ diff --git a/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/obj/Debug/SerialCommChatPocketPC_CS.csproj.GenerateResource.Cache b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/obj/Debug/SerialCommChatPocketPC_CS.csproj.GenerateResource.Cache new file mode 100644 index 0000000..9c3f7d9 Binary files /dev/null and b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/obj/Debug/SerialCommChatPocketPC_CS.csproj.GenerateResource.Cache differ diff --git a/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/obj/Debug/SerialCommChatPocketPC_CS.exe b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/obj/Debug/SerialCommChatPocketPC_CS.exe new file mode 100644 index 0000000..530bfdc Binary files /dev/null and b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/obj/Debug/SerialCommChatPocketPC_CS.exe differ diff --git a/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/obj/Debug/SerialCommChatPocketPC_CS.pdb b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/obj/Debug/SerialCommChatPocketPC_CS.pdb new file mode 100644 index 0000000..0081b71 Binary files /dev/null and b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/obj/Debug/SerialCommChatPocketPC_CS.pdb differ diff --git a/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/obj/SerialCommChatPocketPC_CS.csproj.FileList.txt b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/obj/SerialCommChatPocketPC_CS.csproj.FileList.txt new file mode 100644 index 0000000..7f9b872 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChatPocketPC_CS/SerialCommChatPocketPC_CS/obj/SerialCommChatPocketPC_CS.csproj.FileList.txt @@ -0,0 +1,8 @@ +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\SerialCommChatPocketPC_CS.Form1.resources +obj\Debug\SerialCommChatPocketPC_CS.Properties.Resources.resources +obj\Debug\SerialCommChatPocketPC_CS.csproj.GenerateResource.Cache +bin\Debug\SerialCommChatPocketPC_CS.exe +bin\Debug\SerialCommChatPocketPC_CS.pdb +obj\Debug\SerialCommChatPocketPC_CS.exe +obj\Debug\SerialCommChatPocketPC_CS.pdb diff --git a/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS.sln b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS.sln new file mode 100644 index 0000000..0942811 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SerialCommChat_CS", "SerialCommChat_CS\SerialCommChat_CS.csproj", "{DEBC6FA8-87D2-45E9-A52F-074096E22D30}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DEBC6FA8-87D2-45E9-A52F-074096E22D30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DEBC6FA8-87D2-45E9-A52F-074096E22D30}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DEBC6FA8-87D2-45E9-A52F-074096E22D30}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DEBC6FA8-87D2-45E9-A52F-074096E22D30}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS.suo b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS.suo new file mode 100644 index 0000000..a5b97f5 Binary files /dev/null and b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS.suo differ diff --git a/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Form1.Designer.cs b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Form1.Designer.cs new file mode 100644 index 0000000..92071a5 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Form1.Designer.cs @@ -0,0 +1,211 @@ +namespace SerialCommChat_CS +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.Label2 = new System.Windows.Forms.Label(); + this.txtPhoneNumber = new System.Windows.Forms.TextBox(); + this.btnDialNumber = new System.Windows.Forms.Button(); + this.GroupBox1 = new System.Windows.Forms.GroupBox(); + this.btnAnswerCall = new System.Windows.Forms.Button(); + this.txtDataReceived = new System.Windows.Forms.RichTextBox(); + this.btnDisconnect = new System.Windows.Forms.Button(); + this.btnConnect = new System.Windows.Forms.Button(); + this.lblMessage = new System.Windows.Forms.Label(); + this.btnSend = new System.Windows.Forms.Button(); + this.txtDataToSend = new System.Windows.Forms.TextBox(); + this.cbbCOMPorts = new System.Windows.Forms.ComboBox(); + this.Label1 = new System.Windows.Forms.Label(); + this.GroupBox1.SuspendLayout(); + this.SuspendLayout(); + // + // Label2 + // + this.Label2.AutoSize = true; + this.Label2.Location = new System.Drawing.Point(6, 22); + this.Label2.Name = "Label2"; + this.Label2.Size = new System.Drawing.Size(78, 13); + this.Label2.TabIndex = 10; + this.Label2.Text = "Phone Number"; + // + // txtPhoneNumber + // + this.txtPhoneNumber.Location = new System.Drawing.Point(85, 19); + this.txtPhoneNumber.Name = "txtPhoneNumber"; + this.txtPhoneNumber.Size = new System.Drawing.Size(99, 20); + this.txtPhoneNumber.TabIndex = 9; + // + // btnDialNumber + // + this.btnDialNumber.Location = new System.Drawing.Point(190, 17); + this.btnDialNumber.Name = "btnDialNumber"; + this.btnDialNumber.Size = new System.Drawing.Size(75, 23); + this.btnDialNumber.TabIndex = 11; + this.btnDialNumber.Text = "Dial Number"; + this.btnDialNumber.UseVisualStyleBackColor = true; + this.btnDialNumber.Click += new System.EventHandler(this.btnDialNumber_Click); + // + // GroupBox1 + // + this.GroupBox1.Controls.Add(this.Label2); + this.GroupBox1.Controls.Add(this.btnAnswerCall); + this.GroupBox1.Controls.Add(this.txtPhoneNumber); + this.GroupBox1.Controls.Add(this.btnDialNumber); + this.GroupBox1.Location = new System.Drawing.Point(12, 290); + this.GroupBox1.Name = "GroupBox1"; + this.GroupBox1.Size = new System.Drawing.Size(352, 50); + this.GroupBox1.TabIndex = 22; + this.GroupBox1.TabStop = false; + this.GroupBox1.Text = "Bluetooth Handset"; + // + // btnAnswerCall + // + this.btnAnswerCall.Location = new System.Drawing.Point(271, 17); + this.btnAnswerCall.Name = "btnAnswerCall"; + this.btnAnswerCall.Size = new System.Drawing.Size(75, 23); + this.btnAnswerCall.TabIndex = 12; + this.btnAnswerCall.Text = "Answer Call"; + this.btnAnswerCall.UseVisualStyleBackColor = true; + this.btnAnswerCall.Click += new System.EventHandler(this.btnAnswerCall_Click); + // + // txtDataReceived + // + this.txtDataReceived.Location = new System.Drawing.Point(12, 63); + this.txtDataReceived.Name = "txtDataReceived"; + this.txtDataReceived.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical; + this.txtDataReceived.Size = new System.Drawing.Size(352, 168); + this.txtDataReceived.TabIndex = 21; + this.txtDataReceived.Text = ""; + // + // btnDisconnect + // + this.btnDisconnect.Location = new System.Drawing.Point(291, 5); + this.btnDisconnect.Name = "btnDisconnect"; + this.btnDisconnect.Size = new System.Drawing.Size(75, 23); + this.btnDisconnect.TabIndex = 20; + this.btnDisconnect.Text = "Disconnect"; + this.btnDisconnect.UseVisualStyleBackColor = true; + this.btnDisconnect.Click += new System.EventHandler(this.btnDisconnect_Click); + // + // btnConnect + // + this.btnConnect.Location = new System.Drawing.Point(210, 5); + this.btnConnect.Name = "btnConnect"; + this.btnConnect.Size = new System.Drawing.Size(75, 23); + this.btnConnect.TabIndex = 19; + this.btnConnect.Text = "Connect"; + this.btnConnect.UseVisualStyleBackColor = true; + this.btnConnect.Click += new System.EventHandler(this.btnConnect_Click); + // + // lblMessage + // + this.lblMessage.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.lblMessage.Location = new System.Drawing.Point(12, 37); + this.lblMessage.Name = "lblMessage"; + this.lblMessage.Size = new System.Drawing.Size(352, 23); + this.lblMessage.TabIndex = 18; + // + // btnSend + // + this.btnSend.Location = new System.Drawing.Point(289, 261); + this.btnSend.Name = "btnSend"; + this.btnSend.Size = new System.Drawing.Size(75, 23); + this.btnSend.TabIndex = 17; + this.btnSend.Text = "Send"; + this.btnSend.UseVisualStyleBackColor = true; + this.btnSend.Click += new System.EventHandler(this.btnSend_Click); + // + // txtDataToSend + // + this.txtDataToSend.Location = new System.Drawing.Point(12, 237); + this.txtDataToSend.Multiline = true; + this.txtDataToSend.Name = "txtDataToSend"; + this.txtDataToSend.Size = new System.Drawing.Size(273, 47); + this.txtDataToSend.TabIndex = 16; + // + // cbbCOMPorts + // + this.cbbCOMPorts.FormattingEnabled = true; + this.cbbCOMPorts.Location = new System.Drawing.Point(122, 7); + this.cbbCOMPorts.Name = "cbbCOMPorts"; + this.cbbCOMPorts.Size = new System.Drawing.Size(80, 21); + this.cbbCOMPorts.TabIndex = 15; + // + // Label1 + // + this.Label1.AutoSize = true; + this.Label1.Location = new System.Drawing.Point(12, 10); + this.Label1.Name = "Label1"; + this.Label1.Size = new System.Drawing.Size(104, 13); + this.Label1.TabIndex = 14; + this.Label1.Text = "Available COM Ports"; + // + // Form1 + // + this.AcceptButton = this.btnSend; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.SystemColors.Control; + this.ClientSize = new System.Drawing.Size(378, 349); + this.Controls.Add(this.GroupBox1); + this.Controls.Add(this.txtDataReceived); + this.Controls.Add(this.btnDisconnect); + this.Controls.Add(this.btnConnect); + this.Controls.Add(this.lblMessage); + this.Controls.Add(this.btnSend); + this.Controls.Add(this.txtDataToSend); + this.Controls.Add(this.cbbCOMPorts); + this.Controls.Add(this.Label1); + this.Name = "Form1"; + this.Text = "Serial Chat"; + this.Load += new System.EventHandler(this.Form1_Load); + this.GroupBox1.ResumeLayout(false); + this.GroupBox1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + internal System.Windows.Forms.Label Label2; + internal System.Windows.Forms.TextBox txtPhoneNumber; + internal System.Windows.Forms.Button btnDialNumber; + internal System.Windows.Forms.GroupBox GroupBox1; + internal System.Windows.Forms.Button btnAnswerCall; + internal System.Windows.Forms.RichTextBox txtDataReceived; + internal System.Windows.Forms.Button btnDisconnect; + internal System.Windows.Forms.Button btnConnect; + internal System.Windows.Forms.Label lblMessage; + internal System.Windows.Forms.Button btnSend; + internal System.Windows.Forms.TextBox txtDataToSend; + internal System.Windows.Forms.ComboBox cbbCOMPorts; + internal System.Windows.Forms.Label Label1; + } +} + diff --git a/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Form1.cs b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Form1.cs new file mode 100644 index 0000000..09d7424 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Form1.cs @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace SerialCommChat_CS +{ + public partial class Form1 : Form + { + private System.IO.Ports.SerialPort serialPort = + new System.IO.Ports.SerialPort(); + + public Form1() + { + InitializeComponent(); + } + + private void btnConnect_Click(object sender, EventArgs e) + { + if (serialPort.IsOpen) + { + serialPort.Close(); + } + try + { + serialPort.PortName = cbbCOMPorts.Text; + serialPort.BaudRate = 9600; + serialPort.Parity = System.IO.Ports.Parity.None; + serialPort.DataBits = 8; + serialPort.StopBits = System.IO.Ports.StopBits.One; + // serialPort.Encoding = System.Text.Encoding.Unicode; + serialPort.Open(); + lblMessage.Text = cbbCOMPorts.Text + " connected."; + btnConnect.Enabled = false; + btnDisconnect.Enabled = true; + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + } + + private void DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) + { + txtDataReceived.BeginInvoke(new myDelegate(updateTextBox)); + } + + public delegate void myDelegate(); + public void updateTextBox() + { + //---for receiving plan ASCII text--- + //txtDataReceived.AppendText(serialPort.ReadExisting()); + //txtDataReceived.ScrollToCaret(); + + //---UNICODE work-around--- + int bytesToRead = serialPort.BytesToRead; + char[] ch = new char[bytesToRead]; + int bytesRead = 0; + bytesRead = serialPort.Read(ch, 0, bytesToRead); + string str = new string(ch, 0, bytesRead); + txtDataReceived.AppendText(str); + txtDataReceived.ScrollToCaret(); + } + + private void btnDisconnect_Click(object sender, EventArgs e) + { + try + { + serialPort.Close(); + lblMessage.Text = serialPort.PortName + " disconnected."; + btnConnect.Enabled = true; + btnDisconnect.Enabled = false; + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + } + + private void btnSend_Click(object sender, EventArgs e) + { + try + { + serialPort.Write(txtDataToSend.Text + Environment.NewLine); + txtDataReceived.AppendText(">" + txtDataToSend.Text + Environment.NewLine); + txtDataReceived.ScrollToCaret(); + txtDataToSend.Text = string.Empty; + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + } + + private void Form1_Load(object sender, EventArgs e) + { + // set the event handler for the DataReceived event + serialPort.DataReceived += + new System.IO.Ports.SerialDataReceivedEventHandler(DataReceived); + + // display all the serial port names on the local computer + string[] portNames = System.IO.Ports.SerialPort.GetPortNames(); + for (int i = 0; i <= portNames.Length - 1; i++) + { + cbbCOMPorts.Items.Add(portNames[i]); + } + btnDisconnect.Enabled = false; + } + + private void btnDialNumber_Click(object sender, EventArgs e) + { + serialPort.Write("ATDT " + txtPhoneNumber.Text + Environment.NewLine); + } + + private void btnAnswerCall_Click(object sender, EventArgs e) + { + serialPort.Write("AT*EVA" + Environment.NewLine); + } + } +} \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Form1.resx b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Form1.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Program.cs b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Program.cs new file mode 100644 index 0000000..3fc30a2 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace SerialCommChat_CS +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Properties/AssemblyInfo.cs b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..710f252 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SerialCommChat_CS")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SerialCommChat_CS")] +[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("6cbcfd0b-b0bd-4c55-a0c8-265162b1f734")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Properties/Resources.Designer.cs b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Properties/Resources.Designer.cs new file mode 100644 index 0000000..9b350a7 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SerialCommChat_CS.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SerialCommChat_CS.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Properties/Resources.resx b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Properties/Settings.Designer.cs b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Properties/Settings.Designer.cs new file mode 100644 index 0000000..396720a --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SerialCommChat_CS.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Properties/Settings.settings b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/SerialCommChat_CS.csproj b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/SerialCommChat_CS.csproj new file mode 100644 index 0000000..692ae00 --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/SerialCommChat_CS.csproj @@ -0,0 +1,78 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {DEBC6FA8-87D2-45E9-A52F-074096E22D30} + WinExe + Properties + SerialCommChat_CS + SerialCommChat_CS + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + Form + + + Form1.cs + + + + + Designer + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + \ No newline at end of file diff --git a/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/bin/Debug/SerialCommChat_CS.exe b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/bin/Debug/SerialCommChat_CS.exe new file mode 100644 index 0000000..3fcd6d0 Binary files /dev/null and b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/bin/Debug/SerialCommChat_CS.exe differ diff --git a/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/bin/Debug/SerialCommChat_CS.pdb b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/bin/Debug/SerialCommChat_CS.pdb new file mode 100644 index 0000000..0ae38eb Binary files /dev/null and b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/bin/Debug/SerialCommChat_CS.pdb differ diff --git a/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/bin/Debug/SerialCommChat_CS.vshost.exe b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/bin/Debug/SerialCommChat_CS.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/bin/Debug/SerialCommChat_CS.vshost.exe differ diff --git a/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/obj/Debug/SerialCommChat_CS.Form1.resources b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/obj/Debug/SerialCommChat_CS.Form1.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/obj/Debug/SerialCommChat_CS.Form1.resources differ diff --git a/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/obj/Debug/SerialCommChat_CS.Properties.Resources.resources b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/obj/Debug/SerialCommChat_CS.Properties.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/obj/Debug/SerialCommChat_CS.Properties.Resources.resources differ diff --git a/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/obj/Debug/SerialCommChat_CS.csproj.GenerateResource.Cache b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/obj/Debug/SerialCommChat_CS.csproj.GenerateResource.Cache new file mode 100644 index 0000000..04d3a99 Binary files /dev/null and b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/obj/Debug/SerialCommChat_CS.csproj.GenerateResource.Cache differ diff --git a/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/obj/Debug/SerialCommChat_CS.exe b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/obj/Debug/SerialCommChat_CS.exe new file mode 100644 index 0000000..3fcd6d0 Binary files /dev/null and b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/obj/Debug/SerialCommChat_CS.exe differ diff --git a/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/obj/Debug/SerialCommChat_CS.pdb b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/obj/Debug/SerialCommChat_CS.pdb new file mode 100644 index 0000000..0ae38eb Binary files /dev/null and b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/obj/Debug/SerialCommChat_CS.pdb differ diff --git a/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/obj/SerialCommChat_CS.csproj.FileList.txt b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/obj/SerialCommChat_CS.csproj.FileList.txt new file mode 100644 index 0000000..a3731aa --- /dev/null +++ b/Chapter02(Serial)/SerialCommChat_CS/SerialCommChat_CS/obj/SerialCommChat_CS.csproj.FileList.txt @@ -0,0 +1,8 @@ +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\SerialCommChat_CS.Form1.resources +obj\Debug\SerialCommChat_CS.Properties.Resources.resources +obj\Debug\SerialCommChat_CS.csproj.GenerateResource.Cache +bin\Debug\SerialCommChat_CS.exe +bin\Debug\SerialCommChat_CS.pdb +obj\Debug\SerialCommChat_CS.exe +obj\Debug\SerialCommChat_CS.pdb diff --git a/Chapter02(Serial)/VirtualEarth/GPSReceiver/Form1.Designer.vb b/Chapter02(Serial)/VirtualEarth/GPSReceiver/Form1.Designer.vb new file mode 100644 index 0000000..15bbba6 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/GPSReceiver/Form1.Designer.vb @@ -0,0 +1,112 @@ + _ +Partial Public Class Form1 + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + private mainMenu1 As System.Windows.Forms.MainMenu + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.mainMenu1 = New System.Windows.Forms.MainMenu + Me.btnConnect = New System.Windows.Forms.Button + Me.Label3 = New System.Windows.Forms.Label + Me.cbbCOMPorts = New System.Windows.Forms.ComboBox + Me.txtGPSData = New System.Windows.Forms.TextBox + Me.Label2 = New System.Windows.Forms.Label + Me.btnDisconnect = New System.Windows.Forms.Button + Me.SuspendLayout() + ' + 'btnConnect + ' + Me.btnConnect.Location = New System.Drawing.Point(157, 3) + Me.btnConnect.Name = "btnConnect" + Me.btnConnect.Size = New System.Drawing.Size(80, 20) + Me.btnConnect.TabIndex = 12 + Me.btnConnect.Text = "Connect" + ' + 'Label3 + ' + Me.Label3.Location = New System.Drawing.Point(3, 5) + Me.Label3.Name = "Label3" + Me.Label3.Size = New System.Drawing.Size(59, 20) + Me.Label3.Text = "COM Port" + ' + 'cbbCOMPorts + ' + Me.cbbCOMPorts.Items.Add("COM1") + Me.cbbCOMPorts.Items.Add("COM2") + Me.cbbCOMPorts.Items.Add("COM3") + Me.cbbCOMPorts.Items.Add("COM4") + Me.cbbCOMPorts.Items.Add("COM5") + Me.cbbCOMPorts.Items.Add("COM6") + Me.cbbCOMPorts.Items.Add("COM7") + Me.cbbCOMPorts.Items.Add("COM8") + Me.cbbCOMPorts.Items.Add("COM9") + Me.cbbCOMPorts.Location = New System.Drawing.Point(68, 3) + Me.cbbCOMPorts.Name = "cbbCOMPorts" + Me.cbbCOMPorts.Size = New System.Drawing.Size(83, 22) + Me.cbbCOMPorts.TabIndex = 11 + ' + 'txtGPSData + ' + Me.txtGPSData.Location = New System.Drawing.Point(3, 51) + Me.txtGPSData.Multiline = True + Me.txtGPSData.Name = "txtGPSData" + Me.txtGPSData.ScrollBars = System.Windows.Forms.ScrollBars.Vertical + Me.txtGPSData.Size = New System.Drawing.Size(234, 214) + Me.txtGPSData.TabIndex = 14 + ' + 'Label2 + ' + Me.Label2.Location = New System.Drawing.Point(3, 28) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(135, 20) + Me.Label2.Text = "Data from GPS" + ' + 'btnDisconnect + ' + Me.btnDisconnect.Location = New System.Drawing.Point(157, 25) + Me.btnDisconnect.Name = "btnDisconnect" + Me.btnDisconnect.Size = New System.Drawing.Size(80, 20) + Me.btnDisconnect.TabIndex = 16 + Me.btnDisconnect.Text = "Disconnect" + ' + 'Form1 + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi + Me.AutoScroll = True + Me.ClientSize = New System.Drawing.Size(240, 268) + Me.Controls.Add(Me.btnDisconnect) + Me.Controls.Add(Me.Label2) + Me.Controls.Add(Me.txtGPSData) + Me.Controls.Add(Me.btnConnect) + Me.Controls.Add(Me.Label3) + Me.Controls.Add(Me.cbbCOMPorts) + Me.Menu = Me.mainMenu1 + Me.Name = "Form1" + Me.Text = "Form1" + Me.ResumeLayout(False) + + End Sub + Friend WithEvents btnConnect As System.Windows.Forms.Button + Friend WithEvents Label3 As System.Windows.Forms.Label + Friend WithEvents cbbCOMPorts As System.Windows.Forms.ComboBox + Friend WithEvents txtGPSData As System.Windows.Forms.TextBox + Friend WithEvents Label2 As System.Windows.Forms.Label + Friend WithEvents btnDisconnect As System.Windows.Forms.Button + +End Class diff --git a/Chapter02(Serial)/VirtualEarth/GPSReceiver/Form1.resx b/Chapter02(Serial)/VirtualEarth/GPSReceiver/Form1.resx new file mode 100644 index 0000000..20d2efa --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/GPSReceiver/Form1.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + Pocket_PC + + + True + + \ No newline at end of file diff --git a/Chapter02(Serial)/VirtualEarth/GPSReceiver/Form1.vb b/Chapter02(Serial)/VirtualEarth/GPSReceiver/Form1.vb new file mode 100644 index 0000000..1062e06 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/GPSReceiver/Form1.vb @@ -0,0 +1,58 @@ +Imports System.IO + +Public Class Form1 + + Dim WithEvents serialPort As New IO.Ports.SerialPort + + Const FILE_NAME = "\My Documents\Personal\GPS.dat" + Private Sub DataReceived( _ + ByVal sender As Object, _ + ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) _ + Handles serialPort.DataReceived + + txtGPSData.BeginInvoke(New _ + myDelegate(AddressOf updateTextBox), _ + New Object() {}) + End Sub + + Public Delegate Sub myDelegate() + Public Sub updateTextBox() + Try + Dim data As String = serialPort.ReadExisting + txtGPSData.Text = _ + data & _ + txtGPSData.Text + '---Using a streamWriter to write to a file + Dim sw As StreamWriter + sw = New StreamWriter(FILE_NAME, True, System.Text.Encoding.ASCII) + sw.WriteLine(data) + sw.Close() + Catch ex As Exception + MsgBox("Error") + End Try + + End Sub + + Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click + Try + If serialPort.IsOpen Then + serialPort.Close() + End If + With serialPort + .PortName = cbbCOMPorts.Text + .BaudRate = 9600 + .Parity = IO.Ports.Parity.None + .DataBits = 8 + .StopBits = IO.Ports.StopBits.One + End With + serialPort.Open() + MsgBox("Port opened successfully!") + Catch ex As Exception + MsgBox(ex.ToString) + End Try + End Sub + + Private Sub btnDisconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisconnect.Click + serialPort.Close() + End Sub +End Class diff --git a/Chapter02(Serial)/VirtualEarth/GPSReceiver/GPSReceiver.suo b/Chapter02(Serial)/VirtualEarth/GPSReceiver/GPSReceiver.suo new file mode 100644 index 0000000..f9f1c94 Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth/GPSReceiver/GPSReceiver.suo differ diff --git a/Chapter02(Serial)/VirtualEarth/GPSReceiver/GPSReceiver.vbproj b/Chapter02(Serial)/VirtualEarth/GPSReceiver/GPSReceiver.vbproj new file mode 100644 index 0000000..bde42ec --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/GPSReceiver/GPSReceiver.vbproj @@ -0,0 +1,108 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {AE18DC1A-A177-4B46-8C1D-00C70D7947B2} + WinExe + GPSReceiver.Form1 + GPSReceiver + GPSReceiver + {68B1623D-7FB9-47D8-8664-7ECEA3297D4F};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + PocketPC + 4118C335-430C-497f-BE48-11C3316B135E + 5.01 + WindowsForms + GPSReceiver + v2.0 + + + + + true + full + true + true + bin\Debug\ + $(PlatformFamilyName)=TRUE + GPSReceiver.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + 512 + Off + true + true + + + pdbonly + false + true + true + bin\Release\ + $(PlatformFamilyName)=TRUE + GPSReceiver.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + 512 + Off + true + true + + + + + + + + + + + + + + + + + + Form + + + Form1.vb + Form + + + + True + True + Resources.resx + + + + + Designer + Form1.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter02(Serial)/VirtualEarth/GPSReceiver/GPSReceiver.vbproj.user b/Chapter02(Serial)/VirtualEarth/GPSReceiver/GPSReceiver.vbproj.user new file mode 100644 index 0000000..76bd09e --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/GPSReceiver/GPSReceiver.vbproj.user @@ -0,0 +1,5 @@ + + + 4118C335-430C-497f-BE48-11C3316B135Ed6518ffb-710f-11d3-99f2-00105a0df099 + + \ No newline at end of file diff --git a/Chapter02(Serial)/VirtualEarth/GPSReceiver/My Project/AssemblyInfo.vb b/Chapter02(Serial)/VirtualEarth/GPSReceiver/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..fc08f93 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/GPSReceiver/My Project/AssemblyInfo.vb @@ -0,0 +1,36 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + diff --git a/Chapter02(Serial)/VirtualEarth/GPSReceiver/My Project/Resources.Designer.vb b/Chapter02(Serial)/VirtualEarth/GPSReceiver/My Project/Resources.Designer.vb new file mode 100644 index 0000000..8d9bbc3 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/GPSReceiver/My Project/Resources.Designer.vb @@ -0,0 +1,59 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict Off +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the Strongly Typed Resource Builder + 'class via a tool like ResGen or Visual Studio.NET. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Module Resources + + Private _resMgr As System.Resources.ResourceManager + + Private _resCulture As System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As System.Resources.ResourceManager + Get + If (_resMgr Is Nothing) Then + Dim temp As System.Resources.ResourceManager = New System.Resources.ResourceManager("GPSReceiver.Resources", GetType(Resources).Assembly) + _resMgr = temp + End If + Return _resMgr + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As System.Globalization.CultureInfo + Get + Return _resCulture + End Get + Set + _resCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Chapter02(Serial)/VirtualEarth/GPSReceiver/My Project/Resources.resx b/Chapter02(Serial)/VirtualEarth/GPSReceiver/My Project/Resources.resx new file mode 100644 index 0000000..3e18af9 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/GPSReceiver/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter02(Serial)/VirtualEarth/GPSReceiver/bin/Debug/GPSReceiver.exe b/Chapter02(Serial)/VirtualEarth/GPSReceiver/bin/Debug/GPSReceiver.exe new file mode 100644 index 0000000..72074c3 Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth/GPSReceiver/bin/Debug/GPSReceiver.exe differ diff --git a/Chapter02(Serial)/VirtualEarth/GPSReceiver/bin/Debug/GPSReceiver.pdb b/Chapter02(Serial)/VirtualEarth/GPSReceiver/bin/Debug/GPSReceiver.pdb new file mode 100644 index 0000000..bce93de Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth/GPSReceiver/bin/Debug/GPSReceiver.pdb differ diff --git a/Chapter02(Serial)/VirtualEarth/GPSReceiver/bin/Debug/GPSReceiver.xml b/Chapter02(Serial)/VirtualEarth/GPSReceiver/bin/Debug/GPSReceiver.xml new file mode 100644 index 0000000..e313b03 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/GPSReceiver/bin/Debug/GPSReceiver.xml @@ -0,0 +1,24 @@ + + + + +GPSReceiver + + + + + + Returns the cached ResourceManager instance used by this class. + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + \ No newline at end of file diff --git a/Chapter02(Serial)/VirtualEarth/GPSReceiver/obj/Debug/GPSReceiver.Form1.resources b/Chapter02(Serial)/VirtualEarth/GPSReceiver/obj/Debug/GPSReceiver.Form1.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth/GPSReceiver/obj/Debug/GPSReceiver.Form1.resources differ diff --git a/Chapter02(Serial)/VirtualEarth/GPSReceiver/obj/Debug/GPSReceiver.Resources.resources b/Chapter02(Serial)/VirtualEarth/GPSReceiver/obj/Debug/GPSReceiver.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth/GPSReceiver/obj/Debug/GPSReceiver.Resources.resources differ diff --git a/Chapter02(Serial)/VirtualEarth/GPSReceiver/obj/Debug/GPSReceiver.exe b/Chapter02(Serial)/VirtualEarth/GPSReceiver/obj/Debug/GPSReceiver.exe new file mode 100644 index 0000000..72074c3 Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth/GPSReceiver/obj/Debug/GPSReceiver.exe differ diff --git a/Chapter02(Serial)/VirtualEarth/GPSReceiver/obj/Debug/GPSReceiver.pdb b/Chapter02(Serial)/VirtualEarth/GPSReceiver/obj/Debug/GPSReceiver.pdb new file mode 100644 index 0000000..bce93de Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth/GPSReceiver/obj/Debug/GPSReceiver.pdb differ diff --git a/Chapter02(Serial)/VirtualEarth/GPSReceiver/obj/Debug/GPSReceiver.vbproj.GenerateResource.Cache b/Chapter02(Serial)/VirtualEarth/GPSReceiver/obj/Debug/GPSReceiver.vbproj.GenerateResource.Cache new file mode 100644 index 0000000..3e94cd2 Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth/GPSReceiver/obj/Debug/GPSReceiver.vbproj.GenerateResource.Cache differ diff --git a/Chapter02(Serial)/VirtualEarth/GPSReceiver/obj/Debug/GPSReceiver.xml b/Chapter02(Serial)/VirtualEarth/GPSReceiver/obj/Debug/GPSReceiver.xml new file mode 100644 index 0000000..e313b03 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/GPSReceiver/obj/Debug/GPSReceiver.xml @@ -0,0 +1,24 @@ + + + + +GPSReceiver + + + + + + Returns the cached ResourceManager instance used by this class. + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + \ No newline at end of file diff --git a/Chapter02(Serial)/VirtualEarth/GPSReceiver/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll b/Chapter02(Serial)/VirtualEarth/GPSReceiver/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll new file mode 100644 index 0000000..6531bb7 Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth/GPSReceiver/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll differ diff --git a/Chapter02(Serial)/VirtualEarth/GPSReceiver/obj/GPSReceiver.vbproj.FileList.txt b/Chapter02(Serial)/VirtualEarth/GPSReceiver/obj/GPSReceiver.vbproj.FileList.txt new file mode 100644 index 0000000..62df0c8 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/GPSReceiver/obj/GPSReceiver.vbproj.FileList.txt @@ -0,0 +1,10 @@ +bin\Debug\GPSReceiver.exe +bin\Debug\GPSReceiver.pdb +bin\Debug\GPSReceiver.xml +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\GPSReceiver.Form1.resources +obj\Debug\GPSReceiver.Resources.resources +obj\Debug\GPSReceiver.vbproj.GenerateResource.Cache +obj\Debug\GPSReceiver.exe +obj\Debug\GPSReceiver.xml +obj\Debug\GPSReceiver.pdb diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/Copy of Map.html b/Chapter02(Serial)/VirtualEarth/VirtualEarth/Copy of Map.html new file mode 100644 index 0000000..2af5188 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/VirtualEarth/Copy of Map.html @@ -0,0 +1,63 @@ + + + My Virtual Earth + + + + + +
+ + diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/Form1.Designer.vb b/Chapter02(Serial)/VirtualEarth/VirtualEarth/Form1.Designer.vb new file mode 100644 index 0000000..0991bcd --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/VirtualEarth/Form1.Designer.vb @@ -0,0 +1,238 @@ + _ +Partial Class Form1 + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.components = New System.ComponentModel.Container + Me.btnClearPath = New System.Windows.Forms.Button + Me.btnShowPath = New System.Windows.Forms.Button + Me.WebBrowser1 = New System.Windows.Forms.WebBrowser + Me.Timer1 = New System.Windows.Forms.Timer(Me.components) + Me.GroupBox1 = New System.Windows.Forms.GroupBox + Me.btnGotoPoint = New System.Windows.Forms.Button + Me.txtLongitude = New System.Windows.Forms.TextBox + Me.txtLatitude = New System.Windows.Forms.TextBox + Me.Label3 = New System.Windows.Forms.Label + Me.Label2 = New System.Windows.Forms.Label + Me.GroupBox2 = New System.Windows.Forms.GroupBox + Me.txtDataReceived = New System.Windows.Forms.TextBox + Me.btnConnect = New System.Windows.Forms.Button + Me.cbbCOMPorts = New System.Windows.Forms.ComboBox + Me.Label1 = New System.Windows.Forms.Label + Me.lblMessage = New System.Windows.Forms.Label + Me.GroupBox3 = New System.Windows.Forms.GroupBox + Me.GroupBox1.SuspendLayout() + Me.GroupBox2.SuspendLayout() + Me.GroupBox3.SuspendLayout() + Me.SuspendLayout() + ' + 'btnClearPath + ' + Me.btnClearPath.Location = New System.Drawing.Point(6, 42) + Me.btnClearPath.Name = "btnClearPath" + Me.btnClearPath.Size = New System.Drawing.Size(233, 23) + Me.btnClearPath.TabIndex = 1 + Me.btnClearPath.Text = "Clear Path" + Me.btnClearPath.UseVisualStyleBackColor = True + ' + 'btnShowPath + ' + Me.btnShowPath.Location = New System.Drawing.Point(6, 19) + Me.btnShowPath.Name = "btnShowPath" + Me.btnShowPath.Size = New System.Drawing.Size(233, 23) + Me.btnShowPath.TabIndex = 2 + Me.btnShowPath.Text = "Show Path" + Me.btnShowPath.UseVisualStyleBackColor = True + ' + 'WebBrowser1 + ' + Me.WebBrowser1.Location = New System.Drawing.Point(2, 3) + Me.WebBrowser1.MinimumSize = New System.Drawing.Size(20, 20) + Me.WebBrowser1.Name = "WebBrowser1" + Me.WebBrowser1.ScrollBarsEnabled = False + Me.WebBrowser1.Size = New System.Drawing.Size(460, 380) + Me.WebBrowser1.TabIndex = 9 + ' + 'Timer1 + ' + Me.Timer1.Interval = 500 + ' + 'GroupBox1 + ' + Me.GroupBox1.Controls.Add(Me.btnGotoPoint) + Me.GroupBox1.Controls.Add(Me.txtLongitude) + Me.GroupBox1.Controls.Add(Me.txtLatitude) + Me.GroupBox1.Controls.Add(Me.Label3) + Me.GroupBox1.Controls.Add(Me.Label2) + Me.GroupBox1.Location = New System.Drawing.Point(468, 3) + Me.GroupBox1.Name = "GroupBox1" + Me.GroupBox1.Size = New System.Drawing.Size(245, 104) + Me.GroupBox1.TabIndex = 11 + Me.GroupBox1.TabStop = False + Me.GroupBox1.Text = "Current Location:" + ' + 'btnGotoPoint + ' + Me.btnGotoPoint.Location = New System.Drawing.Point(141, 71) + Me.btnGotoPoint.Name = "btnGotoPoint" + Me.btnGotoPoint.Size = New System.Drawing.Size(98, 23) + Me.btnGotoPoint.TabIndex = 13 + Me.btnGotoPoint.Text = "Goto Point" + Me.btnGotoPoint.UseVisualStyleBackColor = True + ' + 'txtLongitude + ' + Me.txtLongitude.Location = New System.Drawing.Point(67, 45) + Me.txtLongitude.Name = "txtLongitude" + Me.txtLongitude.Size = New System.Drawing.Size(172, 20) + Me.txtLongitude.TabIndex = 12 + ' + 'txtLatitude + ' + Me.txtLatitude.Location = New System.Drawing.Point(67, 19) + Me.txtLatitude.Name = "txtLatitude" + Me.txtLatitude.Size = New System.Drawing.Size(172, 20) + Me.txtLatitude.TabIndex = 11 + ' + 'Label3 + ' + Me.Label3.AutoSize = True + Me.Label3.Location = New System.Drawing.Point(7, 48) + Me.Label3.Name = "Label3" + Me.Label3.Size = New System.Drawing.Size(54, 13) + Me.Label3.TabIndex = 10 + Me.Label3.Text = "Longitude" + ' + 'Label2 + ' + Me.Label2.AutoSize = True + Me.Label2.Location = New System.Drawing.Point(16, 22) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(45, 13) + Me.Label2.TabIndex = 9 + Me.Label2.Text = "Latitude" + ' + 'GroupBox2 + ' + Me.GroupBox2.Controls.Add(Me.txtDataReceived) + Me.GroupBox2.Controls.Add(Me.btnConnect) + Me.GroupBox2.Controls.Add(Me.cbbCOMPorts) + Me.GroupBox2.Controls.Add(Me.Label1) + Me.GroupBox2.Location = New System.Drawing.Point(468, 113) + Me.GroupBox2.Name = "GroupBox2" + Me.GroupBox2.Size = New System.Drawing.Size(245, 159) + Me.GroupBox2.TabIndex = 12 + Me.GroupBox2.TabStop = False + Me.GroupBox2.Text = "GPS" + ' + 'txtDataReceived + ' + Me.txtDataReceived.Location = New System.Drawing.Point(6, 43) + Me.txtDataReceived.Multiline = True + Me.txtDataReceived.Name = "txtDataReceived" + Me.txtDataReceived.ScrollBars = System.Windows.Forms.ScrollBars.Both + Me.txtDataReceived.Size = New System.Drawing.Size(233, 107) + Me.txtDataReceived.TabIndex = 14 + Me.txtDataReceived.WordWrap = False + ' + 'btnConnect + ' + Me.btnConnect.Location = New System.Drawing.Point(164, 14) + Me.btnConnect.Name = "btnConnect" + Me.btnConnect.Size = New System.Drawing.Size(75, 23) + Me.btnConnect.TabIndex = 13 + Me.btnConnect.Text = "Connect" + Me.btnConnect.UseVisualStyleBackColor = True + ' + 'cbbCOMPorts + ' + Me.cbbCOMPorts.FormattingEnabled = True + Me.cbbCOMPorts.Location = New System.Drawing.Point(78, 16) + Me.cbbCOMPorts.Name = "cbbCOMPorts" + Me.cbbCOMPorts.Size = New System.Drawing.Size(80, 21) + Me.cbbCOMPorts.TabIndex = 12 + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(21, 19) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(51, 13) + Me.Label1.TabIndex = 11 + Me.Label1.Text = "GPS Port" + ' + 'lblMessage + ' + Me.lblMessage.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle + Me.lblMessage.Location = New System.Drawing.Point(471, 354) + Me.lblMessage.Name = "lblMessage" + Me.lblMessage.Size = New System.Drawing.Size(240, 21) + Me.lblMessage.TabIndex = 15 + ' + 'GroupBox3 + ' + Me.GroupBox3.Controls.Add(Me.btnShowPath) + Me.GroupBox3.Controls.Add(Me.btnClearPath) + Me.GroupBox3.Location = New System.Drawing.Point(468, 278) + Me.GroupBox3.Name = "GroupBox3" + Me.GroupBox3.Size = New System.Drawing.Size(245, 73) + Me.GroupBox3.TabIndex = 13 + Me.GroupBox3.TabStop = False + Me.GroupBox3.Text = "Recorded Path" + ' + 'Form1 + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.BackColor = System.Drawing.Color.Khaki + Me.ClientSize = New System.Drawing.Size(718, 385) + Me.Controls.Add(Me.lblMessage) + Me.Controls.Add(Me.GroupBox3) + Me.Controls.Add(Me.GroupBox2) + Me.Controls.Add(Me.GroupBox1) + Me.Controls.Add(Me.WebBrowser1) + Me.Name = "Form1" + Me.Text = "Microsoft Virtual Earth" + Me.GroupBox1.ResumeLayout(False) + Me.GroupBox1.PerformLayout() + Me.GroupBox2.ResumeLayout(False) + Me.GroupBox2.PerformLayout() + Me.GroupBox3.ResumeLayout(False) + Me.ResumeLayout(False) + + End Sub + Friend WithEvents btnClearPath As System.Windows.Forms.Button + Friend WithEvents btnShowPath As System.Windows.Forms.Button + Friend WithEvents WebBrowser1 As System.Windows.Forms.WebBrowser + Friend WithEvents Timer1 As System.Windows.Forms.Timer + Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox + Friend WithEvents btnGotoPoint As System.Windows.Forms.Button + Friend WithEvents txtLongitude As System.Windows.Forms.TextBox + Friend WithEvents txtLatitude As System.Windows.Forms.TextBox + Friend WithEvents Label3 As System.Windows.Forms.Label + Friend WithEvents Label2 As System.Windows.Forms.Label + Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox + Friend WithEvents GroupBox3 As System.Windows.Forms.GroupBox + Friend WithEvents btnConnect As System.Windows.Forms.Button + Friend WithEvents cbbCOMPorts As System.Windows.Forms.ComboBox + Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents txtDataReceived As System.Windows.Forms.TextBox + Friend WithEvents lblMessage As System.Windows.Forms.Label + +End Class diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/Form1.resx b/Chapter02(Serial)/VirtualEarth/VirtualEarth/Form1.resx new file mode 100644 index 0000000..cce5ec2 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/VirtualEarth/Form1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/Form1.vb b/Chapter02(Serial)/VirtualEarth/VirtualEarth/Form1.vb new file mode 100644 index 0000000..383f54b --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/VirtualEarth/Form1.vb @@ -0,0 +1,256 @@ + _ +Public Class Form1 + + '---index of the push pin--- + Private pushpin As Integer = 0 + + '---keeping track of the points--- + Private pointCounter As Integer + + '--used for remembering the lines read + ' from a file containing coordinates--- + Private lineIndex As Integer = 0 + Dim line() As String + + '---serial port for communicating with GPS receiver--- + Private WithEvents serialPort As New IO.Ports.SerialPort + + Private Sub Form1_Load( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles MyBase.Load + + '---display the available COM port on the computer--- + For i As Integer = 0 To _ + My.Computer.Ports.SerialPortNames.Count - 1 + cbbCOMPorts.Items.Add( _ + My.Computer.Ports.SerialPortNames(i)) + Next + + '--Load the Webbrowser control with the Virtual Earth Map--- + Dim fileContents As String + + '---remember to set the Copy to Output Directory + ' property of Map.html to "Copy if newer" + fileContents = My.Computer.FileSystem.ReadAllText( _ + Application.StartupPath & "\Map.html") + + WebBrowser1.DocumentText = fileContents + WebBrowser1.ObjectForScripting = Me + End Sub + + '---clear the plotted path by removing all pushpins--- + Private Sub btnClearPath_Click( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles btnClearPath.Click + For i As Integer = 0 To pushpin + removePushpin(i) + Next + End Sub + + '---plot a path from a GPS data file--- + Private Sub btnShowPath_Click( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles btnShowPath.Click + + Dim fileContents As String = String.Empty + '---let user choose a file--- + Dim openFileDialog1 As New OpenFileDialog() + openFileDialog1.InitialDirectory = "c:\" + openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" + openFileDialog1.FilterIndex = 2 + openFileDialog1.RestoreDirectory = True + + '---Load the content of the selected file--- + If openFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then + fileContents = My.Computer.FileSystem.ReadAllText(openFileDialog1.FileName) + End If + + '---split the content various lines using the $ as the delimiter--- + line = fileContents.Split("$") + lineIndex = 0 + Timer1.Enabled = True + End Sub + + '---go to a particular location on the map--- + Private Sub gotoPosition( _ + ByVal lat As Double, _ + ByVal lng As Double, _ + ByVal showPushpin As Boolean, _ + ByVal pushPinText As String) + + '---display map at specific location--- + Dim param() As Object = New Object() {lat, lng} + WebBrowser1.Document.InvokeScript("goto_map_position", param) + + '---if need to insert pushpin--- + If showPushpin Then + '---set the push pin--- + param = New Object() {pushpin, pushPinText, lat, lng} + WebBrowser1.Document.InvokeScript("addPushpin", param) + pushpin += 1 + End If + End Sub + + '---update the latitude and longitude on the TextBox controls--- + Public Sub mapPositionChange(ByVal lat As Double, ByVal lng As Double) + txtLatitude.Text = lat + txtLongitude.Text = lng + End Sub + + '---remove a pushpin--- + Private Sub removePushpin(ByVal id As Integer) + Dim param() As Object = New Object() {id} + WebBrowser1.Document.InvokeScript("removePushpin", param) + End Sub + + '---set the map to a particular location--- + Private Sub btnGotoPoint_Click( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles btnGotoPoint.Click + + Dim lat, lng As Double + '---get the latitude and longitude--- + lat = txtLatitude.Text + lng = txtLongitude.Text + ' gotoPosition(lat, lng, False, "") + gotoPosition(lat, lng, True, "X") + End Sub + + '---for ploting a path--- + Private Sub Timer1_Tick( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles Timer1.Tick + + If lineIndex = 0 Then pointCounter = 1 + '---plot a point in the path--- + While (lineIndex <= line.Length - 1) + If line(lineIndex).StartsWith("GPGGA") AndAlso _ + processGPSData(line(lineIndex)) Then + lblMessage.Text = "Updating map...point " & pointCounter + pointCounter += 1 + Exit While + End If + lineIndex += 1 + End While + lineIndex += 1 + '---stop the Timer control when the end of the path is reached--- + If lineIndex > line.Length - 1 Then + Timer1.Enabled = False + lblMessage.Text = "Plotting completed." + End If + End Sub + + '---connect to a serial port to communicate with the GPS receiver--- + Private Sub btnConnect_Click( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles btnConnect.Click + If btnConnect.Text = "Connect" Then + btnConnect.Text = "Disconnect" + If serialPort.IsOpen Then + serialPort.Close() + End If + Try + With serialPort + .PortName = cbbCOMPorts.Text + .BaudRate = 9600 + .Parity = IO.Ports.Parity.None + .DataBits = 8 + .StopBits = IO.Ports.StopBits.One + End With + serialPort.Open() + lblMessage.Text = cbbCOMPorts.Text & " connected." + Catch ex As Exception + MsgBox(ex.ToString) + End Try + Else + btnConnect.Text = "Connect" + serialPort.Close() + End If + End Sub + + Private Sub DataReceived( _ + ByVal sender As Object, _ + ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) _ + Handles serialPort.DataReceived + txtDataReceived.BeginInvoke(New _ + myDelegate(AddressOf updateTextBox), _ + New Object() {}) + End Sub + + Public Delegate Sub myDelegate() + Public Sub updateTextBox() + Try + '---for receiving plain ASCII text--- + With txtDataReceived + Dim Data As String = serialPort.ReadExisting + .AppendText(Data) + .ScrollToCaret() + '---process only lines starting with $GPGGA--- + Dim GPSData As String = txtDataReceived.Lines( _ + txtDataReceived.Lines.Length - 2) + If GPSData.StartsWith("$GPGGA") Then + If Not processGPSData(GPSData) Then + lblMessage.Text = "No fix..." + End If + End If + End With + Catch ex As Exception + Console.WriteLine(ex.ToString) + End Try + End Sub + + Private Function processGPSData(ByVal str As String) As Boolean + 'SAMPLE - $GPGGA,092204.999,4250.5589,S,14718.5084,E,1,04,24.4,19.7,M,,,,0000*1F + ' 0 1 2 3 4 5 6 7 8 + ' str = "$GPGGA,092204.999,4250.5589,S,14718.5084,E,1,04,24.4,19.7,M,,,,0000*1F" + Try + '---separate the GPS data into various fields--- + Dim field() As String + field = str.Split(",") + Dim lat, lng As Double + Dim rawLatLng As Double + If field.Length < 15 Then Return False + + '---latitude--- + rawLatLng = Convert.ToDouble(field(2)) + lat = (rawLatLng \ 100) + _ + ((rawLatLng - ((rawLatLng \ 100) * 100)) / 60) + + '---latitude is negative if South--- + If field(3) = "S" Then + lat *= -1.0 + End If + + '---longitude--- + rawLatLng = Convert.ToDouble(field(4)) + lng = (rawLatLng \ 100) + _ + ((rawLatLng - ((rawLatLng \ 100) * 100)) / 60) + + '---longitude is negative if West--- + If field(5) = "W" Then + lng *= -1.0 + End If + + '---update map--- + If str.StartsWith("$") Then + '---live data from GPS--- + gotoPosition(lat, lng, False, "") + Else + '---recorded path--- + gotoPosition(lat, lng, True, "*") + End If + + lblMessage.Text = "Latitude: " & lat & " Longitude: " & lng + Return True + Catch + Return False + End Try + End Function + +End Class diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/Map.html b/Chapter02(Serial)/VirtualEarth/VirtualEarth/Map.html new file mode 100644 index 0000000..3827150 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/VirtualEarth/Map.html @@ -0,0 +1,67 @@ + + + My Virtual Earth + + + + + + +
+ + diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/My Project/Application.Designer.vb b/Chapter02(Serial)/VirtualEarth/VirtualEarth/My Project/Application.Designer.vb new file mode 100644 index 0000000..e9c00fa --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/VirtualEarth/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + 'NOTE: This file is auto-generated; do not modify it directly. To make changes, + ' or if you encounter build errors in this file, go to the Project Designer + ' (go to Project Properties or double-click the My Project node in + ' Solution Explorer), and make changes on the Application tab. + ' + Partial Friend Class MyApplication + + _ + Public Sub New() + MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) + Me.IsSingleInstance = false + Me.EnableVisualStyles = true + Me.SaveMySettingsOnExit = true + Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses + End Sub + + _ + Protected Overrides Sub OnCreateMainForm() + Me.MainForm = Global.VirtualEarth.Form1 + End Sub + End Class +End Namespace diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/My Project/Application.myapp b/Chapter02(Serial)/VirtualEarth/VirtualEarth/My Project/Application.myapp new file mode 100644 index 0000000..1243847 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/VirtualEarth/My Project/Application.myapp @@ -0,0 +1,11 @@ + + + true + Form1 + false + 0 + true + 0 + 0 + true + diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/My Project/AssemblyInfo.vb b/Chapter02(Serial)/VirtualEarth/VirtualEarth/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..f0ea66a --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/VirtualEarth/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + + diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/My Project/Resources.Designer.vb b/Chapter02(Serial)/VirtualEarth/VirtualEarth/My Project/Resources.Designer.vb new file mode 100644 index 0000000..7a62477 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/VirtualEarth/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + +Imports System + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("VirtualEarth.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/My Project/Resources.resx b/Chapter02(Serial)/VirtualEarth/VirtualEarth/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/VirtualEarth/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/My Project/Settings.Designer.vb b/Chapter02(Serial)/VirtualEarth/VirtualEarth/My Project/Settings.Designer.vb new file mode 100644 index 0000000..0c915bc --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/VirtualEarth/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings),MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.VirtualEarth.My.MySettings + Get + Return Global.VirtualEarth.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/My Project/Settings.settings b/Chapter02(Serial)/VirtualEarth/VirtualEarth/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/VirtualEarth/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/VirtualEarth.sln b/Chapter02(Serial)/VirtualEarth/VirtualEarth/VirtualEarth.sln new file mode 100644 index 0000000..c474fc4 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/VirtualEarth/VirtualEarth.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VirtualEarth", "VirtualEarth.vbproj", "{A596933E-3079-4620-8A00-6E703B30317B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A596933E-3079-4620-8A00-6E703B30317B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A596933E-3079-4620-8A00-6E703B30317B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A596933E-3079-4620-8A00-6E703B30317B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A596933E-3079-4620-8A00-6E703B30317B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/VirtualEarth.suo b/Chapter02(Serial)/VirtualEarth/VirtualEarth/VirtualEarth.suo new file mode 100644 index 0000000..86d01f2 Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth/VirtualEarth/VirtualEarth.suo differ diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/VirtualEarth.vbproj b/Chapter02(Serial)/VirtualEarth/VirtualEarth/VirtualEarth.vbproj new file mode 100644 index 0000000..6f7a28f --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/VirtualEarth/VirtualEarth.vbproj @@ -0,0 +1,114 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {A596933E-3079-4620-8A00-6E703B30317B} + WinExe + VirtualEarth.My.MyApplication + VirtualEarth + VirtualEarth + WindowsForms + + + true + full + true + true + bin\Debug\ + VirtualEarth.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + VirtualEarth.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + + + + + + + + + + + + + Form + + + Form1.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + Form1.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + PreserveNewest + + + PreserveNewest + + + + + \ No newline at end of file diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/bin/Debug/Copy of Map.html b/Chapter02(Serial)/VirtualEarth/VirtualEarth/bin/Debug/Copy of Map.html new file mode 100644 index 0000000..2af5188 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/VirtualEarth/bin/Debug/Copy of Map.html @@ -0,0 +1,63 @@ + + + My Virtual Earth + + + + + +
+ + diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/bin/Debug/Map.html b/Chapter02(Serial)/VirtualEarth/VirtualEarth/bin/Debug/Map.html new file mode 100644 index 0000000..3827150 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/VirtualEarth/bin/Debug/Map.html @@ -0,0 +1,67 @@ + + + My Virtual Earth + + + + + + +
+ + diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/bin/Debug/VirtualEarth.exe b/Chapter02(Serial)/VirtualEarth/VirtualEarth/bin/Debug/VirtualEarth.exe new file mode 100644 index 0000000..78c1e70 Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth/VirtualEarth/bin/Debug/VirtualEarth.exe differ diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/bin/Debug/VirtualEarth.pdb b/Chapter02(Serial)/VirtualEarth/VirtualEarth/bin/Debug/VirtualEarth.pdb new file mode 100644 index 0000000..7c30942 Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth/VirtualEarth/bin/Debug/VirtualEarth.pdb differ diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/bin/Debug/VirtualEarth.vshost.exe b/Chapter02(Serial)/VirtualEarth/VirtualEarth/bin/Debug/VirtualEarth.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth/VirtualEarth/bin/Debug/VirtualEarth.vshost.exe differ diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/bin/Debug/VirtualEarth.xml b/Chapter02(Serial)/VirtualEarth/VirtualEarth/bin/Debug/VirtualEarth.xml new file mode 100644 index 0000000..33b7ec4 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/VirtualEarth/bin/Debug/VirtualEarth.xml @@ -0,0 +1,24 @@ + + + + +VirtualEarth + + + + + + Returns the cached ResourceManager instance used by this class. + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + \ No newline at end of file diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll b/Chapter02(Serial)/VirtualEarth/VirtualEarth/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll new file mode 100644 index 0000000..8c4cf1a Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth/VirtualEarth/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll differ diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/obj/Debug/VirtualEarth.Form1.resources b/Chapter02(Serial)/VirtualEarth/VirtualEarth/obj/Debug/VirtualEarth.Form1.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth/VirtualEarth/obj/Debug/VirtualEarth.Form1.resources differ diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/obj/Debug/VirtualEarth.Resources.resources b/Chapter02(Serial)/VirtualEarth/VirtualEarth/obj/Debug/VirtualEarth.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth/VirtualEarth/obj/Debug/VirtualEarth.Resources.resources differ diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/obj/Debug/VirtualEarth.exe b/Chapter02(Serial)/VirtualEarth/VirtualEarth/obj/Debug/VirtualEarth.exe new file mode 100644 index 0000000..78c1e70 Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth/VirtualEarth/obj/Debug/VirtualEarth.exe differ diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/obj/Debug/VirtualEarth.pdb b/Chapter02(Serial)/VirtualEarth/VirtualEarth/obj/Debug/VirtualEarth.pdb new file mode 100644 index 0000000..7c30942 Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth/VirtualEarth/obj/Debug/VirtualEarth.pdb differ diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/obj/Debug/VirtualEarth.vbproj.GenerateResource.Cache b/Chapter02(Serial)/VirtualEarth/VirtualEarth/obj/Debug/VirtualEarth.vbproj.GenerateResource.Cache new file mode 100644 index 0000000..c78992b Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth/VirtualEarth/obj/Debug/VirtualEarth.vbproj.GenerateResource.Cache differ diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/obj/Debug/VirtualEarth.xml b/Chapter02(Serial)/VirtualEarth/VirtualEarth/obj/Debug/VirtualEarth.xml new file mode 100644 index 0000000..33b7ec4 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/VirtualEarth/obj/Debug/VirtualEarth.xml @@ -0,0 +1,24 @@ + + + + +VirtualEarth + + + + + + Returns the cached ResourceManager instance used by this class. + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + \ No newline at end of file diff --git a/Chapter02(Serial)/VirtualEarth/VirtualEarth/obj/VirtualEarth.vbproj.FileList.txt b/Chapter02(Serial)/VirtualEarth/VirtualEarth/obj/VirtualEarth.vbproj.FileList.txt new file mode 100644 index 0000000..d4518d0 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth/VirtualEarth/obj/VirtualEarth.vbproj.FileList.txt @@ -0,0 +1,12 @@ +bin\Debug\Map.html +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\VirtualEarth.vbproj.GenerateResource.Cache +bin\Debug\VirtualEarth.exe +bin\Debug\VirtualEarth.pdb +bin\Debug\VirtualEarth.xml +obj\Debug\VirtualEarth.Form1.resources +obj\Debug\VirtualEarth.Resources.resources +obj\Debug\VirtualEarth.exe +obj\Debug\VirtualEarth.xml +obj\Debug\VirtualEarth.pdb +bin\Debug\Copy of Map.html diff --git a/Chapter02(Serial)/VirtualEarth_CS/Form1.Designer.cs b/Chapter02(Serial)/VirtualEarth_CS/Form1.Designer.cs new file mode 100644 index 0000000..b130a13 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth_CS/Form1.Designer.cs @@ -0,0 +1,257 @@ +namespace VirtualEarth_CS +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.lblMessage = new System.Windows.Forms.Label(); + this.btnConnect = new System.Windows.Forms.Button(); + this.Label2 = new System.Windows.Forms.Label(); + this.txtDataReceived = new System.Windows.Forms.TextBox(); + this.cbbCOMPorts = new System.Windows.Forms.ComboBox(); + this.GroupBox3 = new System.Windows.Forms.GroupBox(); + this.btnShowPath = new System.Windows.Forms.Button(); + this.btnClearPath = new System.Windows.Forms.Button(); + this.GroupBox2 = new System.Windows.Forms.GroupBox(); + this.Label1 = new System.Windows.Forms.Label(); + this.btnGotoPoint = new System.Windows.Forms.Button(); + this.WebBrowser1 = new System.Windows.Forms.WebBrowser(); + this.txtLongitude = new System.Windows.Forms.TextBox(); + this.txtLatitude = new System.Windows.Forms.TextBox(); + this.Timer1 = new System.Windows.Forms.Timer(this.components); + this.Label3 = new System.Windows.Forms.Label(); + this.GroupBox1 = new System.Windows.Forms.GroupBox(); + this.GroupBox3.SuspendLayout(); + this.GroupBox2.SuspendLayout(); + this.GroupBox1.SuspendLayout(); + this.SuspendLayout(); + // + // lblMessage + // + this.lblMessage.Location = new System.Drawing.Point(472, 351); + this.lblMessage.Name = "lblMessage"; + this.lblMessage.Size = new System.Drawing.Size(240, 21); + this.lblMessage.TabIndex = 20; + // + // btnConnect + // + this.btnConnect.Location = new System.Drawing.Point(164, 14); + this.btnConnect.Name = "btnConnect"; + this.btnConnect.Size = new System.Drawing.Size(75, 23); + this.btnConnect.TabIndex = 13; + this.btnConnect.Text = "Connect"; + this.btnConnect.UseVisualStyleBackColor = true; + this.btnConnect.Click += new System.EventHandler(this.btnConnect_Click); + // + // Label2 + // + this.Label2.AutoSize = true; + this.Label2.Location = new System.Drawing.Point(16, 22); + this.Label2.Name = "Label2"; + this.Label2.Size = new System.Drawing.Size(45, 13); + this.Label2.TabIndex = 9; + this.Label2.Text = "Latitude"; + // + // txtDataReceived + // + this.txtDataReceived.Location = new System.Drawing.Point(6, 43); + this.txtDataReceived.Multiline = true; + this.txtDataReceived.Name = "txtDataReceived"; + this.txtDataReceived.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.txtDataReceived.Size = new System.Drawing.Size(233, 107); + this.txtDataReceived.TabIndex = 14; + this.txtDataReceived.WordWrap = false; + // + // cbbCOMPorts + // + this.cbbCOMPorts.FormattingEnabled = true; + this.cbbCOMPorts.Location = new System.Drawing.Point(78, 16); + this.cbbCOMPorts.Name = "cbbCOMPorts"; + this.cbbCOMPorts.Size = new System.Drawing.Size(80, 21); + this.cbbCOMPorts.TabIndex = 12; + // + // GroupBox3 + // + this.GroupBox3.Controls.Add(this.btnShowPath); + this.GroupBox3.Controls.Add(this.btnClearPath); + this.GroupBox3.Location = new System.Drawing.Point(467, 275); + this.GroupBox3.Name = "GroupBox3"; + this.GroupBox3.Size = new System.Drawing.Size(245, 73); + this.GroupBox3.TabIndex = 19; + this.GroupBox3.TabStop = false; + this.GroupBox3.Text = "Recorded Path"; + // + // btnShowPath + // + this.btnShowPath.Location = new System.Drawing.Point(6, 19); + this.btnShowPath.Name = "btnShowPath"; + this.btnShowPath.Size = new System.Drawing.Size(233, 23); + this.btnShowPath.TabIndex = 2; + this.btnShowPath.Text = "Show Path"; + this.btnShowPath.UseVisualStyleBackColor = true; + this.btnShowPath.Click += new System.EventHandler(this.btnShowPath_Click); + // + // btnClearPath + // + this.btnClearPath.Location = new System.Drawing.Point(6, 42); + this.btnClearPath.Name = "btnClearPath"; + this.btnClearPath.Size = new System.Drawing.Size(233, 23); + this.btnClearPath.TabIndex = 1; + this.btnClearPath.Text = "Clear Path"; + this.btnClearPath.UseVisualStyleBackColor = true; + this.btnClearPath.Click += new System.EventHandler(this.btnClearPath_Click); + // + // GroupBox2 + // + this.GroupBox2.Controls.Add(this.txtDataReceived); + this.GroupBox2.Controls.Add(this.btnConnect); + this.GroupBox2.Controls.Add(this.cbbCOMPorts); + this.GroupBox2.Controls.Add(this.Label1); + this.GroupBox2.Location = new System.Drawing.Point(467, 113); + this.GroupBox2.Name = "GroupBox2"; + this.GroupBox2.Size = new System.Drawing.Size(245, 156); + this.GroupBox2.TabIndex = 18; + this.GroupBox2.TabStop = false; + this.GroupBox2.Text = "GPS"; + // + // Label1 + // + this.Label1.AutoSize = true; + this.Label1.Location = new System.Drawing.Point(21, 19); + this.Label1.Name = "Label1"; + this.Label1.Size = new System.Drawing.Size(51, 13); + this.Label1.TabIndex = 11; + this.Label1.Text = "GPS Port"; + // + // btnGotoPoint + // + this.btnGotoPoint.Location = new System.Drawing.Point(141, 71); + this.btnGotoPoint.Name = "btnGotoPoint"; + this.btnGotoPoint.Size = new System.Drawing.Size(98, 23); + this.btnGotoPoint.TabIndex = 13; + this.btnGotoPoint.Text = "Goto Point"; + this.btnGotoPoint.UseVisualStyleBackColor = true; + this.btnGotoPoint.Click += new System.EventHandler(this.btnGotoPoint_Click); + // + // WebBrowser1 + // + this.WebBrowser1.Location = new System.Drawing.Point(2, 3); + this.WebBrowser1.MinimumSize = new System.Drawing.Size(20, 20); + this.WebBrowser1.Name = "WebBrowser1"; + this.WebBrowser1.ScrollBarsEnabled = false; + this.WebBrowser1.Size = new System.Drawing.Size(460, 380); + this.WebBrowser1.TabIndex = 16; + // + // txtLongitude + // + this.txtLongitude.Location = new System.Drawing.Point(67, 45); + this.txtLongitude.Name = "txtLongitude"; + this.txtLongitude.Size = new System.Drawing.Size(172, 20); + this.txtLongitude.TabIndex = 12; + // + // txtLatitude + // + this.txtLatitude.Location = new System.Drawing.Point(67, 19); + this.txtLatitude.Name = "txtLatitude"; + this.txtLatitude.Size = new System.Drawing.Size(172, 20); + this.txtLatitude.TabIndex = 11; + // + // Timer1 + // + this.Timer1.Interval = 500; + this.Timer1.Tick += new System.EventHandler(this.Timer1_Tick); + // + // Label3 + // + this.Label3.AutoSize = true; + this.Label3.Location = new System.Drawing.Point(7, 48); + this.Label3.Name = "Label3"; + this.Label3.Size = new System.Drawing.Size(54, 13); + this.Label3.TabIndex = 10; + this.Label3.Text = "Longitude"; + // + // GroupBox1 + // + this.GroupBox1.Controls.Add(this.btnGotoPoint); + this.GroupBox1.Controls.Add(this.txtLongitude); + this.GroupBox1.Controls.Add(this.txtLatitude); + this.GroupBox1.Controls.Add(this.Label3); + this.GroupBox1.Controls.Add(this.Label2); + this.GroupBox1.Location = new System.Drawing.Point(467, 3); + this.GroupBox1.Name = "GroupBox1"; + this.GroupBox1.Size = new System.Drawing.Size(245, 104); + this.GroupBox1.TabIndex = 17; + this.GroupBox1.TabStop = false; + this.GroupBox1.Text = "Current Location:"; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.Khaki; + this.ClientSize = new System.Drawing.Size(715, 386); + this.Controls.Add(this.lblMessage); + this.Controls.Add(this.GroupBox3); + this.Controls.Add(this.GroupBox2); + this.Controls.Add(this.WebBrowser1); + this.Controls.Add(this.GroupBox1); + this.Name = "Form1"; + this.Text = "Microsoft Virtual Earth"; + this.Load += new System.EventHandler(this.Form1_Load); + this.GroupBox3.ResumeLayout(false); + this.GroupBox2.ResumeLayout(false); + this.GroupBox2.PerformLayout(); + this.GroupBox1.ResumeLayout(false); + this.GroupBox1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + internal System.Windows.Forms.Label lblMessage; + internal System.Windows.Forms.Button btnConnect; + internal System.Windows.Forms.Label Label2; + internal System.Windows.Forms.TextBox txtDataReceived; + internal System.Windows.Forms.ComboBox cbbCOMPorts; + internal System.Windows.Forms.GroupBox GroupBox3; + internal System.Windows.Forms.Button btnShowPath; + internal System.Windows.Forms.Button btnClearPath; + internal System.Windows.Forms.GroupBox GroupBox2; + internal System.Windows.Forms.Label Label1; + internal System.Windows.Forms.Button btnGotoPoint; + internal System.Windows.Forms.WebBrowser WebBrowser1; + internal System.Windows.Forms.TextBox txtLongitude; + internal System.Windows.Forms.TextBox txtLatitude; + internal System.Windows.Forms.Timer Timer1; + internal System.Windows.Forms.Label Label3; + internal System.Windows.Forms.GroupBox GroupBox1; + + } +} + diff --git a/Chapter02(Serial)/VirtualEarth_CS/Form1.cs b/Chapter02(Serial)/VirtualEarth_CS/Form1.cs new file mode 100644 index 0000000..c42e93c --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth_CS/Form1.cs @@ -0,0 +1,236 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace VirtualEarth_CS +{ + [System.Runtime.InteropServices.ComVisibleAttribute(true)] + public partial class Form1 : Form + { + private int pushpin = 0; + + private int pointCounter; + + private int lineIndex = 0; + string[] line; + + private System.IO.Ports.SerialPort serialPort = new System.IO.Ports.SerialPort(); + + public Form1() + { + InitializeComponent(); + } + + private void btnGotoPoint_Click(object sender, EventArgs e) + { + double lat, lng; + lat = Convert.ToDouble(txtLatitude.Text); + lng = Convert.ToDouble(txtLongitude.Text); + gotoPosition(lat, lng, false, ""); + } + + private void Form1_Load(object sender, EventArgs e) + { + // set the event handler for the DataReceived event + serialPort.DataReceived += + new System.IO.Ports.SerialDataReceivedEventHandler(DataReceived); + + string[] portNames = System.IO.Ports.SerialPort.GetPortNames(); + for (int i = 0; i <= portNames.Length - 1; i++) + { + cbbCOMPorts.Items.Add(portNames[i]); + } + + string fileContents; + fileContents = System.IO.File.ReadAllText(Application.StartupPath + "\\Map.html"); + WebBrowser1.DocumentText = fileContents; + WebBrowser1.ObjectForScripting = this; + } + + private void btnClearPath_Click(object sender, EventArgs e) + { + for (int i = 0; i <= pushpin; i++) + { + removePushpin(i); + } + } + + private void btnShowPath_Click(object sender, EventArgs e) + { + string fileContents = string.Empty; + OpenFileDialog openFileDialog1 = new OpenFileDialog(); + openFileDialog1.InitialDirectory = "c:\\"; + openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; + openFileDialog1.FilterIndex = 2; + openFileDialog1.RestoreDirectory = true; + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + fileContents = System.IO.File.ReadAllText(openFileDialog1.FileName); + } + + line = fileContents.Split('$'); + lineIndex = 0; + Timer1.Enabled = true; + } + + //---go to a particular location on the map--- + private void gotoPosition(double lat, double lng, bool showPushpin, string pushPinText) + { + object[] param = new object[] { lat, lng }; + WebBrowser1.Document.InvokeScript("goto_map_position", param); + if (showPushpin) + { + param = new object[] { pushpin, pushPinText, lat, lng }; + WebBrowser1.Document.InvokeScript("addPushpin", param); + pushpin += 1; + } + } + + //---update the latitude and longitude on the TextBox controls--- + public void mapPositionChange(double lat, double lng) + { + txtLatitude.Text = Convert.ToString(lat); + txtLongitude.Text = Convert.ToString(lng); + } + + //---remove a pushpin--- + private void removePushpin(int id) + { + object[] param = new object[] { id }; + WebBrowser1.Document.InvokeScript("removePushpin", param); + } + + private void Timer1_Tick(object sender, EventArgs e) + { + if (lineIndex == 0) + { + pointCounter = 1; + } + while ((lineIndex <= line.Length - 1)) + { + if (line[lineIndex].StartsWith("GPGGA") && processGPSData(line[lineIndex])) + { + lblMessage.Text = "Updating map...point " + pointCounter; + pointCounter += 1; + break; + } + lineIndex += 1; + } + lineIndex += 1; + if (lineIndex > line.Length - 1) + { + Timer1.Enabled = false; + lblMessage.Text = "Plotting completed."; + } + } + + private void btnConnect_Click(object sender, EventArgs e) + { + if (btnConnect.Text == "Connect") + { + btnConnect.Text = "Disconnect"; + if (serialPort.IsOpen) + { + serialPort.Close(); + } + try + { + serialPort.PortName = cbbCOMPorts.Text; + serialPort.BaudRate = 9600; + serialPort.Parity = System.IO.Ports.Parity.None; + serialPort.DataBits = 8; + serialPort.StopBits = System.IO.Ports.StopBits.One; + serialPort.Open(); + lblMessage.Text = cbbCOMPorts.Text + " connected."; + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + } + else + { + btnConnect.Text = "Connect"; + serialPort.Close(); + } + } + + private void DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) + { + txtDataReceived.BeginInvoke(new myDelegate(updateTextBox)); + } + + public delegate void myDelegate(); + public void updateTextBox() + { + try + { + string Data = serialPort.ReadExisting(); + txtDataReceived.AppendText(Data); + txtDataReceived.ScrollToCaret(); + string GPSData = txtDataReceived.Lines[txtDataReceived.Lines.Length - 2]; + if (GPSData.StartsWith("$GPGGA")) + { + if (!(processGPSData(GPSData))) + { + lblMessage.Text = "No fix..."; + } + } + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + } + } + + private bool processGPSData(string str) + { + try + { + string[] field; + field = str.Split(','); + double lat; + double lng; + double rawLatLng; + if (field.Length < 15) + { + return false; + } + + rawLatLng = Convert.ToDouble(field[2]); + lat = ((int)(rawLatLng / 100)) + ((rawLatLng - (((int)(rawLatLng / 100)) * 100)) / 60); + if (field[3] == "S") + { + lat *= -1; + } + + rawLatLng = Convert.ToDouble(field[4]); + lng = ((int)(rawLatLng / 100)) + ((rawLatLng - (((int)(rawLatLng / 100)) * 100)) / 60); + if (field[5] == "W") + { + lng *= -1; + } + + if (str.StartsWith("$")) + { + gotoPosition(lat, lng, false, ""); + + } else + { + gotoPosition(lat, lng, true, "*"); + + } + lblMessage.Text = "Latitude: " + lat + " Longitude: " + lng; + return true; + } + catch + { + return false; + } + } + } +} \ No newline at end of file diff --git a/Chapter02(Serial)/VirtualEarth_CS/Form1.resx b/Chapter02(Serial)/VirtualEarth_CS/Form1.resx new file mode 100644 index 0000000..cce5ec2 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth_CS/Form1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/Chapter02(Serial)/VirtualEarth_CS/Map.html b/Chapter02(Serial)/VirtualEarth_CS/Map.html new file mode 100644 index 0000000..3827150 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth_CS/Map.html @@ -0,0 +1,67 @@ + + + My Virtual Earth + + + + + + +
+ + diff --git a/Chapter02(Serial)/VirtualEarth_CS/Program.cs b/Chapter02(Serial)/VirtualEarth_CS/Program.cs new file mode 100644 index 0000000..38e20f6 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth_CS/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace VirtualEarth_CS +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} \ No newline at end of file diff --git a/Chapter02(Serial)/VirtualEarth_CS/Properties/AssemblyInfo.cs b/Chapter02(Serial)/VirtualEarth_CS/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..9771a16 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth_CS/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("VirtualEarth_CS")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("VirtualEarth_CS")] +[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("feec3c9c-42c9-407f-b8ea-602626948a74")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Chapter02(Serial)/VirtualEarth_CS/Properties/Resources.Designer.cs b/Chapter02(Serial)/VirtualEarth_CS/Properties/Resources.Designer.cs new file mode 100644 index 0000000..f1236ca --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth_CS/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace VirtualEarth_CS.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("VirtualEarth_CS.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Chapter02(Serial)/VirtualEarth_CS/Properties/Resources.resx b/Chapter02(Serial)/VirtualEarth_CS/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth_CS/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter02(Serial)/VirtualEarth_CS/Properties/Settings.Designer.cs b/Chapter02(Serial)/VirtualEarth_CS/Properties/Settings.Designer.cs new file mode 100644 index 0000000..9b8bd67 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth_CS/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace VirtualEarth_CS.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Chapter02(Serial)/VirtualEarth_CS/Properties/Settings.settings b/Chapter02(Serial)/VirtualEarth_CS/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth_CS/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Chapter02(Serial)/VirtualEarth_CS/VirtualEarth_CS.csproj b/Chapter02(Serial)/VirtualEarth_CS/VirtualEarth_CS.csproj new file mode 100644 index 0000000..dc6daf3 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth_CS/VirtualEarth_CS.csproj @@ -0,0 +1,83 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {09F1DE20-21FC-489B-A21B-AD82BF7DA2F9} + WinExe + Properties + VirtualEarth_CS + VirtualEarth_CS + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + Form + + + Form1.cs + + + + + Designer + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + PreserveNewest + + + + + \ No newline at end of file diff --git a/Chapter02(Serial)/VirtualEarth_CS/VirtualEarth_CS.sln b/Chapter02(Serial)/VirtualEarth_CS/VirtualEarth_CS.sln new file mode 100644 index 0000000..08f2d82 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth_CS/VirtualEarth_CS.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VirtualEarth_CS", "VirtualEarth_CS.csproj", "{09F1DE20-21FC-489B-A21B-AD82BF7DA2F9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {09F1DE20-21FC-489B-A21B-AD82BF7DA2F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {09F1DE20-21FC-489B-A21B-AD82BF7DA2F9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {09F1DE20-21FC-489B-A21B-AD82BF7DA2F9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {09F1DE20-21FC-489B-A21B-AD82BF7DA2F9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter02(Serial)/VirtualEarth_CS/VirtualEarth_CS.suo b/Chapter02(Serial)/VirtualEarth_CS/VirtualEarth_CS.suo new file mode 100644 index 0000000..9ade14b Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth_CS/VirtualEarth_CS.suo differ diff --git a/Chapter02(Serial)/VirtualEarth_CS/bin/Debug/Map.html b/Chapter02(Serial)/VirtualEarth_CS/bin/Debug/Map.html new file mode 100644 index 0000000..3827150 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth_CS/bin/Debug/Map.html @@ -0,0 +1,67 @@ + + + My Virtual Earth + + + + + + +
+ + diff --git a/Chapter02(Serial)/VirtualEarth_CS/bin/Debug/VirtualEarth_CS.exe b/Chapter02(Serial)/VirtualEarth_CS/bin/Debug/VirtualEarth_CS.exe new file mode 100644 index 0000000..9389bef Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth_CS/bin/Debug/VirtualEarth_CS.exe differ diff --git a/Chapter02(Serial)/VirtualEarth_CS/bin/Debug/VirtualEarth_CS.pdb b/Chapter02(Serial)/VirtualEarth_CS/bin/Debug/VirtualEarth_CS.pdb new file mode 100644 index 0000000..3f3f9bf Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth_CS/bin/Debug/VirtualEarth_CS.pdb differ diff --git a/Chapter02(Serial)/VirtualEarth_CS/bin/Debug/VirtualEarth_CS.vshost.exe b/Chapter02(Serial)/VirtualEarth_CS/bin/Debug/VirtualEarth_CS.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth_CS/bin/Debug/VirtualEarth_CS.vshost.exe differ diff --git a/Chapter02(Serial)/VirtualEarth_CS/obj/Debug/VirtualEarth_CS.Form1.resources b/Chapter02(Serial)/VirtualEarth_CS/obj/Debug/VirtualEarth_CS.Form1.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth_CS/obj/Debug/VirtualEarth_CS.Form1.resources differ diff --git a/Chapter02(Serial)/VirtualEarth_CS/obj/Debug/VirtualEarth_CS.Properties.Resources.resources b/Chapter02(Serial)/VirtualEarth_CS/obj/Debug/VirtualEarth_CS.Properties.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth_CS/obj/Debug/VirtualEarth_CS.Properties.Resources.resources differ diff --git a/Chapter02(Serial)/VirtualEarth_CS/obj/Debug/VirtualEarth_CS.csproj.GenerateResource.Cache b/Chapter02(Serial)/VirtualEarth_CS/obj/Debug/VirtualEarth_CS.csproj.GenerateResource.Cache new file mode 100644 index 0000000..d263bb4 Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth_CS/obj/Debug/VirtualEarth_CS.csproj.GenerateResource.Cache differ diff --git a/Chapter02(Serial)/VirtualEarth_CS/obj/Debug/VirtualEarth_CS.exe b/Chapter02(Serial)/VirtualEarth_CS/obj/Debug/VirtualEarth_CS.exe new file mode 100644 index 0000000..9389bef Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth_CS/obj/Debug/VirtualEarth_CS.exe differ diff --git a/Chapter02(Serial)/VirtualEarth_CS/obj/Debug/VirtualEarth_CS.pdb b/Chapter02(Serial)/VirtualEarth_CS/obj/Debug/VirtualEarth_CS.pdb new file mode 100644 index 0000000..3f3f9bf Binary files /dev/null and b/Chapter02(Serial)/VirtualEarth_CS/obj/Debug/VirtualEarth_CS.pdb differ diff --git a/Chapter02(Serial)/VirtualEarth_CS/obj/VirtualEarth_CS.csproj.FileList.txt b/Chapter02(Serial)/VirtualEarth_CS/obj/VirtualEarth_CS.csproj.FileList.txt new file mode 100644 index 0000000..9958126 --- /dev/null +++ b/Chapter02(Serial)/VirtualEarth_CS/obj/VirtualEarth_CS.csproj.FileList.txt @@ -0,0 +1,9 @@ +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\VirtualEarth_CS.Form1.resources +obj\Debug\VirtualEarth_CS.Properties.Resources.resources +obj\Debug\VirtualEarth_CS.csproj.GenerateResource.Cache +bin\Debug\Map.html +bin\Debug\VirtualEarth_CS.exe +bin\Debug\VirtualEarth_CS.pdb +obj\Debug\VirtualEarth_CS.exe +obj\Debug\VirtualEarth_CS.pdb diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader.sln b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader.sln new file mode 100644 index 0000000..3765c8b --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "FingerPrintReader", "FingerPrintReader\FingerPrintReader.vbproj", "{B714CE33-585E-4ADD-9FBC-4192DA93C3A5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B714CE33-585E-4ADD-9FBC-4192DA93C3A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B714CE33-585E-4ADD-9FBC-4192DA93C3A5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B714CE33-585E-4ADD-9FBC-4192DA93C3A5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B714CE33-585E-4ADD-9FBC-4192DA93C3A5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader.suo b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader.suo new file mode 100644 index 0000000..7b6700c Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader.suo differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/DBClass.vb b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/DBClass.vb new file mode 100644 index 0000000..5968f0e --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/DBClass.vb @@ -0,0 +1,179 @@ +'------------------------------------------------------------------------------- +'GrFinger Sample +'(c) 2005 Griaule Tecnologia Ltda. +'http://www.griaule.com +'------------------------------------------------------------------------------- +' +'This sample is provided with "GrFinger Fingerprint Recognition Library" and +'can't run without it. It's provided just as an example of using GrFinger +'Fingerprint Recognition Library and should not be used as basis for any +'commercial product. +' +'Griaule Tecnologia makes no representations concerning either the merchantability +'of this software or the suitability of this sample for any particular purpose. +' +'THIS SAMPLE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR +'IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +'OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +'IN NO EVENT SHALL GRIAULE BE LIABLE FOR ANY DIRECT, INDIRECT, +'INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +'NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +'DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +'THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +'(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +'THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +' +'You can download the free version of GrFinger directly from Griaule website. +' +'These notices must be retained in any copies of any part of this +'documentation and/or sample. +' +'------------------------------------------------------------------------------- + +' ----------------------------------------------------------------------------------- +' Database routines +' ----------------------------------------------------------------------------------- + +Imports System.Data.OleDb +Imports System.Runtime.InteropServices + +' Template data +Public Class TTemplate + ' Template itself + Public tpt As System.Array = Array.CreateInstance(GetType(Byte), GrFingerXLib.GRConstants.GR_MAX_SIZE_TEMPLATE) + + + ' Template size + Public Size As Long +End Class + +' Template list +Public Structure TTemplates + ' ID + Public ID As Integer + ' Template itself + Public template As TTemplate +End Structure + +Public Class DBClass + + ' the database we'll be connecting to + Const DBFile As String = "GrFingerSample.mdb" + Const ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + + ' the connection object + Dim connection As New OleDbConnection + + ' Open connection + Public Function OpenDB() As Boolean + Dim filePath As String + Try + filePath = Application.StartupPath() & "\" & DBFile + connection = New OleDb.OleDbConnection(ConnectionString & filePath) + Return True + Catch + Return False + End Try + End Function + + ' Close conection + Public Sub closeDB() + connection.Close() + End Sub + + ' Clear database + Public Sub clearDB() + Dim sqlCMD As OleDbCommand = New OleDbCommand("DELETE FROM enroll", connection) + ' run "clear" query + sqlCMD.Connection.Open() + sqlCMD.ExecuteNonQuery() + sqlCMD.Connection.Close() + End Sub + + ' Add template to database. Returns added template ID. + Public Function AddTemplate(ByRef template As TTemplate) As Long + Dim da As New OleDbDataAdapter("select * from enroll", connection) + + ' Create SQL command containing ? parameter for BLOB. + da.InsertCommand = New OleDbCommand("INSERT INTO enroll (template) Values(?)", connection) + da.InsertCommand.CommandType = CommandType.Text + da.InsertCommand.Parameters.Add("@template", OleDbType.Binary, template.Size, "template") + + ' Open connection + connection.Open() + + ' Fill DataSet. + Dim enroll As DataSet = New DataSet + da.Fill(enroll, "enroll") + + ' Add a new row. + ' Create parameter for ? contained in the SQL statement. + Dim newRow As DataRow = enroll.Tables("enroll").NewRow() + newRow("template") = template.tpt + enroll.Tables("enroll").Rows.Add(newRow) + + ' Include an event to fill in the Autonumber value. + AddHandler da.RowUpdated, New OleDbRowUpdatedEventHandler(AddressOf OnRowUpdated) + + ' Update DataSet. + da.Update(enroll, "enroll") + connection.Close() + + ' return ID + Return newRow("ID") + End Function + + ' Event procedure for OnRowUpdated + Private Sub OnRowUpdated(ByVal sender As Object, ByVal args As OleDbRowUpdatedEventArgs) + ' Include a variable and a command to retrieve identity value + ' from Access database. + Dim newID As Integer = 0 + Dim idCMD As OleDbCommand = New OleDbCommand("SELECT @@IDENTITY", connection) + + If args.StatementType = StatementType.Insert Then + ' Retrieve identity value and store it in column + newID = CInt(idCMD.ExecuteScalar()) + args.Row("ID") = newID + End If + End Sub + + ' Returns a DataTable with all enrolled templates from database. + Public Function getTemplates() As TTemplates() + Dim ds As New DataSet + Dim da As New OleDbDataAdapter("select * from enroll", connection) + Dim ttpts As TTemplates() + Dim i As Integer + + ' Get query response + da.Fill(ds) + Dim tpts As DataRowCollection = ds.Tables(0).Rows + ' Create response array + ReDim ttpts(tpts.Count) + ' No results? + If tpts.Count = 0 Then Return ttpts + ' get each template and put results in our array + For i = 1 To tpts.Count + ttpts(i).template = New TTemplate + ttpts(i).ID = tpts.Item(i - 1).Item("ID") + ttpts(i).template.tpt = tpts.Item(i - 1).Item("template") + ttpts(i).template.Size = ttpts(i).template.tpt.Length + Next + Return ttpts + End Function + + ' Returns template with supplied ID. + Public Function getTemplate(ByVal id As Long) As Byte() + Dim ds As New DataSet + Dim da As New OleDbDataAdapter("select * from enroll where ID = " & id, connection) + Dim tpt As New TTemplate + + ' Get query response + da.Fill(ds) + Dim tpts As DataRowCollection = ds.Tables(0).Rows + ' No results? + If tpts.Count <> 1 Then Return Nothing + ' Deserialize template and return it + Return tpts.Item(0).Item("template") + End Function + +End Class diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/FingerPrintReader.vbproj b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/FingerPrintReader.vbproj new file mode 100644 index 0000000..dbda247 --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/FingerPrintReader.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {B714CE33-585E-4ADD-9FBC-4192DA93C3A5} + WinExe + FingerPrintReader.My.MyApplication + FingerPrintReader + FingerPrintReader + WindowsForms + + + true + full + true + true + bin\Debug\ + FingerPrintReader.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + FingerPrintReader.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + + + + + + + + + + + + + + Form + + + Form1.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + + Designer + Form1.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + {A9995C7C-77BF-4E27-B581-A4B5BBD90E50} + 1 + 0 + 0 + aximp + False + + + {A9995C7C-77BF-4E27-B581-A4B5BBD90E50} + 1 + 0 + 0 + tlbimp + False + + + + + + + + Always + + + + + \ No newline at end of file diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/FingerPrintReader.vbproj.user b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/FingerPrintReader.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/FingerPrintReader.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/Form1.Designer.vb b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/Form1.Designer.vb new file mode 100644 index 0000000..d594d17 --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/Form1.Designer.vb @@ -0,0 +1,234 @@ + _ +Partial Class Form1 + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.components = New System.ComponentModel.Container + Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1)) + Me.PictureBox1 = New System.Windows.Forms.PictureBox + Me.GroupBox1 = New System.Windows.Forms.GroupBox + Me.txtEmail = New System.Windows.Forms.TextBox + Me.Label5 = New System.Windows.Forms.Label + Me.txtContactNumber = New System.Windows.Forms.TextBox + Me.txtCompany = New System.Windows.Forms.TextBox + Me.txtName = New System.Windows.Forms.TextBox + Me.txtSSN = New System.Windows.Forms.TextBox + Me.Label4 = New System.Windows.Forms.Label + Me.Label3 = New System.Windows.Forms.Label + Me.Label2 = New System.Windows.Forms.Label + Me.Label1 = New System.Windows.Forms.Label + Me.lblMessage = New System.Windows.Forms.Label + Me.ListBox1 = New System.Windows.Forms.ListBox + Me.btnRegister = New System.Windows.Forms.Button + Me.AxGrFingerXCtrl1 = New AxGrFingerXLib.AxGrFingerXCtrl + Me.Timer1 = New System.Windows.Forms.Timer(Me.components) + CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit() + Me.GroupBox1.SuspendLayout() + CType(Me.AxGrFingerXCtrl1, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'PictureBox1 + ' + Me.PictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D + Me.PictureBox1.Image = Global.FingerPrintReader.My.Resources.Resources.fingerprintreader + Me.PictureBox1.Location = New System.Drawing.Point(12, 12) + Me.PictureBox1.Name = "PictureBox1" + Me.PictureBox1.Size = New System.Drawing.Size(160, 232) + Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage + Me.PictureBox1.TabIndex = 1 + Me.PictureBox1.TabStop = False + ' + 'GroupBox1 + ' + Me.GroupBox1.Controls.Add(Me.txtEmail) + Me.GroupBox1.Controls.Add(Me.Label5) + Me.GroupBox1.Controls.Add(Me.txtContactNumber) + Me.GroupBox1.Controls.Add(Me.txtCompany) + Me.GroupBox1.Controls.Add(Me.txtName) + Me.GroupBox1.Controls.Add(Me.txtSSN) + Me.GroupBox1.Controls.Add(Me.Label4) + Me.GroupBox1.Controls.Add(Me.Label3) + Me.GroupBox1.Controls.Add(Me.Label2) + Me.GroupBox1.Controls.Add(Me.Label1) + Me.GroupBox1.Location = New System.Drawing.Point(178, 92) + Me.GroupBox1.Name = "GroupBox1" + Me.GroupBox1.Size = New System.Drawing.Size(336, 152) + Me.GroupBox1.TabIndex = 18 + Me.GroupBox1.TabStop = False + Me.GroupBox1.Text = "User's Particulars" + ' + 'txtEmail + ' + Me.txtEmail.Location = New System.Drawing.Point(144, 120) + Me.txtEmail.Name = "txtEmail" + Me.txtEmail.Size = New System.Drawing.Size(184, 20) + Me.txtEmail.TabIndex = 24 + ' + 'Label5 + ' + Me.Label5.AutoSize = True + Me.Label5.Location = New System.Drawing.Point(96, 120) + Me.Label5.Name = "Label5" + Me.Label5.Size = New System.Drawing.Size(32, 13) + Me.Label5.TabIndex = 23 + Me.Label5.Text = "Email" + ' + 'txtContactNumber + ' + Me.txtContactNumber.Location = New System.Drawing.Point(144, 96) + Me.txtContactNumber.Name = "txtContactNumber" + Me.txtContactNumber.Size = New System.Drawing.Size(104, 20) + Me.txtContactNumber.TabIndex = 22 + ' + 'txtCompany + ' + Me.txtCompany.Location = New System.Drawing.Point(144, 72) + Me.txtCompany.Name = "txtCompany" + Me.txtCompany.Size = New System.Drawing.Size(184, 20) + Me.txtCompany.TabIndex = 21 + ' + 'txtName + ' + Me.txtName.Location = New System.Drawing.Point(144, 48) + Me.txtName.Name = "txtName" + Me.txtName.Size = New System.Drawing.Size(184, 20) + Me.txtName.TabIndex = 20 + ' + 'txtSSN + ' + Me.txtSSN.Location = New System.Drawing.Point(144, 24) + Me.txtSSN.Name = "txtSSN" + Me.txtSSN.Size = New System.Drawing.Size(100, 20) + Me.txtSSN.TabIndex = 19 + ' + 'Label4 + ' + Me.Label4.AutoSize = True + Me.Label4.Location = New System.Drawing.Point(48, 96) + Me.Label4.Name = "Label4" + Me.Label4.Size = New System.Drawing.Size(84, 13) + Me.Label4.TabIndex = 18 + Me.Label4.Text = "Contact Number" + ' + 'Label3 + ' + Me.Label3.AutoSize = True + Me.Label3.Location = New System.Drawing.Point(80, 72) + Me.Label3.Name = "Label3" + Me.Label3.Size = New System.Drawing.Size(51, 13) + Me.Label3.TabIndex = 17 + Me.Label3.Text = "Company" + ' + 'Label2 + ' + Me.Label2.AutoSize = True + Me.Label2.Location = New System.Drawing.Point(8, 24) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(117, 13) + Me.Label2.TabIndex = 16 + Me.Label2.Text = "Social Security Number" + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(96, 48) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(35, 13) + Me.Label1.TabIndex = 15 + Me.Label1.Text = "Name" + ' + 'lblMessage + ' + Me.lblMessage.BackColor = System.Drawing.SystemColors.ControlLightLight + Me.lblMessage.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D + Me.lblMessage.Font = New System.Drawing.Font("Microsoft Sans Serif", 15.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.lblMessage.Location = New System.Drawing.Point(178, 12) + Me.lblMessage.Name = "lblMessage" + Me.lblMessage.Size = New System.Drawing.Size(336, 72) + Me.lblMessage.TabIndex = 17 + Me.lblMessage.Text = "Please place your index finger on the fingerprint reader" + ' + 'ListBox1 + ' + Me.ListBox1.Location = New System.Drawing.Point(12, 281) + Me.ListBox1.Name = "ListBox1" + Me.ListBox1.Size = New System.Drawing.Size(502, 95) + Me.ListBox1.TabIndex = 19 + ' + 'btnRegister + ' + Me.btnRegister.Location = New System.Drawing.Point(439, 252) + Me.btnRegister.Name = "btnRegister" + Me.btnRegister.Size = New System.Drawing.Size(75, 23) + Me.btnRegister.TabIndex = 21 + Me.btnRegister.Text = "Register" + Me.btnRegister.UseVisualStyleBackColor = True + ' + 'AxGrFingerXCtrl1 + ' + Me.AxGrFingerXCtrl1.Enabled = True + Me.AxGrFingerXCtrl1.Location = New System.Drawing.Point(41, 37) + Me.AxGrFingerXCtrl1.Name = "AxGrFingerXCtrl1" + Me.AxGrFingerXCtrl1.OcxState = CType(resources.GetObject("AxGrFingerXCtrl1.OcxState"), System.Windows.Forms.AxHost.State) + Me.AxGrFingerXCtrl1.Size = New System.Drawing.Size(32, 32) + Me.AxGrFingerXCtrl1.TabIndex = 22 + ' + 'Timer1 + ' + Me.Timer1.Interval = 5000 + ' + 'Form1 + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(527, 388) + Me.Controls.Add(Me.AxGrFingerXCtrl1) + Me.Controls.Add(Me.btnRegister) + Me.Controls.Add(Me.ListBox1) + Me.Controls.Add(Me.GroupBox1) + Me.Controls.Add(Me.lblMessage) + Me.Controls.Add(Me.PictureBox1) + Me.Name = "Form1" + Me.Text = "Visitor Identification System" + CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit() + Me.GroupBox1.ResumeLayout(False) + Me.GroupBox1.PerformLayout() + CType(Me.AxGrFingerXCtrl1, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + + End Sub + Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox + Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox + Friend WithEvents txtEmail As System.Windows.Forms.TextBox + Friend WithEvents Label5 As System.Windows.Forms.Label + Friend WithEvents txtContactNumber As System.Windows.Forms.TextBox + Friend WithEvents txtCompany As System.Windows.Forms.TextBox + Friend WithEvents txtName As System.Windows.Forms.TextBox + Friend WithEvents txtSSN As System.Windows.Forms.TextBox + Friend WithEvents Label4 As System.Windows.Forms.Label + Friend WithEvents Label3 As System.Windows.Forms.Label + Friend WithEvents Label2 As System.Windows.Forms.Label + Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents lblMessage As System.Windows.Forms.Label + Friend WithEvents ListBox1 As System.Windows.Forms.ListBox + Friend WithEvents btnRegister As System.Windows.Forms.Button + Friend WithEvents AxGrFingerXCtrl1 As AxGrFingerXLib.AxGrFingerXCtrl + Friend WithEvents Timer1 As System.Windows.Forms.Timer + +End Class diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/Form1.resx b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/Form1.resx new file mode 100644 index 0000000..2baddb4 --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/Form1.resx @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w + LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACFTeXN0 + ZW0uV2luZG93cy5Gb3Jtcy5BeEhvc3QrU3RhdGUBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAIQAAAAIB + AAAAAQAAAAAAAAAAAAAAAAwAAAAQBwAATwMAAE8DAAAL + + + + 17, 17 + + + 197 + + \ No newline at end of file diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/Form1.vb b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/Form1.vb new file mode 100644 index 0000000..f231369 --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/Form1.vb @@ -0,0 +1,278 @@ +Imports GrFingerXLib + +Public Class Form1 + '---name of the database--- + Const DBFile = "GrFingerSample.mdb" + Const Logfile = "C:\Log.csv" + Const ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + + '---for an instance of the Util.vb class--- + Private myUtil As Util + '---for storing user’s ID--- + Private _UserID As Integer + '---database connection string--- + Private connection As System.Data.OleDb.OleDbConnection + + Private Sub Form1_Load( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles MyBase.Load + Dim err As Integer + ' initialize util class + myUtil = New Util(ListBox1, PictureBox1, AxGrFingerXCtrl1) + ' Initialize GrFingerX Library + err = myUtil.InitializeGrFinger() + ' Print result in log + If err < 0 Then + myUtil.WriteError(err) + Exit Sub + Else + myUtil.WriteLog( _ + "**GrFingerX Initialized Successfull**") + End If + + '---create a log file--- + If Not System.IO.File.Exists(Logfile) Then + System.IO.File.Create(Logfile) + End If + End Sub + + ' ----------------------------------------------------------------------------------- + ' GrFingerX events + ' ----------------------------------------------------------------------------------- + ' A fingerprint reader was plugged on system + Private Sub AxGrFingerXCtrl1_SensorPlug( _ + ByVal sender As System.Object, _ + ByVal e As AxGrFingerXLib._IGrFingerXCtrlEvents_SensorPlugEvent) _ + Handles AxGrFingerXCtrl1.SensorPlug + myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Plugged.") + AxGrFingerXCtrl1.CapStartCapture(e.idSensor) + End Sub + + ' A fingerprint reader was unplugged from system + Private Sub AxGrFingerXCtrl1_SensorUnplug( _ + ByVal sender As System.Object, _ + ByVal e As AxGrFingerXLib._IGrFingerXCtrlEvents_SensorUnplugEvent) _ + Handles AxGrFingerXCtrl1.SensorUnplug + myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Unplugged.") + AxGrFingerXCtrl1.CapStopCapture(e.idSensor) + End Sub + + ' A finger was placed on reader + Private Sub AxGrFingerXCtrl1_FingerDown( _ + ByVal sender As System.Object, _ + ByVal e As AxGrFingerXLib._IGrFingerXCtrlEvents_FingerDownEvent) _ + Handles AxGrFingerXCtrl1.FingerDown + myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Finger Placed.") + End Sub + + ' A finger was removed from reader + Private Sub AxGrFingerXCtrl1_FingerUp( _ + ByVal sender As System.Object, _ + ByVal e As AxGrFingerXLib._IGrFingerXCtrlEvents_FingerUpEvent) _ + Handles AxGrFingerXCtrl1.FingerUp + myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Finger removed.") + End Sub + + ' An image was acquired from reader + Private Sub AxGrFingerXCtrl1_ImageAcquired( _ + ByVal sender As System.Object, _ + ByVal e As AxGrFingerXLib._IGrFingerXCtrlEvents_ImageAcquiredEvent) _ + Handles AxGrFingerXCtrl1.ImageAcquired + + ' Copying aquired image + myUtil.raw.height = e.height + myUtil.raw.width = e.width + myUtil.raw.res = e.res + myUtil.raw.img = e.rawImage + + ' Signaling that an Image Event occurred. + myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Image captured.") + + ' display fingerprint image + myUtil.PrintBiometricDisplay(False, GRConstants.GR_DEFAULT_CONTEXT) + + '---extract the template from the fingerprint scanned--- + ExtractTemplate() + + '---identify who the user is--- + _UserID = IdentifyFingerprint() + If _UserID > 0 Then + '---user found--- + Beep() + btnRegister.Enabled = False + '---display user's information--- + GetUserInfo() + '---writes to log file--- + WriteToLog(_UserID) + Else + '---user not found--- + ClearDisplay() + btnRegister.Enabled = True + Beep() + lblMessage.Text = "User not found! Please register your information below" + End If + End Sub + + ' Extract a template from a fingerprint image + Private Function ExtractTemplate() As Integer + Dim ret As Integer + ' extract template + ret = myUtil.ExtractTemplate() + ' write template quality to log + If ret = GRConstants.GR_BAD_QUALITY Then + myUtil.WriteLog("Template extracted successfully. Bad quality.") + ElseIf ret = GRConstants.GR_MEDIUM_QUALITY Then + myUtil.WriteLog("Template extracted successfully. Medium quality.") + ElseIf ret = GRConstants.GR_HIGH_QUALITY Then + myUtil.WriteLog("Template extracted successfully. High quality.") + End If + If ret >= 0 Then + ' if no error, display minutiae/segments/directions into the image + myUtil.PrintBiometricDisplay(True, GRConstants.GR_NO_CONTEXT) + Else + ' write error to log + myUtil.WriteError(ret) + End If + Return ret + End Function + + + '---Identify a fingerprint; returns the ID of the user--- + Private Function IdentifyFingerprint() As Integer + Dim ret As Integer, score As Integer + score = 0 + ' identify it + ret = myUtil.Identify(score) + ' write result to log + If ret > 0 Then + myUtil.WriteLog("Fingerprint identified. ID = " & ret & ". Score = " & score & ".") + myUtil.PrintBiometricDisplay(True, GRConstants.GR_DEFAULT_CONTEXT) + ElseIf ret = 0 Then + myUtil.WriteLog("Fingerprint not Found.") + Else + myUtil.WriteError(ret) + End If + Return ret + End Function + + '---get user's information--- + Public Sub GetUserInfo() + Dim filePath As String + Try + filePath = Application.StartupPath() & "\" & DBFile + connection = New OleDb.OleDbConnection(ConnectionString & filePath) + connection.Open() + Dim reader As OleDb.OleDbDataReader + Dim command As OleDb.OleDbCommand = New OleDb.OleDbCommand + command.Connection = connection + '---retrieve user's particulars--- + command.CommandText = "SELECT * FROM Enroll WHERE ID=" & _UserID + reader = command.ExecuteReader(CommandBehavior.CloseConnection) + reader.Read() + + '---display user's particulars--- + lblMessage.Text = "Welcome, " & reader("name") + txtSSN.Text = reader("SSN") + txtName.Text = reader("Name") + txtCompany.Text = reader("Company") + txtContactNumber.Text = reader("ContactNumber") + txtEmail.Text = reader("Email") + + '---reset the timer to another 5 seconds--- + Timer1.Enabled = False + Timer1.Enabled = True + Catch ex As Exception + MsgBox(ex.ToString) + Finally + connection.Close() + End Try + End Sub + + + '---Register button--- + Private Sub btnRegister_Click( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles btnRegister.Click + '---first add the fingerprint--- + _UserID = EnrollFingerprint() + '---then add the particulars--- + AddNewUser() + '---clears the display--- + ClearDisplay() + '---writes to log file--- + WriteToLog(_UserID) + End Sub + + '---adds a fingerprint to the database; returns the ID of the user--- + Private Function EnrollFingerprint() As Integer + Dim id As Integer + ' add fingerprint + id = myUtil.Enroll() + ' write result to log + If id >= 0 Then + myUtil.WriteLog("Fingerprint enrolled with id = " & id) + Else + myUtil.WriteLog("Error: Fingerprint not enrolled") + End If + Return id + End Function + + '---Add a new user's information to the database--- + Public Sub AddNewUser() + Dim filePath As String + Try + filePath = Application.StartupPath() & "\" & DBFile + connection = New OleDb.OleDbConnection(ConnectionString & filePath) + connection.Open() + Dim command As OleDb.OleDbCommand = New OleDb.OleDbCommand + command.Connection = connection + + '---set the user's particulars in the table--- + Dim sql As String = "UPDATE enroll SET SSN='" & txtSSN.Text & "', " & _ + "Name='" & txtName.Text & "', " & _ + "Company='" & txtCompany.Text & "', " & _ + "ContactNumber='" & txtContactNumber.Text & "', " & _ + "Email='" & txtEmail.Text & "' " & _ + " WHERE ID=" & _UserID + command.CommandText = sql + command.ExecuteNonQuery() + MsgBox("User added successfully!") + connection.Close() + Catch ex As Exception + MsgBox(ex.ToString) + End Try + End Sub + + '---Clears the user's particulars--- + Public Sub ClearDisplay() + lblMessage.Text = _ + "Please place your index finger on the fingerprint reader" + PictureBox1.Image = My.Resources.fingerprintreader + + txtSSN.Text = String.Empty + txtName.Text = String.Empty + txtCompany.Text = String.Empty + txtContactNumber.Text = String.Empty + txtEmail.Text = String.Empty + End Sub + + '---the Timer control--- + Private Sub Timer1_Tick( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles Timer1.Tick + ClearDisplay() + Timer1.Enabled = False + End Sub + + Public Sub WriteToLog(ByVal ID As String) + '---write to a log file--- + Dim sw As New System.IO.StreamWriter( _ + Logfile, True, System.Text.Encoding.ASCII) + sw.WriteLine(id & "," & Now.ToString) + sw.Close() + End Sub + +End Class diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/GrFingerSample.mdb b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/GrFingerSample.mdb new file mode 100644 index 0000000..ccc67ac Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/GrFingerSample.mdb differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/My Project/Application.Designer.vb b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/My Project/Application.Designer.vb new file mode 100644 index 0000000..ced615e --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + 'NOTE: This file is auto-generated; do not modify it directly. To make changes, + ' or if you encounter build errors in this file, go to the Project Designer + ' (go to Project Properties or double-click the My Project node in + ' Solution Explorer), and make changes on the Application tab. + ' + Partial Friend Class MyApplication + + _ + Public Sub New() + MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) + Me.IsSingleInstance = false + Me.EnableVisualStyles = true + Me.SaveMySettingsOnExit = true + Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses + End Sub + + _ + Protected Overrides Sub OnCreateMainForm() + Me.MainForm = Global.FingerPrintReader.Form1 + End Sub + End Class +End Namespace diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/My Project/Application.myapp b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/My Project/Application.myapp new file mode 100644 index 0000000..1243847 --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/My Project/Application.myapp @@ -0,0 +1,11 @@ + + + true + Form1 + false + 0 + true + 0 + 0 + true + diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/My Project/AssemblyInfo.vb b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..3ab8344 --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + + diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/My Project/Resources.Designer.vb b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/My Project/Resources.Designer.vb new file mode 100644 index 0000000..6e365f3 --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/My Project/Resources.Designer.vb @@ -0,0 +1,70 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + +Imports System + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("FingerPrintReader.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set + resourceCulture = value + End Set + End Property + + Friend ReadOnly Property fingerprintreader() As System.Drawing.Bitmap + Get + Dim obj As Object = ResourceManager.GetObject("fingerprintreader", resourceCulture) + Return CType(obj,System.Drawing.Bitmap) + End Get + End Property + End Module +End Namespace diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/My Project/Resources.resx b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/My Project/Resources.resx new file mode 100644 index 0000000..304d85d --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/My Project/Resources.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\fingerprintreader.jpg;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/My Project/Settings.Designer.vb b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/My Project/Settings.Designer.vb new file mode 100644 index 0000000..f907336 --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.FingerPrintReader.My.MySettings + Get + Return Global.FingerPrintReader.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/My Project/Settings.settings b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/Resources/fingerprintreader.jpg b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/Resources/fingerprintreader.jpg new file mode 100644 index 0000000..67a13f8 Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/Resources/fingerprintreader.jpg differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/Util.vb b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/Util.vb new file mode 100644 index 0000000..bb25e06 --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/Util.vb @@ -0,0 +1,321 @@ +'------------------------------------------------------------------------------- +'GrFinger Sample +'(c) 2005 Griaule Tecnologia Ltda. +'http://www.griaule.com +'------------------------------------------------------------------------------- +' +'This sample is provided with "GrFinger Fingerprint Recognition Library" and +'can't run without it. It's provided just as an example of using GrFinger +'Fingerprint Recognition Library and should not be used as basis for any +'commercial product. +' +'Griaule Tecnologia makes no representations concerning either the merchantability +'of this software or the suitability of this sample for any particular purpose. +' +'THIS SAMPLE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR +'IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +'OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +'IN NO EVENT SHALL GRIAULE BE LIABLE FOR ANY DIRECT, INDIRECT, +'INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +'NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +'DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +'THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +'(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +'THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +' +'You can download the free version of GrFinger directly from Griaule website. +' +'These notices must be retained in any copies of any part of this +'documentation and/or sample. +' +'------------------------------------------------------------------------------- + +' ----------------------------------------------------------------------------------- +' Support and fingerprint management routines +' ----------------------------------------------------------------------------------- + +Imports GrFingerXLib +Imports Microsoft.VisualBasic + +' Raw image data type. +Public Structure RawImage + ' Image data. + Public img As Object + ' Image width. + Public width As Long + ' Image height. + Public height As Long + ' Image resolution. + Public res As Long +End Structure + +Public Class Util + + ' Some constants to make our code cleaner + Public Const ERR_CANT_OPEN_BD As Integer = -999 + Public Const ERR_INVALID_ID As Integer = -998 + Public Const ERR_INVALID_TEMPLATE As Integer = -997 + + ' Importing necessary HDC functions + Private Declare Function GetDC Lib "user32" (ByVal hwnd As Int32) As Int32 + Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Int32, ByVal hdc As Int32) As Int32 + + ' The last acquired image. + Public raw As RawImage + ' The template extracted from last acquired image. + Public template As New TTemplate + ' Database class. + Public DB As DBClass + ' Reference to main form log. + Private _lbLog As ListBox + ' Reference to main form Image. + Private _pbPic As PictureBox + ' GrFingerX component + Private _GrFingerX As AxGrFingerXLib.AxGrFingerXCtrl + + ' ----------------------------------------------------------------------------------- + ' Support functions + ' ----------------------------------------------------------------------------------- + + ' This class creates an Util class with some functions + ' to help us to develop our GrFinger Application + Public Sub New(ByRef lbLog As ListBox, ByRef pbPic As PictureBox, ByRef GrFingerX As AxGrFingerXLib.AxGrFingerXCtrl) + _lbLog = lbLog + _pbPic = pbPic + _GrFingerX = GrFingerX + End Sub + + ' Write a message in box. + Public Sub WriteLog(ByVal message As String) + _lbLog.Items.Add(message) + _lbLog.SelectedIndex = _lbLog.Items.Count - 1 + _lbLog.ClearSelected() + End Sub + + ' Write and describe an error. + Public Sub WriteError(ByVal errorCode As Integer) + Select Case errorCode + Case GRConstants.GR_ERROR_INITIALIZE_FAIL + WriteLog("Fail to Initialize GrFingerX. (Error:" & errorCode & ")") + Case GRConstants.GR_ERROR_NOT_INITIALIZED + WriteLog("The GrFingerX Library is not initialized. (Error:" & errorCode & ")") + Case GRConstants.GR_ERROR_FAIL_LICENSE_READ + WriteLog("License not found. See manual for troubleshooting. (Error:" & errorCode & ")") + MessageBox.Show("License not found. See manual for troubleshooting.") + Case GRConstants.GR_ERROR_NO_VALID_LICENSE + WriteLog("The license is not valid. See manual for troubleshooting. (Error:" & errorCode & ")") + MessageBox.Show("The license is not valid. See manual for troubleshooting.") + Case GRConstants.GR_ERROR_NULL_ARGUMENT + WriteLog("The parameter have a null value. (Error:" & errorCode & ")") + Case GRConstants.GR_ERROR_FAIL + WriteLog("Fail to create a GDI object. (Error:" & errorCode & ")") + Case GRConstants.GR_ERROR_ALLOC + WriteLog("Fail to create a context. Cannot allocate memory. (Error:" & errorCode & ")") + Case GRConstants.GR_ERROR_PARAMETERS + WriteLog("One or more parameters are out of bound. (Error:" & errorCode & ")") + Case GRConstants.GR_ERROR_WRONG_USE + WriteLog("This function cannot be called at this time. (Error:" & errorCode & ")") + Case GRConstants.GR_ERROR_EXTRACT + WriteLog("Template Extraction failed. (Error:" & errorCode & ")") + Case GRConstants.GR_ERROR_SIZE_OFF_RANGE + WriteLog("Image is too larger or too short. (Error:" & errorCode & ")") + Case GRConstants.GR_ERROR_RES_OFF_RANGE + WriteLog("Image have too low or too high resolution. (Error:" & errorCode & ")") + Case GRConstants.GR_ERROR_CONTEXT_NOT_CREATED + WriteLog("The Context could not be created. (Error:" & errorCode & ")") + Case GRConstants.GR_ERROR_INVALID_CONTEXT + WriteLog("The Context does not exist. (Error:" & errorCode & ")") + + ' Capture error codes + + Case GRConstants.GR_ERROR_CONNECT_SENSOR + WriteLog("Error while connection to sensor. (Error:" & errorCode & ")") + Case GRConstants.GR_ERROR_CAPTURING + WriteLog("Error while capturing from sensor. (Error:" & errorCode & ")") + Case GRConstants.GR_ERROR_CANCEL_CAPTURING + WriteLog("Error while stop capturing from sensor. (Error:" & errorCode & ")") + Case GRConstants.GR_ERROR_INVALID_ID_SENSOR + WriteLog("The idSensor is invalid. (Error:" & errorCode & ")") + Case GRConstants.GR_ERROR_SENSOR_NOT_CAPTURING + WriteLog("The sensor is not capturing. (Error:" & errorCode & ")") + Case GRConstants.GR_ERROR_INVALID_EXT + WriteLog("The File have a unknown extension. (Error:" & errorCode & ")") + Case GRConstants.GR_ERROR_INVALID_FILENAME + WriteLog("The filename is invalid. (Error:" & errorCode & ")") + Case GRConstants.GR_ERROR_INVALID_FILETYPE + WriteLog("The file type is invalid. (Error:" & errorCode & ")") + Case GRConstants.GR_ERROR_SENSOR + WriteLog("The sensor raise an error. (Error:" & errorCode & ")") + + ' Our error codes + + Case ERR_INVALID_TEMPLATE + WriteLog("Invalid Template. (Error:" & errorCode & ")") + Case ERR_INVALID_ID + WriteLog("Invalid ID. (Error:" & errorCode & ")") + Case ERR_CANT_OPEN_BD + WriteLog("Unable to connect to DataBase. (Error:" & errorCode & ")") + Case Else + WriteLog("Error:" & errorCode) + End Select + End Sub + + ' Check if we have a valid template + Private Function TemplateIsValid() As Boolean + ' Check template size + Return template.Size > 0 + End Function + + ' ----------------------------------------------------------------------------------- + ' Main functions for fingerprint recognition management + ' ----------------------------------------------------------------------------------- + + ' Initializes GrFinger ActiveX and all necessary utilities. + Public Function InitializeGrFinger() As Integer + Dim err As Integer + + DB = New DBClass + ' Open DataBase + If DB.OpenDB() = False Then Return ERR_CANT_OPEN_BD + ' Create a new Template + template.Size = 0 + ' Create a new raw image + raw.img = Nothing + raw.width = 0 + raw.height = 0 + ' Initializing library + err = _GrFingerX.Initialize() + If err < 0 Then Return err + Return _GrFingerX.CapInitialize() + End Function + + ' Finalizes and close the DB. + Public Sub FinalizeGrFinger() + ' finalize library + _GrFingerX.Finalize() + _GrFingerX.CapFinalize() + + ' close DB + DB.closeDB() + DB = Nothing + End Sub + + ' Display fingerprint image on screen + Public Sub PrintBiometricDisplay(ByVal biometricDisplay As Boolean, ByVal context As Integer) + + ' handle to finger image + Dim handle As System.Drawing.Image = Nothing + + ' screen HDC + Dim hdc As Integer = GetDC(0) + + If biometricDisplay Then + ' get image with biometric info + _GrFingerX.BiometricDisplay(template.tpt, raw.img, raw.width, raw.height, raw.res, hdc, handle, context) + Else + ' get raw image + _GrFingerX.CapRawImageToHandle(raw.img, raw.width, raw.height, hdc, handle) + End If + + ' draw image on picture box + If Not (handle Is Nothing) Then + _pbPic.Image = handle + _pbPic.Update() + End If + ' release screen HDC + ReleaseDC(0, hdc) + End Sub + + ' Add a fingerprint template to database + Public Function Enroll() As Integer + ' Checking if template is valid. + If TemplateIsValid() Then + ' Adds template to database and gets ID. + Return DB.AddTemplate(template) + Else + Return -1 + End If + End Function + + ' Extract a fingerprint template from current image + Function ExtractTemplate() As Integer + Dim ret As Integer + + ' set current buffer size for extract template + template.Size = template.tpt.Length + + ret = _GrFingerX.Extract(raw.img, raw.width, raw.height, raw.res, template.tpt, template.Size, GRConstants.GR_DEFAULT_CONTEXT) + ' if error, set template size to 0 + ' Result < 0 => extraction problem + If ret < 0 Then template.Size = 0 + Return ret + End Function + + ' Identify current fingerprint on our database + Public Function Identify(ByRef score As Integer) As Integer + Dim ret As Integer + Dim i As Integer + + ' Checking if template is valid. + If Not TemplateIsValid() Then Return ERR_INVALID_TEMPLATE + + ' Starting identification process and supplying query template. + + Dim tmpTpt As Array = Array.CreateInstance(GetType(Byte), template.Size) + Array.Copy(template.tpt, tmpTpt, template.Size) + ret = _GrFingerX.IdentifyPrepare(tmpTpt, GRConstants.GR_DEFAULT_CONTEXT) + ' error? + If ret < 0 Then Return ret + ' Getting enrolled templates from database. + Dim templates As TTemplates() = DB.getTemplates() + ' Iterate over all templates in database + For i = 1 To templates.Length + ' Comparing the current template. + If Not (templates(i - 1).template Is Nothing) Then + Dim tempTpt As Array = Array.CreateInstance(GetType(Byte), templates(i - 1).template.Size) + Array.Copy(templates(i - 1).template.tpt, tempTpt, templates(i - 1).template.Size) + ret = _GrFingerX.Identify(tempTpt, score, GRConstants.GR_DEFAULT_CONTEXT) + End If + ' Checking if query template and reference template match. + If ret = GRConstants.GR_MATCH Then + Return templates(i - 1).ID + End If + If ret < 0 Then Return ret + Next + ' end of database, return "no match" code + Return GRConstants.GR_NOT_MATCH + End Function + + ' Check current fingerprint against another one in our database + Public Function Verify(ByVal id As Integer, ByRef score As Integer) As Integer + Dim tptref As System.Array + + ' Checking if template is valid. + If Not (TemplateIsValid()) Then Return ERR_INVALID_TEMPLATE + ' Getting template with the supplied ID from database. + tptref = DB.getTemplate(id) + ' Checking if ID was found. + If tptref Is Nothing Then Return ERR_INVALID_ID + ' Comparing templates. + Dim tempTpt As Array = Array.CreateInstance(GetType(Byte), template.Size) + Array.Copy(template.tpt, tempTpt, template.Size) + Return _GrFingerX.Verify(tempTpt, tptref, score, GRConstants.GR_DEFAULT_CONTEXT) + End Function + + ' Show GrFinger version and type + Public Sub MessageVersion() + Dim majorVersion As Integer = 0 + Dim minorVersion As Integer = 0 + Dim result As GRConstants + Dim vStr As String = "" + + result = _GrFingerX.GetGrFingerVersion(majorVersion, minorVersion) + If result = GRConstants.GRFINGER_FULL Then vStr = "FULL" + If result = GRConstants.GRFINGER_LIGHT Then vStr = "LIGHT" + If result = GRConstants.GRFINGER_FREE Then vStr = "FREE" + MessageBox.Show("The GrFinger DLL version is " & majorVersion & _ + "." & minorVersion & "." & vbCrLf & _ + "The license type is '" & vStr & "'.", "GrFinger Version") + End Sub + +End Class diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/bin/Debug/AxInterop.GrFingerXLib.dll b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/bin/Debug/AxInterop.GrFingerXLib.dll new file mode 100644 index 0000000..1c9e361 Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/bin/Debug/AxInterop.GrFingerXLib.dll differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/bin/Debug/FingerPrintReader.exe b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/bin/Debug/FingerPrintReader.exe new file mode 100644 index 0000000..0f3bddc Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/bin/Debug/FingerPrintReader.exe differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/bin/Debug/FingerPrintReader.pdb b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/bin/Debug/FingerPrintReader.pdb new file mode 100644 index 0000000..87ef1c2 Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/bin/Debug/FingerPrintReader.pdb differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/bin/Debug/FingerPrintReader.vshost.exe b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/bin/Debug/FingerPrintReader.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/bin/Debug/FingerPrintReader.vshost.exe differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/bin/Debug/FingerPrintReader.xml b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/bin/Debug/FingerPrintReader.xml new file mode 100644 index 0000000..7f5d8d4 --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/bin/Debug/FingerPrintReader.xml @@ -0,0 +1,24 @@ + + + + +FingerPrintReader + + + + + + Returns the cached ResourceManager instance used by this class. + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + \ No newline at end of file diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/bin/Debug/GrFingerSample.mdb b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/bin/Debug/GrFingerSample.mdb new file mode 100644 index 0000000..390b526 Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/bin/Debug/GrFingerSample.mdb differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/bin/Debug/Interop.GrFingerXLib.dll b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/bin/Debug/Interop.GrFingerXLib.dll new file mode 100644 index 0000000..9b7a79c Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/bin/Debug/Interop.GrFingerXLib.dll differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/AxInterop.GrFingerXLib.dll b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/AxInterop.GrFingerXLib.dll new file mode 100644 index 0000000..1c9e361 Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/AxInterop.GrFingerXLib.dll differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/FingerPrintReader.Form1.resources b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/FingerPrintReader.Form1.resources new file mode 100644 index 0000000..44489a1 Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/FingerPrintReader.Form1.resources differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/FingerPrintReader.Resources.resources b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/FingerPrintReader.Resources.resources new file mode 100644 index 0000000..a19c079 Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/FingerPrintReader.Resources.resources differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/FingerPrintReader.exe b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/FingerPrintReader.exe new file mode 100644 index 0000000..0f3bddc Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/FingerPrintReader.exe differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/FingerPrintReader.pdb b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/FingerPrintReader.pdb new file mode 100644 index 0000000..87ef1c2 Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/FingerPrintReader.pdb differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/FingerPrintReader.vbproj.GenerateResource.Cache b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/FingerPrintReader.vbproj.GenerateResource.Cache new file mode 100644 index 0000000..b13d6ab Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/FingerPrintReader.vbproj.GenerateResource.Cache differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/FingerPrintReader.vbproj.ResolveComReference.cache b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/FingerPrintReader.vbproj.ResolveComReference.cache new file mode 100644 index 0000000..9b8397a Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/FingerPrintReader.vbproj.ResolveComReference.cache differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/FingerPrintReader.xml b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/FingerPrintReader.xml new file mode 100644 index 0000000..7f5d8d4 --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/FingerPrintReader.xml @@ -0,0 +1,24 @@ + + + + +FingerPrintReader + + + + + + Returns the cached ResourceManager instance used by this class. + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + \ No newline at end of file diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/Interop.GrFingerXLib.dll b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/Interop.GrFingerXLib.dll new file mode 100644 index 0000000..9b7a79c Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/Interop.GrFingerXLib.dll differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll new file mode 100644 index 0000000..241231b Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/FingerPrintReader.vbproj.FileList.txt b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/FingerPrintReader.vbproj.FileList.txt new file mode 100644 index 0000000..9b57e31 --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader/FingerPrintReader/obj/FingerPrintReader.vbproj.FileList.txt @@ -0,0 +1,16 @@ +bin\Debug\GrFingerSample.mdb +bin\Debug\FingerPrintReader.exe +bin\Debug\FingerPrintReader.pdb +bin\Debug\FingerPrintReader.xml +bin\Debug\Interop.GrFingerXLib.dll +bin\Debug\AxInterop.GrFingerXLib.dll +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\Interop.GrFingerXLib.dll +obj\Debug\AxInterop.GrFingerXLib.dll +obj\Debug\FingerPrintReader.vbproj.ResolveComReference.cache +obj\Debug\FingerPrintReader.Form1.resources +obj\Debug\FingerPrintReader.Resources.resources +obj\Debug\FingerPrintReader.vbproj.GenerateResource.Cache +obj\Debug\FingerPrintReader.exe +obj\Debug\FingerPrintReader.xml +obj\Debug\FingerPrintReader.pdb diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS.sln b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS.sln new file mode 100644 index 0000000..c38591d --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FingerPrintReader_CS", "FingerPrintReader_CS\FingerPrintReader_CS.csproj", "{F2811056-919E-4CF0-BB01-3E7DAF6DFEAF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F2811056-919E-4CF0-BB01-3E7DAF6DFEAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F2811056-919E-4CF0-BB01-3E7DAF6DFEAF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F2811056-919E-4CF0-BB01-3E7DAF6DFEAF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F2811056-919E-4CF0-BB01-3E7DAF6DFEAF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS.suo b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS.suo new file mode 100644 index 0000000..907e574 Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS.suo differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/DBClass.cs b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/DBClass.cs new file mode 100644 index 0000000..d9ecce4 --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/DBClass.cs @@ -0,0 +1,210 @@ +/* + ------------------------------------------------------------------------------- + GrFinger Sample + (c) 2005 Griaule Tecnologia Ltda. + http://www.griaule.com + ------------------------------------------------------------------------------- + + This sample is provided with "GrFinger Fingerprint Recognition Library" and + can't run without it. It's provided just as an example of using GrFinger + Fingerprint Recognition Library and should not be used as basis for any + commercial product. + + Griaule Tecnologia makes no representations concerning either the merchantability + of this software or the suitability of this sample for any particular purpose. + + THIS SAMPLE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL GRIAULE BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + You can download the free version of GrFinger directly from Griaule website. + + These notices must be retained in any copies of any part of this + documentation and/or sample. + + ------------------------------------------------------------------------------- +*/ + +// ----------------------------------------------------------------------------------- +// Database routines +// ----------------------------------------------------------------------------------- + +using System; +using System.Data; +using System.Data.OleDb; +using GrFingerXLib; +using System.Runtime.InteropServices; + +// the template class +public class TTemplate +{ + // Template data. + public System.Array _tpt; + // Template size + public int _size; + + public TTemplate(){ + // Create a byte buffer for the template + _tpt = new byte[(int)GRConstants.GR_MAX_SIZE_TEMPLATE]; + _size = 0; + } +} + +// the database class +public class DBClass{ + + // the connection object + private OleDbConnection _connection; + + // temporary template for retrieving data from DB + private TTemplate tptBlob; + + // the database we'll be connecting to + public readonly string CONNECTION_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=GrFingerSample.mdb"; + + public DBClass(){ + } + + // Open connection + public bool openDB() + { + _connection = new OleDbConnection(); + _connection.ConnectionString = CONNECTION_STRING; + try{ + _connection.Open(); + } + catch{ + return false; + } + tptBlob = new TTemplate(); + return true; + }//END + + // Close conection + public bool closeDB() + { + if(_connection.State != ConnectionState.Closed) + _connection.Close(); + return true; + } + + // Clear database + public bool clearDB() + { + OleDbCommand cmdClear = null; + cmdClear = new OleDbCommand("DELETE FROM enroll", _connection); + + // run "clear" query + if(_connection.State == ConnectionState.Open) + cmdClear.ExecuteNonQuery(); + + return true; + } + + + // Add template to database. Returns added template ID. + public bool addTemplate(TTemplate tpt,ref int id) + { + OleDbCommand cmdInsert = null; + OleDbParameter dbParamInsert = null; + OleDbCommand cmdSelect = null; + + try{ + // Create SQL command containing ? parameter for BLOB. + cmdInsert = new OleDbCommand("INSERT INTO enroll(template) values(?) ", _connection); + // Create parameter for ? contained in the SQL statement. + System.Byte [] temp = new System.Byte[tpt._size + 1]; + System.Array.Copy(tpt._tpt, 0, temp, 0, tpt._size); + + dbParamInsert = new OleDbParameter("@template", OleDbType.VarBinary, tpt._size, + ParameterDirection.Input, false, 0, 0,"ID", + DataRowVersion.Current, temp); + cmdInsert.Parameters.Add(dbParamInsert); + + //execute query + if(_connection.State == ConnectionState.Open) + cmdInsert.ExecuteNonQuery(); + } + catch{ + return false; + } + + try{ + // Create SQL command containing ? parameter for BLOB. + cmdSelect = new OleDbCommand("SELECT top 1 ID FROM enroll ORDER BY ID DESC", _connection); + + id = System.Convert.ToInt32(cmdSelect.ExecuteScalar()); + } + catch { + return false; + } + + return true; + } + + // Returns an OleDbDataReader with all enrolled templates from database. + public OleDbDataReader getTemplates() + { + OleDbCommand cmdGetTemplates; + OleDbDataReader rs; + + //setting up command + cmdGetTemplates = new OleDbCommand("SELECT * FROM enroll", _connection); + rs = cmdGetTemplates.ExecuteReader(); + + return rs; + } + + + // Returns template with the supplied ID. + public TTemplate getTemplate(int id) + { + OleDbCommand cmd = null; + OleDbDataReader dr = null; + tptBlob._size = 0; + try + { + cmd = new OleDbCommand(System.String.Concat("SELECT * FROM enroll WHERE ID = ", System.Convert.ToString((int)id)), _connection); + dr = cmd.ExecuteReader(); + // Get query response + dr.Read(); + getTemplate(dr); + dr.Close(); + } + catch{ + dr.Close(); + } + return tptBlob; + } + + // Return template data from an OleDbDataReader + public TTemplate getTemplate(OleDbDataReader rs) + { + long readedBytes; + tptBlob._size = 0; + // alloc space + System.Byte[] temp = new System.Byte[ + (int)GRConstants.GR_MAX_SIZE_TEMPLATE]; + // get bytes + readedBytes = rs.GetBytes(1, 0, temp, 0,temp.Length); + // copy to structure + System.Array.Copy(temp, 0, tptBlob._tpt,0,(int)readedBytes); + // set real size + tptBlob._size = (int)readedBytes; + + return tptBlob; + } + + // Return enrollment ID from an OleDbDataReader + public int getId(OleDbDataReader rs) + { + return rs.GetInt32(0); + } +} diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/FingerPrintReader_CS.csproj b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/FingerPrintReader_CS.csproj new file mode 100644 index 0000000..163b26c --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/FingerPrintReader_CS.csproj @@ -0,0 +1,105 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {F2811056-919E-4CF0-BB01-3E7DAF6DFEAF} + WinExe + Properties + FingerPrintReader_CS + FingerPrintReader_CS + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Designer + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + {A9995C7C-77BF-4E27-B581-A4B5BBD90E50} + 1 + 0 + 0 + aximp + False + + + {A9995C7C-77BF-4E27-B581-A4B5BBD90E50} + 1 + 0 + 0 + tlbimp + False + + + + + Always + + + + + + \ No newline at end of file diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/FingerPrintReader_CS.csproj.user b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/FingerPrintReader_CS.csproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/FingerPrintReader_CS.csproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Form1.Designer.cs b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Form1.Designer.cs new file mode 100644 index 0000000..2fcd540 --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Form1.Designer.cs @@ -0,0 +1,250 @@ +namespace FingerPrintReader_CS +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); + this.lblMessage = new System.Windows.Forms.Label(); + this.Label3 = new System.Windows.Forms.Label(); + this.Label2 = new System.Windows.Forms.Label(); + this.Label1 = new System.Windows.Forms.Label(); + this.btnRegister = new System.Windows.Forms.Button(); + this.Timer1 = new System.Windows.Forms.Timer(this.components); + this.ListBox1 = new System.Windows.Forms.ListBox(); + this.GroupBox1 = new System.Windows.Forms.GroupBox(); + this.txtEmail = new System.Windows.Forms.TextBox(); + this.Label5 = new System.Windows.Forms.Label(); + this.txtContactNumber = new System.Windows.Forms.TextBox(); + this.txtCompany = new System.Windows.Forms.TextBox(); + this.txtName = new System.Windows.Forms.TextBox(); + this.txtSSN = new System.Windows.Forms.TextBox(); + this.Label4 = new System.Windows.Forms.Label(); + this.PictureBox1 = new System.Windows.Forms.PictureBox(); + this.axGrFingerXCtrl1 = new AxGrFingerXLib.AxGrFingerXCtrl(); + this.GroupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.PictureBox1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.axGrFingerXCtrl1)).BeginInit(); + this.SuspendLayout(); + // + // lblMessage + // + this.lblMessage.BackColor = System.Drawing.SystemColors.ControlLightLight; + this.lblMessage.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.lblMessage.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblMessage.Location = new System.Drawing.Point(178, 12); + this.lblMessage.Name = "lblMessage"; + this.lblMessage.Size = new System.Drawing.Size(336, 72); + this.lblMessage.TabIndex = 23; + this.lblMessage.Text = "Please place your index finger on the fingerprint reader"; + // + // Label3 + // + this.Label3.AutoSize = true; + this.Label3.Location = new System.Drawing.Point(80, 72); + this.Label3.Name = "Label3"; + this.Label3.Size = new System.Drawing.Size(51, 13); + this.Label3.TabIndex = 17; + this.Label3.Text = "Company"; + // + // Label2 + // + this.Label2.AutoSize = true; + this.Label2.Location = new System.Drawing.Point(8, 24); + this.Label2.Name = "Label2"; + this.Label2.Size = new System.Drawing.Size(117, 13); + this.Label2.TabIndex = 16; + this.Label2.Text = "Social Security Number"; + // + // Label1 + // + this.Label1.AutoSize = true; + this.Label1.Location = new System.Drawing.Point(96, 48); + this.Label1.Name = "Label1"; + this.Label1.Size = new System.Drawing.Size(35, 13); + this.Label1.TabIndex = 15; + this.Label1.Text = "Name"; + // + // btnRegister + // + this.btnRegister.Location = new System.Drawing.Point(439, 252); + this.btnRegister.Name = "btnRegister"; + this.btnRegister.Size = new System.Drawing.Size(75, 23); + this.btnRegister.TabIndex = 26; + this.btnRegister.Text = "Register"; + this.btnRegister.UseVisualStyleBackColor = true; + this.btnRegister.Click += new System.EventHandler(this.btnRegister_Click); + // + // Timer1 + // + this.Timer1.Interval = 5000; + this.Timer1.Tick += new System.EventHandler(this.Timer1_Tick); + // + // ListBox1 + // + this.ListBox1.Location = new System.Drawing.Point(12, 281); + this.ListBox1.Name = "ListBox1"; + this.ListBox1.Size = new System.Drawing.Size(502, 95); + this.ListBox1.TabIndex = 25; + // + // GroupBox1 + // + this.GroupBox1.Controls.Add(this.txtEmail); + this.GroupBox1.Controls.Add(this.Label5); + this.GroupBox1.Controls.Add(this.txtContactNumber); + this.GroupBox1.Controls.Add(this.txtCompany); + this.GroupBox1.Controls.Add(this.txtName); + this.GroupBox1.Controls.Add(this.txtSSN); + this.GroupBox1.Controls.Add(this.Label4); + this.GroupBox1.Controls.Add(this.Label3); + this.GroupBox1.Controls.Add(this.Label2); + this.GroupBox1.Controls.Add(this.Label1); + this.GroupBox1.Location = new System.Drawing.Point(178, 92); + this.GroupBox1.Name = "GroupBox1"; + this.GroupBox1.Size = new System.Drawing.Size(336, 152); + this.GroupBox1.TabIndex = 24; + this.GroupBox1.TabStop = false; + this.GroupBox1.Text = "User\'s Particulars"; + // + // txtEmail + // + this.txtEmail.Location = new System.Drawing.Point(144, 120); + this.txtEmail.Name = "txtEmail"; + this.txtEmail.Size = new System.Drawing.Size(184, 20); + this.txtEmail.TabIndex = 24; + // + // Label5 + // + this.Label5.AutoSize = true; + this.Label5.Location = new System.Drawing.Point(96, 120); + this.Label5.Name = "Label5"; + this.Label5.Size = new System.Drawing.Size(32, 13); + this.Label5.TabIndex = 23; + this.Label5.Text = "Email"; + // + // txtContactNumber + // + this.txtContactNumber.Location = new System.Drawing.Point(144, 96); + this.txtContactNumber.Name = "txtContactNumber"; + this.txtContactNumber.Size = new System.Drawing.Size(104, 20); + this.txtContactNumber.TabIndex = 22; + // + // txtCompany + // + this.txtCompany.Location = new System.Drawing.Point(144, 72); + this.txtCompany.Name = "txtCompany"; + this.txtCompany.Size = new System.Drawing.Size(184, 20); + this.txtCompany.TabIndex = 21; + // + // txtName + // + this.txtName.Location = new System.Drawing.Point(144, 48); + this.txtName.Name = "txtName"; + this.txtName.Size = new System.Drawing.Size(184, 20); + this.txtName.TabIndex = 20; + // + // txtSSN + // + this.txtSSN.Location = new System.Drawing.Point(144, 24); + this.txtSSN.Name = "txtSSN"; + this.txtSSN.Size = new System.Drawing.Size(100, 20); + this.txtSSN.TabIndex = 19; + // + // Label4 + // + this.Label4.AutoSize = true; + this.Label4.Location = new System.Drawing.Point(48, 96); + this.Label4.Name = "Label4"; + this.Label4.Size = new System.Drawing.Size(84, 13); + this.Label4.TabIndex = 18; + this.Label4.Text = "Contact Number"; + // + // PictureBox1 + // + this.PictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.PictureBox1.Image = global::FingerPrintReader_CS.Properties.Resources.fingerprintreader; + this.PictureBox1.Location = new System.Drawing.Point(12, 12); + this.PictureBox1.Name = "PictureBox1"; + this.PictureBox1.Size = new System.Drawing.Size(160, 232); + this.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.PictureBox1.TabIndex = 22; + this.PictureBox1.TabStop = false; + // + // axGrFingerXCtrl1 + // + this.axGrFingerXCtrl1.Enabled = true; + this.axGrFingerXCtrl1.Location = new System.Drawing.Point(29, 27); + this.axGrFingerXCtrl1.Name = "axGrFingerXCtrl1"; + this.axGrFingerXCtrl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axGrFingerXCtrl1.OcxState"))); + this.axGrFingerXCtrl1.Size = new System.Drawing.Size(32, 32); + this.axGrFingerXCtrl1.TabIndex = 27; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(527, 388); + this.Controls.Add(this.axGrFingerXCtrl1); + this.Controls.Add(this.lblMessage); + this.Controls.Add(this.btnRegister); + this.Controls.Add(this.ListBox1); + this.Controls.Add(this.GroupBox1); + this.Controls.Add(this.PictureBox1); + this.Name = "Form1"; + this.Text = "Form1"; + this.Load += new System.EventHandler(this.Form1_Load); + this.GroupBox1.ResumeLayout(false); + this.GroupBox1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.PictureBox1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.axGrFingerXCtrl1)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + internal System.Windows.Forms.Label lblMessage; + internal System.Windows.Forms.Label Label3; + internal System.Windows.Forms.Label Label2; + internal System.Windows.Forms.Label Label1; + internal System.Windows.Forms.Button btnRegister; + internal System.Windows.Forms.Timer Timer1; + internal System.Windows.Forms.ListBox ListBox1; + internal System.Windows.Forms.GroupBox GroupBox1; + internal System.Windows.Forms.TextBox txtEmail; + internal System.Windows.Forms.Label Label5; + internal System.Windows.Forms.TextBox txtContactNumber; + internal System.Windows.Forms.TextBox txtCompany; + internal System.Windows.Forms.TextBox txtName; + internal System.Windows.Forms.TextBox txtSSN; + internal System.Windows.Forms.Label Label4; + internal System.Windows.Forms.PictureBox PictureBox1; + private AxGrFingerXLib.AxGrFingerXCtrl axGrFingerXCtrl1; + } +} + diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Form1.cs b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Form1.cs new file mode 100644 index 0000000..a6b124a --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Form1.cs @@ -0,0 +1,319 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +using GrFingerXLib; + +namespace FingerPrintReader_CS +{ + public partial class Form1 : Form + { + + // ---name of the database--- + const string DBFile = "GrFingerSample.mdb"; + const string Logfile = "C:\\Log.csv"; + const string ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="; + Util myUtil; + int _UserID; + System.Data.OleDb.OleDbConnection connection; + + public Form1() + { + InitializeComponent(); + } + + private void Form1_Load(object sender, EventArgs e) + { + int err; + // initialize util class + myUtil = new Util(ListBox1, PictureBox1, null, null, null, null, null, null); + + axGrFingerXCtrl1.SensorPlug += new AxGrFingerXLib. + _IGrFingerXCtrlEvents_SensorPlugEventHandler(axGrFingerXCtrl1_SensorPlug); + axGrFingerXCtrl1.SensorUnplug += new AxGrFingerXLib. + _IGrFingerXCtrlEvents_SensorUnplugEventHandler(axGrFingerXCtrl1_SensorUnplug); + axGrFingerXCtrl1.FingerDown += new AxGrFingerXLib. + _IGrFingerXCtrlEvents_FingerDownEventHandler(axGrFingerXCtrl1_FingerDown); + axGrFingerXCtrl1.FingerUp += new AxGrFingerXLib. + _IGrFingerXCtrlEvents_FingerUpEventHandler(axGrFingerXCtrl1_FingerUp); + axGrFingerXCtrl1.ImageAcquired += new AxGrFingerXLib. + _IGrFingerXCtrlEvents_ImageAcquiredEventHandler(axGrFingerXCtrl1_ImageAcquired); + + // Initialize GrFingerX Library + err = myUtil.InitializeGrFinger(axGrFingerXCtrl1); + // Print result in log + if ((err < 0)) + { + myUtil.WriteError((GRConstants)err); + return; + } + else + { + myUtil.WriteLog("**GrFingerX Initialized Successfull**"); + } + // ---create a log file--- + if (!System.IO.File.Exists(Logfile)) + { + System.IO.File.Create(Logfile); + } + } + + // ----------------------------------------------------------------------------------- + // GrFingerX events + // ----------------------------------------------------------------------------------- + // A fingerprint reader was plugged on system + private void axGrFingerXCtrl1_SensorPlug(object sender, AxGrFingerXLib._IGrFingerXCtrlEvents_SensorPlugEvent e) + { + myUtil.WriteLog(("Sensor: " + + (e.idSensor + ". Event: Plugged."))); + axGrFingerXCtrl1.CapStartCapture(e.idSensor); + } + + // A fingerprint reader was unplugged from system + private void axGrFingerXCtrl1_SensorUnplug(object sender, AxGrFingerXLib._IGrFingerXCtrlEvents_SensorUnplugEvent e) + { + myUtil.WriteLog(("Sensor: " + + (e.idSensor + ". Event: Unplugged."))); + axGrFingerXCtrl1.CapStopCapture(e.idSensor); + } + + // A finger was placed on reader + private void axGrFingerXCtrl1_FingerDown(object sender, AxGrFingerXLib._IGrFingerXCtrlEvents_FingerDownEvent e) + { + myUtil.WriteLog(("Sensor: " + + (e.idSensor + ". Event: Finger Placed."))); + } + + // A finger was removed from reader + private void axGrFingerXCtrl1_FingerUp(object sender, AxGrFingerXLib._IGrFingerXCtrlEvents_FingerUpEvent e) + { + myUtil.WriteLog(("Sensor: " + + (e.idSensor + ". Event: Finger removed."))); + } + + // An image was acquired from reader + private void axGrFingerXCtrl1_ImageAcquired(object sender, AxGrFingerXLib._IGrFingerXCtrlEvents_ImageAcquiredEvent e) + { + // Copying aquired image + myUtil._raw.height = e.height; + myUtil._raw.width = e.width; + myUtil._raw.Res = e.res; + myUtil._raw.img = e.rawImage; + // Signaling that an Image Event occurred. + myUtil.WriteLog(("Sensor: " + + (e.idSensor + ". Event: Image captured."))); + // display fingerprint image + myUtil.PrintBiometricDisplay(false, GRConstants.GR_DEFAULT_CONTEXT); + // ---extract the template from the fingerprint scanned--- + ExtractTemplate(); + // ---identify who the user is--- + _UserID = IdentifyFingerprint(); + if ((_UserID > 0)) + { + // ---user found--- + btnRegister.Enabled = false; + GetUserInfo(); + // ---writes to log file--- + WriteToLog(_UserID.ToString()); + } + else + { + // ---user not found--- + ClearDisplay(); + btnRegister.Enabled = true; + lblMessage.Text = "User not found! Please register your information below"; + } + } + + // Extract a template from a fingerprint image + private int ExtractTemplate() + { + int ret; + // extract template + ret = myUtil.ExtractTemplate(); + // write template quality to log + if ((GRConstants)ret == GRConstants.GR_BAD_QUALITY) + { + myUtil.WriteLog("Template extracted successfully. Bad quality."); + } + else if ((GRConstants)ret == GRConstants.GR_MEDIUM_QUALITY) + { + myUtil.WriteLog("Template extracted successfully. Medium quality."); + } + else if ((GRConstants)ret == GRConstants.GR_HIGH_QUALITY) + { + myUtil.WriteLog("Template extracted successfully. High quality."); + } + if ((ret >= 0)) + { + // if no error, display minutiae/segments/directions into the image + myUtil.PrintBiometricDisplay(true, GRConstants.GR_NO_CONTEXT); + } + else + { + // write error to log + myUtil.WriteError((GRConstants)ret); + } + return ret; + } + + // ---Identify a fingerprint; returns the ID of the user--- + private int IdentifyFingerprint() + { + int ret; + int score; + score = 0; + // identify it + ret = myUtil.Identify(ref score); + // write result to log + if ((ret > 0)) + { + myUtil.WriteLog(("Fingerprint identified. ID = " + + (ret + (". Score = " + + (score + "."))))); + myUtil.PrintBiometricDisplay(true, GRConstants.GR_DEFAULT_CONTEXT); + } + else if ((ret == 0)) + { + myUtil.WriteLog("Fingerprint not Found."); + } + else + { + myUtil.WriteError((GRConstants)ret); + } + return ret; + } + + // ---get user's information--- + public void GetUserInfo() + { + string filePath; + try + { + filePath = (Application.StartupPath + ("\\" + DBFile)); + connection = new System.Data.OleDb.OleDbConnection((ConnectionString + filePath)); + connection.Open(); + System.Data.OleDb.OleDbDataReader reader; + System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand(); + command.Connection = connection; + // ---retrieve user's particulars--- + command.CommandText = ("SELECT * FROM Enroll WHERE ID=" + _UserID); + reader = command.ExecuteReader(CommandBehavior.CloseConnection); + reader.Read(); + // ---display user's particulars--- + lblMessage.Text = ("Welcome, " + reader["name"]); + txtSSN.Text = reader["SSN"].ToString(); + txtName.Text = reader["Name"].ToString(); + txtCompany.Text = reader["Company"].ToString(); + txtContactNumber.Text = reader["ContactNumber"].ToString(); + txtEmail.Text = reader["Email"].ToString(); + // ---reset the timer to another 5 seconds--- + Timer1.Enabled = false; + Timer1.Enabled = true; + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString(), "Error"); + } + finally + { + connection.Close(); + } + } + + // ---Register button--- + private void btnRegister_Click(object sender, System.EventArgs e) + { + // ---first add the fingerprint--- + _UserID = EnrollFingerprint(); + // ---then add the particulars--- + AddNewUser(); + // ---clears the display--- + ClearDisplay(); + // ---writes to log file--- + WriteToLog(_UserID.ToString()); + } + + // ---adds a fingerprint to the database; returns the ID of the user--- + private int EnrollFingerprint() + { + int id; + // add fingerprint + id = myUtil.Enroll(); + // write result to log + if ((id >= 0)) + { + myUtil.WriteLog(("Fingerprint enrolled with id = " + id)); + } + else + { + myUtil.WriteLog("Error: Fingerprint not enrolled"); + } + return id; + } + + // ---Add a new user's information to the database--- + public void AddNewUser() + { + string filePath; + try + { + filePath = (Application.StartupPath + ("\\" + DBFile)); + connection = new System.Data.OleDb.OleDbConnection((ConnectionString + filePath)); + connection.Open(); + System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand(); + command.Connection = connection; + // ---set the user's particulars in the table--- + string sql = ("UPDATE enroll SET SSN=\'" + + (txtSSN.Text + ("\', " + ("Name=\'" + + (txtName.Text + ("\', " + ("Company=\'" + + (txtCompany.Text + ("\', " + ("ContactNumber=\'" + + (txtContactNumber.Text + ("\', " + ("Email=\'" + + (txtEmail.Text + ("\' " + (" WHERE ID=" + _UserID)))))))))))))))); + command.CommandText = sql; + command.ExecuteNonQuery(); + MessageBox.Show("User added successfully!", "Error"); + + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString(), "Error"); + } + finally + { + connection.Close(); + } + } + + // ---Clears the user's particulars--- + public void ClearDisplay() + { + lblMessage.Text = "Please place your index finger " + "on the fingerprint reader"; + PictureBox1.Image = FingerPrintReader_CS. + Properties.Resources.fingerprintreader; + txtSSN.Text = String.Empty; + txtName.Text = String.Empty; + txtCompany.Text = String.Empty; + txtContactNumber.Text = String.Empty; + txtEmail.Text = String.Empty; + } + + public void WriteToLog(string ID) + { + // ---write to a log file--- + System.IO.StreamWriter sw = new System.IO.StreamWriter(Logfile, true, System.Text.Encoding.ASCII); + sw.WriteLine((ID + ("," + System.DateTime.Now.ToString()))); + sw.Close(); + } + + private void Timer1_Tick(object sender, EventArgs e) + { + ClearDisplay(); + Timer1.Enabled = false; + } + } +} \ No newline at end of file diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Form1.resx b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Form1.resx new file mode 100644 index 0000000..1ca3a10 --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Form1.resx @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w + LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACFTeXN0 + ZW0uV2luZG93cy5Gb3Jtcy5BeEhvc3QrU3RhdGUBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAIQAAAAIB + AAAAAQAAAAAAAAAAAAAAAAwAAAAQBwAATwMAAE8DAAAL + + + \ No newline at end of file diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/GrFingerSample.mdb b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/GrFingerSample.mdb new file mode 100644 index 0000000..2e62fef Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/GrFingerSample.mdb differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Program.cs b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Program.cs new file mode 100644 index 0000000..43cdbcb --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace FingerPrintReader_CS +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} \ No newline at end of file diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Properties/AssemblyInfo.cs b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..4b5f296 --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("FingerPrintReader_CS")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("FingerPrintReader_CS")] +[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("143f37f6-f391-4e45-a0de-7e40ceeab16c")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Properties/Resources.Designer.cs b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Properties/Resources.Designer.cs new file mode 100644 index 0000000..136faab --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Properties/Resources.Designer.cs @@ -0,0 +1,70 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace FingerPrintReader_CS.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FingerPrintReader_CS.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + internal static System.Drawing.Bitmap fingerprintreader { + get { + object obj = ResourceManager.GetObject("fingerprintreader", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Properties/Resources.resx b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Properties/Resources.resx new file mode 100644 index 0000000..304d85d --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Properties/Resources.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\fingerprintreader.jpg;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Properties/Settings.Designer.cs b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Properties/Settings.Designer.cs new file mode 100644 index 0000000..3475c69 --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace FingerPrintReader_CS.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Properties/Settings.settings b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Resources/fingerprintreader.jpg b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Resources/fingerprintreader.jpg new file mode 100644 index 0000000..67a13f8 Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Resources/fingerprintreader.jpg differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Util.cs b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Util.cs new file mode 100644 index 0000000..c606375 --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/Util.cs @@ -0,0 +1,432 @@ +/* + ------------------------------------------------------------------------------- + GrFinger Sample + (c) 2005 Griaule Tecnologia Ltda. + http://www.griaule.com + ------------------------------------------------------------------------------- + + This sample is provided with "GrFinger Fingerprint Recognition Library" and + can't run without it. It's provided just as an example of using GrFinger + Fingerprint Recognition Library and should not be used as basis for any + commercial product. + + Griaule Tecnologia makes no representations concerning either the merchantability + of this software or the suitability of this sample for any particular purpose. + + THIS SAMPLE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL GRIAULE BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + You can download the free version of GrFinger directly from Griaule website. + + These notices must be retained in any copies of any part of this + documentation and/or sample. + + ------------------------------------------------------------------------------- +*/ + +// ----------------------------------------------------------------------------------- +// Support and fingerprint management routines +// ----------------------------------------------------------------------------------- + +using GrFingerXLib; +using System; +using System.Drawing; +using System.Data.OleDb; +using System.Windows.Forms; +using System.Runtime.InteropServices; + +// Raw image data type. +public struct TRawImage +{ + // Image data. + public object img; + // Image width. + public int width; + // Image height. + public int height; + // Image resolution. + public int Res; +}; + +public class Util +{ + + // Some constants to make our code cleaner + public const int ERR_CANT_OPEN_BD = -999; + public const int ERR_INVALID_ID = -998; + public const int ERR_INVALID_TEMPLATE = -997; + + // ----------------------------------------------------------------------------------- + // Support functions + // ----------------------------------------------------------------------------------- + + // This class creates an Util class with some functions + // to help us to develop our GrFinger Application + public Util(ListBox lbLog, PictureBox pbPic, + Button btEnroll, Button btnExtract, Button btIdentify, Button btVerify, + CheckBox cbAutoExtract, CheckBox cbAutoIdentify) + { + _lbLog = lbLog; + _pbPic = pbPic; + _btEnroll = btEnroll; + _btExtract = btnExtract; + _btIdentify = btIdentify; + _btVerify = btVerify; + _cbAutoExtract = cbAutoExtract; + _cbAutoIdentify = cbAutoIdentify; + _DB = null; + _tpt = null; + } + + ~Util() + { + } + + // Write a message in log box. + public void WriteLog(String msg) + { + _lbLog.Items.Add(msg); + _lbLog.SelectedIndex = _lbLog.Items.Count - 1; + _lbLog.ClearSelected(); + } + + // Write and describe an error. + public void WriteError(GrFingerXLib.GRConstants errorCode) + { + switch ((int)errorCode) + { + case (int)GRConstants.GR_ERROR_INITIALIZE_FAIL: + WriteLog("Fail to Initialize GrFingerX. (Error:" + errorCode + ")"); + return; + case (int)GRConstants.GR_ERROR_NOT_INITIALIZED: + WriteLog("The GrFingerX Library is not initialized. (Error:" + errorCode + ")"); + return; + case (int)GRConstants.GR_ERROR_FAIL_LICENSE_READ: + WriteLog("License not found. See manual for troubleshooting. (Error:" + errorCode + ")"); + MessageBox.Show("License not found. See manual for troubleshooting."); + return; + case (int)GRConstants.GR_ERROR_NO_VALID_LICENSE: + WriteLog("The license is not valid. See manual for troubleshooting. (Error:" + errorCode + ")"); + MessageBox.Show("The license is not valid. See manual for troubleshooting."); + return; + case (int)GRConstants.GR_ERROR_NULL_ARGUMENT: + WriteLog("The parameter have a null value. (Error:" + errorCode + ")"); + return; + case (int)GRConstants.GR_ERROR_FAIL: + WriteLog("Fail to create a GDI object. (Error:" + errorCode + ")"); + return; + case (int)GRConstants.GR_ERROR_ALLOC: + WriteLog("Fail to create a context. Cannot allocate memory. (Error:" + errorCode + ")"); + return; + case (int)GRConstants.GR_ERROR_PARAMETERS: + WriteLog("One or more parameters are out of bound. (Error:" + errorCode + ")"); + return; + case (int)GRConstants.GR_ERROR_WRONG_USE: + WriteLog("This function cannot be called at this time. (Error:" + errorCode + ")"); + return; + case (int)GRConstants.GR_ERROR_EXTRACT: + WriteLog("Template Extraction failed. (Error:" + errorCode + ")"); + return; + case (int)GRConstants.GR_ERROR_SIZE_OFF_RANGE: + WriteLog("Image is too larger or too short. (Error:" + errorCode + ")"); + return; + case (int)GRConstants.GR_ERROR_RES_OFF_RANGE: + WriteLog("Image have too low or too high resolution. (Error:" + errorCode + ")"); + return; + case (int)GRConstants.GR_ERROR_CONTEXT_NOT_CREATED: + WriteLog("The Context could not be created. (Error:" + errorCode + ")"); + return; + case (int)GRConstants.GR_ERROR_INVALID_CONTEXT: + WriteLog("The Context does not exist. (Error:" + errorCode + ")"); + return; + + // Capture error codes + + case (int)GRConstants.GR_ERROR_CONNECT_SENSOR: + WriteLog("Error while connection to sensor. (Error:" + errorCode + ")"); + return; + case (int)GRConstants.GR_ERROR_CAPTURING: + WriteLog("Error while capturing from sensor. (Error:" + errorCode + ")"); + return; + case (int)GRConstants.GR_ERROR_CANCEL_CAPTURING: + WriteLog("Error while stop capturing from sensor. (Error:" + errorCode + ")"); + return; + case (int)GRConstants.GR_ERROR_INVALID_ID_SENSOR: + WriteLog("The idSensor is invalid. (Error:" + errorCode + ")"); + return; + case (int)GRConstants.GR_ERROR_SENSOR_NOT_CAPTURING: + WriteLog("The sensor is not capturing. (Error:" + errorCode + ")"); + return; + case (int)GRConstants.GR_ERROR_INVALID_EXT: + WriteLog("The File have a unknown extension. (Error:" + errorCode + ")"); + return; + case (int)GRConstants.GR_ERROR_INVALID_FILENAME: + WriteLog("The filename is invalid. (Error:" + errorCode + ")"); + return; + case (int)GRConstants.GR_ERROR_INVALID_FILETYPE: + WriteLog("The file type is invalid. (Error:" + errorCode + ")"); + return; + case (int)GRConstants.GR_ERROR_SENSOR: + WriteLog("The sensor raise an error. (Error:" + errorCode + ")"); + return; + + // Our error codes + case ERR_INVALID_TEMPLATE: + WriteLog("Invalid Template. (Error:"+errorCode+")"); + return; + case ERR_INVALID_ID: + WriteLog("Invalid ID. (Error:"+errorCode+")"); + return; + case ERR_CANT_OPEN_BD: + WriteLog("Unable to connect to DataBase. (Error:"+errorCode+")"); + return; + + default: + WriteLog("Error:" + errorCode); + return; + } + } + + // Check if we have a valid template + private bool TemplateIsValid() { + // Check the template size and data + return ((_tpt._size > 0) && (_tpt._tpt != null)); + } + + // ----------------------------------------------------------------------------------- + // Main functions for fingerprint recognition management + // ----------------------------------------------------------------------------------- + + // Initializes GrFinger ActiveX and all necessary utilities. + public int InitializeGrFinger(AxGrFingerXLib.AxGrFingerXCtrl grfingerx) + { + GRConstants result; + + _grfingerx = grfingerx; + //Check DataBase Class. + if (_DB == null) + _DB = new DBClass(); + //Open DataBase + if(_DB.openDB()==false) + { + return ERR_CANT_OPEN_BD; + } + + //Create a new Template + if (_tpt == null) + _tpt = new TTemplate(); + + //Create a new raw image + _raw = new TRawImage(); + + //Initialize library + result = (GRConstants)_grfingerx.Initialize(); + if (result < 0) return (int)result; + return (int)_grfingerx.CapInitialize(); + } + + // Finalizes library and close DB. + public void FinalizeUtil() { + // finalize library + _grfingerx.Finalize(); + _grfingerx.CapFinalize(); + // close DB + _DB.closeDB(); + _raw.img = null; + _tpt = null; + _DB = null; + } + + // Display fingerprint image on screen + public void PrintBiometricDisplay(bool isBiometric, GrFingerXLib.GRConstants contextId) + { + // handle to finger image + System.Drawing.Image handle = null; + // screen HDC + IntPtr hdc = GetDC(System.IntPtr.Zero); + + if (isBiometric) { + // get image with biometric info + _grfingerx.BiometricDisplay(ref _tpt._tpt, + ref _raw.img,_raw.width,_raw.height,_raw.Res,hdc.ToInt32(), + ref handle,(int)contextId); + } else { + // get raw image + _grfingerx.CapRawImageToHandle(ref _raw.img,_raw.width, + _raw.height, hdc.ToInt32(), ref handle); + } + + // draw image on picture box + if (handle != null) + { + _pbPic.Image = handle; + _pbPic.Update(); + } + + // release screen HDC + ReleaseDC(System.IntPtr.Zero,hdc); + } + + // Add a fingerprint template to database + public int Enroll() + { + int id = 0; + // Checks if template is valid. + if (TemplateIsValid()) + { + // Adds template to database and returns template ID. + _DB.addTemplate(_tpt, ref id); + return id; + } + else + { + return -1; + } + } + + // Extract a fingerprint template from current image + public int ExtractTemplate() + { + int result; + + // set current buffer size for the extract template + _tpt._size = (int)GRConstants.GR_MAX_SIZE_TEMPLATE; + result = (int)_grfingerx.Extract( + ref _raw.img, _raw.width, _raw.height, _raw.Res, + ref _tpt._tpt,ref _tpt._size, + (int)GRConstants.GR_DEFAULT_CONTEXT); + // if error, set template size to 0 + if (result < 0) + { + // Result < 0 => extraction problem + _tpt._size = 0; + } + return result; + } + + // Identify current fingerprint on our database + public int Identify(ref int score) { + GRConstants result; + int id; + OleDbDataReader rs; + TTemplate tptRef; + + // Checking if template is valid. + if(!TemplateIsValid()) return ERR_INVALID_TEMPLATE; + // Starting identification process and supplying query template. + result = (GRConstants) _grfingerx.IdentifyPrepare(ref _tpt._tpt, + (int)GRConstants.GR_DEFAULT_CONTEXT); + // error? + if (result < 0) return (int)result; + // Getting enrolled templates from database. + rs = _DB.getTemplates(); + while(rs.Read()) + { + // Getting current template from recordset. + tptRef = _DB.getTemplate(rs); + + // Comparing current template. + result = (GRConstants) _grfingerx.Identify(ref tptRef._tpt, ref score,(int)GRConstants.GR_DEFAULT_CONTEXT); + + // Checking if query template and the reference template match. + if(result == GRConstants.GR_MATCH) + { + id = _DB.getId(rs); + rs.Close(); + return id; + } + else if (result < 0) + { + rs.Close(); + return (int)result; + } + } + + // Closing recordset. + rs.Close(); + return (int)GRConstants.GR_NOT_MATCH; + } + + // Check current fingerprint against another one in our database + public int Verify(int id, ref int score) { + TTemplate tptRef; + + // Checking if template is valid. + if(!TemplateIsValid()) return ERR_INVALID_TEMPLATE; + + // Getting template with the supplied ID from database. + tptRef = _DB.getTemplate(id); + + // Checking if ID was found. + if ((tptRef._tpt==null) || (tptRef._size == 0)) + { + return ERR_INVALID_ID; + } + + // Comparing templates. + return (int) _grfingerx.Verify(ref _tpt._tpt,ref tptRef._tpt, + ref score, (int)GRConstants.GR_DEFAULT_CONTEXT); + } + + // Show GrFinger version and type + public void MessageVersion() + { + byte majorVersion=0,minorVersion=0; + GRConstants result; + string vStr = ""; + + result = (GRConstants)_grfingerx.GetGrFingerVersion(ref majorVersion, + ref minorVersion); + if(result == GRConstants.GRFINGER_FULL) + vStr = "FULL"; + else if(result == GRConstants.GRFINGER_LIGHT) + vStr = "LIGHT"; + else if(result == GRConstants.GRFINGER_FREE) + vStr = "FREE"; + + MessageBox.Show("The GrFinger DLL version is " + + majorVersion + "." + minorVersion + ". \n" + + "The license type is '" + vStr + "'.","GrFinger Version"); + } + + //Importing necessary HDC functions + [DllImport("user32.dll",EntryPoint="GetDC")] + public static extern IntPtr GetDC(IntPtr ptr); + + [DllImport("user32.dll",EntryPoint="ReleaseDC")] + public static extern IntPtr ReleaseDC(IntPtr hWnd,IntPtr hDc); + + // Database class. + public DBClass _DB; + // The last acquired image. + public TRawImage _raw; + // Reference to main form Image. + public PictureBox _pbPic; + + // The template extracted from last acquired image. + private TTemplate _tpt; + // Reference to main form log. + private ListBox _lbLog; + //references Main form Auto Extract Check Box + private CheckBox _cbAutoExtract; + //references Main form Auto Identify Check Box + private CheckBox _cbAutoIdentify; + //references Main form enroll button + Button _btEnroll; + //references Main form extract button + Button _btExtract; + //references Main form identify button + Button _btIdentify; + //references Main form verify button + Button _btVerify; + // GrFingerX component + AxGrFingerXLib.AxGrFingerXCtrl _grfingerx; +}; diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/bin/Debug/AxInterop.GrFingerXLib.dll b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/bin/Debug/AxInterop.GrFingerXLib.dll new file mode 100644 index 0000000..c89f632 Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/bin/Debug/AxInterop.GrFingerXLib.dll differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/bin/Debug/FingerPrintReader_CS.exe b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/bin/Debug/FingerPrintReader_CS.exe new file mode 100644 index 0000000..1323081 Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/bin/Debug/FingerPrintReader_CS.exe differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/bin/Debug/FingerPrintReader_CS.pdb b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/bin/Debug/FingerPrintReader_CS.pdb new file mode 100644 index 0000000..b70cd12 Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/bin/Debug/FingerPrintReader_CS.pdb differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/bin/Debug/FingerPrintReader_CS.vshost.exe b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/bin/Debug/FingerPrintReader_CS.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/bin/Debug/FingerPrintReader_CS.vshost.exe differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/bin/Debug/GrFingerSample.mdb b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/bin/Debug/GrFingerSample.mdb new file mode 100644 index 0000000..2e62fef Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/bin/Debug/GrFingerSample.mdb differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/bin/Debug/Interop.GrFingerXLib.dll b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/bin/Debug/Interop.GrFingerXLib.dll new file mode 100644 index 0000000..66c46bc Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/bin/Debug/Interop.GrFingerXLib.dll differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/AxInterop.GrFingerXLib.dll b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/AxInterop.GrFingerXLib.dll new file mode 100644 index 0000000..c89f632 Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/AxInterop.GrFingerXLib.dll differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/FingerPrintReader_CS.Form1.resources b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/FingerPrintReader_CS.Form1.resources new file mode 100644 index 0000000..1ea2a41 Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/FingerPrintReader_CS.Form1.resources differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/FingerPrintReader_CS.Properties.Resources.resources b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/FingerPrintReader_CS.Properties.Resources.resources new file mode 100644 index 0000000..a19c079 Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/FingerPrintReader_CS.Properties.Resources.resources differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/FingerPrintReader_CS.csproj.GenerateResource.Cache b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/FingerPrintReader_CS.csproj.GenerateResource.Cache new file mode 100644 index 0000000..7ae94dd Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/FingerPrintReader_CS.csproj.GenerateResource.Cache differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/FingerPrintReader_CS.csproj.ResolveComReference.cache b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/FingerPrintReader_CS.csproj.ResolveComReference.cache new file mode 100644 index 0000000..9b8397a Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/FingerPrintReader_CS.csproj.ResolveComReference.cache differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/FingerPrintReader_CS.exe b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/FingerPrintReader_CS.exe new file mode 100644 index 0000000..1323081 Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/FingerPrintReader_CS.exe differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/FingerPrintReader_CS.pdb b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/FingerPrintReader_CS.pdb new file mode 100644 index 0000000..b70cd12 Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/FingerPrintReader_CS.pdb differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/Interop.GrFingerXLib.dll b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/Interop.GrFingerXLib.dll new file mode 100644 index 0000000..66c46bc Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/Interop.GrFingerXLib.dll differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll new file mode 100644 index 0000000..17e7049 Binary files /dev/null and b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll differ diff --git a/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/FingerPrintReader_CS.csproj.FileList.txt b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/FingerPrintReader_CS.csproj.FileList.txt new file mode 100644 index 0000000..49ab7fc --- /dev/null +++ b/Chapter03(Fingerprint)/FingerPrintReader_CS/FingerPrintReader_CS/obj/FingerPrintReader_CS.csproj.FileList.txt @@ -0,0 +1,14 @@ +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\Interop.GrFingerXLib.dll +obj\Debug\AxInterop.GrFingerXLib.dll +obj\Debug\FingerPrintReader_CS.csproj.ResolveComReference.cache +obj\Debug\FingerPrintReader_CS.Form1.resources +obj\Debug\FingerPrintReader_CS.Properties.Resources.resources +obj\Debug\FingerPrintReader_CS.csproj.GenerateResource.Cache +bin\Debug\FingerPrintReader_CS.exe +bin\Debug\FingerPrintReader_CS.pdb +bin\Debug\Interop.GrFingerXLib.dll +bin\Debug\AxInterop.GrFingerXLib.dll +obj\Debug\FingerPrintReader_CS.exe +obj\Debug\FingerPrintReader_CS.pdb +bin\Debug\GrFingerSample.mdb diff --git a/Chapter04(Infrared)/IRChat/IRChat.sln b/Chapter04(Infrared)/IRChat/IRChat.sln new file mode 100644 index 0000000..efffff6 --- /dev/null +++ b/Chapter04(Infrared)/IRChat/IRChat.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "IRChat", "IRChat\IRChat.vbproj", "{B5867A14-E45D-4CE6-93A9-995101CDBB98}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B5867A14-E45D-4CE6-93A9-995101CDBB98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B5867A14-E45D-4CE6-93A9-995101CDBB98}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B5867A14-E45D-4CE6-93A9-995101CDBB98}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {B5867A14-E45D-4CE6-93A9-995101CDBB98}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B5867A14-E45D-4CE6-93A9-995101CDBB98}.Release|Any CPU.Build.0 = Release|Any CPU + {B5867A14-E45D-4CE6-93A9-995101CDBB98}.Release|Any CPU.Deploy.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter04(Infrared)/IRChat/IRChat.suo b/Chapter04(Infrared)/IRChat/IRChat.suo new file mode 100644 index 0000000..d03d8d0 Binary files /dev/null and b/Chapter04(Infrared)/IRChat/IRChat.suo differ diff --git a/Chapter04(Infrared)/IRChat/IRChat/Form1.Designer.vb b/Chapter04(Infrared)/IRChat/IRChat/Form1.Designer.vb new file mode 100644 index 0000000..d4c3079 --- /dev/null +++ b/Chapter04(Infrared)/IRChat/IRChat/Form1.Designer.vb @@ -0,0 +1,87 @@ + _ +Partial Public Class Form1 + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + private mainMenu1 As System.Windows.Forms.MainMenu + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.mainMenu1 = New System.Windows.Forms.MainMenu + Me.mnuSend = New System.Windows.Forms.MenuItem + Me.txtMessage = New System.Windows.Forms.TextBox + Me.txtMessagesArchive = New System.Windows.Forms.TextBox + Me.StatusBar1 = New System.Windows.Forms.StatusBar + Me.SuspendLayout() + ' + 'mainMenu1 + ' + Me.mainMenu1.MenuItems.Add(Me.mnuSend) + ' + 'mnuSend + ' + Me.mnuSend.Text = "Send" + ' + 'txtMessage + ' + Me.txtMessage.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.txtMessage.Location = New System.Drawing.Point(3, 3) + Me.txtMessage.Name = "txtMessage" + Me.txtMessage.Size = New System.Drawing.Size(234, 21) + Me.txtMessage.TabIndex = 3 + ' + 'txtMessagesArchive + ' + Me.txtMessagesArchive.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.txtMessagesArchive.Location = New System.Drawing.Point(3, 30) + Me.txtMessagesArchive.Multiline = True + Me.txtMessagesArchive.Name = "txtMessagesArchive" + Me.txtMessagesArchive.ScrollBars = System.Windows.Forms.ScrollBars.Vertical + Me.txtMessagesArchive.Size = New System.Drawing.Size(234, 210) + Me.txtMessagesArchive.TabIndex = 4 + ' + 'StatusBar1 + ' + Me.StatusBar1.Location = New System.Drawing.Point(0, 246) + Me.StatusBar1.Name = "StatusBar1" + Me.StatusBar1.Size = New System.Drawing.Size(240, 22) + Me.StatusBar1.Text = "StatusBar1" + ' + 'Form1 + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi + Me.AutoScroll = True + Me.ClientSize = New System.Drawing.Size(240, 268) + Me.Controls.Add(Me.StatusBar1) + Me.Controls.Add(Me.txtMessage) + Me.Controls.Add(Me.txtMessagesArchive) + Me.Menu = Me.mainMenu1 + Me.Name = "Form1" + Me.Text = "Form1" + Me.ResumeLayout(False) + + End Sub + Friend WithEvents txtMessage As System.Windows.Forms.TextBox + Friend WithEvents txtMessagesArchive As System.Windows.Forms.TextBox + Friend WithEvents mnuSend As System.Windows.Forms.MenuItem + Friend WithEvents StatusBar1 As System.Windows.Forms.StatusBar + +End Class diff --git a/Chapter04(Infrared)/IRChat/IRChat/Form1.resx b/Chapter04(Infrared)/IRChat/IRChat/Form1.resx new file mode 100644 index 0000000..20d2efa --- /dev/null +++ b/Chapter04(Infrared)/IRChat/IRChat/Form1.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + Pocket_PC + + + True + + \ No newline at end of file diff --git a/Chapter04(Infrared)/IRChat/IRChat/Form1.vb b/Chapter04(Infrared)/IRChat/IRChat/Form1.vb new file mode 100644 index 0000000..0dd72a6 --- /dev/null +++ b/Chapter04(Infrared)/IRChat/IRChat/Form1.vb @@ -0,0 +1,129 @@ +Imports System.Net +Imports System.IO +Imports System.Net.Sockets + +Public Class Form1 + Inherits System.Windows.Forms.Form + + '---define the constants--- + Const MAX_MESSAGE_SIZE As Integer = 1024 + Const MAX_TRIES As Integer = 3 + + Private ServiceName As String = "default" + + '---SEND menu item--- + Private Sub mnuSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuSend.Click + mnuSend.Enabled = False + sendMessage(MAX_TRIES, txtMessage.Text) + mnuSend.Enabled = True + txtMessage.Text = String.Empty + txtMessage.Focus() + End Sub + + Private Sub SendMessage(ByVal NumRetries As Integer, ByVal str As String) + + Dim client As IrDAClient = Nothing + Dim CurrentTries As Integer = 0 + + '---try to establish a connection--- + Do + Try + client = New IrDAClient(ServiceName) + Catch se As Exception + If (CurrentTries >= NumRetries) Then + Throw se + End If + End Try + CurrentTries = CurrentTries + 1 + Loop While client Is Nothing And CurrentTries < NumRetries + + '---timeout occurred--- + If (client Is Nothing) Then + StatusBar1.BeginInvoke( _ + New myDelegate(AddressOf UpdateStatus), New Object() _ + {"Error establishing contact"}) + Return + End If + + '---send the message over a stream object--- + Dim stream As System.IO.Stream = Nothing + Try + stream = client.GetStream() + stream.Write(System.Text.ASCIIEncoding.ASCII.GetBytes(str), 0, str.Length) + '---update the status bar--- + StatusBar1.BeginInvoke( _ + New myDelegate(AddressOf UpdateStatus), New Object() _ + {"Message sent!"}) + '---display the message that was sent--- + txtMessagesArchive.Text = str & vbCrLf & txtMessagesArchive.Text + Catch e As Exception + StatusBar1.BeginInvoke( _ + New myDelegate(AddressOf UpdateStatus), New Object() _ + {"Error sending message."}) + Finally + If (Not stream Is Nothing) Then stream.Close() + If (Not client Is Nothing) Then client.Close() + End Try + End Sub + + Private Function ReceiveMessage() As String + Dim bytesRead As Integer = 0 + Dim listener As IrDAListener = New IrDAListener(ServiceName) + Dim client As IrDAClient = Nothing + Dim stream As System.IO.Stream = Nothing + Dim Buffer(MAX_MESSAGE_SIZE - 1) As Byte + Dim str As String = String.Empty + Try + listener.Start() + client = listener.AcceptIrDAClient() '---blocking call--- + stream = client.GetStream() + bytesRead = stream.Read(Buffer, 0, Buffer.Length) + '---display the received message--- + str = ">" & System.Text.ASCIIEncoding.ASCII.GetString(Buffer, 0, bytesRead) + Catch ex As SocketException + '---ignore error--- + Catch e As Exception + StatusBar1.BeginInvoke( _ + New myDelegate(AddressOf UpdateStatus), New Object() _ + {e.ToString}) + Finally + If (Not stream Is Nothing) Then stream.Close() + If (Not client Is Nothing) Then client.Close() + listener.Stop() + End Try + Return str + End Function + + Public Sub ReceiveLoop() + Dim strReceived As String + strReceived = ReceiveMessage() + '---keep on listening for new message + While True + If strReceived <> String.Empty Then + txtMessagesArchive.BeginInvoke( _ + New myDelegate(AddressOf UpdateTextBox), New Object() {strReceived}) + End If + strReceived = ReceiveMessage() + End While + End Sub + + Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load + txtMessage.Focus() + '---receive incoming messages as a separate thread--- + Dim t1 As System.Threading.Thread + t1 = New Threading.Thread(AddressOf receiveLoop) + t1.Start() + End Sub + + Private Delegate Sub myDelegate(ByVal str As String) + Private Sub UpdateTextBox(ByVal str As String) + '---delegate to update the textbox control + txtMessagesArchive.Text = str & vbCrLf & txtMessagesArchive.Text + End Sub + + Private Sub UpdateStatus(ByVal str As String) + '---delegate to update the statusbar control + StatusBar1.Text = str + End Sub + +End Class diff --git a/Chapter04(Infrared)/IRChat/IRChat/IRChat.vbproj b/Chapter04(Infrared)/IRChat/IRChat/IRChat.vbproj new file mode 100644 index 0000000..75e5621 --- /dev/null +++ b/Chapter04(Infrared)/IRChat/IRChat/IRChat.vbproj @@ -0,0 +1,109 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {B5867A14-E45D-4CE6-93A9-995101CDBB98} + WinExe + IRChat.Form1 + IRChat + IRChat + {68B1623D-7FB9-47D8-8664-7ECEA3297D4F};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + PocketPC + 4118C335-430C-497f-BE48-11C3316B135E + 5.01 + WindowsForms + IRChat + v2.0 + + + + + true + full + true + true + bin\Debug\ + $(PlatformFamilyName)=TRUE + IRChat.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + 512 + Off + true + true + + + pdbonly + false + true + true + bin\Release\ + $(PlatformFamilyName)=TRUE + IRChat.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + 512 + Off + true + true + + + + + + + + + + + + + + + + + + + Form + + + Form1.vb + Form + + + + True + True + Resources.resx + + + + + Designer + Form1.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter04(Infrared)/IRChat/IRChat/IRChat.vbproj.user b/Chapter04(Infrared)/IRChat/IRChat/IRChat.vbproj.user new file mode 100644 index 0000000..e248a3d --- /dev/null +++ b/Chapter04(Infrared)/IRChat/IRChat/IRChat.vbproj.user @@ -0,0 +1,6 @@ + + + 4118C335-430C-497f-BE48-11C3316B135Ed6518ffb-710f-11d3-99f2-00105a0df099 + ShowAllFiles + + \ No newline at end of file diff --git a/Chapter04(Infrared)/IRChat/IRChat/My Project/AssemblyInfo.vb b/Chapter04(Infrared)/IRChat/IRChat/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..9a97271 --- /dev/null +++ b/Chapter04(Infrared)/IRChat/IRChat/My Project/AssemblyInfo.vb @@ -0,0 +1,36 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + diff --git a/Chapter04(Infrared)/IRChat/IRChat/My Project/Resources.Designer.vb b/Chapter04(Infrared)/IRChat/IRChat/My Project/Resources.Designer.vb new file mode 100644 index 0000000..d64c496 --- /dev/null +++ b/Chapter04(Infrared)/IRChat/IRChat/My Project/Resources.Designer.vb @@ -0,0 +1,59 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict Off +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the Strongly Typed Resource Builder + 'class via a tool like ResGen or Visual Studio.NET. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Module Resources + + Private _resMgr As System.Resources.ResourceManager + + Private _resCulture As System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As System.Resources.ResourceManager + Get + If (_resMgr Is Nothing) Then + Dim temp As System.Resources.ResourceManager = New System.Resources.ResourceManager("IRChat.Resources", GetType(Resources).Assembly) + _resMgr = temp + End If + Return _resMgr + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As System.Globalization.CultureInfo + Get + Return _resCulture + End Get + Set + _resCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Chapter04(Infrared)/IRChat/IRChat/My Project/Resources.resx b/Chapter04(Infrared)/IRChat/IRChat/My Project/Resources.resx new file mode 100644 index 0000000..3e18af9 --- /dev/null +++ b/Chapter04(Infrared)/IRChat/IRChat/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter04(Infrared)/IRChat/IRChat/bin/Debug/IRChat.exe b/Chapter04(Infrared)/IRChat/IRChat/bin/Debug/IRChat.exe new file mode 100644 index 0000000..4382dff Binary files /dev/null and b/Chapter04(Infrared)/IRChat/IRChat/bin/Debug/IRChat.exe differ diff --git a/Chapter04(Infrared)/IRChat/IRChat/bin/Debug/IRChat.pdb b/Chapter04(Infrared)/IRChat/IRChat/bin/Debug/IRChat.pdb new file mode 100644 index 0000000..a78e2dd Binary files /dev/null and b/Chapter04(Infrared)/IRChat/IRChat/bin/Debug/IRChat.pdb differ diff --git a/Chapter04(Infrared)/IRChat/IRChat/bin/Debug/IRChat.xml b/Chapter04(Infrared)/IRChat/IRChat/bin/Debug/IRChat.xml new file mode 100644 index 0000000..d546dcb --- /dev/null +++ b/Chapter04(Infrared)/IRChat/IRChat/bin/Debug/IRChat.xml @@ -0,0 +1,24 @@ + + + + +IRChat + + + + + + Returns the cached ResourceManager instance used by this class. + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + \ No newline at end of file diff --git a/Chapter04(Infrared)/IRChat/IRChat/obj/Debug/IRChat.Form1.resources b/Chapter04(Infrared)/IRChat/IRChat/obj/Debug/IRChat.Form1.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter04(Infrared)/IRChat/IRChat/obj/Debug/IRChat.Form1.resources differ diff --git a/Chapter04(Infrared)/IRChat/IRChat/obj/Debug/IRChat.Resources.resources b/Chapter04(Infrared)/IRChat/IRChat/obj/Debug/IRChat.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter04(Infrared)/IRChat/IRChat/obj/Debug/IRChat.Resources.resources differ diff --git a/Chapter04(Infrared)/IRChat/IRChat/obj/Debug/IRChat.exe b/Chapter04(Infrared)/IRChat/IRChat/obj/Debug/IRChat.exe new file mode 100644 index 0000000..4382dff Binary files /dev/null and b/Chapter04(Infrared)/IRChat/IRChat/obj/Debug/IRChat.exe differ diff --git a/Chapter04(Infrared)/IRChat/IRChat/obj/Debug/IRChat.pdb b/Chapter04(Infrared)/IRChat/IRChat/obj/Debug/IRChat.pdb new file mode 100644 index 0000000..a78e2dd Binary files /dev/null and b/Chapter04(Infrared)/IRChat/IRChat/obj/Debug/IRChat.pdb differ diff --git a/Chapter04(Infrared)/IRChat/IRChat/obj/Debug/IRChat.vbproj.GenerateResource.Cache b/Chapter04(Infrared)/IRChat/IRChat/obj/Debug/IRChat.vbproj.GenerateResource.Cache new file mode 100644 index 0000000..2f861f1 Binary files /dev/null and b/Chapter04(Infrared)/IRChat/IRChat/obj/Debug/IRChat.vbproj.GenerateResource.Cache differ diff --git a/Chapter04(Infrared)/IRChat/IRChat/obj/Debug/IRChat.xml b/Chapter04(Infrared)/IRChat/IRChat/obj/Debug/IRChat.xml new file mode 100644 index 0000000..d546dcb --- /dev/null +++ b/Chapter04(Infrared)/IRChat/IRChat/obj/Debug/IRChat.xml @@ -0,0 +1,24 @@ + + + + +IRChat + + + + + + Returns the cached ResourceManager instance used by this class. + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + \ No newline at end of file diff --git a/Chapter04(Infrared)/IRChat/IRChat/obj/Debug/ResolveAssemblyReference.cache b/Chapter04(Infrared)/IRChat/IRChat/obj/Debug/ResolveAssemblyReference.cache new file mode 100644 index 0000000..f561cc0 Binary files /dev/null and b/Chapter04(Infrared)/IRChat/IRChat/obj/Debug/ResolveAssemblyReference.cache differ diff --git a/Chapter04(Infrared)/IRChat/IRChat/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll b/Chapter04(Infrared)/IRChat/IRChat/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll new file mode 100644 index 0000000..86287a7 Binary files /dev/null and b/Chapter04(Infrared)/IRChat/IRChat/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll differ diff --git a/Chapter04(Infrared)/IRChat/IRChat/obj/IRChat.vbproj.FileList.txt b/Chapter04(Infrared)/IRChat/IRChat/obj/IRChat.vbproj.FileList.txt new file mode 100644 index 0000000..94bb0cf --- /dev/null +++ b/Chapter04(Infrared)/IRChat/IRChat/obj/IRChat.vbproj.FileList.txt @@ -0,0 +1,10 @@ +bin\Debug\IRChat.exe +bin\Debug\IRChat.pdb +bin\Debug\IRChat.xml +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\IRChat.Form1.resources +obj\Debug\IRChat.Resources.resources +obj\Debug\IRChat.vbproj.GenerateResource.Cache +obj\Debug\IRChat.exe +obj\Debug\IRChat.xml +obj\Debug\IRChat.pdb diff --git a/Chapter04(Infrared)/IRChat_CS/IRChat_CS.sln b/Chapter04(Infrared)/IRChat_CS/IRChat_CS.sln new file mode 100644 index 0000000..9281439 --- /dev/null +++ b/Chapter04(Infrared)/IRChat_CS/IRChat_CS.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IRChat_CS", "IRChat_CS\IRChat_CS.csproj", "{F1DDCE7E-8B91-41CF-9DC1-532BF1332AA6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F1DDCE7E-8B91-41CF-9DC1-532BF1332AA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F1DDCE7E-8B91-41CF-9DC1-532BF1332AA6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F1DDCE7E-8B91-41CF-9DC1-532BF1332AA6}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {F1DDCE7E-8B91-41CF-9DC1-532BF1332AA6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F1DDCE7E-8B91-41CF-9DC1-532BF1332AA6}.Release|Any CPU.Build.0 = Release|Any CPU + {F1DDCE7E-8B91-41CF-9DC1-532BF1332AA6}.Release|Any CPU.Deploy.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter04(Infrared)/IRChat_CS/IRChat_CS.suo b/Chapter04(Infrared)/IRChat_CS/IRChat_CS.suo new file mode 100644 index 0000000..12f7c8a Binary files /dev/null and b/Chapter04(Infrared)/IRChat_CS/IRChat_CS.suo differ diff --git a/Chapter04(Infrared)/IRChat_CS/IRChat_CS/Form1.Designer.cs b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/Form1.Designer.cs new file mode 100644 index 0000000..bde9893 --- /dev/null +++ b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/Form1.Designer.cs @@ -0,0 +1,102 @@ +namespace IRChat_CS +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.mnuSend = new System.Windows.Forms.MenuItem(); + this.mainMenu1 = new System.Windows.Forms.MainMenu(); + this.StatusBar1 = new System.Windows.Forms.StatusBar(); + this.txtMessage = new System.Windows.Forms.TextBox(); + this.txtMessagesArchive = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // mnuSend + // + this.mnuSend.Text = "Send"; + this.mnuSend.Click += new System.EventHandler(this.mnuSend_Click); + // + // mainMenu1 + // + this.mainMenu1.MenuItems.Add(this.mnuSend); + // + // StatusBar1 + // + this.StatusBar1.Location = new System.Drawing.Point(0, 246); + this.StatusBar1.Name = "StatusBar1"; + this.StatusBar1.Size = new System.Drawing.Size(240, 22); + this.StatusBar1.Text = "StatusBar1"; + // + // txtMessage + // + this.txtMessage.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtMessage.Location = new System.Drawing.Point(3, 2); + this.txtMessage.Name = "txtMessage"; + this.txtMessage.Size = new System.Drawing.Size(234, 21); + this.txtMessage.TabIndex = 6; + // + // txtMessagesArchive + // + this.txtMessagesArchive.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtMessagesArchive.Location = new System.Drawing.Point(3, 29); + this.txtMessagesArchive.Multiline = true; + this.txtMessagesArchive.Name = "txtMessagesArchive"; + this.txtMessagesArchive.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.txtMessagesArchive.Size = new System.Drawing.Size(234, 210); + this.txtMessagesArchive.TabIndex = 7; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.AutoScroll = true; + this.ClientSize = new System.Drawing.Size(240, 268); + this.Controls.Add(this.StatusBar1); + this.Controls.Add(this.txtMessage); + this.Controls.Add(this.txtMessagesArchive); + this.Menu = this.mainMenu1; + this.Name = "Form1"; + this.Text = "Form1"; + this.Load += new System.EventHandler(this.Form1_Load); + this.ResumeLayout(false); + + } + + #endregion + + internal System.Windows.Forms.MenuItem mnuSend; + private System.Windows.Forms.MainMenu mainMenu1; + internal System.Windows.Forms.StatusBar StatusBar1; + internal System.Windows.Forms.TextBox txtMessage; + internal System.Windows.Forms.TextBox txtMessagesArchive; + } +} + diff --git a/Chapter04(Infrared)/IRChat_CS/IRChat_CS/Form1.cs b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/Form1.cs new file mode 100644 index 0000000..2467a53 --- /dev/null +++ b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/Form1.cs @@ -0,0 +1,159 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +using System.Net; +using System.IO; +using System.Net.Sockets; + +namespace IRChat_CS +{ + public partial class Form1 : Form + { + const int MAX_MESSAGE_SIZE = 1024; + const int MAX_TRIES = 3; + private string ServiceName = "default"; + + public Form1() + { + InitializeComponent(); + } + + private void SendMessage(int NumRetries, string str) + { + IrDAClient client = null; + int CurrentTries = 0; + do + { + try + { + client = new IrDAClient(ServiceName); + } + catch (Exception se) + { + if ((CurrentTries >= NumRetries)) + { + throw se; + } + } + CurrentTries = CurrentTries + 1; + } while (client == null & CurrentTries < NumRetries); + + if ((client == null)) + { + StatusBar1.BeginInvoke(new myDelegate(UpdateStatus), new object[] { "Error establishing contact" }); + + return; + } + + System.IO.Stream stream = null; + try + { + stream = client.GetStream(); + stream.Write(System.Text.ASCIIEncoding.ASCII.GetBytes(str), 0, str.Length); + StatusBar1.BeginInvoke(new myDelegate(UpdateStatus), new object[] { "Message sent!" }); + txtMessagesArchive.Text = str + "\r\n" + txtMessagesArchive.Text; + } + catch (Exception e) + { + StatusBar1.BeginInvoke(new myDelegate(UpdateStatus), new object[] { "Error sending message." }); + } + finally + { + if ((!(stream == null))) + { + stream.Close(); + } + if ((!(client == null))) + { + client.Close(); + } + } + } + + private string ReceiveMessage() + { + int bytesRead = 0; + IrDAListener listener = new IrDAListener(ServiceName); + IrDAClient client = null; + System.IO.Stream stream = null; + byte[] Buffer = new byte[MAX_MESSAGE_SIZE - 1]; + string str = string.Empty; + try + { + listener.Start(); + client = listener.AcceptIrDAClient(); + stream = client.GetStream(); + bytesRead = stream.Read(Buffer, 0, Buffer.Length); + str = ">" + System.Text.ASCIIEncoding.ASCII.GetString(Buffer, 0, bytesRead); + } + catch (SocketException ex) + { + } + catch (Exception e) + { + StatusBar1.BeginInvoke(new myDelegate(UpdateStatus), new object[] { e.ToString() }); + } + finally + { + if ((!(stream == null))) + { + stream.Close(); + } + if ((!(client == null))) + { + client.Close(); + } + listener.Stop(); + } + return str; + } + + public void ReceiveLoop() + { + string strReceived; + strReceived = ReceiveMessage(); + while (true) + { + if (strReceived != string.Empty) + { + txtMessagesArchive.BeginInvoke(new myDelegate(UpdateTextBox), new object[] { strReceived }); + } + strReceived = ReceiveMessage(); + } + } + + private delegate void myDelegate(string str); + + private void UpdateTextBox(string str) + { + txtMessagesArchive.Text = str + "\r\n" + txtMessagesArchive.Text; + } + + private void UpdateStatus(string str) + { + StatusBar1.Text = str; + } + + private void mnuSend_Click(object sender, EventArgs e) + { + mnuSend.Enabled = false; + SendMessage(MAX_TRIES, txtMessage.Text); + mnuSend.Enabled = true; + txtMessage.Text = string.Empty; + txtMessage.Focus(); + } + + private void Form1_Load(object sender, EventArgs e) + { + txtMessage.Focus(); + System.Threading.Thread t1; + t1 = new System.Threading.Thread(ReceiveLoop); + t1.Start(); + } + } +} \ No newline at end of file diff --git a/Chapter04(Infrared)/IRChat_CS/IRChat_CS/Form1.resx b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/Form1.resx new file mode 100644 index 0000000..20d2efa --- /dev/null +++ b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/Form1.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + Pocket_PC + + + True + + \ No newline at end of file diff --git a/Chapter04(Infrared)/IRChat_CS/IRChat_CS/IRChat_CS.csproj b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/IRChat_CS.csproj new file mode 100644 index 0000000..dea4fac --- /dev/null +++ b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/IRChat_CS.csproj @@ -0,0 +1,94 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {F1DDCE7E-8B91-41CF-9DC1-532BF1332AA6} + WinExe + Properties + IRChat_CS + IRChat_CS + {4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + PocketPC + 4118C335-430C-497f-BE48-11C3316B135E + 5.01 + IRChat_CS + v2.0 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE;$(PlatformFamilyName) + true + true + prompt + 512 + 4 + Off + + + pdbonly + true + bin\Release\ + TRACE;$(PlatformFamilyName) + true + true + prompt + 512 + 4 + Off + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Designer + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter04(Infrared)/IRChat_CS/IRChat_CS/IRChat_CS.csproj.user b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/IRChat_CS.csproj.user new file mode 100644 index 0000000..76bd09e --- /dev/null +++ b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/IRChat_CS.csproj.user @@ -0,0 +1,5 @@ + + + 4118C335-430C-497f-BE48-11C3316B135Ed6518ffb-710f-11d3-99f2-00105a0df099 + + \ No newline at end of file diff --git a/Chapter04(Infrared)/IRChat_CS/IRChat_CS/Program.cs b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/Program.cs new file mode 100644 index 0000000..818951a --- /dev/null +++ b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/Program.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace IRChat_CS +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [MTAThread] + static void Main() + { + Application.Run(new Form1()); + } + } +} \ No newline at end of file diff --git a/Chapter04(Infrared)/IRChat_CS/IRChat_CS/Properties/AssemblyInfo.cs b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..01d191a --- /dev/null +++ b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("IRChat_CS")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("IRChat_CS")] +[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("5deb4944-1f6c-4e73-8a7f-97112eff1bf8")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] + diff --git a/Chapter04(Infrared)/IRChat_CS/IRChat_CS/Properties/Resources.Designer.cs b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/Properties/Resources.Designer.cs new file mode 100644 index 0000000..f823ad0 --- /dev/null +++ b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/Properties/Resources.Designer.cs @@ -0,0 +1,68 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace IRChat_CS.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the Strongly Typed Resource Builder + // class via a tool like ResGen or Visual Studio.NET. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + class Resources + { + + private static System.Resources.ResourceManager _resMgr; + + private static System.Globalization.CultureInfo _resCulture; + + /*FamANDAssem*/ + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + public static System.Resources.ResourceManager ResourceManager + { + get + { + if ((_resMgr == null)) + { + System.Resources.ResourceManager temp = new System.Resources.ResourceManager("IRChat_CS.Properties.Resources", typeof(Resources).Assembly); + _resMgr = temp; + } + return _resMgr; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + public static System.Globalization.CultureInfo Culture + { + get + { + return _resCulture; + } + set + { + _resCulture = value; + } + } + } +} diff --git a/Chapter04(Infrared)/IRChat_CS/IRChat_CS/Properties/Resources.resx b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/Properties/Resources.resx new file mode 100644 index 0000000..3e18af9 --- /dev/null +++ b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter04(Infrared)/IRChat_CS/IRChat_CS/bin/Debug/IRChat_CS.exe b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/bin/Debug/IRChat_CS.exe new file mode 100644 index 0000000..78b249e Binary files /dev/null and b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/bin/Debug/IRChat_CS.exe differ diff --git a/Chapter04(Infrared)/IRChat_CS/IRChat_CS/bin/Debug/IRChat_CS.pdb b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/bin/Debug/IRChat_CS.pdb new file mode 100644 index 0000000..4f3f178 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/bin/Debug/IRChat_CS.pdb differ diff --git a/Chapter04(Infrared)/IRChat_CS/IRChat_CS/obj/Debug/IRChat_CS.Form1.resources b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/obj/Debug/IRChat_CS.Form1.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/obj/Debug/IRChat_CS.Form1.resources differ diff --git a/Chapter04(Infrared)/IRChat_CS/IRChat_CS/obj/Debug/IRChat_CS.Properties.Resources.resources b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/obj/Debug/IRChat_CS.Properties.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/obj/Debug/IRChat_CS.Properties.Resources.resources differ diff --git a/Chapter04(Infrared)/IRChat_CS/IRChat_CS/obj/Debug/IRChat_CS.csproj.GenerateResource.Cache b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/obj/Debug/IRChat_CS.csproj.GenerateResource.Cache new file mode 100644 index 0000000..6d303fe Binary files /dev/null and b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/obj/Debug/IRChat_CS.csproj.GenerateResource.Cache differ diff --git a/Chapter04(Infrared)/IRChat_CS/IRChat_CS/obj/Debug/IRChat_CS.exe b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/obj/Debug/IRChat_CS.exe new file mode 100644 index 0000000..78b249e Binary files /dev/null and b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/obj/Debug/IRChat_CS.exe differ diff --git a/Chapter04(Infrared)/IRChat_CS/IRChat_CS/obj/Debug/IRChat_CS.pdb b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/obj/Debug/IRChat_CS.pdb new file mode 100644 index 0000000..4f3f178 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/obj/Debug/IRChat_CS.pdb differ diff --git a/Chapter04(Infrared)/IRChat_CS/IRChat_CS/obj/Debug/ResolveAssemblyReference.cache b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/obj/Debug/ResolveAssemblyReference.cache new file mode 100644 index 0000000..6c3fd5a Binary files /dev/null and b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/obj/Debug/ResolveAssemblyReference.cache differ diff --git a/Chapter04(Infrared)/IRChat_CS/IRChat_CS/obj/IRChat_CS.csproj.FileList.txt b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/obj/IRChat_CS.csproj.FileList.txt new file mode 100644 index 0000000..804159d --- /dev/null +++ b/Chapter04(Infrared)/IRChat_CS/IRChat_CS/obj/IRChat_CS.csproj.FileList.txt @@ -0,0 +1,8 @@ +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\IRChat_CS.Form1.resources +obj\Debug\IRChat_CS.Properties.Resources.resources +obj\Debug\IRChat_CS.csproj.GenerateResource.Cache +bin\Debug\IRChat_CS.exe +bin\Debug\IRChat_CS.pdb +obj\Debug\IRChat_CS.exe +obj\Debug\IRChat_CS.pdb diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop.sln b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop.sln new file mode 100644 index 0000000..3fba19f --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "IRChat_Desktop", "IRChat_Desktop\IRChat_Desktop.vbproj", "{5789A2BB-AB1E-43DF-B426-E2873A3C4500}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5789A2BB-AB1E-43DF-B426-E2873A3C4500}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5789A2BB-AB1E-43DF-B426-E2873A3C4500}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5789A2BB-AB1E-43DF-B426-E2873A3C4500}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5789A2BB-AB1E-43DF-B426-E2873A3C4500}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop.suo b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop.suo new file mode 100644 index 0000000..3232339 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop.suo differ diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/Form1.Designer.vb b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/Form1.Designer.vb new file mode 100644 index 0000000..c647f0b --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/Form1.Designer.vb @@ -0,0 +1,100 @@ + _ +Partial Class Form1 + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.txtMessage = New System.Windows.Forms.TextBox + Me.txtMessagesArchive = New System.Windows.Forms.TextBox + Me.btnSend = New System.Windows.Forms.Button + Me.StatusStrip1 = New System.Windows.Forms.StatusStrip + Me.ToolStripStatusLabel1 = New System.Windows.Forms.ToolStripStatusLabel + Me.StatusStrip1.SuspendLayout() + Me.SuspendLayout() + ' + 'txtMessage + ' + Me.txtMessage.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.txtMessage.Location = New System.Drawing.Point(9, 6) + Me.txtMessage.Name = "txtMessage" + Me.txtMessage.Size = New System.Drawing.Size(215, 20) + Me.txtMessage.TabIndex = 5 + ' + 'txtMessagesArchive + ' + Me.txtMessagesArchive.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.txtMessagesArchive.Location = New System.Drawing.Point(9, 32) + Me.txtMessagesArchive.Multiline = True + Me.txtMessagesArchive.Name = "txtMessagesArchive" + Me.txtMessagesArchive.ScrollBars = System.Windows.Forms.ScrollBars.Vertical + Me.txtMessagesArchive.Size = New System.Drawing.Size(215, 225) + Me.txtMessagesArchive.TabIndex = 6 + ' + 'btnSend + ' + Me.btnSend.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.btnSend.Location = New System.Drawing.Point(149, 263) + Me.btnSend.Name = "btnSend" + Me.btnSend.Size = New System.Drawing.Size(75, 23) + Me.btnSend.TabIndex = 8 + Me.btnSend.Text = "Send" + Me.btnSend.UseVisualStyleBackColor = True + ' + 'StatusStrip1 + ' + Me.StatusStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripStatusLabel1}) + Me.StatusStrip1.Location = New System.Drawing.Point(0, 289) + Me.StatusStrip1.Name = "StatusStrip1" + Me.StatusStrip1.Size = New System.Drawing.Size(232, 22) + Me.StatusStrip1.TabIndex = 10 + Me.StatusStrip1.Text = "StatusStrip1" + ' + 'ToolStripStatusLabel1 + ' + Me.ToolStripStatusLabel1.Name = "ToolStripStatusLabel1" + Me.ToolStripStatusLabel1.Size = New System.Drawing.Size(111, 17) + Me.ToolStripStatusLabel1.Text = "ToolStripStatusLabel1" + ' + 'Form1 + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(232, 311) + Me.Controls.Add(Me.StatusStrip1) + Me.Controls.Add(Me.btnSend) + Me.Controls.Add(Me.txtMessage) + Me.Controls.Add(Me.txtMessagesArchive) + Me.Name = "Form1" + Me.Text = "Form1" + Me.StatusStrip1.ResumeLayout(False) + Me.StatusStrip1.PerformLayout() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents txtMessage As System.Windows.Forms.TextBox + Friend WithEvents txtMessagesArchive As System.Windows.Forms.TextBox + Friend WithEvents btnSend As System.Windows.Forms.Button + Friend WithEvents StatusStrip1 As System.Windows.Forms.StatusStrip + Friend WithEvents ToolStripStatusLabel1 As System.Windows.Forms.ToolStripStatusLabel + +End Class diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/Form1.resx b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/Form1.resx new file mode 100644 index 0000000..faac01d --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/Form1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/Form1.vb b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/Form1.vb new file mode 100644 index 0000000..d7f09da --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/Form1.vb @@ -0,0 +1,127 @@ +Imports System.Net +Imports System.IO +Imports System.Net.Sockets +Imports InTheHand.Net.Sockets + +Public Class Form1 + + '---define the constants--- + Const MAX_MESSAGE_SIZE As Integer = 1280 + Const MAX_TRIES As Integer = 3 + + Private ServiceName As String = "default" + + Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click + btnSend.Enabled = False + SendMessage(MAX_TRIES, txtMessage.Text) + btnSend.Enabled = True + txtMessage.Text = String.Empty + txtMessage.Focus() + End Sub + + Private Sub SendMessage(ByVal NumRetries As Integer, ByVal str As String) + Dim client As IrDAClient = Nothing + Dim CurrentTries As Integer = 0 + + '---try to establish a connection--- + Do + Try + client = New IrDAClient(ServiceName) + Catch se As Exception + If (CurrentTries >= NumRetries) Then + Throw se + End If + End Try + CurrentTries = CurrentTries + 1 + Loop While client Is Nothing And CurrentTries < NumRetries + + '---timeout occurred--- + If (client Is Nothing) Then + 'lblStatus.BeginInvoke( _ + txtMessagesArchive.BeginInvoke( _ + New myDelegate(AddressOf UpdateStatus), New Object() _ + {"Error establishing contact"}) + Return + End If + + '---send the message over a stream object--- + Dim stream As System.IO.Stream = Nothing + Try + stream = client.GetStream() + stream.Write(System.Text.ASCIIEncoding.ASCII.GetBytes(str), 0, str.Length) + '---update the status bar--- + txtMessagesArchive.BeginInvoke( _ + New myDelegate(AddressOf UpdateStatus), New Object() _ + {"Message sent!"}) + '---display the message that was sent--- + txtMessagesArchive.Text = str & vbCrLf & txtMessagesArchive.Text + Catch e As Exception + txtMessagesArchive.BeginInvoke( _ + New myDelegate(AddressOf UpdateStatus), New Object() _ + {"Error sending message."}) + Finally + If (Not stream Is Nothing) Then stream.Close() + If (Not client Is Nothing) Then client.Close() + End Try + End Sub + + Private Function ReceiveMessage() As String + Dim bytesRead As Integer = 0 + Dim listener As IrDAListener = New IrDAListener(ServiceName) + Dim client As IrDAClient = Nothing + Dim stream As System.IO.Stream = Nothing + Dim Buffer(MAX_MESSAGE_SIZE - 1) As Byte + Dim str As String = String.Empty + Try + listener.Start() + client = listener.AcceptIrDAClient() '---blocking call--- + stream = client.GetStream() + bytesRead = stream.Read(Buffer, 0, Buffer.Length) + '---display the received message--- + str = ">" & System.Text.ASCIIEncoding.ASCII.GetString(Buffer, 0, bytesRead) + Catch ex As SocketException + '---ignore error--- + Catch e As Exception + txtMessagesArchive.BeginInvoke( _ + New myDelegate(AddressOf UpdateStatus), New Object() _ + {e.ToString}) + Finally + If (Not stream Is Nothing) Then stream.Close() + If (Not client Is Nothing) Then client.Close() + listener.Stop() + End Try + Return str + End Function + + Public Sub ReceiveLoop() + Dim strReceived As String + strReceived = ReceiveMessage() + '---keep on listening for new message + While True + If strReceived <> String.Empty Then + txtMessagesArchive.BeginInvoke( _ + New myDelegate(AddressOf UpdateTextBox), New Object() {strReceived}) + End If + strReceived = ReceiveMessage() + End While + End Sub + + Private Delegate Sub myDelegate(ByVal str As String) + Private Sub UpdateTextBox(ByVal str As String) + '---delegate to update the textbox control + txtMessagesArchive.Text = str & vbCrLf & txtMessagesArchive.Text + End Sub + + Private Sub UpdateStatus(ByVal str As String) + '---delegate to update the statusbar control + ToolStripStatusLabel1.Text = str + End Sub + + Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load + txtMessage.Focus() + '---receive incoming messages as a separate thread--- + Dim t1 As System.Threading.Thread + t1 = New Threading.Thread(AddressOf ReceiveLoop) + t1.Start() + End Sub +End Class diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/IRChat_Desktop.vbproj b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/IRChat_Desktop.vbproj new file mode 100644 index 0000000..88b4d56 --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/IRChat_Desktop.vbproj @@ -0,0 +1,110 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {5789A2BB-AB1E-43DF-B426-E2873A3C4500} + WinExe + IRChat_Desktop.My.MyApplication + IRChat_Desktop + IRChat_Desktop + WindowsForms + + + true + full + true + true + bin\Debug\ + IRChat_Desktop.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + IRChat_Desktop.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + False + ..\..\..\..\..\..\Program Files\In The Hand Ltd\32feet.NET\Assemblies\XP2\InTheHand.Net.Personal.dll + + + + + + + + + + + + + + + + + + + + + Form + + + Form1.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + Form1.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + \ No newline at end of file diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/IRChat_Desktop.vbproj.user b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/IRChat_Desktop.vbproj.user new file mode 100644 index 0000000..6a34e7d --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/IRChat_Desktop.vbproj.user @@ -0,0 +1,5 @@ + + + ShowAllFiles + + \ No newline at end of file diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/My Project/Application.Designer.vb b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/My Project/Application.Designer.vb new file mode 100644 index 0000000..05e11af --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + 'NOTE: This file is auto-generated; do not modify it directly. To make changes, + ' or if you encounter build errors in this file, go to the Project Designer + ' (go to Project Properties or double-click the My Project node in + ' Solution Explorer), and make changes on the Application tab. + ' + Partial Friend Class MyApplication + + _ + Public Sub New() + MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) + Me.IsSingleInstance = false + Me.EnableVisualStyles = true + Me.SaveMySettingsOnExit = true + Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses + End Sub + + _ + Protected Overrides Sub OnCreateMainForm() + Me.MainForm = Global.IRChat_Desktop.Form1 + End Sub + End Class +End Namespace diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/My Project/Application.myapp b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/My Project/Application.myapp new file mode 100644 index 0000000..1243847 --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/My Project/Application.myapp @@ -0,0 +1,11 @@ + + + true + Form1 + false + 0 + true + 0 + 0 + true + diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/My Project/AssemblyInfo.vb b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..922d594 --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + + diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/My Project/Resources.Designer.vb b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/My Project/Resources.Designer.vb new file mode 100644 index 0000000..7acb1ef --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ' + ' A strongly-typed resource class, for looking up localized strings, etc. + ' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ' + ' Returns the cached ResourceManager instance used by this class. + ' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("IRChat_Desktop.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ' + ' Overrides the current thread's CurrentUICulture property for all + ' resource lookups using this strongly typed resource class. + ' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/My Project/Resources.resx b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/My Project/Settings.Designer.vb b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/My Project/Settings.Designer.vb new file mode 100644 index 0000000..b6016b5 --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.IRChat_Desktop.My.MySettings + Get + Return Global.IRChat_Desktop.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/My Project/Settings.settings b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/bin/Debug/IRChat_Desktop.exe b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/bin/Debug/IRChat_Desktop.exe new file mode 100644 index 0000000..3a3ec89 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/bin/Debug/IRChat_Desktop.exe differ diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/bin/Debug/IRChat_Desktop.pdb b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/bin/Debug/IRChat_Desktop.pdb new file mode 100644 index 0000000..86f40e4 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/bin/Debug/IRChat_Desktop.pdb differ diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/bin/Debug/IRChat_Desktop.vshost.exe b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/bin/Debug/IRChat_Desktop.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/bin/Debug/IRChat_Desktop.vshost.exe differ diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/bin/Debug/IRChat_Desktop.xml b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/bin/Debug/IRChat_Desktop.xml new file mode 100644 index 0000000..a2a88e5 --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/bin/Debug/IRChat_Desktop.xml @@ -0,0 +1,11 @@ + + + + +IRChat_Desktop + + + + + + \ No newline at end of file diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/bin/Debug/InTheHand.Net.Personal.dll b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/bin/Debug/InTheHand.Net.Personal.dll new file mode 100644 index 0000000..e4e99f4 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/bin/Debug/InTheHand.Net.Personal.dll differ diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/bin/Debug/InTheHand.Net.Personal.xml b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/bin/Debug/InTheHand.Net.Personal.xml new file mode 100644 index 0000000..f175766 --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/bin/Debug/InTheHand.Net.Personal.xml @@ -0,0 +1,3026 @@ + + + + InTheHand.Net.Personal + + + + + Defines configuration option names for the class when used with IrDA. + + + + + Returns a list of IrDA device IDs for IR capable devices within range. + + + + + Enables an application to set a single class in the local IAS. + The application specifies the class to set, the attribute, and attribute type. + + + + + Queries IAS on a given service and class name for its attributes. + + + + + Retrieves the maximum PDU length required to use . + + + + + Sets socket to bypass TinyTP layer to directly communicate with IrLMP. + + + + + Disables TinyTP mode and sends data directly over IrLMP frames. + + + + + Puts the IrDA socket into IrCOMM mode. + + + + + Enables the Sharp mode. + + + + + Summary description for WsaQuerySet. + + + + + Returns name of device if specified in query. + + + + + Identifies the services class in the form of a GUID. + + + + + This context varies depending upon the function. + + + + + Represents an IrDA device address. + + + + + Initializes a new instance of the class with the specified address. + + Address as 4 byte array. + address passed was not a 4 byte array. + + + + Initializes a new instance of the class with the specified address. + + representation of the address. + + + + Returns the IrDA address as an integer. + + + + + + Returns the internal byte array. + + + + + + Determines whether a string is a valid IrDA address. + + The string to validate. + The version of the string. + true if irdaString is a valid IrDA address; otherwise, false. + + + + Converts the string representation of an IrDA address to a new instance. + + A string containing an address to convert. + New instance. + Address must be specified in hex format optionally separated by the colon or period character e.g. 00000000, 00:00:00:00 or 00.00.00.00. + + + + Converts the address to its equivalent string representation. + + The string representation of this instance. + + + + Returns a representation of the value of this instance, according to the provided format specifier. + + A single format specifier that indicates how to format the value of this Guid. The format parameter can be "N", "C" or "P". If format is null or the empty string (""), "N" is used. + A representation of the value of this . + + SpecifierFormat of Return Value + N8 digits: XXXXXXXX + C8 digits separated by colons: XX:XX:XX:XX + P8 digits separated by periods: XX.XX.XX.XX + + + + + Compares two instances for equality. + + + + + + + Returns the hash code for this instance. + + + + + + Returns an indication whether the values of two specified objects are equal. + + + + + + + + Returns an indication whether the values of two specified objects are not equal. + + + + + + + + Provides a null IrDA address. + + + + + Dummy SDP record into which we can insert the Guid and channel + + + + + Register the service. For SAP, this means sending out a periodic broadcast. + This is an NOP for the DNS namespace. + For persistent data stores, this means updating the address information. + + + + + Remove the service from the registry. + For SAP, this means stop sending out the periodic broadcast. + This is an NOP for the DNS namespace. + For persistent data stores this means deleting address information. + + + + + Delete the service from dynamic name and persistent spaces. + For services represented by multiple CSADDR_INFO structures (using the SERVICE_MULTIPLE flag), only the specified address will be deleted, and this must match exactly the corresponding CSADDR_INFO structure that was specified when the service was registered + + + + + Stores version information for a Bluetooth device. + + + + + + + + + + + Version of the current Host Controller Interface (HCI) in the Bluetooth hardware. + + This value changes only when new versions of the Bluetooth hardware are created for the new Bluetooth Special Interest Group (SIG) specifications. + + + + Version of the current Link Manager Protocol (LMP) in the Bluetooth hardware. + + + + + Name of the Bluetooth hardware manufacturer. + + + + + + + + + + Specifies the status codes returned for an Object Exchange (OBEX) operation. + + OBEX codes are directly related to their HTTP equivalents - see . + + + + Applied to another code to indicate this is the only response or final response in a series. + + + + + Equivalent to HTTP status 100. + Continue indicates that the client can continue with its request. + + + + + Equivalent to HTTP status 200. + OK indicates that the request succeeded and that the requested information is in the response. + This is the most common status code to receive. + + + + + Equivalent to HTTP status 201. + Created indicates that the request resulted in a new resource created before the response was sent. + + + + + Equivalent to HTTP status 202. + Accepted indicates that the request has been accepted for further processing. + + + + + Equivalent to HTTP status 203. + NonAuthoritativeInformation indicates that the returned metainformation is from a cached copy instead of the origin server and therefore may be incorrect. + + + + + Equivalent to HTTP status 204. + NoContent indicates that the request has been successfully processed and that the response is intentionally blank. + + + + + Equivalent to HTTP status 205. + ResetContent indicates that the client should reset (not reload) the current resource. + + + + + Equivalent to HTTP status 206. + PartialContent indicates that the response is a partial response as requested by a GET request that includes a byte range. + + + + + Equivalent to HTTP status 300. + MultipleChoices indicates that the requested information has multiple representations. + + + + + Equivalent to HTTP status 301. + MovedPermanently indicates that the requested information has been moved to the URI specified in the Location header. + The default action when this status is received is to follow the Location header associated with the response. + + + + + Equivalent to HTTP status 302. + Redirect indicates that the requested information is located at the URI specified in the Location header. + The default action when this status is received is to follow the Location header associated with the response. + When the original request method was POST, the redirected request will use the GET method. + + + + + Equivalent to HTTP status 303. + SeeOther automatically redirects the client to the URI specified in the Location header as the result of a POST. The request to the resource specified by the Location header will be made with a GET. + + + + + Equivalent to HTTP status 304. + NotModified indicates that the client's cached copy is up to date. + The contents of the resource are not transferred. + + + + + Equivalent to HTTP status 305. + UseProxy indicates that the request should use the proxy server at the URI specified in the Location header. + + + + + Equivalent to HTTP status 400. + BadRequest indicates that the request could not be understood by the server. BadRequest is sent when no other error is applicable, or if the exact error is unknown or does not have its own error code. + + + + + Equivalent to HTTP status 401. + Unauthorized indicates that the requested resource requires authentication. The WWW-Authenticate header contains the details of how to perform the authentication. + + + + + Equivalent to HTTP status 402. + PaymentRequired is reserved for future use. + + + + + Equivalent to HTTP status 403. + Forbidden indicates that the server refuses to fulfill the request. + + + + + Equivalent to HTTP status 404. + NotFound indicates that the requested resource does not exist on the server. + + + + + Equivalent to HTTP status 405. + MethodNotAllowed indicates that the request method (POST or GET) is not allowed on the requested resource. + + + + + Equivalent to HTTP status 406. + NotAcceptable indicates that the client has indicated with Accept headers that it will not accept any of the available representations of the resource. + + + + + Equivalent to HTTP status 407. + ProxyAuthenticationRequired indicates that the requested proxy requires authentication. + The Proxy-authenticate header contains the details of how to perform the authentication. + + + + + Equivalent to HTTP status 408. + RequestTimeout indicates that the client did not send a request within the time the server was expecting the request. + + + + + Equivalent to HTTP status 409. + Conflict indicates that the request could not be carried out because of a conflict on the server. + + + + + Equivalent to HTTP status 410. + Gone indicates that the requested resource is no longer available. + + + + + Equivalent to HTTP status 411. + LengthRequired indicates that the required Content-length header is missing. + + + + + Equivalent to HTTP status 412. + PreconditionFailed indicates that a condition set for this request failed, and the request cannot be carried out. + Conditions are set with conditional request headers like If-Match, If-None-Match, or If-Unmodified-Since. + + + + + Equivalent to HTTP status 413. + RequestEntityTooLarge indicates that the request is too large for the server to process. + + + + + Equivalent to HTTP status 414. + RequestUriTooLong indicates that the URI is too long. + + + + + Equivalent to HTTP status 415. + UnsupportedMediaType indicates that the request is an unsupported type. + + + + + Equivalent to HTTP status 500. + InternalServerError indicates that a generic error has occurred on the server. + + + + + Equivalent to HTTP status 501. + NotImplemented indicates that the server does not support the requested function. + + + + + Equivalent to HTTP status 502. + BadGateway indicates that an intermediate proxy server received a bad response from another proxy or the origin server. + + + + + Equivalent to HTTP status 503. + ServiceUnavailable indicates that the server is temporarily unavailable, usually due to high load or maintenance. + + + + + Equivalent to HTTP status 504. + GatewayTimeout indicates that an intermediate proxy server timed out while waiting for a response from another proxy or the origin server. + + + + + Equivalent to HTTP status 505. + HttpVersionNotSupported indicates that the requested HTTP version is not supported by the server. + + + + + + + + + + + + + + + Standard Bluetooth Profile identifiers. + + + + + Represents an empty service Guid. + + + + + Represents the base Guid from which all standard Bluetooth profiles are derived - not used for connections. + + + + + + + + + + + + + + + + + + + + Provides a basic Serial emulation connect over Bluetooth. + + + + + Used to establish PPP connections over RFComm channels. + + + + + + + + + + + + + + + Used for sending binary objects between devices. + + + + + OBEX version of an FTP server + + + + + + + + + + Supports Bluetooth headset devices. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Supports hands free kits such as a car kits which provide audio and more advanced call control than the Headset profile. + + + + + + + + + + + + + + + + + + + + Used for printing simple text, HTML, vCard objects and similar. + + + + + + + + + + Supports human interface devices such as keyboards and mice. + + + + + + + + + + + + + + + + + + + + Common_ISDN_Access + + + + + + + + + + UDI_MT + + + + + UDI_TA + + + + + + + + + + SIM_Access + + + + + Phonebook Access - PCE + + + + + Phonebook Access - PSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ESDP_UPNP_IP_PAN + + + + + ESDP_UPNP_IP_LAP + + + + + ESDP_UPNP_L2CAP + + + + + + + + + + + + + + + + + + + + Handles security between bluetooth devices. Current supported on devices only. + + + + + This function stores the personal identification number (PIN) for the Bluetooth device. + Not supported on Windows XP + + Address of remote device. + Pin, alphanumeric string of between 1 and 16 ASCII characters. + True on success, else False. + Not supported on Windows XP - use PairRequest + + + + This function revokes the personal identification number (PIN) for the Bluetooth device. + Not supported on Windows XP + + The remote device. + True on success, else False. + + + + Intiates pairing for a remote device. + + Remote device with which to pair. + Chosen PIN code, must be between 1 and 16 ASCII characters. + + + + + Remove the pairing with the specified device + + Remote device with which to remove pairing. + TRUE if device was successfully removed, else FALSE. + + + + Not supported on Windows XP + + + + + + + + Retrieves the address of the Bluetooth peer device authentication that requires the PIN code. + Not supported on Windows XP + + of the remote device, or null if there is no outstanding PIN request. + + + + Refuses an outstanding PIN request. + Not supported on Windows XP + + Address of the requesting device. + + + + Provides connection services for an infrared connection. + + Provides services for an infrared end point that includes making connections, obtaining data streams and discovering devices. + Infrared connections are made by specifying a service name, which can be any value provided the participating devices refer the same name. + + + + + Initializes a new instance of the class. + + + + + Initializes a new instance of the class for a specified service. + + + + + + Initializes a new instance of the class for connecting to a specified endpoint. + + An . + + + + Obtains information about available devices. + + Returns a maximum of 8 devices, for more flexibility use the other overloads. + + + + Obtains information about a specified number of devices. + + The maximum number of devices to get information about. + + + + + Obtains information about available devices using a socket. + + The maximum number of devices to get information about. + + + + + + Gets the name of a device using a specified socket. + + A valid socket. + The name of the remote device. + + + + Connects a client to a specified endpoint. + + + + + + Connects a client to a specified service. + + + + + + Closes the socket of the connection. + + + + + Gets the underlying stream of data. + + + + + + The number of bytes of data received from the network and available to be read. + + + + + Gets or sets the underlying . + + + + + Gets a value indicating whether the underlying for an is connected to a remote host. + + + + + Gets the name of the device participating in the communication. + + + + + Provides an OBEX implementation of the class. + + + + + Create a new Obex request with the specified . + + + Uri must use one of the following schemes - obex, obex-push, obex-ftp, obex-sync. + The host name must be the device address in short hex, or dotted hex notation - not the default representation using the colon separator + + + + Gets a object to use to write request data. + + + + + + Reads the contents of the specified file to the request stream. + + The filename (including the path) from which to read. + Provides an easy equivalent to manually writing the file contents to the request stream. + + + + Returns the OBEX server response. + + + + + + + + + + + Gets or sets the method for the request. + + For Object Exchange the method code is mapped to the equivalent HTTP style method. + For example "PUT", "GET" etc. In this version only "PUT" is supported and is the default value. + + + + Gets or sets the value of the Type OBEX header. + + + + + Gets or sets the Length OBEX header. + + This property is mandatory, if not set no data will be sent. + If you use the helper method this value is automatically populated with the size of the file that was read. + + + + Not Supported - do not use, this will throw an exception. + + + + + Gets or sets the time-out value for the method. + + The number of milliseconds to wait before the request times out. + The default is 50,000 milliseconds (50 seconds). + A value of -1 or 0 represents no time-out. + + + + Gets the original Uniform Resource Identifier (URI) of the request. + + For an ObexPush request the URI will use the "obex://" prefix, followed by the numerical device id in hex format. + The path section of the URI represents the remote filename of the pushed object. Subfolders are not supported. Some devices may only support specific object types e.g. V-Card. + + + + Methods which can be carried out in an Object Exchange transaction. + + + + + Sends an object to a receiving device. + + + + + Requests a file from the remote device. + + + + + Negotiate an Object Exchange connection with a remote device. + + + + + Disconnect an existing Object Exchange session. + + + + + Sends the last packet of an object to a receiving device. + + + + + Change remote path on an Object Exchange server. + + + + + Manufacturer codes. + + Defined in Bluetooth Specifications Assigned Numbers. + + + + + + + + + Internal bytes + + + + + + Size of the structure. + + + + + Defines configuration option names for the class. + + + + + On connected socket, triggers authentication. + On not connected socket, forces authentication on connection. + For incoming connection this means that connection is rejected if authentication cannot be performed. + + The optval and optlen parameters are ignored; however, Winsock implementation on Windows CE requires optlen to be at least 4 and optval to point to at least an integer datum. + + + + Toggles authentication under Windows XP. + + optlen=sizeof(ULONG), optval = &(ULONG)TRUE/FALSE + + + + On a connected socket, this command turns encryption on or off. + On an unconnected socket, this forces encryption to be on or off on connection. + For an incoming connection, this means that the connection is rejected if the encryption cannot be turned on. + + + + + This sets or revokes PIN code to use with a connection or socket. + + + + + This sets or revokes link key to use with a connection or peer device. + + + + + Returns link key associated with peer Bluetooth device. + + + + + Get or set the default MTU on Windows XP. + + optlen=sizeof(ULONG), optval = &mtu + + + + This sets default MTU (maximum transmission unit) for connection negotiation. + While allowed for connected socket, it has no effect if the negotiation has already completed. + Setting it on listening socket will propagate the value for all incoming connections. + + + + + Returns MTU (maximum transmission unit). + For connected socket, this is negotiated value, for server (accepting) socket it is MTU proposed for negotiation on connection request. + + + + + Get or set the maximum MTU on Windows XP. + + optlen=sizeof(ULONG), optval = &max. mtu + + + + This sets maximum MTU for connection negotiation. + While allowed for connected socket, it has no effect if the negotiation has already completed. + Setting it on listening socket will propagate the value for all incoming connections. + + + + + Returns maximum MTU acceptable MTU value for a connection on this socket. + Because negotiation has already happened, has little meaning for connected socket. + + + + + Get or set the minimum MTU on Windows XP. + + optlen=sizeof(ULONG), optval = &min. mtu + + + + This sets minimum MTU for connection negotiation. + While allowed for connected socket, it has no effect if the negotiation has already completed. + Setting it on listening socket will propagate the value for all incoming connections. + + + + + Returns minimum MTU acceptable MTU value for a connection on this socket. + Because negotiation has already happened, has little meaning for connected socket. + + + + + This sets XON limit. + Setting it on listening socket will propagate the value for all incoming connections. + + + + + Returns XON limit for a connection. + XON limit is only used for peers that do not support credit-based flow control (mandatory in the Bluetooth Core Specification version 1.1). + When amount of incoming data received, but not read by an application for a given connection grows past this limit, a flow control command is sent to the peer requiring suspension of transmission. + + + + + This sets XOFF limit. + Setting it on listening socket will propagate the value for all incoming connections. + + + + + Returns XOFF limit for a connection. + XOFF limit is only used for peers that do not support credit-based flow control (mandatory in the Bluetooth Core Specification 1.1). + If flow has been suspended because of buffer run-up, when amount of incoming data received, but not read by an application for a given connection falls below this limit, a flow control command is sent to the peer allowing continuation of transmission. + + + + + Specifies maximum amount of data that can be buffered inside RFCOMM (this is amount of data before call to send blocks). + + + + + Returns maximum amount of data that can be buffered inside RFCOMM (this is amount of data before call to send blocks). + + + + + Specifies maximum amount of data that can be buffered for a connection. + This buffer size is used to compute number of credits granted to peer device when credit-based flow control is implemented. + This specifies the maximum amount of data that can be buffered. + + + + + Returns maximum amount of data that can be buffered for a connection. + This buffer size is used to compute number of credits granted to peer device when credit-based flow control is implemented. + This specifies the maximum amount of data that can be buffered. + + + + + Retrieves last v24 and break signals set through MSC command from peer device. + + + + + Retrieves last line status signals set through RLS command from peer device. + + + + + Sends MSC command. V24 and breaks are as specified in RFCOMM Specification. + Only modem signals and breaks can be controlled, RFCOMM reserved fields such as flow control are ignored and should be set to 0. + + + + + Sends RLS command. + Argument is as specified in RFCOMM Specification. + + + + + Gets flow control type on the connected socket. + + + + + Sets the page timeout for the card. + The socket does not have to be connected. + + + + + Gets the current page timeout. + The socket does not have to be connected. + + + + + Sets the scan mode for the card. + The socket does not have to be connected. + + + + + Gets the current scan mode. + The socket does not have to be connected. + + + + + Sets the class of the device. + The socket does not have to be connected. + + + + + Retrieve the Class of Device. + + + + + Get the version information from the Bluetooth adapter. + + + + + Get the version of the remote adapter. + + + + + Retrieves the authentication settings. + The socket does not have to be connected. + + + + + Sets the authentication policy of the device. + + + + + Reads the remote name of the device. + The socket does not have to be connected. + + + + + Retrieves the link policy of the device. + + + + + Sets the link policy for an existing baseband connection. + The socket must be connected. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gets the current mode of the connection. + The mode can either be sniff, park, or hold. The socket must be connected. + + + + + Contains helper functionality. + + + + + Specifies that the URI is accessed through the Object Exchange (OBEX) protocol. + + + + + Specifies that the URI is accessed through the Object Exchange (OBEX) Push protocol. + + + + + Specifies that the URI is accessed through the Object Exchange (OBEX) FTP protocol. + + + + + Specifies that the URI is accessed through the Object Exchange (OBEX) Sync protocol. + + + + + Provides information about remote devices connected by infrared communications. + + + + + + Compares two instances for equality. + + + + + + + Returns the hash code for this instance. + + + + + + Returns the address of the remote device. + + + + + Provided solely for compatibility with System.Net.IrDA - consider using instead. + + + + + Gets the name of the device. + + + + + Gets the character set used by the server, such as ASCII. + + + + + Gets the type of the device, such as a computer. + + + + + Specifies the current status of the Bluetooth hardware. + + + + + Status cannot be determined. + + + + + Bluetooth radio not present. + + + + + Bluetooth radio is in the process of starting up. + + + + + Bluetooth radio is active. + + + + + Bluetooth radio is in the process of shutting down. + + + + + Bluetooth radio is in an error state. + + + + + Class of Device flags as assigned in the Bluetooth specifications. + + Defined in Bluetooth Specifications Assigned Numbers. + + + + Defines additional IrDA socket option levels for the and methods. + + + + + + + + + + Defines the type of an IAS attribute. + + + + + Identifies an integer attribute value. + + + + + Identifies a binary, or octet, attribute value. + + + + + Identifies a string attribute value. + + + + + Represents an end point for an infrared connection. + + + + + + Initializes a new instance of the class. + + The device identifier. + The name of the service to connect to. + + + + Initializes a new instance of the class. + + The device address. + The name of the service to connect to. + + + + Serializes endpoint information into a . + + + + + + Creates an from a socket address + + A . + + + + + Compares two instances for equality. + + + + + + + Returns the hash code for this instance. + + + + + + Gets or sets an address for the device. + + + + + Gets or sets an identifier for the device. + + + + + Gets or sets the name of the service. + + + + + Gets the address family to which the endpoint belongs. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Bluetooth specific flags returned from WSALookupServiceNext + in WSAQUERYSET.dwOutputFlags in response to device inquiry. + + + + + Establishes connections to a peer device and provides Bluetooth port information. + + + + + Specifies the minimum value that can be assigned to the Port property. + + + + + Specifies the maximum value that can be assigned to the Port property. + + + + + Initializes a new instance of the class with the specified address and service. + + The Bluetooth address of the device. A six byte array. + The Bluetooth service to use. + + + + Initializes a new instance of the class with the specified address, service and port number. + + The Bluetooth address of the device. A six byte array. + The Bluetooth service to use. + Radio channel to use, -1 for any. + + + + Serializes endpoint information into a instance. + + A instance containing the socket address for the endpoint. + + + + Creates an endpoint from a socket address. + + The to use for the endpoint. + An instance using the specified socket address. + + + + Compares two instances for equality. + + + + + + + Returns the hash code for this instance. + + + + + + Gets the address family of the Bluetooth address. + + + + + Gets or sets the Bluetooth address of the endpoint. + + + + + Gets or sets the Bluetooth service to use for the connection. + + + + + Gets or sets the service channel number of the endpoint. + + + + + Defines additional Bluetooth socket option levels for the and methods. + + + + + + + + + + + + + + + + + + + + Provides information about an available device obtained by the client during device discovery. + + + + + + + + + + + + + + + + + Forces the system to refresh the device information. + + + + + Updates the device name used to display the device. + + On Windows CE this only affects devices which are already paired. + + + + Enables or disables services for a Bluetooth device. + + The service GUID on the remote device. + Service state - TRUE to enable the service, FALSE to disable it. + This function only supports Windows XP, calling it on CE will throw a PlatformNotSupportedException. + Thrown if this method is called on Windows CE platforms. + + + + + + + + + + + Displays information about the device. + + + + + Compares two instances for equality. + + + + + + + Returns the hash code for this instance. + + + + + + Gets the device identifier. + + + + + Gets a name of a device. + + + + + Returns the Class of Device of the remote device. + + + + + Returns a list of services which are already installed for use on the calling machine. + + Will only return available services for paired devices. + + + + Device connected. + + Not supported under Windows CE and will always return false. + + + + Device remembered. + + Not supported under Windows CE and will always return false. + + + + Device Authenticated. + + Now supported on both CE and XP. + + + + Date and Time this device was last seen by the system. + + Not supported under Windows CE and will return DateTime.MinValue. + + + + Date and Time this device was last used by the system. + + Not supported under Windows CE and will return DateTime.MinValue. + + + + Places a socket in a listening state to monitor infrared connections from a specified service or network address. + + This class monitors a service by specifying a service name or a network address. + The listener does not listen until you call the method. + + + + + Initializes a new instance of the class. + + The network address to monitor for making a connection. + + + + Initializes a new instance of the class. + + The name of the service to listen for. + + + + Starts the socket to listen for incoming connections. + + + + + Stops the socket from monitoring connections. + + + + + Creates a new socket for a connection. + + A socket. + + + + Creates a client object for a connection when the specified service or endpoint is detected by the listener component. + + An object. + + + + Determines if a connection is pending. + + true if there is a connection pending; otherwise, false. + + + + Gets the underlying network . + + + + + Gets a value that indicates whether the is actively listening for client connections. + + + + + Gets an representing the local device. + + + + + Provides client connections for Bluetooth network services. + + This class currently only supports devices which use the Microsoft Bluetooth stack such as the Orange SPV E200, devices which use the WidComm stack will not work. + + + + Creates a new instance of . + + + + + Initializes a new instance of the class and binds it to the specified local endpoint. + + The to which you bind the Bluetooth Socket. + Only necessary on multi-radio system where you want to select the local radio to use. + + + + Discovers accessible Bluetooth devices and returns their names and addresses. + + An array of BluetoothDeviceInfo objects describing the devices discovered. + + + + Discovers accessible Bluetooth devices and returns their names and addresses. + + The maximum number of devices to get information about. + An array of BluetoothDeviceInfo objects describing the devices discovered. + + + + Discovers accessible Bluetooth devices and returns their names and addresses. + + The maximum number of devices to get information about. + True to return previously authenticated/paired devices. + True to return remembered devices. + True to return previously unknown devices. + An array of BluetoothDeviceInfo objects describing the devices discovered. + + + + Connects a client to a specified endpoint. + + A that represents the remote device. + + + + Closes the socket of the connection. + + + + + Gets the underlying stream of data. + + The underlying . + returns a that you can use to send and receive data. + The class inherits from the class, which provides a rich collection of methods and properties used to facilitate network communications. + You must call the method first, or the method will throw an . + After you have obtained the , call the method to send data to the remote host. + Call the method to receive data arriving from the remote host. + Both of these methods block until the specified operation is performed. + You can avoid blocking on a read operation by checking the property. + A true value means that data has arrived from the remote host and is available for reading. + In this case, is guaranteed to complete immediately. + If the remote host has shutdown its connection, will immediately return with zero bytes. + The is not connected to a remote host. + The has been closed. + + + + Set or change the PIN to be used with a specific remote device. + + Address of Bluetooth device. + PIN string consisting of 1-16 ASCII characters. + + + + Gets the name of the specified remote device. + + Address of remote device. + Friendly name of specified device. + + + + Gets the name of a device by a specified socket. + + A . + Returns a string value of the computer or device name. + + + + + + + + + + + + + + + Frees resources used by the class. + + + + + Amount of time allowed to perform the query. + + On Windows CE the actual value used is expressed in units of 1.28 seconds, so will be the nearest match for the value supplied. + The default value is 10 seconds. The maximum is 60 seconds. + + + + Gets the amount of data that has been received from the network and is available to be read. + + The number of bytes of data received from the network and available to be read. + The has been closed. + + + + Gets or sets the underlying . + + + + + Gets a value indicating whether the underlying for a is connected to a remote host. + + true if the socket was connected to a remote resource as of the most recent operation; otherwise, false. + + + + Gets or sets the authentication state of the current connect or behaviour to use when connection is established. + + + For disconnected sockets, specifies that authentication is required in order for a connect or accept operation to complete successfully. + Setting this option actively initiates authentication during connection establishment, if the two Bluetooth devices were not previously authenticated. + The user interface for passkey exchange, if necessary, is provided by the operating system outside the application context. + For outgoing connections that require authentication, the connect operation fails with WSAEACCES if authentication is not successful. + In response, the application may prompt the user to authenticate the two Bluetooth devices before connection. + For incoming connections, the connection is rejected if authentication cannot be established and returns a WSAEHOSTDOWN error. + + + + + On unconnected sockets, enforces encryption to establish a connection. + Encryption is only available for authenticated connections. + For incoming connections, a connection for which encryption cannot be established is automatically rejected and returns WSAEHOSTDOWN as the error. + For outgoing connections, the connect function fails with WSAEACCES if encryption cannot be established. + In response, the application may prompt the user to authenticate the two Bluetooth devices before connection. + + + + + Returns link key associated with peer Bluetooth device. + + + + + Returns the Link Policy of the current connection. + + + + + Retrieves the version of the local Bluetooth equipment. + + + + + Sets the PIN associated with the currently connected device. + + PIN which must be composed of 1 to 16 ASCII characters. + Assigning null (Nothing in VB) or an empty String will revoke the PIN. + + + + Gets the name of the remote device. + + + + + Provides access to the request and response objects used by the class. + + + + + Gets the that represents a client's request for a resource + + + + + Describes the character sets supported by the device. + + The enumeration describes the following character sets, which are used by the and classes. + + + + + The ASCII character set. + + + + + The western European graphic character set. + + + + + The eastern European graphic character set. + + + + + The southern European graphic character set. + + + + + The northern European graphic character set. + + + + + The Cyrillic graphic character set. + + + + + The Arabic graphic character set. + + + + + The Greek graphic character set. + + + + + The Hebrew graphic character set. + + + + + The Turkish graphic character set. + + + + + The Unicode character set. + + + + + Specifies the media type information for an object. + + + + + Specifies the type of image data in an object. + + + + + Specifies that the image data is in Graphics Interchange Format (GIF). + + + + + Specifies that the image data is in Joint Photographic Experts Group (JPEG) format. + + + + + Specifies the type of text data in an object. + + + + + Specifies that the data is in HTML format. + + + + + Specifies that the data is in plain text format. + + + + + Specifies that the data is in vCalendar format. + + + + + Specifies that the data is in vCard format. + + + + + Specifies that the data is in vMsg format. + + + + + Specifies that the data is in vNote format. + + + + + Specifies that the data is in XML format. + + + + + Specifies the type of Object Exchange specific data. + + + + + Used to retrieve supported object types. + + + + + Used to retrieve folder listing with OBEX FTP. + + + + + Used to retrieve an object profile. + + + + + Provides an OBEX implementation of the class. + + + + + Gets the stream used to read the body of the response from the server. + + + + + + Writes the contents of the response to the specified file path. + + The filename (including the path) from which to read. + + + + Frees the resources held by the response. + + + + + Gets the headers associated with this response from the server. + + + + + + + + + + + + + + + Returns a status code to indicate the outcome of the request. + + + + + Used to create a new web request for obex uri scheme + + + + + Supported network transports for Object Exchange. + + + + + Infrared (IrDA) + + + + + Bluetooth + + + + + TCP/IP + + + + + Flags to describe Link Policy. + + + + + Disables all LAN Manager (LM) modes. + + + + + Enables the master slave switch. + + + + + Enables Hold mode. + + + + + Enables Sniff Mode. + + + + + Enables Park Mode. + + + + + Represents a Bluetooth Radio device. + + Allows you to query properties of the radio hardware and set the mode. + + + + Gets a value that indicates whether the 32feet.NET library can be used with the current device. + + + + + Gets the primary . + + For Windows CE based devices this is the only , for Windows XP this is the first available device. + If the device has a third-party stack this property will return null + + + + Gets an array of all Bluetooth radios on the system. + + Under Windows CE this will only ever return a single device. + If the device has a third-party stack this property will return an empty collection + + + + Gets the handle for this radio. + + Relevant only on Windows XP. + + + + Returns the current status of the Bluetooth radio hardware. + + A member of the enumeration. + + + + Gets or Sets the current mode of operation of the Bluetooth radio. + + This setting will be persisted when the device is reset. + An Icon will be displayed in the tray on the Home screen and the device will emit a blue LED when Bluetooth is enabled. + + + + Returns the address of the local Bluetooth radio device. + + + + + Returns the friendly name of the local Bluetooth radio. + + + + + Returns the Class of Device. + + + + + Returns the manufacturer of the device. + + + + + Returns the manufacturer of the Bluetooth software stack running locally. + Currently only Microsoft is supported. + + + + + Specifies additional protocols that the class supports. + + + + + Bluetooth RFComm protocol. + + + + + Describes an enumeration of possible device types, such as Fax. + + + + + + Unspecified device type. + + + + + A Plug and Play interface. + + + + + A Pocket PC or similar. + + + + + A personal computer. + + + + + A printer. + + + + + A modem. + + + + + A fax. + + + + + A local area network access. + + + + + Contains extended hint bytes. + + + + + A telephonic device. + + + + + A personal computer file server. + + + + + Device supports IrCOMM. + + + + + Device supports Object Exchange. + + + + + Describes the device and service capabilities of a device. + + + + + + + + + + + + + + + + + Returns the device type. + + + + + Returns supported service types. + + + + + Describes an incoming OBEX request to an object. + + + + + Writes the body of the request to the specified file path. + + The filename (including the path) to write to. + + + + Gets the length of the body data included in the request. + New in v1.5.51015 + + A long value that contains the value from the request's Length header. + This value is -1 if the content length is not known. + The Length header expresses the length, in bytes, of the body data that accompanies the request. + + + + Gets the MIME type of the body data included in the request. + + A that contains the text of the request's Type header. + + + + Gets the collection of header name/value pairs sent in the request. + + A that contains the OBEX headers included in the request. + For a complete list of request headers, see the enumeration. + + + + Get the device address and service to which the request is directed. + + + + + Gets the method specified by the client. + + Only PUT is supported in this version. + + + + Gets a stream that contains the body data sent by the client. + + + + + Gets the OBEX version used by the requesting client + + + + + Gets the URL information (without the host and port) requested by the client. + + A that contains the raw URL for this request. + + + + Gets the device address and service from which the request originated. + + + + + Gets the server address to which the request is directed. + + + + + Gets the object requested by the client. + + A object that identifies the resource requested by the client. + + + + Determine all the possible modes of operation of the Bluetooth radio. + + + + + Bluetooth is disabled on the device. + + + + + Bluetooth is connectable but your device cannot be discovered by other devices. + + + + + Bluetooth is activated and fully discoverable. + + + + + Listens for connections from Bluetooth network clients. + + The class provides simple methods that listen for and accept incoming connection requests in blocking synchronous mode. + You can use either a or a to connect with a + + + + Initializes a new instance of the class. + + The device address to monitor for making a connection. + + + + Initializes a new instance of the class that listens for incoming connection attempts on the specified local Bluetooth address and service identifier. + + A that represents the local Bluetooth radio address. + The Bluetooth service to listen for. + + + + Initializes a new instance of the class. + + The Bluetooth service to listen for. + + + + Initializes a new instance of the class. + + The Bluetooth service to listen for. + Prepared SDP Record to publish + Offset into the SDP record in which to place the actual channel. + It is recommended that you use the alternative constructor which takes just a service guid for your custom profile implementations. + + + + Initializes a new instance of the class. + + A that represents the local Bluetooth radio address. + The Bluetooth service to listen for. + Prepared SDP Record to publish + Offset into the SDP record in which to place the actual channel. + It is recommended that you use the alternative constructor which takes just a service guid for your custom profile implementations. + + + + Starts the socket to listen for incoming connections. + + + + + Stops the socket from monitoring connections. + + + + + Creates a new socket for a connection. + + AcceptSocket is a blocking method that returns a that you can use to send and receive data. + If you want to avoid blocking, use the method to determine if connection requests are available in the incoming connection queue. + The returned is initialized with the address and channel number of the remote device. + You can use any of the Send and Receive methods available in the class to communicate with the remote device. + When you are finished using the , be sure to call its method. + If your application is relatively simple, consider using the method rather than the AcceptSocket method. + provides you with simple methods for sending and receiving data over a network in blocking synchronous mode. + A used to send and receive data. + Listener is stopped. + + + + Creates a client object for a connection when the specified service or endpoint is detected by the listener component. + + AcceptTcpClient is a blocking method that returns a that you can use to send and receive data. + Use the method to determine if connection requests are available in the incoming connection queue if you want to avoid blocking. + Use the method to obtain the underlying of the returned . + The will provide you with methods for sending and receiving with the remote host. + When you are through with the , be sure to call its method. + If you want greater flexibility than a offers, consider using . + A component. + Listener is stopped. + + + + Determines if there is a connection pending. + + true if there is a connection pending; otherwise, false. + + + + Gets the underlying of the current . + + + + + Get or set class of device flags which this service adds to the host device. + + + + + Gets the underlying network . + + The underlying . + creates a to listen for incoming client connection requests. + Classes deriving from can use this property to get this . + Use the underlying returned by the property if you require access beyond that which provides. + Note property only returns the used to listen for incoming client connection requests. + Use the method to accept a pending connection request and obtain a for sending and receiving data. + You can also use the method to accept a pending connection request and obtain a for sending and receiving data. + + + + Specifies additional addressing schemes that an instance of the class can use. + + + + + Bluetooth address. + + 32 + + + + IrDA address used on some Windows CE platforms (Has a different value to AddressFamily.IrDA). + + 22 + + + + Provides a simple, programmatically controlled OBEX protocol listener. + + + + + Initializes a new instance of the ObexListener class using the Bluetooth transport. + + + + + Initializes a new instance of the ObexListener class specifiying the transport to use. + + + + + Allows this instance to receive incoming requests. + + + + + Causes this instance to stop receiving incoming requests. + + + + + Shuts down the ObexListener. + + + + + Waits for an incoming request and returns when one is received. + + + + + + Gets a value that indicates whether the has been started. + + + + + Standard IrDA service names. + + + + + + + + + + + + + + + + + + + + Represents a Bluetooth device address. + + + + + + + + + + + + + + + + + + + + + + + + + Initializes a new instance of the class with the specified address. + + representation of the address. + + + + Initializes a new instance of the class with the specified address. + + Address as 6 byte array. + address passed was not a 6 byte array. + + + + Determines whether a string is a valid Bluetooth address. + + The string to validate. + The version of the string. + true if bluetoothString is a valid Bluetooth address; otherwise, false. + + + + Converts the string representation of a Bluetooth address to a new instance. + + A string containing an address to convert. + New instance. + Address must be specified in hex format optionally separated by the colon or period character e.g. 000000000000, 00:00:00:00:00:00 or 00.00.00.00.00.00. + + + + Returns the internal byte array. + + + + + + Returns the Bluetooth address as a long integer. + + + + + + Compares two instances for equality. + + + + + + + Returns the hash code for this instance. + + + + + + Returns an indication whether the values of two specified objects are equal.New in v1.5 + + + + + + + + Returns an indication whether the values of two specified objects are not equal. + + + + + + + + Converts the address to its equivalent string representation. + + The string representation of this instance. + The default return format is without a separator character - use the other overload for ToString for more formatting options. + + + + Returns a representation of the value of this instance, according to the provided format specifier. + + A single format specifier that indicates how to format the value of this Guid. + The format parameter can be "N", "C", or "P". + If format is null or the empty string (""), "D" is used. + A representation of the value of this . + + SpecifierFormat of Return Value + N12 digits: XXXXXXXXXXXX + C12 digits separated by colons: XX:XX:XX:XX:XX:XX + P12 digits separated by periods: XX.XX.XX.XX.XX.XX + + + + + Provides a null Bluetooth address. + + + + + Significant address part. + + + + + Non-significant address part. + + + + + Provides helper methods for the class. + + + + + Indicates whether the specified String object is a null reference. + + A reference. + true if the value parameter is a null reference (Nothing in Visual Basic) or an empty string (""); otherwise, false. + IsNullOrEmpty is a convenience method that enables you to simultaneously test whether a String is a null reference (Nothing in Visual Basic) or its value is . + + + + Provides a form to select an available Bluetooth device. + + + + + + + + + + + + + + + + Gets or sets the information text. + + + + + + + + + + If TRUE, invokes the Add New Device Wizard. + + Supported only on Windows XP + + + + If TRUE, forces authentication before returning. + + Supported only on Windows XP + + + + If TRUE, authenticated devices are shown in the picker. + + + + + If TRUE, remembered devices are shown in the picker. + + Supported only on Windows XP. + + + + If TRUE, unknown devices are shown in the picker. + + + + + If TRUE, skips the Services page in the Add New Device Wizard. + + Supported only on Windows XP + + + + Represents an individual SDP record. + + + + + Creates a new instance from the raw SDP record bytes. + + SDP record. + + + + Returns the record bytes. + + + + + diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/obj/Debug/IRChat_Desktop.Form1.resources b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/obj/Debug/IRChat_Desktop.Form1.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/obj/Debug/IRChat_Desktop.Form1.resources differ diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/obj/Debug/IRChat_Desktop.Resources.resources b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/obj/Debug/IRChat_Desktop.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/obj/Debug/IRChat_Desktop.Resources.resources differ diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/obj/Debug/IRChat_Desktop.exe b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/obj/Debug/IRChat_Desktop.exe new file mode 100644 index 0000000..3a3ec89 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/obj/Debug/IRChat_Desktop.exe differ diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/obj/Debug/IRChat_Desktop.pdb b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/obj/Debug/IRChat_Desktop.pdb new file mode 100644 index 0000000..86f40e4 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/obj/Debug/IRChat_Desktop.pdb differ diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/obj/Debug/IRChat_Desktop.vbproj.GenerateResource.Cache b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/obj/Debug/IRChat_Desktop.vbproj.GenerateResource.Cache new file mode 100644 index 0000000..3397813 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/obj/Debug/IRChat_Desktop.vbproj.GenerateResource.Cache differ diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/obj/Debug/IRChat_Desktop.xml b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/obj/Debug/IRChat_Desktop.xml new file mode 100644 index 0000000..a2a88e5 --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/obj/Debug/IRChat_Desktop.xml @@ -0,0 +1,11 @@ + + + + +IRChat_Desktop + + + + + + \ No newline at end of file diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/obj/Debug/ResolveAssemblyReference.cache b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/obj/Debug/ResolveAssemblyReference.cache new file mode 100644 index 0000000..ba949d6 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/obj/Debug/ResolveAssemblyReference.cache differ diff --git a/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/obj/IRChat_Desktop.vbproj.FileList.txt b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/obj/IRChat_Desktop.vbproj.FileList.txt new file mode 100644 index 0000000..8e31a2f --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop/IRChat_Desktop/obj/IRChat_Desktop.vbproj.FileList.txt @@ -0,0 +1,12 @@ +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\IRChat_Desktop.Form1.resources +obj\Debug\IRChat_Desktop.Resources.resources +obj\Debug\IRChat_Desktop.vbproj.GenerateResource.Cache +bin\Debug\IRChat_Desktop.exe +bin\Debug\IRChat_Desktop.pdb +bin\Debug\IRChat_Desktop.xml +bin\Debug\InTheHand.Net.Personal.dll +bin\Debug\InTheHand.Net.Personal.xml +obj\Debug\IRChat_Desktop.exe +obj\Debug\IRChat_Desktop.xml +obj\Debug\IRChat_Desktop.pdb diff --git a/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS.sln b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS.sln new file mode 100644 index 0000000..17708a1 --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IRChat_Desktop_CS", "IRChat_Desktop_CS\IRChat_Desktop_CS.csproj", "{39C1D659-D76B-42B4-8902-122FECBDBD70}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {39C1D659-D76B-42B4-8902-122FECBDBD70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {39C1D659-D76B-42B4-8902-122FECBDBD70}.Debug|Any CPU.Build.0 = Debug|Any CPU + {39C1D659-D76B-42B4-8902-122FECBDBD70}.Release|Any CPU.ActiveCfg = Release|Any CPU + {39C1D659-D76B-42B4-8902-122FECBDBD70}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS.suo b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS.suo new file mode 100644 index 0000000..a66f191 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS.suo differ diff --git a/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Form1.Designer.cs b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Form1.Designer.cs new file mode 100644 index 0000000..80e83aa --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Form1.Designer.cs @@ -0,0 +1,117 @@ +namespace IRChat_Desktop_CS +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.btnSend = new System.Windows.Forms.Button(); + this.StatusStrip1 = new System.Windows.Forms.StatusStrip(); + this.ToolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); + this.txtMessage = new System.Windows.Forms.TextBox(); + this.txtMessagesArchive = new System.Windows.Forms.TextBox(); + this.StatusStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // btnSend + // + this.btnSend.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnSend.Location = new System.Drawing.Point(149, 260); + this.btnSend.Name = "btnSend"; + this.btnSend.Size = new System.Drawing.Size(75, 23); + this.btnSend.TabIndex = 13; + this.btnSend.Text = "Send"; + this.btnSend.UseVisualStyleBackColor = true; + this.btnSend.Click += new System.EventHandler(this.btnSend_Click); + // + // StatusStrip1 + // + this.StatusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.ToolStripStatusLabel1}); + this.StatusStrip1.Location = new System.Drawing.Point(0, 289); + this.StatusStrip1.Name = "StatusStrip1"; + this.StatusStrip1.Size = new System.Drawing.Size(232, 22); + this.StatusStrip1.TabIndex = 14; + this.StatusStrip1.Text = "StatusStrip1"; + // + // ToolStripStatusLabel1 + // + this.ToolStripStatusLabel1.Name = "ToolStripStatusLabel1"; + this.ToolStripStatusLabel1.Size = new System.Drawing.Size(111, 17); + this.ToolStripStatusLabel1.Text = "ToolStripStatusLabel1"; + // + // txtMessage + // + this.txtMessage.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtMessage.Location = new System.Drawing.Point(9, 3); + this.txtMessage.Name = "txtMessage"; + this.txtMessage.Size = new System.Drawing.Size(215, 20); + this.txtMessage.TabIndex = 11; + // + // txtMessagesArchive + // + this.txtMessagesArchive.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtMessagesArchive.Location = new System.Drawing.Point(9, 29); + this.txtMessagesArchive.Multiline = true; + this.txtMessagesArchive.Name = "txtMessagesArchive"; + this.txtMessagesArchive.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.txtMessagesArchive.Size = new System.Drawing.Size(215, 225); + this.txtMessagesArchive.TabIndex = 12; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(232, 311); + this.Controls.Add(this.btnSend); + this.Controls.Add(this.StatusStrip1); + this.Controls.Add(this.txtMessage); + this.Controls.Add(this.txtMessagesArchive); + this.Name = "Form1"; + this.Text = "Form1"; + this.Load += new System.EventHandler(this.Form1_Load); + this.StatusStrip1.ResumeLayout(false); + this.StatusStrip1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + internal System.Windows.Forms.Button btnSend; + internal System.Windows.Forms.StatusStrip StatusStrip1; + internal System.Windows.Forms.ToolStripStatusLabel ToolStripStatusLabel1; + internal System.Windows.Forms.TextBox txtMessage; + internal System.Windows.Forms.TextBox txtMessagesArchive; + + } +} + diff --git a/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Form1.cs b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Form1.cs new file mode 100644 index 0000000..4df96c6 --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Form1.cs @@ -0,0 +1,184 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +using System.Net; +using System.IO; +using System.Net.Sockets; +using InTheHand.Net.Sockets; + +namespace IRChat_Desktop_CS +{ + public partial class Form1 : Form + { + //---define the constants--- + const int MAX_MESSAGE_SIZE = 1024; + const int MAX_TRIES = 3; + + //---define the member variables--- + private string ServiceName = "default"; + + public Form1() + { + InitializeComponent(); + } + + private void btnSend_Click(object sender, EventArgs e) + { + btnSend.Enabled = false; + SendMessage(MAX_TRIES, txtMessage.Text); + btnSend.Enabled = true; + txtMessage.Text = string.Empty; + txtMessage.Focus(); + } + + private void SendMessage(int NumRetries, string str) + { + IrDAClient client = null; + int CurrentTries = 0; + //---try to establish a connection--- + do + { + try + { + client = new IrDAClient(ServiceName); + } + catch (Exception se) + { + if ((CurrentTries >= NumRetries)) + { + throw se; + } + } + CurrentTries = CurrentTries + 1; + } while (client == null & CurrentTries < NumRetries); + + //---timeout occurred--- + if ((client == null)) + { + txtMessagesArchive.BeginInvoke(new myDelegate(UpdateStatus), + new object[] { "Error establishing contact" }); + return; + } + + //---send the message over a stream object--- + System.IO.Stream stream = null; + try + { + stream = client.GetStream(); + stream.Write(System.Text.ASCIIEncoding.ASCII.GetBytes(str), 0, str.Length); + + //---update the status bar--- + txtMessagesArchive.BeginInvoke(new myDelegate(UpdateStatus), + new object[] { "Message sent!" }); + + //---display the message that was sent--- + txtMessagesArchive.Text = str + Environment.NewLine + txtMessagesArchive.Text; + } + catch (Exception e) + { + txtMessagesArchive.BeginInvoke(new myDelegate(UpdateStatus), + new object[] { "Error sending message." }); + } + finally + { + if ((!(stream == null))) + { + stream.Close(); + } + if ((!(client == null))) + { + client.Close(); + } + } + } + + private void Form1_Load(object sender, EventArgs e) + { + txtMessage.Focus(); + + //---receive incoming messages as a separate thread--- + System.Threading.Thread t1; + t1 = new System.Threading.Thread(ReceiveLoop); + t1.Start(); + } + + public void ReceiveLoop() + { + string strReceived; + strReceived = ReceiveMessage(); + + //---keep on listening for new message--- + while (true) + { + if (strReceived != string.Empty) + { + txtMessagesArchive.BeginInvoke( + new myDelegate(UpdateTextBox), + new object[] { strReceived }); + } + strReceived = ReceiveMessage(); + } + } + + private string ReceiveMessage() + { + int bytesRead = 0; + IrDAListener listener = new IrDAListener(ServiceName); + IrDAClient client = null; + System.IO.Stream stream = null; + byte[] Buffer = new byte[MAX_MESSAGE_SIZE - 1]; + string str = string.Empty; + try + { + listener.Start(); + + //---blocking call--- + client = listener.AcceptIrDAClient(); + stream = client.GetStream(); + bytesRead = stream.Read(Buffer, 0, Buffer.Length); + + //---format the received message--- + str = ">" + System.Text.ASCIIEncoding.ASCII.GetString(Buffer, 0, bytesRead); + } + catch (SocketException ex) + { + //---ignore error--- + } + catch (Exception e) + { + txtMessagesArchive.BeginInvoke(new myDelegate(UpdateStatus), + new object[] { e.ToString() }); + } + finally + { + if ((!(stream == null))) + { + stream.Close(); + } + if ((!(client == null))) + { + client.Close(); + } + listener.Stop(); + } + return str; + } + + private delegate void myDelegate(string str); + private void UpdateTextBox(string str) + { + //---delegate to update the textbox control--- + txtMessagesArchive.Text = str + Environment.NewLine + txtMessagesArchive.Text; + } + private void UpdateStatus(string str) + { + //---delegate to update the statusbar control--- + ToolStripStatusLabel1.Text = str; + } + } +} \ No newline at end of file diff --git a/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Form1.resx b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Form1.resx new file mode 100644 index 0000000..faac01d --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Form1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/IRChat_Desktop_CS.csproj b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/IRChat_Desktop_CS.csproj new file mode 100644 index 0000000..d5c21ad --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/IRChat_Desktop_CS.csproj @@ -0,0 +1,79 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {39C1D659-D76B-42B4-8902-122FECBDBD70} + WinExe + Properties + IRChat_Desktop_CS + IRChat_Desktop_CS + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Designer + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + \ No newline at end of file diff --git a/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Program.cs b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Program.cs new file mode 100644 index 0000000..7912d08 --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace IRChat_Desktop_CS +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} \ No newline at end of file diff --git a/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Properties/AssemblyInfo.cs b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..fee93a0 --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("IRChat_Desktop_CS")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("IRChat_Desktop_CS")] +[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("195ded13-61cf-436b-bf38-d8cb30229b66")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Properties/Resources.Designer.cs b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Properties/Resources.Designer.cs new file mode 100644 index 0000000..1b3ad45 --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace IRChat_Desktop_CS.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("IRChat_Desktop_CS.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Properties/Resources.resx b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Properties/Settings.Designer.cs b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Properties/Settings.Designer.cs new file mode 100644 index 0000000..21ef2aa --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace IRChat_Desktop_CS.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Properties/Settings.settings b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/bin/Debug/IRChat_Desktop_CS.exe b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/bin/Debug/IRChat_Desktop_CS.exe new file mode 100644 index 0000000..e60a9e0 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/bin/Debug/IRChat_Desktop_CS.exe differ diff --git a/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/bin/Debug/IRChat_Desktop_CS.pdb b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/bin/Debug/IRChat_Desktop_CS.pdb new file mode 100644 index 0000000..8c40460 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/bin/Debug/IRChat_Desktop_CS.pdb differ diff --git a/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/bin/Debug/IRChat_Desktop_CS.vshost.exe b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/bin/Debug/IRChat_Desktop_CS.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/bin/Debug/IRChat_Desktop_CS.vshost.exe differ diff --git a/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/bin/Debug/InTheHand.Net.Personal.dll b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/bin/Debug/InTheHand.Net.Personal.dll new file mode 100644 index 0000000..e4e99f4 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/bin/Debug/InTheHand.Net.Personal.dll differ diff --git a/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/bin/Debug/InTheHand.Net.Personal.xml b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/bin/Debug/InTheHand.Net.Personal.xml new file mode 100644 index 0000000..f175766 --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/bin/Debug/InTheHand.Net.Personal.xml @@ -0,0 +1,3026 @@ + + + + InTheHand.Net.Personal + + + + + Defines configuration option names for the class when used with IrDA. + + + + + Returns a list of IrDA device IDs for IR capable devices within range. + + + + + Enables an application to set a single class in the local IAS. + The application specifies the class to set, the attribute, and attribute type. + + + + + Queries IAS on a given service and class name for its attributes. + + + + + Retrieves the maximum PDU length required to use . + + + + + Sets socket to bypass TinyTP layer to directly communicate with IrLMP. + + + + + Disables TinyTP mode and sends data directly over IrLMP frames. + + + + + Puts the IrDA socket into IrCOMM mode. + + + + + Enables the Sharp mode. + + + + + Summary description for WsaQuerySet. + + + + + Returns name of device if specified in query. + + + + + Identifies the services class in the form of a GUID. + + + + + This context varies depending upon the function. + + + + + Represents an IrDA device address. + + + + + Initializes a new instance of the class with the specified address. + + Address as 4 byte array. + address passed was not a 4 byte array. + + + + Initializes a new instance of the class with the specified address. + + representation of the address. + + + + Returns the IrDA address as an integer. + + + + + + Returns the internal byte array. + + + + + + Determines whether a string is a valid IrDA address. + + The string to validate. + The version of the string. + true if irdaString is a valid IrDA address; otherwise, false. + + + + Converts the string representation of an IrDA address to a new instance. + + A string containing an address to convert. + New instance. + Address must be specified in hex format optionally separated by the colon or period character e.g. 00000000, 00:00:00:00 or 00.00.00.00. + + + + Converts the address to its equivalent string representation. + + The string representation of this instance. + + + + Returns a representation of the value of this instance, according to the provided format specifier. + + A single format specifier that indicates how to format the value of this Guid. The format parameter can be "N", "C" or "P". If format is null or the empty string (""), "N" is used. + A representation of the value of this . + + SpecifierFormat of Return Value + N8 digits: XXXXXXXX + C8 digits separated by colons: XX:XX:XX:XX + P8 digits separated by periods: XX.XX.XX.XX + + + + + Compares two instances for equality. + + + + + + + Returns the hash code for this instance. + + + + + + Returns an indication whether the values of two specified objects are equal. + + + + + + + + Returns an indication whether the values of two specified objects are not equal. + + + + + + + + Provides a null IrDA address. + + + + + Dummy SDP record into which we can insert the Guid and channel + + + + + Register the service. For SAP, this means sending out a periodic broadcast. + This is an NOP for the DNS namespace. + For persistent data stores, this means updating the address information. + + + + + Remove the service from the registry. + For SAP, this means stop sending out the periodic broadcast. + This is an NOP for the DNS namespace. + For persistent data stores this means deleting address information. + + + + + Delete the service from dynamic name and persistent spaces. + For services represented by multiple CSADDR_INFO structures (using the SERVICE_MULTIPLE flag), only the specified address will be deleted, and this must match exactly the corresponding CSADDR_INFO structure that was specified when the service was registered + + + + + Stores version information for a Bluetooth device. + + + + + + + + + + + Version of the current Host Controller Interface (HCI) in the Bluetooth hardware. + + This value changes only when new versions of the Bluetooth hardware are created for the new Bluetooth Special Interest Group (SIG) specifications. + + + + Version of the current Link Manager Protocol (LMP) in the Bluetooth hardware. + + + + + Name of the Bluetooth hardware manufacturer. + + + + + + + + + + Specifies the status codes returned for an Object Exchange (OBEX) operation. + + OBEX codes are directly related to their HTTP equivalents - see . + + + + Applied to another code to indicate this is the only response or final response in a series. + + + + + Equivalent to HTTP status 100. + Continue indicates that the client can continue with its request. + + + + + Equivalent to HTTP status 200. + OK indicates that the request succeeded and that the requested information is in the response. + This is the most common status code to receive. + + + + + Equivalent to HTTP status 201. + Created indicates that the request resulted in a new resource created before the response was sent. + + + + + Equivalent to HTTP status 202. + Accepted indicates that the request has been accepted for further processing. + + + + + Equivalent to HTTP status 203. + NonAuthoritativeInformation indicates that the returned metainformation is from a cached copy instead of the origin server and therefore may be incorrect. + + + + + Equivalent to HTTP status 204. + NoContent indicates that the request has been successfully processed and that the response is intentionally blank. + + + + + Equivalent to HTTP status 205. + ResetContent indicates that the client should reset (not reload) the current resource. + + + + + Equivalent to HTTP status 206. + PartialContent indicates that the response is a partial response as requested by a GET request that includes a byte range. + + + + + Equivalent to HTTP status 300. + MultipleChoices indicates that the requested information has multiple representations. + + + + + Equivalent to HTTP status 301. + MovedPermanently indicates that the requested information has been moved to the URI specified in the Location header. + The default action when this status is received is to follow the Location header associated with the response. + + + + + Equivalent to HTTP status 302. + Redirect indicates that the requested information is located at the URI specified in the Location header. + The default action when this status is received is to follow the Location header associated with the response. + When the original request method was POST, the redirected request will use the GET method. + + + + + Equivalent to HTTP status 303. + SeeOther automatically redirects the client to the URI specified in the Location header as the result of a POST. The request to the resource specified by the Location header will be made with a GET. + + + + + Equivalent to HTTP status 304. + NotModified indicates that the client's cached copy is up to date. + The contents of the resource are not transferred. + + + + + Equivalent to HTTP status 305. + UseProxy indicates that the request should use the proxy server at the URI specified in the Location header. + + + + + Equivalent to HTTP status 400. + BadRequest indicates that the request could not be understood by the server. BadRequest is sent when no other error is applicable, or if the exact error is unknown or does not have its own error code. + + + + + Equivalent to HTTP status 401. + Unauthorized indicates that the requested resource requires authentication. The WWW-Authenticate header contains the details of how to perform the authentication. + + + + + Equivalent to HTTP status 402. + PaymentRequired is reserved for future use. + + + + + Equivalent to HTTP status 403. + Forbidden indicates that the server refuses to fulfill the request. + + + + + Equivalent to HTTP status 404. + NotFound indicates that the requested resource does not exist on the server. + + + + + Equivalent to HTTP status 405. + MethodNotAllowed indicates that the request method (POST or GET) is not allowed on the requested resource. + + + + + Equivalent to HTTP status 406. + NotAcceptable indicates that the client has indicated with Accept headers that it will not accept any of the available representations of the resource. + + + + + Equivalent to HTTP status 407. + ProxyAuthenticationRequired indicates that the requested proxy requires authentication. + The Proxy-authenticate header contains the details of how to perform the authentication. + + + + + Equivalent to HTTP status 408. + RequestTimeout indicates that the client did not send a request within the time the server was expecting the request. + + + + + Equivalent to HTTP status 409. + Conflict indicates that the request could not be carried out because of a conflict on the server. + + + + + Equivalent to HTTP status 410. + Gone indicates that the requested resource is no longer available. + + + + + Equivalent to HTTP status 411. + LengthRequired indicates that the required Content-length header is missing. + + + + + Equivalent to HTTP status 412. + PreconditionFailed indicates that a condition set for this request failed, and the request cannot be carried out. + Conditions are set with conditional request headers like If-Match, If-None-Match, or If-Unmodified-Since. + + + + + Equivalent to HTTP status 413. + RequestEntityTooLarge indicates that the request is too large for the server to process. + + + + + Equivalent to HTTP status 414. + RequestUriTooLong indicates that the URI is too long. + + + + + Equivalent to HTTP status 415. + UnsupportedMediaType indicates that the request is an unsupported type. + + + + + Equivalent to HTTP status 500. + InternalServerError indicates that a generic error has occurred on the server. + + + + + Equivalent to HTTP status 501. + NotImplemented indicates that the server does not support the requested function. + + + + + Equivalent to HTTP status 502. + BadGateway indicates that an intermediate proxy server received a bad response from another proxy or the origin server. + + + + + Equivalent to HTTP status 503. + ServiceUnavailable indicates that the server is temporarily unavailable, usually due to high load or maintenance. + + + + + Equivalent to HTTP status 504. + GatewayTimeout indicates that an intermediate proxy server timed out while waiting for a response from another proxy or the origin server. + + + + + Equivalent to HTTP status 505. + HttpVersionNotSupported indicates that the requested HTTP version is not supported by the server. + + + + + + + + + + + + + + + Standard Bluetooth Profile identifiers. + + + + + Represents an empty service Guid. + + + + + Represents the base Guid from which all standard Bluetooth profiles are derived - not used for connections. + + + + + + + + + + + + + + + + + + + + Provides a basic Serial emulation connect over Bluetooth. + + + + + Used to establish PPP connections over RFComm channels. + + + + + + + + + + + + + + + Used for sending binary objects between devices. + + + + + OBEX version of an FTP server + + + + + + + + + + Supports Bluetooth headset devices. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Supports hands free kits such as a car kits which provide audio and more advanced call control than the Headset profile. + + + + + + + + + + + + + + + + + + + + Used for printing simple text, HTML, vCard objects and similar. + + + + + + + + + + Supports human interface devices such as keyboards and mice. + + + + + + + + + + + + + + + + + + + + Common_ISDN_Access + + + + + + + + + + UDI_MT + + + + + UDI_TA + + + + + + + + + + SIM_Access + + + + + Phonebook Access - PCE + + + + + Phonebook Access - PSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ESDP_UPNP_IP_PAN + + + + + ESDP_UPNP_IP_LAP + + + + + ESDP_UPNP_L2CAP + + + + + + + + + + + + + + + + + + + + Handles security between bluetooth devices. Current supported on devices only. + + + + + This function stores the personal identification number (PIN) for the Bluetooth device. + Not supported on Windows XP + + Address of remote device. + Pin, alphanumeric string of between 1 and 16 ASCII characters. + True on success, else False. + Not supported on Windows XP - use PairRequest + + + + This function revokes the personal identification number (PIN) for the Bluetooth device. + Not supported on Windows XP + + The remote device. + True on success, else False. + + + + Intiates pairing for a remote device. + + Remote device with which to pair. + Chosen PIN code, must be between 1 and 16 ASCII characters. + + + + + Remove the pairing with the specified device + + Remote device with which to remove pairing. + TRUE if device was successfully removed, else FALSE. + + + + Not supported on Windows XP + + + + + + + + Retrieves the address of the Bluetooth peer device authentication that requires the PIN code. + Not supported on Windows XP + + of the remote device, or null if there is no outstanding PIN request. + + + + Refuses an outstanding PIN request. + Not supported on Windows XP + + Address of the requesting device. + + + + Provides connection services for an infrared connection. + + Provides services for an infrared end point that includes making connections, obtaining data streams and discovering devices. + Infrared connections are made by specifying a service name, which can be any value provided the participating devices refer the same name. + + + + + Initializes a new instance of the class. + + + + + Initializes a new instance of the class for a specified service. + + + + + + Initializes a new instance of the class for connecting to a specified endpoint. + + An . + + + + Obtains information about available devices. + + Returns a maximum of 8 devices, for more flexibility use the other overloads. + + + + Obtains information about a specified number of devices. + + The maximum number of devices to get information about. + + + + + Obtains information about available devices using a socket. + + The maximum number of devices to get information about. + + + + + + Gets the name of a device using a specified socket. + + A valid socket. + The name of the remote device. + + + + Connects a client to a specified endpoint. + + + + + + Connects a client to a specified service. + + + + + + Closes the socket of the connection. + + + + + Gets the underlying stream of data. + + + + + + The number of bytes of data received from the network and available to be read. + + + + + Gets or sets the underlying . + + + + + Gets a value indicating whether the underlying for an is connected to a remote host. + + + + + Gets the name of the device participating in the communication. + + + + + Provides an OBEX implementation of the class. + + + + + Create a new Obex request with the specified . + + + Uri must use one of the following schemes - obex, obex-push, obex-ftp, obex-sync. + The host name must be the device address in short hex, or dotted hex notation - not the default representation using the colon separator + + + + Gets a object to use to write request data. + + + + + + Reads the contents of the specified file to the request stream. + + The filename (including the path) from which to read. + Provides an easy equivalent to manually writing the file contents to the request stream. + + + + Returns the OBEX server response. + + + + + + + + + + + Gets or sets the method for the request. + + For Object Exchange the method code is mapped to the equivalent HTTP style method. + For example "PUT", "GET" etc. In this version only "PUT" is supported and is the default value. + + + + Gets or sets the value of the Type OBEX header. + + + + + Gets or sets the Length OBEX header. + + This property is mandatory, if not set no data will be sent. + If you use the helper method this value is automatically populated with the size of the file that was read. + + + + Not Supported - do not use, this will throw an exception. + + + + + Gets or sets the time-out value for the method. + + The number of milliseconds to wait before the request times out. + The default is 50,000 milliseconds (50 seconds). + A value of -1 or 0 represents no time-out. + + + + Gets the original Uniform Resource Identifier (URI) of the request. + + For an ObexPush request the URI will use the "obex://" prefix, followed by the numerical device id in hex format. + The path section of the URI represents the remote filename of the pushed object. Subfolders are not supported. Some devices may only support specific object types e.g. V-Card. + + + + Methods which can be carried out in an Object Exchange transaction. + + + + + Sends an object to a receiving device. + + + + + Requests a file from the remote device. + + + + + Negotiate an Object Exchange connection with a remote device. + + + + + Disconnect an existing Object Exchange session. + + + + + Sends the last packet of an object to a receiving device. + + + + + Change remote path on an Object Exchange server. + + + + + Manufacturer codes. + + Defined in Bluetooth Specifications Assigned Numbers. + + + + + + + + + Internal bytes + + + + + + Size of the structure. + + + + + Defines configuration option names for the class. + + + + + On connected socket, triggers authentication. + On not connected socket, forces authentication on connection. + For incoming connection this means that connection is rejected if authentication cannot be performed. + + The optval and optlen parameters are ignored; however, Winsock implementation on Windows CE requires optlen to be at least 4 and optval to point to at least an integer datum. + + + + Toggles authentication under Windows XP. + + optlen=sizeof(ULONG), optval = &(ULONG)TRUE/FALSE + + + + On a connected socket, this command turns encryption on or off. + On an unconnected socket, this forces encryption to be on or off on connection. + For an incoming connection, this means that the connection is rejected if the encryption cannot be turned on. + + + + + This sets or revokes PIN code to use with a connection or socket. + + + + + This sets or revokes link key to use with a connection or peer device. + + + + + Returns link key associated with peer Bluetooth device. + + + + + Get or set the default MTU on Windows XP. + + optlen=sizeof(ULONG), optval = &mtu + + + + This sets default MTU (maximum transmission unit) for connection negotiation. + While allowed for connected socket, it has no effect if the negotiation has already completed. + Setting it on listening socket will propagate the value for all incoming connections. + + + + + Returns MTU (maximum transmission unit). + For connected socket, this is negotiated value, for server (accepting) socket it is MTU proposed for negotiation on connection request. + + + + + Get or set the maximum MTU on Windows XP. + + optlen=sizeof(ULONG), optval = &max. mtu + + + + This sets maximum MTU for connection negotiation. + While allowed for connected socket, it has no effect if the negotiation has already completed. + Setting it on listening socket will propagate the value for all incoming connections. + + + + + Returns maximum MTU acceptable MTU value for a connection on this socket. + Because negotiation has already happened, has little meaning for connected socket. + + + + + Get or set the minimum MTU on Windows XP. + + optlen=sizeof(ULONG), optval = &min. mtu + + + + This sets minimum MTU for connection negotiation. + While allowed for connected socket, it has no effect if the negotiation has already completed. + Setting it on listening socket will propagate the value for all incoming connections. + + + + + Returns minimum MTU acceptable MTU value for a connection on this socket. + Because negotiation has already happened, has little meaning for connected socket. + + + + + This sets XON limit. + Setting it on listening socket will propagate the value for all incoming connections. + + + + + Returns XON limit for a connection. + XON limit is only used for peers that do not support credit-based flow control (mandatory in the Bluetooth Core Specification version 1.1). + When amount of incoming data received, but not read by an application for a given connection grows past this limit, a flow control command is sent to the peer requiring suspension of transmission. + + + + + This sets XOFF limit. + Setting it on listening socket will propagate the value for all incoming connections. + + + + + Returns XOFF limit for a connection. + XOFF limit is only used for peers that do not support credit-based flow control (mandatory in the Bluetooth Core Specification 1.1). + If flow has been suspended because of buffer run-up, when amount of incoming data received, but not read by an application for a given connection falls below this limit, a flow control command is sent to the peer allowing continuation of transmission. + + + + + Specifies maximum amount of data that can be buffered inside RFCOMM (this is amount of data before call to send blocks). + + + + + Returns maximum amount of data that can be buffered inside RFCOMM (this is amount of data before call to send blocks). + + + + + Specifies maximum amount of data that can be buffered for a connection. + This buffer size is used to compute number of credits granted to peer device when credit-based flow control is implemented. + This specifies the maximum amount of data that can be buffered. + + + + + Returns maximum amount of data that can be buffered for a connection. + This buffer size is used to compute number of credits granted to peer device when credit-based flow control is implemented. + This specifies the maximum amount of data that can be buffered. + + + + + Retrieves last v24 and break signals set through MSC command from peer device. + + + + + Retrieves last line status signals set through RLS command from peer device. + + + + + Sends MSC command. V24 and breaks are as specified in RFCOMM Specification. + Only modem signals and breaks can be controlled, RFCOMM reserved fields such as flow control are ignored and should be set to 0. + + + + + Sends RLS command. + Argument is as specified in RFCOMM Specification. + + + + + Gets flow control type on the connected socket. + + + + + Sets the page timeout for the card. + The socket does not have to be connected. + + + + + Gets the current page timeout. + The socket does not have to be connected. + + + + + Sets the scan mode for the card. + The socket does not have to be connected. + + + + + Gets the current scan mode. + The socket does not have to be connected. + + + + + Sets the class of the device. + The socket does not have to be connected. + + + + + Retrieve the Class of Device. + + + + + Get the version information from the Bluetooth adapter. + + + + + Get the version of the remote adapter. + + + + + Retrieves the authentication settings. + The socket does not have to be connected. + + + + + Sets the authentication policy of the device. + + + + + Reads the remote name of the device. + The socket does not have to be connected. + + + + + Retrieves the link policy of the device. + + + + + Sets the link policy for an existing baseband connection. + The socket must be connected. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gets the current mode of the connection. + The mode can either be sniff, park, or hold. The socket must be connected. + + + + + Contains helper functionality. + + + + + Specifies that the URI is accessed through the Object Exchange (OBEX) protocol. + + + + + Specifies that the URI is accessed through the Object Exchange (OBEX) Push protocol. + + + + + Specifies that the URI is accessed through the Object Exchange (OBEX) FTP protocol. + + + + + Specifies that the URI is accessed through the Object Exchange (OBEX) Sync protocol. + + + + + Provides information about remote devices connected by infrared communications. + + + + + + Compares two instances for equality. + + + + + + + Returns the hash code for this instance. + + + + + + Returns the address of the remote device. + + + + + Provided solely for compatibility with System.Net.IrDA - consider using instead. + + + + + Gets the name of the device. + + + + + Gets the character set used by the server, such as ASCII. + + + + + Gets the type of the device, such as a computer. + + + + + Specifies the current status of the Bluetooth hardware. + + + + + Status cannot be determined. + + + + + Bluetooth radio not present. + + + + + Bluetooth radio is in the process of starting up. + + + + + Bluetooth radio is active. + + + + + Bluetooth radio is in the process of shutting down. + + + + + Bluetooth radio is in an error state. + + + + + Class of Device flags as assigned in the Bluetooth specifications. + + Defined in Bluetooth Specifications Assigned Numbers. + + + + Defines additional IrDA socket option levels for the and methods. + + + + + + + + + + Defines the type of an IAS attribute. + + + + + Identifies an integer attribute value. + + + + + Identifies a binary, or octet, attribute value. + + + + + Identifies a string attribute value. + + + + + Represents an end point for an infrared connection. + + + + + + Initializes a new instance of the class. + + The device identifier. + The name of the service to connect to. + + + + Initializes a new instance of the class. + + The device address. + The name of the service to connect to. + + + + Serializes endpoint information into a . + + + + + + Creates an from a socket address + + A . + + + + + Compares two instances for equality. + + + + + + + Returns the hash code for this instance. + + + + + + Gets or sets an address for the device. + + + + + Gets or sets an identifier for the device. + + + + + Gets or sets the name of the service. + + + + + Gets the address family to which the endpoint belongs. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Bluetooth specific flags returned from WSALookupServiceNext + in WSAQUERYSET.dwOutputFlags in response to device inquiry. + + + + + Establishes connections to a peer device and provides Bluetooth port information. + + + + + Specifies the minimum value that can be assigned to the Port property. + + + + + Specifies the maximum value that can be assigned to the Port property. + + + + + Initializes a new instance of the class with the specified address and service. + + The Bluetooth address of the device. A six byte array. + The Bluetooth service to use. + + + + Initializes a new instance of the class with the specified address, service and port number. + + The Bluetooth address of the device. A six byte array. + The Bluetooth service to use. + Radio channel to use, -1 for any. + + + + Serializes endpoint information into a instance. + + A instance containing the socket address for the endpoint. + + + + Creates an endpoint from a socket address. + + The to use for the endpoint. + An instance using the specified socket address. + + + + Compares two instances for equality. + + + + + + + Returns the hash code for this instance. + + + + + + Gets the address family of the Bluetooth address. + + + + + Gets or sets the Bluetooth address of the endpoint. + + + + + Gets or sets the Bluetooth service to use for the connection. + + + + + Gets or sets the service channel number of the endpoint. + + + + + Defines additional Bluetooth socket option levels for the and methods. + + + + + + + + + + + + + + + + + + + + Provides information about an available device obtained by the client during device discovery. + + + + + + + + + + + + + + + + + Forces the system to refresh the device information. + + + + + Updates the device name used to display the device. + + On Windows CE this only affects devices which are already paired. + + + + Enables or disables services for a Bluetooth device. + + The service GUID on the remote device. + Service state - TRUE to enable the service, FALSE to disable it. + This function only supports Windows XP, calling it on CE will throw a PlatformNotSupportedException. + Thrown if this method is called on Windows CE platforms. + + + + + + + + + + + Displays information about the device. + + + + + Compares two instances for equality. + + + + + + + Returns the hash code for this instance. + + + + + + Gets the device identifier. + + + + + Gets a name of a device. + + + + + Returns the Class of Device of the remote device. + + + + + Returns a list of services which are already installed for use on the calling machine. + + Will only return available services for paired devices. + + + + Device connected. + + Not supported under Windows CE and will always return false. + + + + Device remembered. + + Not supported under Windows CE and will always return false. + + + + Device Authenticated. + + Now supported on both CE and XP. + + + + Date and Time this device was last seen by the system. + + Not supported under Windows CE and will return DateTime.MinValue. + + + + Date and Time this device was last used by the system. + + Not supported under Windows CE and will return DateTime.MinValue. + + + + Places a socket in a listening state to monitor infrared connections from a specified service or network address. + + This class monitors a service by specifying a service name or a network address. + The listener does not listen until you call the method. + + + + + Initializes a new instance of the class. + + The network address to monitor for making a connection. + + + + Initializes a new instance of the class. + + The name of the service to listen for. + + + + Starts the socket to listen for incoming connections. + + + + + Stops the socket from monitoring connections. + + + + + Creates a new socket for a connection. + + A socket. + + + + Creates a client object for a connection when the specified service or endpoint is detected by the listener component. + + An object. + + + + Determines if a connection is pending. + + true if there is a connection pending; otherwise, false. + + + + Gets the underlying network . + + + + + Gets a value that indicates whether the is actively listening for client connections. + + + + + Gets an representing the local device. + + + + + Provides client connections for Bluetooth network services. + + This class currently only supports devices which use the Microsoft Bluetooth stack such as the Orange SPV E200, devices which use the WidComm stack will not work. + + + + Creates a new instance of . + + + + + Initializes a new instance of the class and binds it to the specified local endpoint. + + The to which you bind the Bluetooth Socket. + Only necessary on multi-radio system where you want to select the local radio to use. + + + + Discovers accessible Bluetooth devices and returns their names and addresses. + + An array of BluetoothDeviceInfo objects describing the devices discovered. + + + + Discovers accessible Bluetooth devices and returns their names and addresses. + + The maximum number of devices to get information about. + An array of BluetoothDeviceInfo objects describing the devices discovered. + + + + Discovers accessible Bluetooth devices and returns their names and addresses. + + The maximum number of devices to get information about. + True to return previously authenticated/paired devices. + True to return remembered devices. + True to return previously unknown devices. + An array of BluetoothDeviceInfo objects describing the devices discovered. + + + + Connects a client to a specified endpoint. + + A that represents the remote device. + + + + Closes the socket of the connection. + + + + + Gets the underlying stream of data. + + The underlying . + returns a that you can use to send and receive data. + The class inherits from the class, which provides a rich collection of methods and properties used to facilitate network communications. + You must call the method first, or the method will throw an . + After you have obtained the , call the method to send data to the remote host. + Call the method to receive data arriving from the remote host. + Both of these methods block until the specified operation is performed. + You can avoid blocking on a read operation by checking the property. + A true value means that data has arrived from the remote host and is available for reading. + In this case, is guaranteed to complete immediately. + If the remote host has shutdown its connection, will immediately return with zero bytes. + The is not connected to a remote host. + The has been closed. + + + + Set or change the PIN to be used with a specific remote device. + + Address of Bluetooth device. + PIN string consisting of 1-16 ASCII characters. + + + + Gets the name of the specified remote device. + + Address of remote device. + Friendly name of specified device. + + + + Gets the name of a device by a specified socket. + + A . + Returns a string value of the computer or device name. + + + + + + + + + + + + + + + Frees resources used by the class. + + + + + Amount of time allowed to perform the query. + + On Windows CE the actual value used is expressed in units of 1.28 seconds, so will be the nearest match for the value supplied. + The default value is 10 seconds. The maximum is 60 seconds. + + + + Gets the amount of data that has been received from the network and is available to be read. + + The number of bytes of data received from the network and available to be read. + The has been closed. + + + + Gets or sets the underlying . + + + + + Gets a value indicating whether the underlying for a is connected to a remote host. + + true if the socket was connected to a remote resource as of the most recent operation; otherwise, false. + + + + Gets or sets the authentication state of the current connect or behaviour to use when connection is established. + + + For disconnected sockets, specifies that authentication is required in order for a connect or accept operation to complete successfully. + Setting this option actively initiates authentication during connection establishment, if the two Bluetooth devices were not previously authenticated. + The user interface for passkey exchange, if necessary, is provided by the operating system outside the application context. + For outgoing connections that require authentication, the connect operation fails with WSAEACCES if authentication is not successful. + In response, the application may prompt the user to authenticate the two Bluetooth devices before connection. + For incoming connections, the connection is rejected if authentication cannot be established and returns a WSAEHOSTDOWN error. + + + + + On unconnected sockets, enforces encryption to establish a connection. + Encryption is only available for authenticated connections. + For incoming connections, a connection for which encryption cannot be established is automatically rejected and returns WSAEHOSTDOWN as the error. + For outgoing connections, the connect function fails with WSAEACCES if encryption cannot be established. + In response, the application may prompt the user to authenticate the two Bluetooth devices before connection. + + + + + Returns link key associated with peer Bluetooth device. + + + + + Returns the Link Policy of the current connection. + + + + + Retrieves the version of the local Bluetooth equipment. + + + + + Sets the PIN associated with the currently connected device. + + PIN which must be composed of 1 to 16 ASCII characters. + Assigning null (Nothing in VB) or an empty String will revoke the PIN. + + + + Gets the name of the remote device. + + + + + Provides access to the request and response objects used by the class. + + + + + Gets the that represents a client's request for a resource + + + + + Describes the character sets supported by the device. + + The enumeration describes the following character sets, which are used by the and classes. + + + + + The ASCII character set. + + + + + The western European graphic character set. + + + + + The eastern European graphic character set. + + + + + The southern European graphic character set. + + + + + The northern European graphic character set. + + + + + The Cyrillic graphic character set. + + + + + The Arabic graphic character set. + + + + + The Greek graphic character set. + + + + + The Hebrew graphic character set. + + + + + The Turkish graphic character set. + + + + + The Unicode character set. + + + + + Specifies the media type information for an object. + + + + + Specifies the type of image data in an object. + + + + + Specifies that the image data is in Graphics Interchange Format (GIF). + + + + + Specifies that the image data is in Joint Photographic Experts Group (JPEG) format. + + + + + Specifies the type of text data in an object. + + + + + Specifies that the data is in HTML format. + + + + + Specifies that the data is in plain text format. + + + + + Specifies that the data is in vCalendar format. + + + + + Specifies that the data is in vCard format. + + + + + Specifies that the data is in vMsg format. + + + + + Specifies that the data is in vNote format. + + + + + Specifies that the data is in XML format. + + + + + Specifies the type of Object Exchange specific data. + + + + + Used to retrieve supported object types. + + + + + Used to retrieve folder listing with OBEX FTP. + + + + + Used to retrieve an object profile. + + + + + Provides an OBEX implementation of the class. + + + + + Gets the stream used to read the body of the response from the server. + + + + + + Writes the contents of the response to the specified file path. + + The filename (including the path) from which to read. + + + + Frees the resources held by the response. + + + + + Gets the headers associated with this response from the server. + + + + + + + + + + + + + + + Returns a status code to indicate the outcome of the request. + + + + + Used to create a new web request for obex uri scheme + + + + + Supported network transports for Object Exchange. + + + + + Infrared (IrDA) + + + + + Bluetooth + + + + + TCP/IP + + + + + Flags to describe Link Policy. + + + + + Disables all LAN Manager (LM) modes. + + + + + Enables the master slave switch. + + + + + Enables Hold mode. + + + + + Enables Sniff Mode. + + + + + Enables Park Mode. + + + + + Represents a Bluetooth Radio device. + + Allows you to query properties of the radio hardware and set the mode. + + + + Gets a value that indicates whether the 32feet.NET library can be used with the current device. + + + + + Gets the primary . + + For Windows CE based devices this is the only , for Windows XP this is the first available device. + If the device has a third-party stack this property will return null + + + + Gets an array of all Bluetooth radios on the system. + + Under Windows CE this will only ever return a single device. + If the device has a third-party stack this property will return an empty collection + + + + Gets the handle for this radio. + + Relevant only on Windows XP. + + + + Returns the current status of the Bluetooth radio hardware. + + A member of the enumeration. + + + + Gets or Sets the current mode of operation of the Bluetooth radio. + + This setting will be persisted when the device is reset. + An Icon will be displayed in the tray on the Home screen and the device will emit a blue LED when Bluetooth is enabled. + + + + Returns the address of the local Bluetooth radio device. + + + + + Returns the friendly name of the local Bluetooth radio. + + + + + Returns the Class of Device. + + + + + Returns the manufacturer of the device. + + + + + Returns the manufacturer of the Bluetooth software stack running locally. + Currently only Microsoft is supported. + + + + + Specifies additional protocols that the class supports. + + + + + Bluetooth RFComm protocol. + + + + + Describes an enumeration of possible device types, such as Fax. + + + + + + Unspecified device type. + + + + + A Plug and Play interface. + + + + + A Pocket PC or similar. + + + + + A personal computer. + + + + + A printer. + + + + + A modem. + + + + + A fax. + + + + + A local area network access. + + + + + Contains extended hint bytes. + + + + + A telephonic device. + + + + + A personal computer file server. + + + + + Device supports IrCOMM. + + + + + Device supports Object Exchange. + + + + + Describes the device and service capabilities of a device. + + + + + + + + + + + + + + + + + Returns the device type. + + + + + Returns supported service types. + + + + + Describes an incoming OBEX request to an object. + + + + + Writes the body of the request to the specified file path. + + The filename (including the path) to write to. + + + + Gets the length of the body data included in the request. + New in v1.5.51015 + + A long value that contains the value from the request's Length header. + This value is -1 if the content length is not known. + The Length header expresses the length, in bytes, of the body data that accompanies the request. + + + + Gets the MIME type of the body data included in the request. + + A that contains the text of the request's Type header. + + + + Gets the collection of header name/value pairs sent in the request. + + A that contains the OBEX headers included in the request. + For a complete list of request headers, see the enumeration. + + + + Get the device address and service to which the request is directed. + + + + + Gets the method specified by the client. + + Only PUT is supported in this version. + + + + Gets a stream that contains the body data sent by the client. + + + + + Gets the OBEX version used by the requesting client + + + + + Gets the URL information (without the host and port) requested by the client. + + A that contains the raw URL for this request. + + + + Gets the device address and service from which the request originated. + + + + + Gets the server address to which the request is directed. + + + + + Gets the object requested by the client. + + A object that identifies the resource requested by the client. + + + + Determine all the possible modes of operation of the Bluetooth radio. + + + + + Bluetooth is disabled on the device. + + + + + Bluetooth is connectable but your device cannot be discovered by other devices. + + + + + Bluetooth is activated and fully discoverable. + + + + + Listens for connections from Bluetooth network clients. + + The class provides simple methods that listen for and accept incoming connection requests in blocking synchronous mode. + You can use either a or a to connect with a + + + + Initializes a new instance of the class. + + The device address to monitor for making a connection. + + + + Initializes a new instance of the class that listens for incoming connection attempts on the specified local Bluetooth address and service identifier. + + A that represents the local Bluetooth radio address. + The Bluetooth service to listen for. + + + + Initializes a new instance of the class. + + The Bluetooth service to listen for. + + + + Initializes a new instance of the class. + + The Bluetooth service to listen for. + Prepared SDP Record to publish + Offset into the SDP record in which to place the actual channel. + It is recommended that you use the alternative constructor which takes just a service guid for your custom profile implementations. + + + + Initializes a new instance of the class. + + A that represents the local Bluetooth radio address. + The Bluetooth service to listen for. + Prepared SDP Record to publish + Offset into the SDP record in which to place the actual channel. + It is recommended that you use the alternative constructor which takes just a service guid for your custom profile implementations. + + + + Starts the socket to listen for incoming connections. + + + + + Stops the socket from monitoring connections. + + + + + Creates a new socket for a connection. + + AcceptSocket is a blocking method that returns a that you can use to send and receive data. + If you want to avoid blocking, use the method to determine if connection requests are available in the incoming connection queue. + The returned is initialized with the address and channel number of the remote device. + You can use any of the Send and Receive methods available in the class to communicate with the remote device. + When you are finished using the , be sure to call its method. + If your application is relatively simple, consider using the method rather than the AcceptSocket method. + provides you with simple methods for sending and receiving data over a network in blocking synchronous mode. + A used to send and receive data. + Listener is stopped. + + + + Creates a client object for a connection when the specified service or endpoint is detected by the listener component. + + AcceptTcpClient is a blocking method that returns a that you can use to send and receive data. + Use the method to determine if connection requests are available in the incoming connection queue if you want to avoid blocking. + Use the method to obtain the underlying of the returned . + The will provide you with methods for sending and receiving with the remote host. + When you are through with the , be sure to call its method. + If you want greater flexibility than a offers, consider using . + A component. + Listener is stopped. + + + + Determines if there is a connection pending. + + true if there is a connection pending; otherwise, false. + + + + Gets the underlying of the current . + + + + + Get or set class of device flags which this service adds to the host device. + + + + + Gets the underlying network . + + The underlying . + creates a to listen for incoming client connection requests. + Classes deriving from can use this property to get this . + Use the underlying returned by the property if you require access beyond that which provides. + Note property only returns the used to listen for incoming client connection requests. + Use the method to accept a pending connection request and obtain a for sending and receiving data. + You can also use the method to accept a pending connection request and obtain a for sending and receiving data. + + + + Specifies additional addressing schemes that an instance of the class can use. + + + + + Bluetooth address. + + 32 + + + + IrDA address used on some Windows CE platforms (Has a different value to AddressFamily.IrDA). + + 22 + + + + Provides a simple, programmatically controlled OBEX protocol listener. + + + + + Initializes a new instance of the ObexListener class using the Bluetooth transport. + + + + + Initializes a new instance of the ObexListener class specifiying the transport to use. + + + + + Allows this instance to receive incoming requests. + + + + + Causes this instance to stop receiving incoming requests. + + + + + Shuts down the ObexListener. + + + + + Waits for an incoming request and returns when one is received. + + + + + + Gets a value that indicates whether the has been started. + + + + + Standard IrDA service names. + + + + + + + + + + + + + + + + + + + + Represents a Bluetooth device address. + + + + + + + + + + + + + + + + + + + + + + + + + Initializes a new instance of the class with the specified address. + + representation of the address. + + + + Initializes a new instance of the class with the specified address. + + Address as 6 byte array. + address passed was not a 6 byte array. + + + + Determines whether a string is a valid Bluetooth address. + + The string to validate. + The version of the string. + true if bluetoothString is a valid Bluetooth address; otherwise, false. + + + + Converts the string representation of a Bluetooth address to a new instance. + + A string containing an address to convert. + New instance. + Address must be specified in hex format optionally separated by the colon or period character e.g. 000000000000, 00:00:00:00:00:00 or 00.00.00.00.00.00. + + + + Returns the internal byte array. + + + + + + Returns the Bluetooth address as a long integer. + + + + + + Compares two instances for equality. + + + + + + + Returns the hash code for this instance. + + + + + + Returns an indication whether the values of two specified objects are equal.New in v1.5 + + + + + + + + Returns an indication whether the values of two specified objects are not equal. + + + + + + + + Converts the address to its equivalent string representation. + + The string representation of this instance. + The default return format is without a separator character - use the other overload for ToString for more formatting options. + + + + Returns a representation of the value of this instance, according to the provided format specifier. + + A single format specifier that indicates how to format the value of this Guid. + The format parameter can be "N", "C", or "P". + If format is null or the empty string (""), "D" is used. + A representation of the value of this . + + SpecifierFormat of Return Value + N12 digits: XXXXXXXXXXXX + C12 digits separated by colons: XX:XX:XX:XX:XX:XX + P12 digits separated by periods: XX.XX.XX.XX.XX.XX + + + + + Provides a null Bluetooth address. + + + + + Significant address part. + + + + + Non-significant address part. + + + + + Provides helper methods for the class. + + + + + Indicates whether the specified String object is a null reference. + + A reference. + true if the value parameter is a null reference (Nothing in Visual Basic) or an empty string (""); otherwise, false. + IsNullOrEmpty is a convenience method that enables you to simultaneously test whether a String is a null reference (Nothing in Visual Basic) or its value is . + + + + Provides a form to select an available Bluetooth device. + + + + + + + + + + + + + + + + Gets or sets the information text. + + + + + + + + + + If TRUE, invokes the Add New Device Wizard. + + Supported only on Windows XP + + + + If TRUE, forces authentication before returning. + + Supported only on Windows XP + + + + If TRUE, authenticated devices are shown in the picker. + + + + + If TRUE, remembered devices are shown in the picker. + + Supported only on Windows XP. + + + + If TRUE, unknown devices are shown in the picker. + + + + + If TRUE, skips the Services page in the Add New Device Wizard. + + Supported only on Windows XP + + + + Represents an individual SDP record. + + + + + Creates a new instance from the raw SDP record bytes. + + SDP record. + + + + Returns the record bytes. + + + + + diff --git a/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/obj/Debug/IRChat_Desktop_CS.Form1.resources b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/obj/Debug/IRChat_Desktop_CS.Form1.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/obj/Debug/IRChat_Desktop_CS.Form1.resources differ diff --git a/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/obj/Debug/IRChat_Desktop_CS.Properties.Resources.resources b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/obj/Debug/IRChat_Desktop_CS.Properties.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/obj/Debug/IRChat_Desktop_CS.Properties.Resources.resources differ diff --git a/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/obj/Debug/IRChat_Desktop_CS.csproj.GenerateResource.Cache b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/obj/Debug/IRChat_Desktop_CS.csproj.GenerateResource.Cache new file mode 100644 index 0000000..d233e04 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/obj/Debug/IRChat_Desktop_CS.csproj.GenerateResource.Cache differ diff --git a/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/obj/Debug/IRChat_Desktop_CS.exe b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/obj/Debug/IRChat_Desktop_CS.exe new file mode 100644 index 0000000..e60a9e0 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/obj/Debug/IRChat_Desktop_CS.exe differ diff --git a/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/obj/Debug/IRChat_Desktop_CS.pdb b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/obj/Debug/IRChat_Desktop_CS.pdb new file mode 100644 index 0000000..8c40460 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/obj/Debug/IRChat_Desktop_CS.pdb differ diff --git a/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/obj/Debug/ResolveAssemblyReference.cache b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/obj/Debug/ResolveAssemblyReference.cache new file mode 100644 index 0000000..a6fe704 Binary files /dev/null and b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/obj/Debug/ResolveAssemblyReference.cache differ diff --git a/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/obj/IRChat_Desktop_CS.csproj.FileList.txt b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/obj/IRChat_Desktop_CS.csproj.FileList.txt new file mode 100644 index 0000000..249bcb5 --- /dev/null +++ b/Chapter04(Infrared)/IRChat_Desktop_CS/IRChat_Desktop_CS/obj/IRChat_Desktop_CS.csproj.FileList.txt @@ -0,0 +1,10 @@ +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\IRChat_Desktop_CS.Form1.resources +obj\Debug\IRChat_Desktop_CS.Properties.Resources.resources +obj\Debug\IRChat_Desktop_CS.csproj.GenerateResource.Cache +bin\Debug\IRChat_Desktop_CS.exe +bin\Debug\IRChat_Desktop_CS.pdb +bin\Debug\InTheHand.Net.Personal.dll +bin\Debug\InTheHand.Net.Personal.xml +obj\Debug\IRChat_Desktop_CS.exe +obj\Debug\IRChat_Desktop_CS.pdb diff --git a/Chapter05(RFID)/Attendance_Parallax/Attendance.sln b/Chapter05(RFID)/Attendance_Parallax/Attendance.sln new file mode 100644 index 0000000..740cc63 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax/Attendance.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Attendance", "Attendance.vbproj", "{D86B83B8-5886-4CB1-BCAA-6DD95D8337D7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D86B83B8-5886-4CB1-BCAA-6DD95D8337D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D86B83B8-5886-4CB1-BCAA-6DD95D8337D7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D86B83B8-5886-4CB1-BCAA-6DD95D8337D7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D86B83B8-5886-4CB1-BCAA-6DD95D8337D7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter05(RFID)/Attendance_Parallax/Attendance.suo b/Chapter05(RFID)/Attendance_Parallax/Attendance.suo new file mode 100644 index 0000000..6415ccc Binary files /dev/null and b/Chapter05(RFID)/Attendance_Parallax/Attendance.suo differ diff --git a/Chapter05(RFID)/Attendance_Parallax/Attendance.vbproj b/Chapter05(RFID)/Attendance_Parallax/Attendance.vbproj new file mode 100644 index 0000000..535ff0f --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax/Attendance.vbproj @@ -0,0 +1,123 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {D86B83B8-5886-4CB1-BCAA-6DD95D8337D7} + WinExe + Attendance.My.MyApplication + Attendance + Attendance + WindowsForms + + + true + full + true + true + bin\Debug\ + Attendance.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + Attendance.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + + + + + + + + + + + + + Form + + + Form1.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + True + True + NorthwindDataSet.xsd + + + + + Designer + Form1.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + NorthwindDataSet.xsd + + + MSDataSetGenerator + NorthwindDataSet.Designer.vb + Designer + + + NorthwindDataSet.xsd + + + + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Parallax/Attendance.vbproj.user b/Chapter05(RFID)/Attendance_Parallax/Attendance.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax/Attendance.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Parallax/Form1.Designer.vb b/Chapter05(RFID)/Attendance_Parallax/Form1.Designer.vb new file mode 100644 index 0000000..6375231 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax/Form1.Designer.vb @@ -0,0 +1,472 @@ + _ +Partial Class Form1 + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.components = New System.ComponentModel.Container + Dim EmployeeIDLabel As System.Windows.Forms.Label + Dim LastNameLabel As System.Windows.Forms.Label + Dim FirstNameLabel As System.Windows.Forms.Label + Dim TitleLabel As System.Windows.Forms.Label + Dim PhotoLabel As System.Windows.Forms.Label + Dim TagIDLabel As System.Windows.Forms.Label + Dim Label2 As System.Windows.Forms.Label + Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1)) + Me.GroupBox1 = New System.Windows.Forms.GroupBox + Me.btnDeassign = New System.Windows.Forms.Button + Me.txtEmployeeID = New System.Windows.Forms.TextBox + Me.btnFind = New System.Windows.Forms.Button + Me.btnAssign = New System.Windows.Forms.Button + Me.txtTagID = New System.Windows.Forms.TextBox + Me.Label1 = New System.Windows.Forms.Label + Me.NorthwindDataSet = New Attendance.NorthwindDataSet + Me.EmployeesBindingSource = New System.Windows.Forms.BindingSource(Me.components) + Me.EmployeesTableAdapter = New Attendance.NorthwindDataSetTableAdapters.EmployeesTableAdapter + Me.EmployeesBindingNavigator = New System.Windows.Forms.BindingNavigator(Me.components) + Me.BindingNavigatorAddNewItem = New System.Windows.Forms.ToolStripButton + Me.BindingNavigatorCountItem = New System.Windows.Forms.ToolStripLabel + Me.BindingNavigatorDeleteItem = New System.Windows.Forms.ToolStripButton + Me.BindingNavigatorMoveFirstItem = New System.Windows.Forms.ToolStripButton + Me.BindingNavigatorMovePreviousItem = New System.Windows.Forms.ToolStripButton + Me.BindingNavigatorSeparator = New System.Windows.Forms.ToolStripSeparator + Me.BindingNavigatorPositionItem = New System.Windows.Forms.ToolStripTextBox + Me.BindingNavigatorSeparator1 = New System.Windows.Forms.ToolStripSeparator + Me.BindingNavigatorMoveNextItem = New System.Windows.Forms.ToolStripButton + Me.BindingNavigatorMoveLastItem = New System.Windows.Forms.ToolStripButton + Me.BindingNavigatorSeparator2 = New System.Windows.Forms.ToolStripSeparator + Me.EmployeesBindingNavigatorSaveItem = New System.Windows.Forms.ToolStripButton + Me.EmployeeIDLabel1 = New System.Windows.Forms.Label + Me.LastNameTextBox = New System.Windows.Forms.TextBox + Me.FirstNameTextBox = New System.Windows.Forms.TextBox + Me.TitleTextBox = New System.Windows.Forms.TextBox + Me.PhotoPictureBox = New System.Windows.Forms.PictureBox + Me.TagIDLabel1 = New System.Windows.Forms.Label + Me.StatusStrip1 = New System.Windows.Forms.StatusStrip + Me.ToolStripStatusLabel1 = New System.Windows.Forms.ToolStripStatusLabel + Me.Timer1 = New System.Windows.Forms.Timer(Me.components) + EmployeeIDLabel = New System.Windows.Forms.Label + LastNameLabel = New System.Windows.Forms.Label + FirstNameLabel = New System.Windows.Forms.Label + TitleLabel = New System.Windows.Forms.Label + PhotoLabel = New System.Windows.Forms.Label + TagIDLabel = New System.Windows.Forms.Label + Label2 = New System.Windows.Forms.Label + Me.GroupBox1.SuspendLayout() + CType(Me.NorthwindDataSet, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.EmployeesBindingSource, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.EmployeesBindingNavigator, System.ComponentModel.ISupportInitialize).BeginInit() + Me.EmployeesBindingNavigator.SuspendLayout() + CType(Me.PhotoPictureBox, System.ComponentModel.ISupportInitialize).BeginInit() + Me.StatusStrip1.SuspendLayout() + Me.SuspendLayout() + ' + 'EmployeeIDLabel + ' + EmployeeIDLabel.AutoSize = True + EmployeeIDLabel.Location = New System.Drawing.Point(10, 58) + EmployeeIDLabel.Name = "EmployeeIDLabel" + EmployeeIDLabel.Size = New System.Drawing.Size(70, 13) + EmployeeIDLabel.TabIndex = 12 + EmployeeIDLabel.Text = "Employee ID:" + ' + 'LastNameLabel + ' + LastNameLabel.AutoSize = True + LastNameLabel.Location = New System.Drawing.Point(10, 81) + LastNameLabel.Name = "LastNameLabel" + LastNameLabel.Size = New System.Drawing.Size(61, 13) + LastNameLabel.TabIndex = 14 + LastNameLabel.Text = "Last Name:" + ' + 'FirstNameLabel + ' + FirstNameLabel.AutoSize = True + FirstNameLabel.Location = New System.Drawing.Point(10, 107) + FirstNameLabel.Name = "FirstNameLabel" + FirstNameLabel.Size = New System.Drawing.Size(60, 13) + FirstNameLabel.TabIndex = 16 + FirstNameLabel.Text = "First Name:" + ' + 'TitleLabel + ' + TitleLabel.AutoSize = True + TitleLabel.Location = New System.Drawing.Point(10, 133) + TitleLabel.Name = "TitleLabel" + TitleLabel.Size = New System.Drawing.Size(30, 13) + TitleLabel.TabIndex = 18 + TitleLabel.Text = "Title:" + ' + 'PhotoLabel + ' + PhotoLabel.AutoSize = True + PhotoLabel.Location = New System.Drawing.Point(10, 156) + PhotoLabel.Name = "PhotoLabel" + PhotoLabel.Size = New System.Drawing.Size(38, 13) + PhotoLabel.TabIndex = 20 + PhotoLabel.Text = "Photo:" + ' + 'TagIDLabel + ' + TagIDLabel.AutoSize = True + TagIDLabel.Location = New System.Drawing.Point(10, 35) + TagIDLabel.Name = "TagIDLabel" + TagIDLabel.Size = New System.Drawing.Size(43, 13) + TagIDLabel.TabIndex = 22 + TagIDLabel.Text = "Tag ID:" + ' + 'Label2 + ' + Label2.AutoSize = True + Label2.Location = New System.Drawing.Point(5, 104) + Label2.Name = "Label2" + Label2.Size = New System.Drawing.Size(139, 13) + Label2.TabIndex = 13 + Label2.Text = "Search for Employee (by ID)" + ' + 'GroupBox1 + ' + Me.GroupBox1.Controls.Add(Me.btnDeassign) + Me.GroupBox1.Controls.Add(Me.txtEmployeeID) + Me.GroupBox1.Controls.Add(Me.btnFind) + Me.GroupBox1.Controls.Add(Label2) + Me.GroupBox1.Controls.Add(Me.btnAssign) + Me.GroupBox1.Controls.Add(Me.txtTagID) + Me.GroupBox1.Controls.Add(Me.Label1) + Me.GroupBox1.Location = New System.Drawing.Point(224, 34) + Me.GroupBox1.Name = "GroupBox1" + Me.GroupBox1.Size = New System.Drawing.Size(176, 232) + Me.GroupBox1.TabIndex = 11 + Me.GroupBox1.TabStop = False + Me.GroupBox1.Text = "Administrator" + ' + 'btnDeassign + ' + Me.btnDeassign.Location = New System.Drawing.Point(5, 189) + Me.btnDeassign.Name = "btnDeassign" + Me.btnDeassign.Size = New System.Drawing.Size(163, 37) + Me.btnDeassign.TabIndex = 19 + Me.btnDeassign.Text = "Deassign Tag from Employee" + Me.btnDeassign.UseVisualStyleBackColor = True + ' + 'txtEmployeeID + ' + Me.txtEmployeeID.Location = New System.Drawing.Point(5, 120) + Me.txtEmployeeID.Name = "txtEmployeeID" + Me.txtEmployeeID.Size = New System.Drawing.Size(103, 20) + Me.txtEmployeeID.TabIndex = 18 + ' + 'btnFind + ' + Me.btnFind.Location = New System.Drawing.Point(114, 118) + Me.btnFind.Name = "btnFind" + Me.btnFind.Size = New System.Drawing.Size(54, 23) + Me.btnFind.TabIndex = 17 + Me.btnFind.Text = "Find" + Me.btnFind.UseVisualStyleBackColor = True + ' + 'btnAssign + ' + Me.btnAssign.Location = New System.Drawing.Point(5, 146) + Me.btnAssign.Name = "btnAssign" + Me.btnAssign.Size = New System.Drawing.Size(163, 37) + Me.btnAssign.TabIndex = 3 + Me.btnAssign.Text = "Assign Tag to Employee" + Me.btnAssign.UseVisualStyleBackColor = True + ' + 'txtTagID + ' + Me.txtTagID.Location = New System.Drawing.Point(6, 32) + Me.txtTagID.Multiline = True + Me.txtTagID.Name = "txtTagID" + Me.txtTagID.ReadOnly = True + Me.txtTagID.Size = New System.Drawing.Size(162, 20) + Me.txtTagID.TabIndex = 2 + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(3, 16) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(40, 13) + Me.Label1.TabIndex = 1 + Me.Label1.Text = "Tag ID" + ' + 'NorthwindDataSet + ' + Me.NorthwindDataSet.DataSetName = "NorthwindDataSet" + Me.NorthwindDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema + ' + 'EmployeesBindingSource + ' + Me.EmployeesBindingSource.DataMember = "Employees" + Me.EmployeesBindingSource.DataSource = Me.NorthwindDataSet + ' + 'EmployeesTableAdapter + ' + Me.EmployeesTableAdapter.ClearBeforeFill = True + ' + 'EmployeesBindingNavigator + ' + Me.EmployeesBindingNavigator.AddNewItem = Me.BindingNavigatorAddNewItem + Me.EmployeesBindingNavigator.BindingSource = Me.EmployeesBindingSource + Me.EmployeesBindingNavigator.CountItem = Me.BindingNavigatorCountItem + Me.EmployeesBindingNavigator.DeleteItem = Me.BindingNavigatorDeleteItem + Me.EmployeesBindingNavigator.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.BindingNavigatorMoveFirstItem, Me.BindingNavigatorMovePreviousItem, Me.BindingNavigatorSeparator, Me.BindingNavigatorPositionItem, Me.BindingNavigatorCountItem, Me.BindingNavigatorSeparator1, Me.BindingNavigatorMoveNextItem, Me.BindingNavigatorMoveLastItem, Me.BindingNavigatorSeparator2, Me.BindingNavigatorAddNewItem, Me.BindingNavigatorDeleteItem, Me.EmployeesBindingNavigatorSaveItem}) + Me.EmployeesBindingNavigator.Location = New System.Drawing.Point(0, 0) + Me.EmployeesBindingNavigator.MoveFirstItem = Me.BindingNavigatorMoveFirstItem + Me.EmployeesBindingNavigator.MoveLastItem = Me.BindingNavigatorMoveLastItem + Me.EmployeesBindingNavigator.MoveNextItem = Me.BindingNavigatorMoveNextItem + Me.EmployeesBindingNavigator.MovePreviousItem = Me.BindingNavigatorMovePreviousItem + Me.EmployeesBindingNavigator.Name = "EmployeesBindingNavigator" + Me.EmployeesBindingNavigator.PositionItem = Me.BindingNavigatorPositionItem + Me.EmployeesBindingNavigator.Size = New System.Drawing.Size(412, 25) + Me.EmployeesBindingNavigator.TabIndex = 12 + Me.EmployeesBindingNavigator.Text = "BindingNavigator1" + ' + 'BindingNavigatorAddNewItem + ' + Me.BindingNavigatorAddNewItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.BindingNavigatorAddNewItem.Image = CType(resources.GetObject("BindingNavigatorAddNewItem.Image"), System.Drawing.Image) + Me.BindingNavigatorAddNewItem.Name = "BindingNavigatorAddNewItem" + Me.BindingNavigatorAddNewItem.RightToLeftAutoMirrorImage = True + Me.BindingNavigatorAddNewItem.Size = New System.Drawing.Size(23, 22) + Me.BindingNavigatorAddNewItem.Text = "Add new" + ' + 'BindingNavigatorCountItem + ' + Me.BindingNavigatorCountItem.Name = "BindingNavigatorCountItem" + Me.BindingNavigatorCountItem.Size = New System.Drawing.Size(36, 22) + Me.BindingNavigatorCountItem.Text = "of {0}" + Me.BindingNavigatorCountItem.ToolTipText = "Total number of items" + ' + 'BindingNavigatorDeleteItem + ' + Me.BindingNavigatorDeleteItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.BindingNavigatorDeleteItem.Image = CType(resources.GetObject("BindingNavigatorDeleteItem.Image"), System.Drawing.Image) + Me.BindingNavigatorDeleteItem.Name = "BindingNavigatorDeleteItem" + Me.BindingNavigatorDeleteItem.RightToLeftAutoMirrorImage = True + Me.BindingNavigatorDeleteItem.Size = New System.Drawing.Size(23, 22) + Me.BindingNavigatorDeleteItem.Text = "Delete" + ' + 'BindingNavigatorMoveFirstItem + ' + Me.BindingNavigatorMoveFirstItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.BindingNavigatorMoveFirstItem.Image = CType(resources.GetObject("BindingNavigatorMoveFirstItem.Image"), System.Drawing.Image) + Me.BindingNavigatorMoveFirstItem.Name = "BindingNavigatorMoveFirstItem" + Me.BindingNavigatorMoveFirstItem.RightToLeftAutoMirrorImage = True + Me.BindingNavigatorMoveFirstItem.Size = New System.Drawing.Size(23, 22) + Me.BindingNavigatorMoveFirstItem.Text = "Move first" + ' + 'BindingNavigatorMovePreviousItem + ' + Me.BindingNavigatorMovePreviousItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.BindingNavigatorMovePreviousItem.Image = CType(resources.GetObject("BindingNavigatorMovePreviousItem.Image"), System.Drawing.Image) + Me.BindingNavigatorMovePreviousItem.Name = "BindingNavigatorMovePreviousItem" + Me.BindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = True + Me.BindingNavigatorMovePreviousItem.Size = New System.Drawing.Size(23, 22) + Me.BindingNavigatorMovePreviousItem.Text = "Move previous" + ' + 'BindingNavigatorSeparator + ' + Me.BindingNavigatorSeparator.Name = "BindingNavigatorSeparator" + Me.BindingNavigatorSeparator.Size = New System.Drawing.Size(6, 25) + ' + 'BindingNavigatorPositionItem + ' + Me.BindingNavigatorPositionItem.AccessibleName = "Position" + Me.BindingNavigatorPositionItem.AutoSize = False + Me.BindingNavigatorPositionItem.Name = "BindingNavigatorPositionItem" + Me.BindingNavigatorPositionItem.Size = New System.Drawing.Size(50, 21) + Me.BindingNavigatorPositionItem.Text = "0" + Me.BindingNavigatorPositionItem.ToolTipText = "Current position" + ' + 'BindingNavigatorSeparator1 + ' + Me.BindingNavigatorSeparator1.Name = "BindingNavigatorSeparator1" + Me.BindingNavigatorSeparator1.Size = New System.Drawing.Size(6, 25) + ' + 'BindingNavigatorMoveNextItem + ' + Me.BindingNavigatorMoveNextItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.BindingNavigatorMoveNextItem.Image = CType(resources.GetObject("BindingNavigatorMoveNextItem.Image"), System.Drawing.Image) + Me.BindingNavigatorMoveNextItem.Name = "BindingNavigatorMoveNextItem" + Me.BindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = True + Me.BindingNavigatorMoveNextItem.Size = New System.Drawing.Size(23, 22) + Me.BindingNavigatorMoveNextItem.Text = "Move next" + ' + 'BindingNavigatorMoveLastItem + ' + Me.BindingNavigatorMoveLastItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.BindingNavigatorMoveLastItem.Image = CType(resources.GetObject("BindingNavigatorMoveLastItem.Image"), System.Drawing.Image) + Me.BindingNavigatorMoveLastItem.Name = "BindingNavigatorMoveLastItem" + Me.BindingNavigatorMoveLastItem.RightToLeftAutoMirrorImage = True + Me.BindingNavigatorMoveLastItem.Size = New System.Drawing.Size(23, 22) + Me.BindingNavigatorMoveLastItem.Text = "Move last" + ' + 'BindingNavigatorSeparator2 + ' + Me.BindingNavigatorSeparator2.Name = "BindingNavigatorSeparator2" + Me.BindingNavigatorSeparator2.Size = New System.Drawing.Size(6, 25) + ' + 'EmployeesBindingNavigatorSaveItem + ' + Me.EmployeesBindingNavigatorSaveItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.EmployeesBindingNavigatorSaveItem.Image = CType(resources.GetObject("EmployeesBindingNavigatorSaveItem.Image"), System.Drawing.Image) + Me.EmployeesBindingNavigatorSaveItem.Name = "EmployeesBindingNavigatorSaveItem" + Me.EmployeesBindingNavigatorSaveItem.Size = New System.Drawing.Size(23, 22) + Me.EmployeesBindingNavigatorSaveItem.Text = "Save Data" + ' + 'EmployeeIDLabel1 + ' + Me.EmployeeIDLabel1.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.EmployeesBindingSource, "EmployeeID", True)) + Me.EmployeeIDLabel1.Location = New System.Drawing.Point(86, 58) + Me.EmployeeIDLabel1.Name = "EmployeeIDLabel1" + Me.EmployeeIDLabel1.Size = New System.Drawing.Size(124, 13) + Me.EmployeeIDLabel1.TabIndex = 13 + ' + 'LastNameTextBox + ' + Me.LastNameTextBox.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.EmployeesBindingSource, "LastName", True)) + Me.LastNameTextBox.Location = New System.Drawing.Point(86, 78) + Me.LastNameTextBox.Name = "LastNameTextBox" + Me.LastNameTextBox.Size = New System.Drawing.Size(124, 20) + Me.LastNameTextBox.TabIndex = 15 + ' + 'FirstNameTextBox + ' + Me.FirstNameTextBox.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.EmployeesBindingSource, "FirstName", True)) + Me.FirstNameTextBox.Location = New System.Drawing.Point(86, 104) + Me.FirstNameTextBox.Name = "FirstNameTextBox" + Me.FirstNameTextBox.Size = New System.Drawing.Size(124, 20) + Me.FirstNameTextBox.TabIndex = 17 + ' + 'TitleTextBox + ' + Me.TitleTextBox.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.EmployeesBindingSource, "Title", True)) + Me.TitleTextBox.Location = New System.Drawing.Point(86, 130) + Me.TitleTextBox.Name = "TitleTextBox" + Me.TitleTextBox.Size = New System.Drawing.Size(124, 20) + Me.TitleTextBox.TabIndex = 19 + ' + 'PhotoPictureBox + ' + Me.PhotoPictureBox.DataBindings.Add(New System.Windows.Forms.Binding("Image", Me.EmployeesBindingSource, "Photo", True)) + Me.PhotoPictureBox.Location = New System.Drawing.Point(86, 156) + Me.PhotoPictureBox.Name = "PhotoPictureBox" + Me.PhotoPictureBox.Size = New System.Drawing.Size(95, 110) + Me.PhotoPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage + Me.PhotoPictureBox.TabIndex = 21 + Me.PhotoPictureBox.TabStop = False + ' + 'TagIDLabel1 + ' + Me.TagIDLabel1.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.EmployeesBindingSource, "TagID", True)) + Me.TagIDLabel1.Location = New System.Drawing.Point(86, 35) + Me.TagIDLabel1.Name = "TagIDLabel1" + Me.TagIDLabel1.Size = New System.Drawing.Size(124, 13) + Me.TagIDLabel1.TabIndex = 23 + ' + 'StatusStrip1 + ' + Me.StatusStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripStatusLabel1}) + Me.StatusStrip1.Location = New System.Drawing.Point(0, 277) + Me.StatusStrip1.Name = "StatusStrip1" + Me.StatusStrip1.Size = New System.Drawing.Size(412, 22) + Me.StatusStrip1.TabIndex = 24 + Me.StatusStrip1.Text = "StatusStrip1" + ' + 'ToolStripStatusLabel1 + ' + Me.ToolStripStatusLabel1.Name = "ToolStripStatusLabel1" + Me.ToolStripStatusLabel1.Size = New System.Drawing.Size(111, 17) + Me.ToolStripStatusLabel1.Text = "ToolStripStatusLabel1" + ' + 'Timer1 + ' + ' + 'Form1 + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(412, 299) + Me.Controls.Add(Me.StatusStrip1) + Me.Controls.Add(EmployeeIDLabel) + Me.Controls.Add(Me.EmployeeIDLabel1) + Me.Controls.Add(LastNameLabel) + Me.Controls.Add(Me.LastNameTextBox) + Me.Controls.Add(FirstNameLabel) + Me.Controls.Add(Me.FirstNameTextBox) + Me.Controls.Add(TitleLabel) + Me.Controls.Add(Me.TitleTextBox) + Me.Controls.Add(PhotoLabel) + Me.Controls.Add(Me.PhotoPictureBox) + Me.Controls.Add(TagIDLabel) + Me.Controls.Add(Me.TagIDLabel1) + Me.Controls.Add(Me.EmployeesBindingNavigator) + Me.Controls.Add(Me.GroupBox1) + Me.Name = "Form1" + Me.Text = "Attendance System" + Me.GroupBox1.ResumeLayout(False) + Me.GroupBox1.PerformLayout() + CType(Me.NorthwindDataSet, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.EmployeesBindingSource, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.EmployeesBindingNavigator, System.ComponentModel.ISupportInitialize).EndInit() + Me.EmployeesBindingNavigator.ResumeLayout(False) + Me.EmployeesBindingNavigator.PerformLayout() + CType(Me.PhotoPictureBox, System.ComponentModel.ISupportInitialize).EndInit() + Me.StatusStrip1.ResumeLayout(False) + Me.StatusStrip1.PerformLayout() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox + Friend WithEvents btnAssign As System.Windows.Forms.Button + Friend WithEvents txtTagID As System.Windows.Forms.TextBox + Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents NorthwindDataSet As Attendance.NorthwindDataSet + Friend WithEvents EmployeesBindingSource As System.Windows.Forms.BindingSource + Friend WithEvents EmployeesTableAdapter As Attendance.NorthwindDataSetTableAdapters.EmployeesTableAdapter + Friend WithEvents EmployeesBindingNavigator As System.Windows.Forms.BindingNavigator + Friend WithEvents BindingNavigatorAddNewItem As System.Windows.Forms.ToolStripButton + Friend WithEvents BindingNavigatorCountItem As System.Windows.Forms.ToolStripLabel + Friend WithEvents BindingNavigatorDeleteItem As System.Windows.Forms.ToolStripButton + Friend WithEvents BindingNavigatorMoveFirstItem As System.Windows.Forms.ToolStripButton + Friend WithEvents BindingNavigatorMovePreviousItem As System.Windows.Forms.ToolStripButton + Friend WithEvents BindingNavigatorSeparator As System.Windows.Forms.ToolStripSeparator + Friend WithEvents BindingNavigatorPositionItem As System.Windows.Forms.ToolStripTextBox + Friend WithEvents BindingNavigatorSeparator1 As System.Windows.Forms.ToolStripSeparator + Friend WithEvents BindingNavigatorMoveNextItem As System.Windows.Forms.ToolStripButton + Friend WithEvents BindingNavigatorMoveLastItem As System.Windows.Forms.ToolStripButton + Friend WithEvents BindingNavigatorSeparator2 As System.Windows.Forms.ToolStripSeparator + Friend WithEvents EmployeesBindingNavigatorSaveItem As System.Windows.Forms.ToolStripButton + Friend WithEvents EmployeeIDLabel1 As System.Windows.Forms.Label + Friend WithEvents LastNameTextBox As System.Windows.Forms.TextBox + Friend WithEvents FirstNameTextBox As System.Windows.Forms.TextBox + Friend WithEvents TitleTextBox As System.Windows.Forms.TextBox + Friend WithEvents PhotoPictureBox As System.Windows.Forms.PictureBox + Friend WithEvents TagIDLabel1 As System.Windows.Forms.Label + Friend WithEvents btnFind As System.Windows.Forms.Button + Friend WithEvents txtEmployeeID As System.Windows.Forms.TextBox + Friend WithEvents btnDeassign As System.Windows.Forms.Button + Friend WithEvents StatusStrip1 As System.Windows.Forms.StatusStrip + Friend WithEvents ToolStripStatusLabel1 As System.Windows.Forms.ToolStripStatusLabel + Friend WithEvents Timer1 As System.Windows.Forms.Timer + +End Class diff --git a/Chapter05(RFID)/Attendance_Parallax/Form1.resx b/Chapter05(RFID)/Attendance_Parallax/Form1.resx new file mode 100644 index 0000000..93a07fa --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax/Form1.resx @@ -0,0 +1,245 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + 17, 17 + + + 159, 17 + + + 335, 17 + + + 506, 17 + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAU1JREFUOE9jYBi0 + 4O4C9v+35nH+vzqH6//FGbz/SXbodaDGP48a//952PD/5GQB0g04P50XbsDBHhHSDTg+SRBoe93/Pw+q + /u9oFydswKWZPP/PTuX7fxKo8Ui/0P993SJAzeX//94r+r++Qeb/qhq5/0srFf/PL1X+P6tIFdPAU0B/ + /nlYD9RUC8SV///cKwHivP9/72b+/3sn+f/f23H//92MAOKQ/5NyNDENONQrDHbu3/ulQI0FQI3ZQI2p + QI0J///digZqDPv/70bQ/3/X/f53peliGrCzXeL/lmap/+vAzpX/v6RC8f/fWzFAjeH/p+Zp/J+QpfW/ + O0P3f3uq/v/mREPCYTIb6E+Qc//dCPjfk6FDWAN6QgH5898NfyD2+9+arE+6Ad3pumD/gnB9nBHpBrQk + GfxviDf8XxNr/L8y2oR0A0hO++RqAAAkI9ieo+gjUwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAW9JREFUOE+tkk0o + w3EYx3dV3kq5uKBWDiPT8hISMiQsMiEyQ9qBg0hoFwcHUi7kgIvkQFJSTrQ4zdvmrTW1/kuT0i74x+X3 + MRal/fEnv8tz+H2fz/N8vz0azX88PG6wmcDp4E881hYR3VUIixF2Nr+FcO2DlbnPGjaWoM+M6DAiOitg + YUoR8rqhsJTBWG/kP6fOMKTegGjKh/7mTyIx0oUw58C0/XubLM8iKtPeQIx2gfcMJgbD0FBVlRE+D7QU + hS2ZshANuTDQqq75fQIHe6GVcxHV6VCr/2VzQIKmAshOQNbHc6+PhTqDOggBP5jzoDCJoLUaLo7fwr3V + hSCr8z8EeHcLbSU8FCfjLU0nuL/70cB4Py5tDLL7UBnC8xMMW6EkhRNdIsGt9QjhTXkGUnsN8rVf4Q72 + tpFzEnGlRiH1NIL8qDjJoY1DdjkVADNjSGnReI2ZIF196VW22+D8SAFw6YLJITjaV5e2qotSIXoBiiMD + HEVvQ/IAAAAASUVORK5CYII= + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAStJREFUOE9jYBg0 + oHDW8/9NC57/z5z4+D8uR4W3P8Apx5A789n/VUfe/8elKL77wf/ghmu4DciY8vT/wn0fsCqK73n4f+n+ + ///9qy/gNiCh58n/aVveYyiKaL8P1pw56/9/r9ITuA2I7Hr0v3f1BxRFoa33wJpb1wFt7/z73yX/AG4D + Apsf/q+b/w6uKLjl7v9Fe///7wBqzpjz879d3c//9hnbcRvgUXX/f/60NyiK7Ipv/0+f8/u/f9e3/zqF + 7/5bJKzHbYB96d3/2ZNfYyjSTzn/36ToxX+VrE//jSOX4TbAIu/O/9T+11gVGSSd+C+b9vW/bvA83AYY + Zt3+H9byEqci/dTL/zV8p+E2QCftxn+/6od4Fal4TMBtgFPulf8gBXgVDZqMh+wQAPB2wKsSwCgmAAAA + AElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAL1JREFUOE9jYBgy + ILz9wX+yHRvf/eB/cMM18gyI73n4f+n+///9qy+QbkBE+32w5sxZ//97lZ4gzYDQ1ntgza3rgLZ3/v3v + kn+AeAOCW+7+X7T3//8OoOaMOT//29X9/G+fsZ14A0ChbVd8+3/6nN///bu+/dcpfPffImE9aQaADNFP + Of/fpOjFf5WsT/+NI5eRbgDIEIOkE/9l077+1w2eR54BYJekXv6v4TuNfANAhqh4TKDMALKTMc01AgDQ + FGCYkuTLEQAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAKtJREFUOE9jYBh0 + oHDW8/8UOSp35rP/Cd33yDckY8rT//P2//6f0HWHPEMSep78n73v1//OrX//u5VeJt2QyK5H/6ds+/W/ + ZOnf/wnT//63yT1LmiGBzQ//t659D9ZsXPLlv3T0tf/GkcuIN8Sj6v7/krnv4JoVXXqI1wyKPvvSu/8D + W56BbSZZM8gAi7w7/20KrpCnGWSAYdZt8jWDDNBJu0GanylKtoNCMwCgfl+gC2KedgAAAABJRU5ErkJg + gg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAATBJREFUOE9jYBhU + oHDW8/+4HASSa1rw/H/mxMc41TDkznz2P6H7HlYFILlVR97/D29/gNuAjClP/8/b//t/QtcdDEUguYX7 + PvwPbriG24CEnif/Z+/79b9z69//bqWXURSC5KZtef/fv/oCbgMiux79n7Lt1/+SpX//J0z/+98m9yxc + MUiud/WH/16lJ3AbENj88H/r2vdgzcYlX/5LR1/7bxy5DKwBJFc3/91/l/wDuA3wqLr/v2TuO7hmRZce + uGKQXP60N//tM7bjNsC+9O7/wJZnYJuRNYNcAJLLnvz6v0XCetwGWOTd+W9TcAVDM8gAkFxq/2u4l7Cm + F8Os21g1gxSD5MJaXv7XDZ6H2wU6aTdwSoLk/Kof/tfwnYbbAHz5yin3yn8VjwlgPKjyHwMAvtG/s0Vm + x8MAAAAASUVORK5CYII= + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAilJREFUOE+tk91L + k3EUx/cvdN9N0EW3NTWGa7EaPOUcyqphWBG9PZEv5dJlmqhYmUYtXyBb4dJJy+kknFT4BqZIjaFMJUsz + V7TEoabYRDD49ju/6Pm1Mm/qB+fy8znPOef7qFT/4z17GgWVr30Zbd4lPHYvoLEhgvuOGdTWfIL9dgg3 + yqdQWjKBwoLXyMsdxYXzQSi9CeztAWqqV7HRW1ldgzGtF4fTnvBSBN7WRS6orPjyV57gyMIKdpufQ62W + YTnkEQL3o3kuKC35vK7gJ/w+vIg4kw8Fl6dxwNwkBM76WS64ZHv3h+BXeGQygm2SF9accaSmOIWg7m6Y + C7KzRmMEv8ODwTA2692Q5QBMJocQVFd95AL5TEARrAf3+D9gU2IDjhx9gaSkWiG4WTmN7i6wUwLHT76C + 5dgA3zYtjGamz6bOP+A+HLR0QpLsQnC1bBIdPrAMAE2ub+zuX1F+fY4vlRZGM2dmBBU4ObUdBkOFEFwp + HIenGXjoXGPBicKYnhNT5hM2pJ8r4p2TUxi83wO9vkwIbHljDAaq7kR5ZxJQSOK0EobezmJsag5y7jXs + NbZxWLvHBZ2uSAgolo57UD6bBASfzb+FN6F5hGaWcLHYjni9i8GNiN/1ANrEfCHIzBhmcy/zmbcaPNiy + Q0JLRz98XYPo7vNj4OUQ9pksUOvqkcDg7Zo6aDTWWMHpU/08npQwCgndmU5F26aF0czUlYrgnQnZQvAv + f/R3bGg6a0rM640AAAAASUVORK5CYII= + + + + 696, 17 + + + 808, 17 + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Parallax/Form1.vb b/Chapter05(RFID)/Attendance_Parallax/Form1.vb new file mode 100644 index 0000000..01228e6 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax/Form1.vb @@ -0,0 +1,197 @@ +Imports System.Data +Imports System.Data.SqlClient +Imports System.IO + +Public Class Form1 + '---serial port to listen to incoming data--- + Private WithEvents serialPort As New IO.Ports.SerialPort + '---tag ID read from the reader--- + Private tagID As String = String.Empty + '---the time that the tag ID was recorded--- + Private timeRecorded As DateTime = Now + + '---COM port to listen to--- + Const COM As String = "COM3" + '---file name of the log file--- + Const FILE_NAME As String = "C:\Attendance.csv" + '---the interval before the employee record is cleared + ' from the screen (in seconds)--- + Const INTERVAL As Integer = 3 + + Private Sub Form1_Load( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles MyBase.Load + + 'TODO: This line of code loads data into the + ' 'NorthwindDataSet.Employees' table. You can move, + ' or remove it, as needed. + Me.EmployeesTableAdapter.Fill(Me.NorthwindDataSet.Employees) + + '---Clear the employee when the app is loaded--- + EmployeesBindingSource.Filter = "TAGID='xxxxxxxxxx'" + '---set the timer interval to clear the employee record--- + Timer1.Interval = INTERVAL * 1000 'convert to milliseconds + + '---open the serial port connecting to the reader--- + If serialPort.IsOpen Then + serialPort.Close() + End If + Try + With serialPort + .PortName = COM + .BaudRate = 2400 + .Parity = IO.Ports.Parity.None + .DataBits = 8 + .StopBits = IO.Ports.StopBits.One + .Handshake = IO.Ports.Handshake.None + End With + serialPort.Open() + Catch ex As Exception + MsgBox(ex.ToString) + End Try + End Sub + + Private Sub EmployeesBindingNavigatorSaveItem_Click( _ + ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Handles EmployeesBindingNavigatorSaveItem.Click + Me.Validate() + Me.EmployeesBindingSource.EndEdit() + Me.EmployeesTableAdapter.Update(Me.NorthwindDataSet.Employees) + '------------------------------------------------------------- + End Sub + + Private Sub DataReceived( _ + ByVal sender As Object, _ + ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) _ + Handles serialPort.DataReceived + + '---when incoming data is received, update the TagID textbox--- + txtTagID.BeginInvoke(New _ + myDelegate(AddressOf updateTextBox), _ + New Object() {}) + End Sub + + '---update the Tag ID textbox--- + Public Delegate Sub myDelegate() + Public Sub updateTextBox() + '---for receiving plain ASCII text--- + With txtTagID + .AppendText(serialPort.ReadExisting) + .ScrollToCaret() + End With + End Sub + + Private Sub btnAssign_Click( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles btnAssign.Click + '---obtain the tag ID that was read--- + If txtTagID.Lines.Length > 1 Then + Dim tagID As String = txtTagID.Lines(txtTagID.Lines.Length - 2) + Else + ToolStripStatusLabel1.Text = "No tag id scanned." + Exit Sub + End If + + If txtTagID.Text <> String.Empty Then + '---assign the Tag ID to the current employee--- + TagIDLabel1.Text = tagID + ToolStripStatusLabel1.Text = "Tag associated with employee." + '---save the record--- + Me.Validate() + Me.EmployeesBindingSource.EndEdit() + Me.EmployeesTableAdapter.Update(Me.NorthwindDataSet.Employees) + End If + End Sub + + Private Sub txtTagID_TextChanged( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles txtTagID.TextChanged + + If txtTagID.Lines(txtTagID.Lines.Length - 1) = String.Empty Then + '---get the tag ID that is read--- + Dim temptagID As String = txtTagID.Lines(txtTagID.Lines.Length - 2) + + '---get the time interval between the last read time + ' and the current time--- + Dim tp As TimeSpan = Now.Subtract(timeRecorded) + Dim timeInterval As Double = tp.Ticks / TimeSpan.TicksPerSecond + + If (temptagID = tagID) And timeInterval < INTERVAL Then + '---if it is the same tag and the time interval + ' is less than 3 seconds, the tag won't be registered--- + Exit Sub + End If + + '---the tag is saved--- + tagID = temptagID + EmployeesBindingSource.RemoveFilter() + + '---find the employee associated with the tag--- + EmployeesBindingSource.Filter = "TAGID='" & tagID & "'" + If EmployeesBindingSource.Count < 1 Then + ToolStripStatusLabel1.Text = "Employee not found." + Else + ToolStripStatusLabel1.Text = "Employee found." + '---write the employee information to log file--- + WriteToLog(EmployeeIDLabel1.Text, _ + LastNameTextBox.Text & ", " & FirstNameTextBox.Text) + '---reset the timer--- + Timer1.Enabled = False + Timer1.Enabled = True + End If + '---save the time this tag was recorded--- + timeRecorded = Now + End If + End Sub + + Private Sub btnFind_Click( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles btnFind.Click + '---search for employee--- + If txtEmployeeID.Text = String.Empty Then + EmployeesBindingSource.RemoveFilter() + Else + EmployeesBindingSource.Filter = _ + "EmployeeID='" & txtEmployeeID.Text & "'" + End If + End Sub + + Private Sub btnDeassign_Click( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles btnDeassign.Click + + If Trim(TagIDLabel1.Text) = String.Empty Then + ToolStripStatusLabel1.Text = "Current employee has no tag ID." + Exit Sub + End If + '---deassociate tag ID from employee--- + TagIDLabel1.Text = String.Empty + '---save the record--- + Me.Validate() + Me.EmployeesBindingSource.EndEdit() + Me.EmployeesTableAdapter.Update(Me.NorthwindDataSet.Employees) + ToolStripStatusLabel1.Text = "Tag deassociated from employee." + End Sub + + Private Sub WriteToLog( _ + ByVal employeeID As String, _ + ByVal employeeName As String) + '---write to log file--- + Dim str As String = employeeID & "," & _ + employeeName & "," & Now & Chr(13) + My.Computer.FileSystem.WriteAllText(FILE_NAME, str, True) + End Sub + + Private Sub Timer1_Tick( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles Timer1.Tick + '---clear the employee--- + EmployeesBindingSource.Filter = "TAGID='xxxxxxxxxx'" + Timer1.Enabled = False + End Sub +End Class diff --git a/Chapter05(RFID)/Attendance_Parallax/My Project/Application.Designer.vb b/Chapter05(RFID)/Attendance_Parallax/My Project/Application.Designer.vb new file mode 100644 index 0000000..f55b41e --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + 'NOTE: This file is auto-generated; do not modify it directly. To make changes, + ' or if you encounter build errors in this file, go to the Project Designer + ' (go to Project Properties or double-click the My Project node in + ' Solution Explorer), and make changes on the Application tab. + ' + Partial Friend Class MyApplication + + _ + Public Sub New() + MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) + Me.IsSingleInstance = false + Me.EnableVisualStyles = true + Me.SaveMySettingsOnExit = true + Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses + End Sub + + _ + Protected Overrides Sub OnCreateMainForm() + Me.MainForm = Global.Attendance.Form1 + End Sub + End Class +End Namespace diff --git a/Chapter05(RFID)/Attendance_Parallax/My Project/Application.myapp b/Chapter05(RFID)/Attendance_Parallax/My Project/Application.myapp new file mode 100644 index 0000000..0f12f32 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + Form1 + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Parallax/My Project/AssemblyInfo.vb b/Chapter05(RFID)/Attendance_Parallax/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..6f0671c --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + + diff --git a/Chapter05(RFID)/Attendance_Parallax/My Project/Resources.Designer.vb b/Chapter05(RFID)/Attendance_Parallax/My Project/Resources.Designer.vb new file mode 100644 index 0000000..8aa363f --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ' + ' A strongly-typed resource class, for looking up localized strings, etc. + ' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ' + ' Returns the cached ResourceManager instance used by this class. + ' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Attendance.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ' + ' Overrides the current thread's CurrentUICulture property for all + ' resource lookups using this strongly typed resource class. + ' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Chapter05(RFID)/Attendance_Parallax/My Project/Resources.resx b/Chapter05(RFID)/Attendance_Parallax/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Parallax/My Project/Settings.Designer.vb b/Chapter05(RFID)/Attendance_Parallax/My Project/Settings.Designer.vb new file mode 100644 index 0000000..c3ec89f --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax/My Project/Settings.Designer.vb @@ -0,0 +1,83 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings),MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + + _ + Public ReadOnly Property NorthwindConnectionString() As String + Get + Return CType(Me("NorthwindConnectionString"),String) + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.Attendance.My.MySettings + Get + Return Global.Attendance.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Chapter05(RFID)/Attendance_Parallax/My Project/Settings.settings b/Chapter05(RFID)/Attendance_Parallax/My Project/Settings.settings new file mode 100644 index 0000000..52b713c --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax/My Project/Settings.settings @@ -0,0 +1,14 @@ + + + + + + <?xml version="1.0" encoding="utf-16"?> +<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <ConnectionString>Data Source=.\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True</ConnectionString> + <ProviderName>System.Data.SqlClient</ProviderName> +</SerializableConnectionString> + Data Source=.\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True + + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Parallax/NorthwindDataSet.Designer.vb b/Chapter05(RFID)/Attendance_Parallax/NorthwindDataSet.Designer.vb new file mode 100644 index 0000000..ada1df6 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax/NorthwindDataSet.Designer.vb @@ -0,0 +1,1006 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict Off +Option Explicit On + +Imports System + + + _ +Partial Public Class NorthwindDataSet + Inherits System.Data.DataSet + + Private tableEmployees As EmployeesDataTable + + Private _schemaSerializationMode As System.Data.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema + + _ + Public Sub New() + MyBase.New + Me.BeginInit + Me.InitClass + Dim schemaChangedHandler As System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged + AddHandler MyBase.Tables.CollectionChanged, schemaChangedHandler + AddHandler MyBase.Relations.CollectionChanged, schemaChangedHandler + Me.EndInit + End Sub + + _ + Protected Sub New(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext) + MyBase.New(info, context, false) + If (Me.IsBinarySerialized(info, context) = true) Then + Me.InitVars(false) + Dim schemaChangedHandler1 As System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged + AddHandler Me.Tables.CollectionChanged, schemaChangedHandler1 + AddHandler Me.Relations.CollectionChanged, schemaChangedHandler1 + Return + End If + Dim strSchema As String = CType(info.GetValue("XmlSchema", GetType(String)),String) + If (Me.DetermineSchemaSerializationMode(info, context) = System.Data.SchemaSerializationMode.IncludeSchema) Then + Dim ds As System.Data.DataSet = New System.Data.DataSet + ds.ReadXmlSchema(New System.Xml.XmlTextReader(New System.IO.StringReader(strSchema))) + If (Not (ds.Tables("Employees")) Is Nothing) Then + MyBase.Tables.Add(New EmployeesDataTable(ds.Tables("Employees"))) + End If + Me.DataSetName = ds.DataSetName + Me.Prefix = ds.Prefix + Me.Namespace = ds.Namespace + Me.Locale = ds.Locale + Me.CaseSensitive = ds.CaseSensitive + Me.EnforceConstraints = ds.EnforceConstraints + Me.Merge(ds, false, System.Data.MissingSchemaAction.Add) + Me.InitVars + Else + Me.ReadXmlSchema(New System.Xml.XmlTextReader(New System.IO.StringReader(strSchema))) + End If + Me.GetSerializationData(info, context) + Dim schemaChangedHandler As System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged + AddHandler MyBase.Tables.CollectionChanged, schemaChangedHandler + AddHandler Me.Relations.CollectionChanged, schemaChangedHandler + End Sub + + _ + Public ReadOnly Property Employees() As EmployeesDataTable + Get + Return Me.tableEmployees + End Get + End Property + + _ + Public Overrides Property SchemaSerializationMode() As System.Data.SchemaSerializationMode + Get + Return Me._schemaSerializationMode + End Get + Set + Me._schemaSerializationMode = value + End Set + End Property + + _ + Public Shadows ReadOnly Property Tables() As System.Data.DataTableCollection + Get + Return MyBase.Tables + End Get + End Property + + _ + Public Shadows ReadOnly Property Relations() As System.Data.DataRelationCollection + Get + Return MyBase.Relations + End Get + End Property + + _ + Protected Overrides Sub InitializeDerivedDataSet() + Me.BeginInit + Me.InitClass + Me.EndInit + End Sub + + _ + Public Overrides Function Clone() As System.Data.DataSet + Dim cln As NorthwindDataSet = CType(MyBase.Clone,NorthwindDataSet) + cln.InitVars + cln.SchemaSerializationMode = Me.SchemaSerializationMode + Return cln + End Function + + _ + Protected Overrides Function ShouldSerializeTables() As Boolean + Return false + End Function + + _ + Protected Overrides Function ShouldSerializeRelations() As Boolean + Return false + End Function + + _ + Protected Overrides Sub ReadXmlSerializable(ByVal reader As System.Xml.XmlReader) + If (Me.DetermineSchemaSerializationMode(reader) = System.Data.SchemaSerializationMode.IncludeSchema) Then + Me.Reset + Dim ds As System.Data.DataSet = New System.Data.DataSet + ds.ReadXml(reader) + If (Not (ds.Tables("Employees")) Is Nothing) Then + MyBase.Tables.Add(New EmployeesDataTable(ds.Tables("Employees"))) + End If + Me.DataSetName = ds.DataSetName + Me.Prefix = ds.Prefix + Me.Namespace = ds.Namespace + Me.Locale = ds.Locale + Me.CaseSensitive = ds.CaseSensitive + Me.EnforceConstraints = ds.EnforceConstraints + Me.Merge(ds, false, System.Data.MissingSchemaAction.Add) + Me.InitVars + Else + Me.ReadXml(reader) + Me.InitVars + End If + End Sub + + _ + Protected Overrides Function GetSchemaSerializable() As System.Xml.Schema.XmlSchema + Dim stream As System.IO.MemoryStream = New System.IO.MemoryStream + Me.WriteXmlSchema(New System.Xml.XmlTextWriter(stream, Nothing)) + stream.Position = 0 + Return System.Xml.Schema.XmlSchema.Read(New System.Xml.XmlTextReader(stream), Nothing) + End Function + + _ + Friend Overloads Sub InitVars() + Me.InitVars(true) + End Sub + + _ + Friend Overloads Sub InitVars(ByVal initTable As Boolean) + Me.tableEmployees = CType(MyBase.Tables("Employees"),EmployeesDataTable) + If (initTable = true) Then + If (Not (Me.tableEmployees) Is Nothing) Then + Me.tableEmployees.InitVars + End If + End If + End Sub + + _ + Private Sub InitClass() + Me.DataSetName = "NorthwindDataSet" + Me.Prefix = "" + Me.Namespace = "http://tempuri.org/NorthwindDataSet.xsd" + Me.EnforceConstraints = true + Me.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema + Me.tableEmployees = New EmployeesDataTable + MyBase.Tables.Add(Me.tableEmployees) + End Sub + + _ + Private Function ShouldSerializeEmployees() As Boolean + Return false + End Function + + _ + Private Sub SchemaChanged(ByVal sender As Object, ByVal e As System.ComponentModel.CollectionChangeEventArgs) + If (e.Action = System.ComponentModel.CollectionChangeAction.Remove) Then + Me.InitVars + End If + End Sub + + _ + Public Shared Function GetTypedDataSetSchema(ByVal xs As System.Xml.Schema.XmlSchemaSet) As System.Xml.Schema.XmlSchemaComplexType + Dim ds As NorthwindDataSet = New NorthwindDataSet + Dim type As System.Xml.Schema.XmlSchemaComplexType = New System.Xml.Schema.XmlSchemaComplexType + Dim sequence As System.Xml.Schema.XmlSchemaSequence = New System.Xml.Schema.XmlSchemaSequence + xs.Add(ds.GetSchemaSerializable) + Dim any As System.Xml.Schema.XmlSchemaAny = New System.Xml.Schema.XmlSchemaAny + any.Namespace = ds.Namespace + sequence.Items.Add(any) + type.Particle = sequence + Return type + End Function + + Public Delegate Sub EmployeesRowChangeEventHandler(ByVal sender As Object, ByVal e As EmployeesRowChangeEvent) + + _ + Partial Public Class EmployeesDataTable + Inherits System.Data.DataTable + Implements System.Collections.IEnumerable + + Private columnEmployeeID As System.Data.DataColumn + + Private columnLastName As System.Data.DataColumn + + Private columnFirstName As System.Data.DataColumn + + Private columnTitle As System.Data.DataColumn + + Private columnPhoto As System.Data.DataColumn + + Private columnTagID As System.Data.DataColumn + + _ + Public Sub New() + MyBase.New + Me.TableName = "Employees" + Me.BeginInit + Me.InitClass + Me.EndInit + End Sub + + _ + Friend Sub New(ByVal table As System.Data.DataTable) + MyBase.New + Me.TableName = table.TableName + If (table.CaseSensitive <> table.DataSet.CaseSensitive) Then + Me.CaseSensitive = table.CaseSensitive + End If + If (table.Locale.ToString <> table.DataSet.Locale.ToString) Then + Me.Locale = table.Locale + End If + If (table.Namespace <> table.DataSet.Namespace) Then + Me.Namespace = table.Namespace + End If + Me.Prefix = table.Prefix + Me.MinimumCapacity = table.MinimumCapacity + End Sub + + _ + Protected Sub New(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext) + MyBase.New(info, context) + Me.InitVars + End Sub + + _ + Public ReadOnly Property EmployeeIDColumn() As System.Data.DataColumn + Get + Return Me.columnEmployeeID + End Get + End Property + + _ + Public ReadOnly Property LastNameColumn() As System.Data.DataColumn + Get + Return Me.columnLastName + End Get + End Property + + _ + Public ReadOnly Property FirstNameColumn() As System.Data.DataColumn + Get + Return Me.columnFirstName + End Get + End Property + + _ + Public ReadOnly Property TitleColumn() As System.Data.DataColumn + Get + Return Me.columnTitle + End Get + End Property + + _ + Public ReadOnly Property PhotoColumn() As System.Data.DataColumn + Get + Return Me.columnPhoto + End Get + End Property + + _ + Public ReadOnly Property TagIDColumn() As System.Data.DataColumn + Get + Return Me.columnTagID + End Get + End Property + + _ + Public ReadOnly Property Count() As Integer + Get + Return Me.Rows.Count + End Get + End Property + + _ + Public Default ReadOnly Property Item(ByVal index As Integer) As EmployeesRow + Get + Return CType(Me.Rows(index),EmployeesRow) + End Get + End Property + + Public Event EmployeesRowChanging As EmployeesRowChangeEventHandler + + Public Event EmployeesRowChanged As EmployeesRowChangeEventHandler + + Public Event EmployeesRowDeleting As EmployeesRowChangeEventHandler + + Public Event EmployeesRowDeleted As EmployeesRowChangeEventHandler + + _ + Public Overloads Sub AddEmployeesRow(ByVal row As EmployeesRow) + Me.Rows.Add(row) + End Sub + + _ + Public Overloads Function AddEmployeesRow(ByVal LastName As String, ByVal FirstName As String, ByVal Title As String, ByVal Photo() As Byte, ByVal TagID As String) As EmployeesRow + Dim rowEmployeesRow As EmployeesRow = CType(Me.NewRow,EmployeesRow) + rowEmployeesRow.ItemArray = New Object() {Nothing, LastName, FirstName, Title, Photo, TagID} + Me.Rows.Add(rowEmployeesRow) + Return rowEmployeesRow + End Function + + _ + Public Function FindByEmployeeID(ByVal EmployeeID As Integer) As EmployeesRow + Return CType(Me.Rows.Find(New Object() {EmployeeID}),EmployeesRow) + End Function + + _ + Public Overridable Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator + Return Me.Rows.GetEnumerator + End Function + + _ + Public Overrides Function Clone() As System.Data.DataTable + Dim cln As EmployeesDataTable = CType(MyBase.Clone,EmployeesDataTable) + cln.InitVars + Return cln + End Function + + _ + Protected Overrides Function CreateInstance() As System.Data.DataTable + Return New EmployeesDataTable + End Function + + _ + Friend Sub InitVars() + Me.columnEmployeeID = MyBase.Columns("EmployeeID") + Me.columnLastName = MyBase.Columns("LastName") + Me.columnFirstName = MyBase.Columns("FirstName") + Me.columnTitle = MyBase.Columns("Title") + Me.columnPhoto = MyBase.Columns("Photo") + Me.columnTagID = MyBase.Columns("TagID") + End Sub + + _ + Private Sub InitClass() + Me.columnEmployeeID = New System.Data.DataColumn("EmployeeID", GetType(Integer), Nothing, System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnEmployeeID) + Me.columnLastName = New System.Data.DataColumn("LastName", GetType(String), Nothing, System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnLastName) + Me.columnFirstName = New System.Data.DataColumn("FirstName", GetType(String), Nothing, System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnFirstName) + Me.columnTitle = New System.Data.DataColumn("Title", GetType(String), Nothing, System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnTitle) + Me.columnPhoto = New System.Data.DataColumn("Photo", GetType(Byte()), Nothing, System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnPhoto) + Me.columnTagID = New System.Data.DataColumn("TagID", GetType(String), Nothing, System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnTagID) + Me.Constraints.Add(New System.Data.UniqueConstraint("Constraint1", New System.Data.DataColumn() {Me.columnEmployeeID}, true)) + Me.columnEmployeeID.AutoIncrement = true + Me.columnEmployeeID.AllowDBNull = false + Me.columnEmployeeID.ReadOnly = true + Me.columnEmployeeID.Unique = true + Me.columnLastName.AllowDBNull = false + Me.columnLastName.MaxLength = 20 + Me.columnFirstName.AllowDBNull = false + Me.columnFirstName.MaxLength = 10 + Me.columnTitle.MaxLength = 30 + Me.columnTagID.MaxLength = 10 + End Sub + + _ + Public Function NewEmployeesRow() As EmployeesRow + Return CType(Me.NewRow,EmployeesRow) + End Function + + _ + Protected Overrides Function NewRowFromBuilder(ByVal builder As System.Data.DataRowBuilder) As System.Data.DataRow + Return New EmployeesRow(builder) + End Function + + _ + Protected Overrides Function GetRowType() As System.Type + Return GetType(EmployeesRow) + End Function + + _ + Protected Overrides Sub OnRowChanged(ByVal e As System.Data.DataRowChangeEventArgs) + MyBase.OnRowChanged(e) + If (Not (Me.EmployeesRowChangedEvent) Is Nothing) Then + RaiseEvent EmployeesRowChanged(Me, New EmployeesRowChangeEvent(CType(e.Row,EmployeesRow), e.Action)) + End If + End Sub + + _ + Protected Overrides Sub OnRowChanging(ByVal e As System.Data.DataRowChangeEventArgs) + MyBase.OnRowChanging(e) + If (Not (Me.EmployeesRowChangingEvent) Is Nothing) Then + RaiseEvent EmployeesRowChanging(Me, New EmployeesRowChangeEvent(CType(e.Row,EmployeesRow), e.Action)) + End If + End Sub + + _ + Protected Overrides Sub OnRowDeleted(ByVal e As System.Data.DataRowChangeEventArgs) + MyBase.OnRowDeleted(e) + If (Not (Me.EmployeesRowDeletedEvent) Is Nothing) Then + RaiseEvent EmployeesRowDeleted(Me, New EmployeesRowChangeEvent(CType(e.Row,EmployeesRow), e.Action)) + End If + End Sub + + _ + Protected Overrides Sub OnRowDeleting(ByVal e As System.Data.DataRowChangeEventArgs) + MyBase.OnRowDeleting(e) + If (Not (Me.EmployeesRowDeletingEvent) Is Nothing) Then + RaiseEvent EmployeesRowDeleting(Me, New EmployeesRowChangeEvent(CType(e.Row,EmployeesRow), e.Action)) + End If + End Sub + + _ + Public Sub RemoveEmployeesRow(ByVal row As EmployeesRow) + Me.Rows.Remove(row) + End Sub + + _ + Public Shared Function GetTypedTableSchema(ByVal xs As System.Xml.Schema.XmlSchemaSet) As System.Xml.Schema.XmlSchemaComplexType + Dim type As System.Xml.Schema.XmlSchemaComplexType = New System.Xml.Schema.XmlSchemaComplexType + Dim sequence As System.Xml.Schema.XmlSchemaSequence = New System.Xml.Schema.XmlSchemaSequence + Dim ds As NorthwindDataSet = New NorthwindDataSet + xs.Add(ds.GetSchemaSerializable) + Dim any1 As System.Xml.Schema.XmlSchemaAny = New System.Xml.Schema.XmlSchemaAny + any1.Namespace = "http://www.w3.org/2001/XMLSchema" + any1.MinOccurs = New Decimal(0) + any1.MaxOccurs = Decimal.MaxValue + any1.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax + sequence.Items.Add(any1) + Dim any2 As System.Xml.Schema.XmlSchemaAny = New System.Xml.Schema.XmlSchemaAny + any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1" + any2.MinOccurs = New Decimal(1) + any2.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax + sequence.Items.Add(any2) + Dim attribute1 As System.Xml.Schema.XmlSchemaAttribute = New System.Xml.Schema.XmlSchemaAttribute + attribute1.Name = "namespace" + attribute1.FixedValue = ds.Namespace + type.Attributes.Add(attribute1) + Dim attribute2 As System.Xml.Schema.XmlSchemaAttribute = New System.Xml.Schema.XmlSchemaAttribute + attribute2.Name = "tableTypeName" + attribute2.FixedValue = "EmployeesDataTable" + type.Attributes.Add(attribute2) + type.Particle = sequence + Return type + End Function + End Class + + _ + Partial Public Class EmployeesRow + Inherits System.Data.DataRow + + Private tableEmployees As EmployeesDataTable + + _ + Friend Sub New(ByVal rb As System.Data.DataRowBuilder) + MyBase.New(rb) + Me.tableEmployees = CType(Me.Table,EmployeesDataTable) + End Sub + + _ + Public Property EmployeeID() As Integer + Get + Return CType(Me(Me.tableEmployees.EmployeeIDColumn),Integer) + End Get + Set + Me(Me.tableEmployees.EmployeeIDColumn) = value + End Set + End Property + + _ + Public Property LastName() As String + Get + Return CType(Me(Me.tableEmployees.LastNameColumn),String) + End Get + Set + Me(Me.tableEmployees.LastNameColumn) = value + End Set + End Property + + _ + Public Property FirstName() As String + Get + Return CType(Me(Me.tableEmployees.FirstNameColumn),String) + End Get + Set + Me(Me.tableEmployees.FirstNameColumn) = value + End Set + End Property + + _ + Public Property Title() As String + Get + Try + Return CType(Me(Me.tableEmployees.TitleColumn),String) + Catch e As System.InvalidCastException + Throw New System.Data.StrongTypingException("The value for column 'Title' in table 'Employees' is DBNull.", e) + End Try + End Get + Set + Me(Me.tableEmployees.TitleColumn) = value + End Set + End Property + + _ + Public Property Photo() As Byte() + Get + Try + Return CType(Me(Me.tableEmployees.PhotoColumn),Byte()) + Catch e As System.InvalidCastException + Throw New System.Data.StrongTypingException("The value for column 'Photo' in table 'Employees' is DBNull.", e) + End Try + End Get + Set + Me(Me.tableEmployees.PhotoColumn) = value + End Set + End Property + + _ + Public Property TagID() As String + Get + Try + Return CType(Me(Me.tableEmployees.TagIDColumn),String) + Catch e As System.InvalidCastException + Throw New System.Data.StrongTypingException("The value for column 'TagID' in table 'Employees' is DBNull.", e) + End Try + End Get + Set + Me(Me.tableEmployees.TagIDColumn) = value + End Set + End Property + + _ + Public Function IsTitleNull() As Boolean + Return Me.IsNull(Me.tableEmployees.TitleColumn) + End Function + + _ + Public Sub SetTitleNull() + Me(Me.tableEmployees.TitleColumn) = System.Convert.DBNull + End Sub + + _ + Public Function IsPhotoNull() As Boolean + Return Me.IsNull(Me.tableEmployees.PhotoColumn) + End Function + + _ + Public Sub SetPhotoNull() + Me(Me.tableEmployees.PhotoColumn) = System.Convert.DBNull + End Sub + + _ + Public Function IsTagIDNull() As Boolean + Return Me.IsNull(Me.tableEmployees.TagIDColumn) + End Function + + _ + Public Sub SetTagIDNull() + Me(Me.tableEmployees.TagIDColumn) = System.Convert.DBNull + End Sub + End Class + + _ + Public Class EmployeesRowChangeEvent + Inherits System.EventArgs + + Private eventRow As EmployeesRow + + Private eventAction As System.Data.DataRowAction + + _ + Public Sub New(ByVal row As EmployeesRow, ByVal action As System.Data.DataRowAction) + MyBase.New + Me.eventRow = row + Me.eventAction = action + End Sub + + _ + Public ReadOnly Property Row() As EmployeesRow + Get + Return Me.eventRow + End Get + End Property + + _ + Public ReadOnly Property Action() As System.Data.DataRowAction + Get + Return Me.eventAction + End Get + End Property + End Class +End Class + +Namespace NorthwindDataSetTableAdapters + + _ + Partial Public Class EmployeesTableAdapter + Inherits System.ComponentModel.Component + + Private WithEvents _adapter As System.Data.SqlClient.SqlDataAdapter + + Private _connection As System.Data.SqlClient.SqlConnection + + Private _commandCollection() As System.Data.SqlClient.SqlCommand + + Private _clearBeforeFill As Boolean + + _ + Public Sub New() + MyBase.New + Me.ClearBeforeFill = true + End Sub + + _ + Private ReadOnly Property Adapter() As System.Data.SqlClient.SqlDataAdapter + Get + If (Me._adapter Is Nothing) Then + Me.InitAdapter + End If + Return Me._adapter + End Get + End Property + + _ + Friend Property Connection() As System.Data.SqlClient.SqlConnection + Get + If (Me._connection Is Nothing) Then + Me.InitConnection + End If + Return Me._connection + End Get + Set + Me._connection = value + If (Not (Me.Adapter.InsertCommand) Is Nothing) Then + Me.Adapter.InsertCommand.Connection = value + End If + If (Not (Me.Adapter.DeleteCommand) Is Nothing) Then + Me.Adapter.DeleteCommand.Connection = value + End If + If (Not (Me.Adapter.UpdateCommand) Is Nothing) Then + Me.Adapter.UpdateCommand.Connection = value + End If + Dim i As Integer = 0 + Do While (i < Me.CommandCollection.Length) + If (Not (Me.CommandCollection(i)) Is Nothing) Then + CType(Me.CommandCollection(i),System.Data.SqlClient.SqlCommand).Connection = value + End If + i = (i + 1) + Loop + End Set + End Property + + _ + Protected ReadOnly Property CommandCollection() As System.Data.SqlClient.SqlCommand() + Get + If (Me._commandCollection Is Nothing) Then + Me.InitCommandCollection + End If + Return Me._commandCollection + End Get + End Property + + _ + Public Property ClearBeforeFill() As Boolean + Get + Return Me._clearBeforeFill + End Get + Set + Me._clearBeforeFill = value + End Set + End Property + + _ + Private Sub InitAdapter() + Me._adapter = New System.Data.SqlClient.SqlDataAdapter + Dim tableMapping As System.Data.Common.DataTableMapping = New System.Data.Common.DataTableMapping + tableMapping.SourceTable = "Table" + tableMapping.DataSetTable = "Employees" + tableMapping.ColumnMappings.Add("EmployeeID", "EmployeeID") + tableMapping.ColumnMappings.Add("LastName", "LastName") + tableMapping.ColumnMappings.Add("FirstName", "FirstName") + tableMapping.ColumnMappings.Add("Title", "Title") + tableMapping.ColumnMappings.Add("Photo", "Photo") + tableMapping.ColumnMappings.Add("TagID", "TagID") + Me._adapter.TableMappings.Add(tableMapping) + Me._adapter.DeleteCommand = New System.Data.SqlClient.SqlCommand + Me._adapter.DeleteCommand.Connection = Me.Connection + Me._adapter.DeleteCommand.CommandText = "DELETE FROM [dbo].[Employees] WHERE (([EmployeeID] = @Original_EmployeeID) AND (["& _ + "LastName] = @Original_LastName) AND ([FirstName] = @Original_FirstName) AND ((@I"& _ + "sNull_Title = 1 AND [Title] IS NULL) OR ([Title] = @Original_Title)) AND ((@IsNu"& _ + "ll_TagID = 1 AND [TagID] IS NULL) OR ([TagID] = @Original_TagID)))" + Me._adapter.DeleteCommand.CommandType = System.Data.CommandType.Text + Me._adapter.DeleteCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_EmployeeID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "EmployeeID", System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.DeleteCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_LastName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "LastName", System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.DeleteCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_FirstName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "FirstName", System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.DeleteCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@IsNull_Title", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "Title", System.Data.DataRowVersion.Original, true, Nothing, "", "", "")) + Me._adapter.DeleteCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Title", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "Title", System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.DeleteCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@IsNull_TagID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "TagID", System.Data.DataRowVersion.Original, true, Nothing, "", "", "")) + Me._adapter.DeleteCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_TagID", System.Data.SqlDbType.NChar, 0, System.Data.ParameterDirection.Input, 0, 0, "TagID", System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.InsertCommand = New System.Data.SqlClient.SqlCommand + Me._adapter.InsertCommand.Connection = Me.Connection + Me._adapter.InsertCommand.CommandText = "INSERT INTO [dbo].[Employees] ([LastName], [FirstName], [Title], [Photo], [TagID]"& _ + ") VALUES (@LastName, @FirstName, @Title, @Photo, @TagID);"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"SELECT EmployeeID, La"& _ + "stName, FirstName, Title, Photo, TagID FROM Employees WHERE (EmployeeID = SCOPE_"& _ + "IDENTITY())" + Me._adapter.InsertCommand.CommandType = System.Data.CommandType.Text + Me._adapter.InsertCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@LastName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "LastName", System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.InsertCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@FirstName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "FirstName", System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.InsertCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Title", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "Title", System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.InsertCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Photo", System.Data.SqlDbType.Image, 0, System.Data.ParameterDirection.Input, 0, 0, "Photo", System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.InsertCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@TagID", System.Data.SqlDbType.NChar, 0, System.Data.ParameterDirection.Input, 0, 0, "TagID", System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand = New System.Data.SqlClient.SqlCommand + Me._adapter.UpdateCommand.Connection = Me.Connection + Me._adapter.UpdateCommand.CommandText = "UPDATE [dbo].[Employees] SET [LastName] = @LastName, [FirstName] = @FirstName, [T"& _ + "itle] = @Title, [Photo] = @Photo, [TagID] = @TagID WHERE (([EmployeeID] = @Origi"& _ + "nal_EmployeeID) AND ([LastName] = @Original_LastName) AND ([FirstName] = @Origin"& _ + "al_FirstName) AND ((@IsNull_Title = 1 AND [Title] IS NULL) OR ([Title] = @Origin"& _ + "al_Title)) AND ((@IsNull_TagID = 1 AND [TagID] IS NULL) OR ([TagID] = @Original_"& _ + "TagID)));"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"SELECT EmployeeID, LastName, FirstName, Title, Photo, TagID FROM Empl"& _ + "oyees WHERE (EmployeeID = @EmployeeID)" + Me._adapter.UpdateCommand.CommandType = System.Data.CommandType.Text + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@LastName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "LastName", System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@FirstName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "FirstName", System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Title", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "Title", System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Photo", System.Data.SqlDbType.Image, 0, System.Data.ParameterDirection.Input, 0, 0, "Photo", System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@TagID", System.Data.SqlDbType.NChar, 0, System.Data.ParameterDirection.Input, 0, 0, "TagID", System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_EmployeeID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "EmployeeID", System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_LastName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "LastName", System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_FirstName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "FirstName", System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@IsNull_Title", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "Title", System.Data.DataRowVersion.Original, true, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Title", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "Title", System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@IsNull_TagID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "TagID", System.Data.DataRowVersion.Original, true, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_TagID", System.Data.SqlDbType.NChar, 0, System.Data.ParameterDirection.Input, 0, 0, "TagID", System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@EmployeeID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, 0, 0, "EmployeeID", System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + End Sub + + _ + Private Sub InitConnection() + Me._connection = New System.Data.SqlClient.SqlConnection + Me._connection.ConnectionString = Global.Attendance.My.MySettings.Default.NorthwindConnectionString + End Sub + + _ + Private Sub InitCommandCollection() + Me._commandCollection = New System.Data.SqlClient.SqlCommand(0) {} + Me._commandCollection(0) = New System.Data.SqlClient.SqlCommand + Me._commandCollection(0).Connection = Me.Connection + Me._commandCollection(0).CommandText = "SELECT EmployeeID, LastName, FirstName, Title, Photo, TagID FROM dbo.Employees" + Me._commandCollection(0).CommandType = System.Data.CommandType.Text + End Sub + + _ + Public Overloads Overridable Function Fill(ByVal dataTable As NorthwindDataSet.EmployeesDataTable) As Integer + Me.Adapter.SelectCommand = Me.CommandCollection(0) + If (Me.ClearBeforeFill = true) Then + dataTable.Clear + End If + Dim returnValue As Integer = Me.Adapter.Fill(dataTable) + Return returnValue + End Function + + _ + Public Overloads Overridable Function GetData() As NorthwindDataSet.EmployeesDataTable + Me.Adapter.SelectCommand = Me.CommandCollection(0) + Dim dataTable As NorthwindDataSet.EmployeesDataTable = New NorthwindDataSet.EmployeesDataTable + Me.Adapter.Fill(dataTable) + Return dataTable + End Function + + _ + Public Overloads Overridable Function Update(ByVal dataTable As NorthwindDataSet.EmployeesDataTable) As Integer + Return Me.Adapter.Update(dataTable) + End Function + + _ + Public Overloads Overridable Function Update(ByVal dataSet As NorthwindDataSet) As Integer + Return Me.Adapter.Update(dataSet, "Employees") + End Function + + _ + Public Overloads Overridable Function Update(ByVal dataRow As System.Data.DataRow) As Integer + Return Me.Adapter.Update(New System.Data.DataRow() {dataRow}) + End Function + + _ + Public Overloads Overridable Function Update(ByVal dataRows() As System.Data.DataRow) As Integer + Return Me.Adapter.Update(dataRows) + End Function + + _ + Public Overloads Overridable Function Delete(ByVal Original_EmployeeID As Integer, ByVal Original_LastName As String, ByVal Original_FirstName As String, ByVal Original_Title As String, ByVal Original_TagID As String) As Integer + Me.Adapter.DeleteCommand.Parameters(0).Value = CType(Original_EmployeeID,Integer) + If (Original_LastName Is Nothing) Then + Throw New System.ArgumentNullException("Original_LastName") + Else + Me.Adapter.DeleteCommand.Parameters(1).Value = CType(Original_LastName,String) + End If + If (Original_FirstName Is Nothing) Then + Throw New System.ArgumentNullException("Original_FirstName") + Else + Me.Adapter.DeleteCommand.Parameters(2).Value = CType(Original_FirstName,String) + End If + If (Original_Title Is Nothing) Then + Me.Adapter.DeleteCommand.Parameters(3).Value = CType(1,Object) + Me.Adapter.DeleteCommand.Parameters(4).Value = System.DBNull.Value + Else + Me.Adapter.DeleteCommand.Parameters(3).Value = CType(0,Object) + Me.Adapter.DeleteCommand.Parameters(4).Value = CType(Original_Title,String) + End If + If (Original_TagID Is Nothing) Then + Me.Adapter.DeleteCommand.Parameters(5).Value = CType(1,Object) + Me.Adapter.DeleteCommand.Parameters(6).Value = System.DBNull.Value + Else + Me.Adapter.DeleteCommand.Parameters(5).Value = CType(0,Object) + Me.Adapter.DeleteCommand.Parameters(6).Value = CType(Original_TagID,String) + End If + Dim previousConnectionState As System.Data.ConnectionState = Me.Adapter.DeleteCommand.Connection.State + If ((Me.Adapter.DeleteCommand.Connection.State And System.Data.ConnectionState.Open) _ + <> System.Data.ConnectionState.Open) Then + Me.Adapter.DeleteCommand.Connection.Open + End If + Try + Dim returnValue As Integer = Me.Adapter.DeleteCommand.ExecuteNonQuery + Return returnValue + Finally + If (previousConnectionState = System.Data.ConnectionState.Closed) Then + Me.Adapter.DeleteCommand.Connection.Close + End If + End Try + End Function + + _ + Public Overloads Overridable Function Insert(ByVal LastName As String, ByVal FirstName As String, ByVal Title As String, ByVal Photo() As Byte, ByVal TagID As String) As Integer + If (LastName Is Nothing) Then + Throw New System.ArgumentNullException("LastName") + Else + Me.Adapter.InsertCommand.Parameters(0).Value = CType(LastName,String) + End If + If (FirstName Is Nothing) Then + Throw New System.ArgumentNullException("FirstName") + Else + Me.Adapter.InsertCommand.Parameters(1).Value = CType(FirstName,String) + End If + If (Title Is Nothing) Then + Me.Adapter.InsertCommand.Parameters(2).Value = System.DBNull.Value + Else + Me.Adapter.InsertCommand.Parameters(2).Value = CType(Title,String) + End If + If (Photo Is Nothing) Then + Me.Adapter.InsertCommand.Parameters(3).Value = System.DBNull.Value + Else + Me.Adapter.InsertCommand.Parameters(3).Value = CType(Photo,Byte()) + End If + If (TagID Is Nothing) Then + Me.Adapter.InsertCommand.Parameters(4).Value = System.DBNull.Value + Else + Me.Adapter.InsertCommand.Parameters(4).Value = CType(TagID,String) + End If + Dim previousConnectionState As System.Data.ConnectionState = Me.Adapter.InsertCommand.Connection.State + If ((Me.Adapter.InsertCommand.Connection.State And System.Data.ConnectionState.Open) _ + <> System.Data.ConnectionState.Open) Then + Me.Adapter.InsertCommand.Connection.Open + End If + Try + Dim returnValue As Integer = Me.Adapter.InsertCommand.ExecuteNonQuery + Return returnValue + Finally + If (previousConnectionState = System.Data.ConnectionState.Closed) Then + Me.Adapter.InsertCommand.Connection.Close + End If + End Try + End Function + + _ + Public Overloads Overridable Function Update(ByVal LastName As String, ByVal FirstName As String, ByVal Title As String, ByVal Photo() As Byte, ByVal TagID As String, ByVal Original_EmployeeID As Integer, ByVal Original_LastName As String, ByVal Original_FirstName As String, ByVal Original_Title As String, ByVal Original_TagID As String, ByVal EmployeeID As Integer) As Integer + If (LastName Is Nothing) Then + Throw New System.ArgumentNullException("LastName") + Else + Me.Adapter.UpdateCommand.Parameters(0).Value = CType(LastName,String) + End If + If (FirstName Is Nothing) Then + Throw New System.ArgumentNullException("FirstName") + Else + Me.Adapter.UpdateCommand.Parameters(1).Value = CType(FirstName,String) + End If + If (Title Is Nothing) Then + Me.Adapter.UpdateCommand.Parameters(2).Value = System.DBNull.Value + Else + Me.Adapter.UpdateCommand.Parameters(2).Value = CType(Title,String) + End If + If (Photo Is Nothing) Then + Me.Adapter.UpdateCommand.Parameters(3).Value = System.DBNull.Value + Else + Me.Adapter.UpdateCommand.Parameters(3).Value = CType(Photo,Byte()) + End If + If (TagID Is Nothing) Then + Me.Adapter.UpdateCommand.Parameters(4).Value = System.DBNull.Value + Else + Me.Adapter.UpdateCommand.Parameters(4).Value = CType(TagID,String) + End If + Me.Adapter.UpdateCommand.Parameters(5).Value = CType(Original_EmployeeID,Integer) + If (Original_LastName Is Nothing) Then + Throw New System.ArgumentNullException("Original_LastName") + Else + Me.Adapter.UpdateCommand.Parameters(6).Value = CType(Original_LastName,String) + End If + If (Original_FirstName Is Nothing) Then + Throw New System.ArgumentNullException("Original_FirstName") + Else + Me.Adapter.UpdateCommand.Parameters(7).Value = CType(Original_FirstName,String) + End If + If (Original_Title Is Nothing) Then + Me.Adapter.UpdateCommand.Parameters(8).Value = CType(1,Object) + Me.Adapter.UpdateCommand.Parameters(9).Value = System.DBNull.Value + Else + Me.Adapter.UpdateCommand.Parameters(8).Value = CType(0,Object) + Me.Adapter.UpdateCommand.Parameters(9).Value = CType(Original_Title,String) + End If + If (Original_TagID Is Nothing) Then + Me.Adapter.UpdateCommand.Parameters(10).Value = CType(1,Object) + Me.Adapter.UpdateCommand.Parameters(11).Value = System.DBNull.Value + Else + Me.Adapter.UpdateCommand.Parameters(10).Value = CType(0,Object) + Me.Adapter.UpdateCommand.Parameters(11).Value = CType(Original_TagID,String) + End If + Me.Adapter.UpdateCommand.Parameters(12).Value = CType(EmployeeID,Integer) + Dim previousConnectionState As System.Data.ConnectionState = Me.Adapter.UpdateCommand.Connection.State + If ((Me.Adapter.UpdateCommand.Connection.State And System.Data.ConnectionState.Open) _ + <> System.Data.ConnectionState.Open) Then + Me.Adapter.UpdateCommand.Connection.Open + End If + Try + Dim returnValue As Integer = Me.Adapter.UpdateCommand.ExecuteNonQuery + Return returnValue + Finally + If (previousConnectionState = System.Data.ConnectionState.Closed) Then + Me.Adapter.UpdateCommand.Connection.Close + End If + End Try + End Function + End Class +End Namespace diff --git a/Chapter05(RFID)/Attendance_Parallax/NorthwindDataSet.xsc b/Chapter05(RFID)/Attendance_Parallax/NorthwindDataSet.xsc new file mode 100644 index 0000000..2dbd3f0 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax/NorthwindDataSet.xsc @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Parallax/NorthwindDataSet.xsd b/Chapter05(RFID)/Attendance_Parallax/NorthwindDataSet.xsd new file mode 100644 index 0000000..2ad06dc --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax/NorthwindDataSet.xsd @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + DELETE FROM [dbo].[Employees] WHERE (([EmployeeID] = @Original_EmployeeID) AND ([LastName] = @Original_LastName) AND ([FirstName] = @Original_FirstName) AND ((@IsNull_Title = 1 AND [Title] IS NULL) OR ([Title] = @Original_Title)) AND ((@IsNull_TagID = 1 AND [TagID] IS NULL) OR ([TagID] = @Original_TagID))) + + + + + + + + + + + + + + + + + + + + + INSERT INTO [dbo].[Employees] ([LastName], [FirstName], [Title], [Photo], [TagID]) VALUES (@LastName, @FirstName, @Title, @Photo, @TagID); +SELECT EmployeeID, LastName, FirstName, Title, Photo, TagID FROM Employees WHERE (EmployeeID = SCOPE_IDENTITY()) + + + + + + + + + + + + + + + + + SELECT EmployeeID, LastName, FirstName, Title, Photo, TagID FROM dbo.Employees + + + + + + + UPDATE [dbo].[Employees] SET [LastName] = @LastName, [FirstName] = @FirstName, [Title] = @Title, [Photo] = @Photo, [TagID] = @TagID WHERE (([EmployeeID] = @Original_EmployeeID) AND ([LastName] = @Original_LastName) AND ([FirstName] = @Original_FirstName) AND ((@IsNull_Title = 1 AND [Title] IS NULL) OR ([Title] = @Original_Title)) AND ((@IsNull_TagID = 1 AND [TagID] IS NULL) OR ([TagID] = @Original_TagID))); +SELECT EmployeeID, LastName, FirstName, Title, Photo, TagID FROM Employees WHERE (EmployeeID = @EmployeeID) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Parallax/NorthwindDataSet.xss b/Chapter05(RFID)/Attendance_Parallax/NorthwindDataSet.xss new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax/NorthwindDataSet.xss @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Parallax/app.config b/Chapter05(RFID)/Attendance_Parallax/app.config new file mode 100644 index 0000000..f541ced --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax/app.config @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter05(RFID)/Attendance_Parallax/bin/Debug/Attendance.exe b/Chapter05(RFID)/Attendance_Parallax/bin/Debug/Attendance.exe new file mode 100644 index 0000000..9b68e90 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Parallax/bin/Debug/Attendance.exe differ diff --git a/Chapter05(RFID)/Attendance_Parallax/bin/Debug/Attendance.exe.config b/Chapter05(RFID)/Attendance_Parallax/bin/Debug/Attendance.exe.config new file mode 100644 index 0000000..f541ced --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax/bin/Debug/Attendance.exe.config @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter05(RFID)/Attendance_Parallax/bin/Debug/Attendance.pdb b/Chapter05(RFID)/Attendance_Parallax/bin/Debug/Attendance.pdb new file mode 100644 index 0000000..078412f Binary files /dev/null and b/Chapter05(RFID)/Attendance_Parallax/bin/Debug/Attendance.pdb differ diff --git a/Chapter05(RFID)/Attendance_Parallax/bin/Debug/Attendance.vshost.exe b/Chapter05(RFID)/Attendance_Parallax/bin/Debug/Attendance.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Parallax/bin/Debug/Attendance.vshost.exe differ diff --git a/Chapter05(RFID)/Attendance_Parallax/bin/Debug/Attendance.vshost.exe.config b/Chapter05(RFID)/Attendance_Parallax/bin/Debug/Attendance.vshost.exe.config new file mode 100644 index 0000000..f541ced --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax/bin/Debug/Attendance.vshost.exe.config @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter05(RFID)/Attendance_Parallax/bin/Debug/Attendance.xml b/Chapter05(RFID)/Attendance_Parallax/bin/Debug/Attendance.xml new file mode 100644 index 0000000..afe0f32 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax/bin/Debug/Attendance.xml @@ -0,0 +1,11 @@ + + + + +Attendance + + + + + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Parallax/obj/Attendance.vbproj.FileList.txt b/Chapter05(RFID)/Attendance_Parallax/obj/Attendance.vbproj.FileList.txt new file mode 100644 index 0000000..a02c32c --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax/obj/Attendance.vbproj.FileList.txt @@ -0,0 +1,11 @@ +bin\Debug\Attendance.exe.config +bin\Debug\Attendance.exe +bin\Debug\Attendance.pdb +bin\Debug\Attendance.xml +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\Attendance.Form1.resources +obj\Debug\Attendance.Resources.resources +obj\Debug\Attendance.vbproj.GenerateResource.Cache +obj\Debug\Attendance.exe +obj\Debug\Attendance.xml +obj\Debug\Attendance.pdb diff --git a/Chapter05(RFID)/Attendance_Parallax/obj/Debug/Attendance.Form1.resources b/Chapter05(RFID)/Attendance_Parallax/obj/Debug/Attendance.Form1.resources new file mode 100644 index 0000000..1aa111d Binary files /dev/null and b/Chapter05(RFID)/Attendance_Parallax/obj/Debug/Attendance.Form1.resources differ diff --git a/Chapter05(RFID)/Attendance_Parallax/obj/Debug/Attendance.Resources.resources b/Chapter05(RFID)/Attendance_Parallax/obj/Debug/Attendance.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Parallax/obj/Debug/Attendance.Resources.resources differ diff --git a/Chapter05(RFID)/Attendance_Parallax/obj/Debug/Attendance.exe b/Chapter05(RFID)/Attendance_Parallax/obj/Debug/Attendance.exe new file mode 100644 index 0000000..9b68e90 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Parallax/obj/Debug/Attendance.exe differ diff --git a/Chapter05(RFID)/Attendance_Parallax/obj/Debug/Attendance.pdb b/Chapter05(RFID)/Attendance_Parallax/obj/Debug/Attendance.pdb new file mode 100644 index 0000000..078412f Binary files /dev/null and b/Chapter05(RFID)/Attendance_Parallax/obj/Debug/Attendance.pdb differ diff --git a/Chapter05(RFID)/Attendance_Parallax/obj/Debug/Attendance.vbproj.GenerateResource.Cache b/Chapter05(RFID)/Attendance_Parallax/obj/Debug/Attendance.vbproj.GenerateResource.Cache new file mode 100644 index 0000000..829cb65 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Parallax/obj/Debug/Attendance.vbproj.GenerateResource.Cache differ diff --git a/Chapter05(RFID)/Attendance_Parallax/obj/Debug/Attendance.xml b/Chapter05(RFID)/Attendance_Parallax/obj/Debug/Attendance.xml new file mode 100644 index 0000000..afe0f32 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax/obj/Debug/Attendance.xml @@ -0,0 +1,11 @@ + + + + +Attendance + + + + + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Parallax/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll b/Chapter05(RFID)/Attendance_Parallax/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll new file mode 100644 index 0000000..2840e96 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Parallax/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll differ diff --git a/Chapter05(RFID)/Attendance_Parallax/obj/Debug/TempPE/NorthwindDataSet.Designer.vb.dll b/Chapter05(RFID)/Attendance_Parallax/obj/Debug/TempPE/NorthwindDataSet.Designer.vb.dll new file mode 100644 index 0000000..50c198a Binary files /dev/null and b/Chapter05(RFID)/Attendance_Parallax/obj/Debug/TempPE/NorthwindDataSet.Designer.vb.dll differ diff --git a/Chapter05(RFID)/Attendance_Parallax/obj/Debug/TempPE/NorthwindDataSet1.Designer.vb.dll b/Chapter05(RFID)/Attendance_Parallax/obj/Debug/TempPE/NorthwindDataSet1.Designer.vb.dll new file mode 100644 index 0000000..bea0ead Binary files /dev/null and b/Chapter05(RFID)/Attendance_Parallax/obj/Debug/TempPE/NorthwindDataSet1.Designer.vb.dll differ diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS.sln b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS.sln new file mode 100644 index 0000000..d6407ad --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Attendance_CS", "Attendance_CS\Attendance_CS.csproj", "{821C624A-FAFE-4B97-9BDA-1C12E5A70669}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {821C624A-FAFE-4B97-9BDA-1C12E5A70669}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {821C624A-FAFE-4B97-9BDA-1C12E5A70669}.Debug|Any CPU.Build.0 = Debug|Any CPU + {821C624A-FAFE-4B97-9BDA-1C12E5A70669}.Release|Any CPU.ActiveCfg = Release|Any CPU + {821C624A-FAFE-4B97-9BDA-1C12E5A70669}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS.suo b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS.suo new file mode 100644 index 0000000..fd97802 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS.suo differ diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Attendance_CS.csproj b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Attendance_CS.csproj new file mode 100644 index 0000000..d4b7134 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Attendance_CS.csproj @@ -0,0 +1,95 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {821C624A-FAFE-4B97-9BDA-1C12E5A70669} + WinExe + Properties + Attendance_CS + Attendance_CS + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + Form + + + Form1.cs + + + True + True + NorthwindDataSet.xsd + + + + + Designer + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + + NorthwindDataSet.xsd + + + MSDataSetGenerator + NorthwindDataSet.Designer.cs + Designer + + + NorthwindDataSet.xsd + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Form1.Designer.cs b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Form1.Designer.cs new file mode 100644 index 0000000..32fc624 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Form1.Designer.cs @@ -0,0 +1,505 @@ +namespace Attendance_CS +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); + System.Windows.Forms.Label employeeIDLabel; + System.Windows.Forms.Label lastNameLabel; + System.Windows.Forms.Label firstNameLabel; + System.Windows.Forms.Label titleLabel; + System.Windows.Forms.Label photoLabel; + System.Windows.Forms.Label tagIDLabel; + System.Windows.Forms.Label Label2; + this.northwindDataSet = new Attendance_CS.NorthwindDataSet(); + this.employeesBindingSource = new System.Windows.Forms.BindingSource(this.components); + this.employeesTableAdapter = new Attendance_CS.NorthwindDataSetTableAdapters.EmployeesTableAdapter(); + this.employeesBindingNavigator = new System.Windows.Forms.BindingNavigator(this.components); + this.bindingNavigatorMoveFirstItem = new System.Windows.Forms.ToolStripButton(); + this.bindingNavigatorMovePreviousItem = new System.Windows.Forms.ToolStripButton(); + this.bindingNavigatorSeparator = new System.Windows.Forms.ToolStripSeparator(); + this.bindingNavigatorPositionItem = new System.Windows.Forms.ToolStripTextBox(); + this.bindingNavigatorCountItem = new System.Windows.Forms.ToolStripLabel(); + this.bindingNavigatorSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.bindingNavigatorMoveNextItem = new System.Windows.Forms.ToolStripButton(); + this.bindingNavigatorMoveLastItem = new System.Windows.Forms.ToolStripButton(); + this.bindingNavigatorSeparator2 = new System.Windows.Forms.ToolStripSeparator(); + this.bindingNavigatorAddNewItem = new System.Windows.Forms.ToolStripButton(); + this.bindingNavigatorDeleteItem = new System.Windows.Forms.ToolStripButton(); + this.employeesBindingNavigatorSaveItem = new System.Windows.Forms.ToolStripButton(); + this.employeeIDLabel1 = new System.Windows.Forms.Label(); + this.lastNameTextBox = new System.Windows.Forms.TextBox(); + this.firstNameTextBox = new System.Windows.Forms.TextBox(); + this.titleTextBox = new System.Windows.Forms.TextBox(); + this.photoPictureBox = new System.Windows.Forms.PictureBox(); + this.tagIDLabel1 = new System.Windows.Forms.Label(); + this.StatusStrip1 = new System.Windows.Forms.StatusStrip(); + this.ToolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); + this.GroupBox1 = new System.Windows.Forms.GroupBox(); + this.btnDeassign = new System.Windows.Forms.Button(); + this.txtEmployeeID = new System.Windows.Forms.TextBox(); + this.btnFind = new System.Windows.Forms.Button(); + this.btnAssign = new System.Windows.Forms.Button(); + this.txtTagID = new System.Windows.Forms.TextBox(); + this.Label1 = new System.Windows.Forms.Label(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + employeeIDLabel = new System.Windows.Forms.Label(); + lastNameLabel = new System.Windows.Forms.Label(); + firstNameLabel = new System.Windows.Forms.Label(); + titleLabel = new System.Windows.Forms.Label(); + photoLabel = new System.Windows.Forms.Label(); + tagIDLabel = new System.Windows.Forms.Label(); + Label2 = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.northwindDataSet)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.employeesBindingSource)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.employeesBindingNavigator)).BeginInit(); + this.employeesBindingNavigator.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.photoPictureBox)).BeginInit(); + this.StatusStrip1.SuspendLayout(); + this.GroupBox1.SuspendLayout(); + this.SuspendLayout(); + // + // northwindDataSet + // + this.northwindDataSet.DataSetName = "NorthwindDataSet"; + this.northwindDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema; + // + // employeesBindingSource + // + this.employeesBindingSource.DataMember = "Employees"; + this.employeesBindingSource.DataSource = this.northwindDataSet; + // + // employeesTableAdapter + // + this.employeesTableAdapter.ClearBeforeFill = true; + // + // employeesBindingNavigator + // + this.employeesBindingNavigator.AddNewItem = this.bindingNavigatorAddNewItem; + this.employeesBindingNavigator.BindingSource = this.employeesBindingSource; + this.employeesBindingNavigator.CountItem = this.bindingNavigatorCountItem; + this.employeesBindingNavigator.DeleteItem = this.bindingNavigatorDeleteItem; + this.employeesBindingNavigator.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.bindingNavigatorMoveFirstItem, + this.bindingNavigatorMovePreviousItem, + this.bindingNavigatorSeparator, + this.bindingNavigatorPositionItem, + this.bindingNavigatorCountItem, + this.bindingNavigatorSeparator1, + this.bindingNavigatorMoveNextItem, + this.bindingNavigatorMoveLastItem, + this.bindingNavigatorSeparator2, + this.bindingNavigatorAddNewItem, + this.bindingNavigatorDeleteItem, + this.employeesBindingNavigatorSaveItem}); + this.employeesBindingNavigator.Location = new System.Drawing.Point(0, 0); + this.employeesBindingNavigator.MoveFirstItem = this.bindingNavigatorMoveFirstItem; + this.employeesBindingNavigator.MoveLastItem = this.bindingNavigatorMoveLastItem; + this.employeesBindingNavigator.MoveNextItem = this.bindingNavigatorMoveNextItem; + this.employeesBindingNavigator.MovePreviousItem = this.bindingNavigatorMovePreviousItem; + this.employeesBindingNavigator.Name = "employeesBindingNavigator"; + this.employeesBindingNavigator.PositionItem = this.bindingNavigatorPositionItem; + this.employeesBindingNavigator.Size = new System.Drawing.Size(412, 25); + this.employeesBindingNavigator.TabIndex = 0; + this.employeesBindingNavigator.Text = "bindingNavigator1"; + // + // bindingNavigatorMoveFirstItem + // + this.bindingNavigatorMoveFirstItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.bindingNavigatorMoveFirstItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveFirstItem.Image"))); + this.bindingNavigatorMoveFirstItem.Name = "bindingNavigatorMoveFirstItem"; + this.bindingNavigatorMoveFirstItem.RightToLeftAutoMirrorImage = true; + this.bindingNavigatorMoveFirstItem.Size = new System.Drawing.Size(23, 22); + this.bindingNavigatorMoveFirstItem.Text = "Move first"; + // + // bindingNavigatorMovePreviousItem + // + this.bindingNavigatorMovePreviousItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.bindingNavigatorMovePreviousItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMovePreviousItem.Image"))); + this.bindingNavigatorMovePreviousItem.Name = "bindingNavigatorMovePreviousItem"; + this.bindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = true; + this.bindingNavigatorMovePreviousItem.Size = new System.Drawing.Size(23, 22); + this.bindingNavigatorMovePreviousItem.Text = "Move previous"; + // + // bindingNavigatorSeparator + // + this.bindingNavigatorSeparator.Name = "bindingNavigatorSeparator"; + this.bindingNavigatorSeparator.Size = new System.Drawing.Size(6, 25); + // + // bindingNavigatorPositionItem + // + this.bindingNavigatorPositionItem.AccessibleName = "Position"; + this.bindingNavigatorPositionItem.AutoSize = false; + this.bindingNavigatorPositionItem.Name = "bindingNavigatorPositionItem"; + this.bindingNavigatorPositionItem.Size = new System.Drawing.Size(50, 21); + this.bindingNavigatorPositionItem.Text = "0"; + this.bindingNavigatorPositionItem.ToolTipText = "Current position"; + // + // bindingNavigatorCountItem + // + this.bindingNavigatorCountItem.Name = "bindingNavigatorCountItem"; + this.bindingNavigatorCountItem.Size = new System.Drawing.Size(36, 13); + this.bindingNavigatorCountItem.Text = "of {0}"; + this.bindingNavigatorCountItem.ToolTipText = "Total number of items"; + // + // bindingNavigatorSeparator1 + // + this.bindingNavigatorSeparator1.Name = "bindingNavigatorSeparator"; + this.bindingNavigatorSeparator1.Size = new System.Drawing.Size(6, 6); + // + // bindingNavigatorMoveNextItem + // + this.bindingNavigatorMoveNextItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.bindingNavigatorMoveNextItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveNextItem.Image"))); + this.bindingNavigatorMoveNextItem.Name = "bindingNavigatorMoveNextItem"; + this.bindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = true; + this.bindingNavigatorMoveNextItem.Size = new System.Drawing.Size(23, 20); + this.bindingNavigatorMoveNextItem.Text = "Move next"; + // + // bindingNavigatorMoveLastItem + // + this.bindingNavigatorMoveLastItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.bindingNavigatorMoveLastItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveLastItem.Image"))); + this.bindingNavigatorMoveLastItem.Name = "bindingNavigatorMoveLastItem"; + this.bindingNavigatorMoveLastItem.RightToLeftAutoMirrorImage = true; + this.bindingNavigatorMoveLastItem.Size = new System.Drawing.Size(23, 20); + this.bindingNavigatorMoveLastItem.Text = "Move last"; + // + // bindingNavigatorSeparator2 + // + this.bindingNavigatorSeparator2.Name = "bindingNavigatorSeparator"; + this.bindingNavigatorSeparator2.Size = new System.Drawing.Size(6, 6); + // + // bindingNavigatorAddNewItem + // + this.bindingNavigatorAddNewItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.bindingNavigatorAddNewItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorAddNewItem.Image"))); + this.bindingNavigatorAddNewItem.Name = "bindingNavigatorAddNewItem"; + this.bindingNavigatorAddNewItem.RightToLeftAutoMirrorImage = true; + this.bindingNavigatorAddNewItem.Size = new System.Drawing.Size(23, 22); + this.bindingNavigatorAddNewItem.Text = "Add new"; + // + // bindingNavigatorDeleteItem + // + this.bindingNavigatorDeleteItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.bindingNavigatorDeleteItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorDeleteItem.Image"))); + this.bindingNavigatorDeleteItem.Name = "bindingNavigatorDeleteItem"; + this.bindingNavigatorDeleteItem.RightToLeftAutoMirrorImage = true; + this.bindingNavigatorDeleteItem.Size = new System.Drawing.Size(23, 20); + this.bindingNavigatorDeleteItem.Text = "Delete"; + // + // employeesBindingNavigatorSaveItem + // + this.employeesBindingNavigatorSaveItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.employeesBindingNavigatorSaveItem.Image = ((System.Drawing.Image)(resources.GetObject("employeesBindingNavigatorSaveItem.Image"))); + this.employeesBindingNavigatorSaveItem.Name = "employeesBindingNavigatorSaveItem"; + this.employeesBindingNavigatorSaveItem.Size = new System.Drawing.Size(23, 23); + this.employeesBindingNavigatorSaveItem.Text = "Save Data"; + this.employeesBindingNavigatorSaveItem.Click += new System.EventHandler(this.employeesBindingNavigatorSaveItem_Click); + // + // employeeIDLabel + // + employeeIDLabel.AutoSize = true; + employeeIDLabel.Location = new System.Drawing.Point(13, 59); + employeeIDLabel.Name = "employeeIDLabel"; + employeeIDLabel.Size = new System.Drawing.Size(70, 13); + employeeIDLabel.TabIndex = 1; + employeeIDLabel.Text = "Employee ID:"; + // + // employeeIDLabel1 + // + this.employeeIDLabel1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.employeesBindingSource, "EmployeeID", true)); + this.employeeIDLabel1.Location = new System.Drawing.Point(89, 59); + this.employeeIDLabel1.Name = "employeeIDLabel1"; + this.employeeIDLabel1.Size = new System.Drawing.Size(100, 23); + this.employeeIDLabel1.TabIndex = 2; + // + // lastNameLabel + // + lastNameLabel.AutoSize = true; + lastNameLabel.Location = new System.Drawing.Point(13, 88); + lastNameLabel.Name = "lastNameLabel"; + lastNameLabel.Size = new System.Drawing.Size(61, 13); + lastNameLabel.TabIndex = 3; + lastNameLabel.Text = "Last Name:"; + // + // lastNameTextBox + // + this.lastNameTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.employeesBindingSource, "LastName", true)); + this.lastNameTextBox.Location = new System.Drawing.Point(89, 85); + this.lastNameTextBox.Name = "lastNameTextBox"; + this.lastNameTextBox.Size = new System.Drawing.Size(129, 20); + this.lastNameTextBox.TabIndex = 4; + // + // firstNameLabel + // + firstNameLabel.AutoSize = true; + firstNameLabel.Location = new System.Drawing.Point(13, 114); + firstNameLabel.Name = "firstNameLabel"; + firstNameLabel.Size = new System.Drawing.Size(60, 13); + firstNameLabel.TabIndex = 5; + firstNameLabel.Text = "First Name:"; + // + // firstNameTextBox + // + this.firstNameTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.employeesBindingSource, "FirstName", true)); + this.firstNameTextBox.Location = new System.Drawing.Point(89, 111); + this.firstNameTextBox.Name = "firstNameTextBox"; + this.firstNameTextBox.Size = new System.Drawing.Size(129, 20); + this.firstNameTextBox.TabIndex = 6; + // + // titleLabel + // + titleLabel.AutoSize = true; + titleLabel.Location = new System.Drawing.Point(13, 140); + titleLabel.Name = "titleLabel"; + titleLabel.Size = new System.Drawing.Size(30, 13); + titleLabel.TabIndex = 7; + titleLabel.Text = "Title:"; + // + // titleTextBox + // + this.titleTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.employeesBindingSource, "Title", true)); + this.titleTextBox.Location = new System.Drawing.Point(89, 137); + this.titleTextBox.Name = "titleTextBox"; + this.titleTextBox.Size = new System.Drawing.Size(129, 20); + this.titleTextBox.TabIndex = 8; + // + // photoLabel + // + photoLabel.AutoSize = true; + photoLabel.Location = new System.Drawing.Point(13, 163); + photoLabel.Name = "photoLabel"; + photoLabel.Size = new System.Drawing.Size(38, 13); + photoLabel.TabIndex = 9; + photoLabel.Text = "Photo:"; + // + // photoPictureBox + // + this.photoPictureBox.DataBindings.Add(new System.Windows.Forms.Binding("Image", this.employeesBindingSource, "Photo", true)); + this.photoPictureBox.Location = new System.Drawing.Point(89, 163); + this.photoPictureBox.Name = "photoPictureBox"; + this.photoPictureBox.Size = new System.Drawing.Size(95, 110); + this.photoPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.photoPictureBox.TabIndex = 10; + this.photoPictureBox.TabStop = false; + // + // tagIDLabel + // + tagIDLabel.AutoSize = true; + tagIDLabel.Location = new System.Drawing.Point(13, 36); + tagIDLabel.Name = "tagIDLabel"; + tagIDLabel.Size = new System.Drawing.Size(43, 13); + tagIDLabel.TabIndex = 11; + tagIDLabel.Text = "Tag ID:"; + // + // tagIDLabel1 + // + this.tagIDLabel1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.employeesBindingSource, "TagID", true)); + this.tagIDLabel1.Location = new System.Drawing.Point(89, 36); + this.tagIDLabel1.Name = "tagIDLabel1"; + this.tagIDLabel1.Size = new System.Drawing.Size(100, 23); + this.tagIDLabel1.TabIndex = 12; + // + // StatusStrip1 + // + this.StatusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.ToolStripStatusLabel1}); + this.StatusStrip1.Location = new System.Drawing.Point(0, 277); + this.StatusStrip1.Name = "StatusStrip1"; + this.StatusStrip1.Size = new System.Drawing.Size(412, 22); + this.StatusStrip1.TabIndex = 26; + this.StatusStrip1.Text = "StatusStrip1"; + // + // ToolStripStatusLabel1 + // + this.ToolStripStatusLabel1.Name = "ToolStripStatusLabel1"; + this.ToolStripStatusLabel1.Size = new System.Drawing.Size(111, 17); + this.ToolStripStatusLabel1.Text = "ToolStripStatusLabel1"; + // + // GroupBox1 + // + this.GroupBox1.Controls.Add(this.btnDeassign); + this.GroupBox1.Controls.Add(this.txtEmployeeID); + this.GroupBox1.Controls.Add(this.btnFind); + this.GroupBox1.Controls.Add(Label2); + this.GroupBox1.Controls.Add(this.btnAssign); + this.GroupBox1.Controls.Add(this.txtTagID); + this.GroupBox1.Controls.Add(this.Label1); + this.GroupBox1.Location = new System.Drawing.Point(224, 36); + this.GroupBox1.Name = "GroupBox1"; + this.GroupBox1.Size = new System.Drawing.Size(176, 232); + this.GroupBox1.TabIndex = 25; + this.GroupBox1.TabStop = false; + this.GroupBox1.Text = "Administrator"; + // + // btnDeassign + // + this.btnDeassign.Location = new System.Drawing.Point(5, 189); + this.btnDeassign.Name = "btnDeassign"; + this.btnDeassign.Size = new System.Drawing.Size(163, 37); + this.btnDeassign.TabIndex = 19; + this.btnDeassign.Text = "Deassign Tag from Employee"; + this.btnDeassign.UseVisualStyleBackColor = true; + this.btnDeassign.Click += new System.EventHandler(this.btnDeassign_Click); + // + // txtEmployeeID + // + this.txtEmployeeID.Location = new System.Drawing.Point(5, 120); + this.txtEmployeeID.Name = "txtEmployeeID"; + this.txtEmployeeID.Size = new System.Drawing.Size(103, 20); + this.txtEmployeeID.TabIndex = 18; + // + // btnFind + // + this.btnFind.Location = new System.Drawing.Point(114, 118); + this.btnFind.Name = "btnFind"; + this.btnFind.Size = new System.Drawing.Size(54, 23); + this.btnFind.TabIndex = 17; + this.btnFind.Text = "Find"; + this.btnFind.UseVisualStyleBackColor = true; + this.btnFind.Click += new System.EventHandler(this.btnFind_Click); + // + // Label2 + // + Label2.AutoSize = true; + Label2.Location = new System.Drawing.Point(5, 104); + Label2.Name = "Label2"; + Label2.Size = new System.Drawing.Size(139, 13); + Label2.TabIndex = 13; + Label2.Text = "Search for Employee (by ID)"; + // + // btnAssign + // + this.btnAssign.Location = new System.Drawing.Point(5, 146); + this.btnAssign.Name = "btnAssign"; + this.btnAssign.Size = new System.Drawing.Size(163, 37); + this.btnAssign.TabIndex = 3; + this.btnAssign.Text = "Assign Tag to Employee"; + this.btnAssign.UseVisualStyleBackColor = true; + this.btnAssign.Click += new System.EventHandler(this.btnAssign_Click); + // + // txtTagID + // + this.txtTagID.Location = new System.Drawing.Point(6, 32); + this.txtTagID.Multiline = true; + this.txtTagID.Name = "txtTagID"; + this.txtTagID.ReadOnly = true; + this.txtTagID.Size = new System.Drawing.Size(162, 20); + this.txtTagID.TabIndex = 2; + this.txtTagID.TextChanged += new System.EventHandler(this.txtTagID_TextChanged); + // + // Label1 + // + this.Label1.AutoSize = true; + this.Label1.Location = new System.Drawing.Point(3, 16); + this.Label1.Name = "Label1"; + this.Label1.Size = new System.Drawing.Size(40, 13); + this.Label1.TabIndex = 1; + this.Label1.Text = "Tag ID"; + // + // timer1 + // + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(412, 299); + this.Controls.Add(this.StatusStrip1); + this.Controls.Add(this.GroupBox1); + this.Controls.Add(employeeIDLabel); + this.Controls.Add(this.employeeIDLabel1); + this.Controls.Add(lastNameLabel); + this.Controls.Add(this.lastNameTextBox); + this.Controls.Add(firstNameLabel); + this.Controls.Add(this.firstNameTextBox); + this.Controls.Add(titleLabel); + this.Controls.Add(this.titleTextBox); + this.Controls.Add(photoLabel); + this.Controls.Add(this.photoPictureBox); + this.Controls.Add(tagIDLabel); + this.Controls.Add(this.tagIDLabel1); + this.Controls.Add(this.employeesBindingNavigator); + this.Name = "Form1"; + this.Text = "Form1"; + this.Load += new System.EventHandler(this.Form1_Load); + ((System.ComponentModel.ISupportInitialize)(this.northwindDataSet)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.employeesBindingSource)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.employeesBindingNavigator)).EndInit(); + this.employeesBindingNavigator.ResumeLayout(false); + this.employeesBindingNavigator.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.photoPictureBox)).EndInit(); + this.StatusStrip1.ResumeLayout(false); + this.StatusStrip1.PerformLayout(); + this.GroupBox1.ResumeLayout(false); + this.GroupBox1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private NorthwindDataSet northwindDataSet; + private System.Windows.Forms.BindingSource employeesBindingSource; + private Attendance_CS.NorthwindDataSetTableAdapters.EmployeesTableAdapter employeesTableAdapter; + private System.Windows.Forms.BindingNavigator employeesBindingNavigator; + private System.Windows.Forms.ToolStripButton bindingNavigatorAddNewItem; + private System.Windows.Forms.ToolStripLabel bindingNavigatorCountItem; + private System.Windows.Forms.ToolStripButton bindingNavigatorDeleteItem; + private System.Windows.Forms.ToolStripButton bindingNavigatorMoveFirstItem; + private System.Windows.Forms.ToolStripButton bindingNavigatorMovePreviousItem; + private System.Windows.Forms.ToolStripSeparator bindingNavigatorSeparator; + private System.Windows.Forms.ToolStripTextBox bindingNavigatorPositionItem; + private System.Windows.Forms.ToolStripSeparator bindingNavigatorSeparator1; + private System.Windows.Forms.ToolStripButton bindingNavigatorMoveNextItem; + private System.Windows.Forms.ToolStripButton bindingNavigatorMoveLastItem; + private System.Windows.Forms.ToolStripSeparator bindingNavigatorSeparator2; + private System.Windows.Forms.ToolStripButton employeesBindingNavigatorSaveItem; + private System.Windows.Forms.Label employeeIDLabel1; + private System.Windows.Forms.TextBox lastNameTextBox; + private System.Windows.Forms.TextBox firstNameTextBox; + private System.Windows.Forms.TextBox titleTextBox; + private System.Windows.Forms.PictureBox photoPictureBox; + private System.Windows.Forms.Label tagIDLabel1; + internal System.Windows.Forms.StatusStrip StatusStrip1; + internal System.Windows.Forms.ToolStripStatusLabel ToolStripStatusLabel1; + internal System.Windows.Forms.GroupBox GroupBox1; + internal System.Windows.Forms.Button btnDeassign; + internal System.Windows.Forms.TextBox txtEmployeeID; + internal System.Windows.Forms.Button btnFind; + internal System.Windows.Forms.Button btnAssign; + internal System.Windows.Forms.TextBox txtTagID; + internal System.Windows.Forms.Label Label1; + private System.Windows.Forms.Timer timer1; + } +} + diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Form1.cs b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Form1.cs new file mode 100644 index 0000000..12b43df --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Form1.cs @@ -0,0 +1,166 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +using System.Data; +using System.Data.SqlClient; +using System.IO; + +namespace Attendance_CS +{ + public partial class Form1 : Form + { + private System.IO.Ports.SerialPort serialPort = new System.IO.Ports.SerialPort(); + private string tagID = string.Empty; + private DateTime timeRecorded = System.DateTime.Today; + const string COM = "COM6"; + const string FILE_NAME = "C:\\Attendance.csv"; + const int INTERVAL = 3; + + public Form1() + { + InitializeComponent(); + } + + private void employeesBindingNavigatorSaveItem_Click(object sender, EventArgs e) + { + this.Validate(); + this.employeesBindingSource.EndEdit(); + this.employeesTableAdapter.Update(this.northwindDataSet.Employees); + } + + private void Form1_Load(object sender, EventArgs e) + { + // TODO: This line of code loads data into the 'northwindDataSet.Employees' table. You can move, or remove it, as needed. + this.employeesTableAdapter.Fill(this.northwindDataSet.Employees); + + serialPort.DataReceived += + new System.IO.Ports.SerialDataReceivedEventHandler(DataReceived); + + employeesBindingSource.Filter = "TAGID='xxxxxxxxxx'"; + timer1.Interval = INTERVAL * 1000; + if (serialPort.IsOpen) + { + serialPort.Close(); + } + try + { + serialPort.PortName = COM; + serialPort.BaudRate = 9600; + serialPort.Parity = System.IO.Ports.Parity.None; + serialPort.DataBits = 8; + serialPort.StopBits = System.IO.Ports.StopBits.One; + serialPort.Handshake = System.IO.Ports.Handshake.None; + serialPort.Open(); + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + } + + private void DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) + { + txtTagID.BeginInvoke(new myDelegate(updateTextBox), new object[] { }); + } + + public delegate void myDelegate(); + public void updateTextBox() + { + txtTagID.AppendText(serialPort.ReadExisting()); + txtTagID.ScrollToCaret(); + } + + private void btnFind_Click(object sender, EventArgs e) + { + if (txtEmployeeID.Text == string.Empty) + { + employeesBindingSource.RemoveFilter(); + } + else + { + employeesBindingSource.Filter = "EmployeeID='" + txtEmployeeID.Text + "'"; + } + } + + private void WriteToLog(string employeeID, string employeeName) + { + string str = employeeID + "," + employeeName + "," + System.DateTime.Today.ToString() + Environment.NewLine; + File.AppendAllText(FILE_NAME, str); + } + + private void txtTagID_TextChanged(object sender, EventArgs e) + { + if (txtTagID.Lines[txtTagID.Lines.Length - 1] == string.Empty) + { + string temptagID = txtTagID.Lines[txtTagID.Lines.Length - 2]; + TimeSpan tp = System.DateTime.Today.Subtract(timeRecorded); + double timeInterval = tp.Ticks / TimeSpan.TicksPerSecond; + if ((temptagID == tagID) & timeInterval < INTERVAL) + { + return; + } + tagID = temptagID; + employeesBindingSource.RemoveFilter(); + employeesBindingSource.Filter = "TAGID='" + tagID + "'"; + if (employeesBindingSource.Count < 1) + { + ToolStripStatusLabel1.Text = "Employee not found."; + } + else + { + ToolStripStatusLabel1.Text = "Employee found."; + WriteToLog(employeeIDLabel1.Text, lastNameTextBox.Text + ", " + firstNameTextBox.Text); + timer1.Enabled = false; + timer1.Enabled = true; + } + timeRecorded = System.DateTime.Today; + } + } + + private void timer1_Tick(object sender, EventArgs e) + { + employeesBindingSource.Filter = "TAGID='xxxxxxxxxx'"; + timer1.Enabled = false; + } + + private void btnAssign_Click(object sender, EventArgs e) + { + if (txtTagID.Lines.Length > 1) + { + string tagID = txtTagID.Lines[txtTagID.Lines.Length - 2]; + } + else + { + ToolStripStatusLabel1.Text = "No tag id scanned."; + return; + } + if (txtTagID.Text != string.Empty) + { + tagIDLabel1.Text = tagID; + ToolStripStatusLabel1.Text = "Tag associated with employee."; + this.Validate(); + this.employeesBindingSource.EndEdit(); + this.employeesTableAdapter.Update(this.northwindDataSet.Employees); + } + } + + private void btnDeassign_Click(object sender, EventArgs e) + { + if (tagIDLabel1.Text.Trim() == string.Empty) + { + ToolStripStatusLabel1.Text = "Current employee has no tag ID."; + return; + } + tagIDLabel1.Text = string.Empty; + this.Validate(); + this.employeesBindingSource.EndEdit(); + this.employeesTableAdapter.Update(this.northwindDataSet.Employees); + ToolStripStatusLabel1.Text = "Tag deassociated from employee."; + } + } +} \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Form1.resx b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Form1.resx new file mode 100644 index 0000000..b4eee7c --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Form1.resx @@ -0,0 +1,245 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 158, 17 + + + 333, 17 + + + 504, 17 + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAU1JREFUOE9jYBi0 + 4O4C9v+35nH+vzqH6//FGbz/SXbodaDGP48a//952PD/5GQB0g04P50XbsDBHhHSDTg+SRBoe93/Pw+q + /u9oFydswKWZPP/PTuX7fxKo8Ui/0P993SJAzeX//94r+r++Qeb/qhq5/0srFf/PL1X+P6tIFdPAU0B/ + /nlYD9RUC8SV///cKwHivP9/72b+/3sn+f/f23H//92MAOKQ/5NyNDENONQrDHbu3/ulQI0FQI3ZQI2p + QI0J///digZqDPv/70bQ/3/X/f53peliGrCzXeL/lmap/+vAzpX/v6RC8f/fWzFAjeH/p+Zp/J+QpfW/ + O0P3f3uq/v/mREPCYTIb6E+Qc//dCPjfk6FDWAN6QgH5898NfyD2+9+arE+6Ad3pumD/gnB9nBHpBrQk + GfxviDf8XxNr/L8y2oR0A0hO++RqAAAkI9ieo+gjUwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAW9JREFUOE+tkk0o + w3EYx3dV3kq5uKBWDiPT8hISMiQsMiEyQ9qBg0hoFwcHUi7kgIvkQFJSTrQ4zdvmrTW1/kuT0i74x+X3 + MRal/fEnv8tz+H2fz/N8vz0azX88PG6wmcDp4E881hYR3VUIixF2Nr+FcO2DlbnPGjaWoM+M6DAiOitg + YUoR8rqhsJTBWG/kP6fOMKTegGjKh/7mTyIx0oUw58C0/XubLM8iKtPeQIx2gfcMJgbD0FBVlRE+D7QU + hS2ZshANuTDQqq75fQIHe6GVcxHV6VCr/2VzQIKmAshOQNbHc6+PhTqDOggBP5jzoDCJoLUaLo7fwr3V + hSCr8z8EeHcLbSU8FCfjLU0nuL/70cB4Py5tDLL7UBnC8xMMW6EkhRNdIsGt9QjhTXkGUnsN8rVf4Q72 + tpFzEnGlRiH1NIL8qDjJoY1DdjkVADNjSGnReI2ZIF196VW22+D8SAFw6YLJITjaV5e2qotSIXoBiiMD + HEVvQ/IAAAAASUVORK5CYII= + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAStJREFUOE9jYBg0 + oHDW8/9NC57/z5z4+D8uR4W3P8Apx5A789n/VUfe/8elKL77wf/ghmu4DciY8vT/wn0fsCqK73n4f+n+ + ///9qy/gNiCh58n/aVveYyiKaL8P1pw56/9/r9ITuA2I7Hr0v3f1BxRFoa33wJpb1wFt7/z73yX/AG4D + Apsf/q+b/w6uKLjl7v9Fe///7wBqzpjz879d3c//9hnbcRvgUXX/f/60NyiK7Ipv/0+f8/u/f9e3/zqF + 7/5bJKzHbYB96d3/2ZNfYyjSTzn/36ToxX+VrE//jSOX4TbAIu/O/9T+11gVGSSd+C+b9vW/bvA83AYY + Zt3+H9byEqci/dTL/zV8p+E2QCftxn+/6od4Fal4TMBtgFPulf8gBXgVDZqMh+wQAPB2wKsSwCgmAAAA + AElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAL1JREFUOE9jYBgy + ILz9wX+yHRvf/eB/cMM18gyI73n4f+n+///9qy+QbkBE+32w5sxZ//97lZ4gzYDQ1ntgza3rgLZ3/v3v + kn+AeAOCW+7+X7T3//8OoOaMOT//29X9/G+fsZ14A0ChbVd8+3/6nN///bu+/dcpfPffImE9aQaADNFP + Of/fpOjFf5WsT/+NI5eRbgDIEIOkE/9l077+1w2eR54BYJekXv6v4TuNfANAhqh4TKDMALKTMc01AgDQ + FGCYkuTLEQAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAKtJREFUOE9jYBh0 + oHDW8/8UOSp35rP/Cd33yDckY8rT//P2//6f0HWHPEMSep78n73v1//OrX//u5VeJt2QyK5H/6ds+/W/ + ZOnf/wnT//63yT1LmiGBzQ//t659D9ZsXPLlv3T0tf/GkcuIN8Sj6v7/krnv4JoVXXqI1wyKPvvSu/8D + W56BbSZZM8gAi7w7/20KrpCnGWSAYdZt8jWDDNBJu0GanylKtoNCMwCgfl+gC2KedgAAAABJRU5ErkJg + gg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAATBJREFUOE9jYBhU + oHDW8/+4HASSa1rw/H/mxMc41TDkznz2P6H7HlYFILlVR97/D29/gNuAjClP/8/b//t/QtcdDEUguYX7 + PvwPbriG24CEnif/Z+/79b9z69//bqWXURSC5KZtef/fv/oCbgMiux79n7Lt1/+SpX//J0z/+98m9yxc + MUiud/WH/16lJ3AbENj88H/r2vdgzcYlX/5LR1/7bxy5DKwBJFc3/91/l/wDuA3wqLr/v2TuO7hmRZce + uGKQXP60N//tM7bjNsC+9O7/wJZnYJuRNYNcAJLLnvz6v0XCetwGWOTd+W9TcAVDM8gAkFxq/2u4l7Cm + F8Os21g1gxSD5MJaXv7XDZ6H2wU6aTdwSoLk/Kof/tfwnYbbAHz5yin3yn8VjwlgPKjyHwMAvtG/s0Vm + x8MAAAAASUVORK5CYII= + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAilJREFUOE+tk91L + k3EUx/cvdN9N0EW3NTWGa7EaPOUcyqphWBG9PZEv5dJlmqhYmUYtXyBb4dJJy+kknFT4BqZIjaFMJUsz + V7TEoabYRDD49ju/6Pm1Mm/qB+fy8znPOef7qFT/4z17GgWVr30Zbd4lPHYvoLEhgvuOGdTWfIL9dgg3 + yqdQWjKBwoLXyMsdxYXzQSi9CeztAWqqV7HRW1ldgzGtF4fTnvBSBN7WRS6orPjyV57gyMIKdpufQ62W + YTnkEQL3o3kuKC35vK7gJ/w+vIg4kw8Fl6dxwNwkBM76WS64ZHv3h+BXeGQygm2SF9accaSmOIWg7m6Y + C7KzRmMEv8ODwTA2692Q5QBMJocQVFd95AL5TEARrAf3+D9gU2IDjhx9gaSkWiG4WTmN7i6wUwLHT76C + 5dgA3zYtjGamz6bOP+A+HLR0QpLsQnC1bBIdPrAMAE2ub+zuX1F+fY4vlRZGM2dmBBU4ObUdBkOFEFwp + HIenGXjoXGPBicKYnhNT5hM2pJ8r4p2TUxi83wO9vkwIbHljDAaq7kR5ZxJQSOK0EobezmJsag5y7jXs + NbZxWLvHBZ2uSAgolo57UD6bBASfzb+FN6F5hGaWcLHYjni9i8GNiN/1ANrEfCHIzBhmcy/zmbcaPNiy + Q0JLRz98XYPo7vNj4OUQ9pksUOvqkcDg7Zo6aDTWWMHpU/08npQwCgndmU5F26aF0czUlYrgnQnZQvAv + f/R3bGg6a0rM640AAAAASUVORK5CYII= + + + + False + + + False + + + False + + + False + + + False + + + False + + + 808, 17 + + + False + + + 17, 54 + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/NorthwindDataSet.Designer.cs b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/NorthwindDataSet.Designer.cs new file mode 100644 index 0000000..aac164a --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/NorthwindDataSet.Designer.cs @@ -0,0 +1,1023 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +#pragma warning disable 1591 + +namespace Attendance_CS { + using System; + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + [Serializable()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.ComponentModel.ToolboxItem(true)] + [System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedDataSetSchema")] + [System.Xml.Serialization.XmlRootAttribute("NorthwindDataSet")] + [System.ComponentModel.Design.HelpKeywordAttribute("vs.data.DataSet")] + public partial class NorthwindDataSet : System.Data.DataSet { + + private EmployeesDataTable tableEmployees; + + private System.Data.SchemaSerializationMode _schemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema; + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public NorthwindDataSet() { + this.BeginInit(); + this.InitClass(); + System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged); + base.Tables.CollectionChanged += schemaChangedHandler; + base.Relations.CollectionChanged += schemaChangedHandler; + this.EndInit(); + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected NorthwindDataSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : + base(info, context, false) { + if ((this.IsBinarySerialized(info, context) == true)) { + this.InitVars(false); + System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler1 = new System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged); + this.Tables.CollectionChanged += schemaChangedHandler1; + this.Relations.CollectionChanged += schemaChangedHandler1; + return; + } + string strSchema = ((string)(info.GetValue("XmlSchema", typeof(string)))); + if ((this.DetermineSchemaSerializationMode(info, context) == System.Data.SchemaSerializationMode.IncludeSchema)) { + System.Data.DataSet ds = new System.Data.DataSet(); + ds.ReadXmlSchema(new System.Xml.XmlTextReader(new System.IO.StringReader(strSchema))); + if ((ds.Tables["Employees"] != null)) { + base.Tables.Add(new EmployeesDataTable(ds.Tables["Employees"])); + } + this.DataSetName = ds.DataSetName; + this.Prefix = ds.Prefix; + this.Namespace = ds.Namespace; + this.Locale = ds.Locale; + this.CaseSensitive = ds.CaseSensitive; + this.EnforceConstraints = ds.EnforceConstraints; + this.Merge(ds, false, System.Data.MissingSchemaAction.Add); + this.InitVars(); + } + else { + this.ReadXmlSchema(new System.Xml.XmlTextReader(new System.IO.StringReader(strSchema))); + } + this.GetSerializationData(info, context); + System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged); + base.Tables.CollectionChanged += schemaChangedHandler; + this.Relations.CollectionChanged += schemaChangedHandler; + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.ComponentModel.Browsable(false)] + [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)] + public EmployeesDataTable Employees { + get { + return this.tableEmployees; + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.ComponentModel.BrowsableAttribute(true)] + [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Visible)] + public override System.Data.SchemaSerializationMode SchemaSerializationMode { + get { + return this._schemaSerializationMode; + } + set { + this._schemaSerializationMode = value; + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public new System.Data.DataTableCollection Tables { + get { + return base.Tables; + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public new System.Data.DataRelationCollection Relations { + get { + return base.Relations; + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void InitializeDerivedDataSet() { + this.BeginInit(); + this.InitClass(); + this.EndInit(); + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public override System.Data.DataSet Clone() { + NorthwindDataSet cln = ((NorthwindDataSet)(base.Clone())); + cln.InitVars(); + cln.SchemaSerializationMode = this.SchemaSerializationMode; + return cln; + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override bool ShouldSerializeTables() { + return false; + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override bool ShouldSerializeRelations() { + return false; + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void ReadXmlSerializable(System.Xml.XmlReader reader) { + if ((this.DetermineSchemaSerializationMode(reader) == System.Data.SchemaSerializationMode.IncludeSchema)) { + this.Reset(); + System.Data.DataSet ds = new System.Data.DataSet(); + ds.ReadXml(reader); + if ((ds.Tables["Employees"] != null)) { + base.Tables.Add(new EmployeesDataTable(ds.Tables["Employees"])); + } + this.DataSetName = ds.DataSetName; + this.Prefix = ds.Prefix; + this.Namespace = ds.Namespace; + this.Locale = ds.Locale; + this.CaseSensitive = ds.CaseSensitive; + this.EnforceConstraints = ds.EnforceConstraints; + this.Merge(ds, false, System.Data.MissingSchemaAction.Add); + this.InitVars(); + } + else { + this.ReadXml(reader); + this.InitVars(); + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override System.Xml.Schema.XmlSchema GetSchemaSerializable() { + System.IO.MemoryStream stream = new System.IO.MemoryStream(); + this.WriteXmlSchema(new System.Xml.XmlTextWriter(stream, null)); + stream.Position = 0; + return System.Xml.Schema.XmlSchema.Read(new System.Xml.XmlTextReader(stream), null); + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal void InitVars() { + this.InitVars(true); + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal void InitVars(bool initTable) { + this.tableEmployees = ((EmployeesDataTable)(base.Tables["Employees"])); + if ((initTable == true)) { + if ((this.tableEmployees != null)) { + this.tableEmployees.InitVars(); + } + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + private void InitClass() { + this.DataSetName = "NorthwindDataSet"; + this.Prefix = ""; + this.Namespace = "http://tempuri.org/NorthwindDataSet.xsd"; + this.EnforceConstraints = true; + this.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema; + this.tableEmployees = new EmployeesDataTable(); + base.Tables.Add(this.tableEmployees); + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + private bool ShouldSerializeEmployees() { + return false; + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + private void SchemaChanged(object sender, System.ComponentModel.CollectionChangeEventArgs e) { + if ((e.Action == System.ComponentModel.CollectionChangeAction.Remove)) { + this.InitVars(); + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(System.Xml.Schema.XmlSchemaSet xs) { + NorthwindDataSet ds = new NorthwindDataSet(); + System.Xml.Schema.XmlSchemaComplexType type = new System.Xml.Schema.XmlSchemaComplexType(); + System.Xml.Schema.XmlSchemaSequence sequence = new System.Xml.Schema.XmlSchemaSequence(); + xs.Add(ds.GetSchemaSerializable()); + System.Xml.Schema.XmlSchemaAny any = new System.Xml.Schema.XmlSchemaAny(); + any.Namespace = ds.Namespace; + sequence.Items.Add(any); + type.Particle = sequence; + return type; + } + + public delegate void EmployeesRowChangeEventHandler(object sender, EmployeesRowChangeEvent e); + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + [System.Serializable()] + [System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedTableSchema")] + public partial class EmployeesDataTable : System.Data.DataTable, System.Collections.IEnumerable { + + private System.Data.DataColumn columnEmployeeID; + + private System.Data.DataColumn columnLastName; + + private System.Data.DataColumn columnFirstName; + + private System.Data.DataColumn columnTitle; + + private System.Data.DataColumn columnPhoto; + + private System.Data.DataColumn columnTagID; + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public EmployeesDataTable() { + this.TableName = "Employees"; + this.BeginInit(); + this.InitClass(); + this.EndInit(); + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal EmployeesDataTable(System.Data.DataTable table) { + this.TableName = table.TableName; + if ((table.CaseSensitive != table.DataSet.CaseSensitive)) { + this.CaseSensitive = table.CaseSensitive; + } + if ((table.Locale.ToString() != table.DataSet.Locale.ToString())) { + this.Locale = table.Locale; + } + if ((table.Namespace != table.DataSet.Namespace)) { + this.Namespace = table.Namespace; + } + this.Prefix = table.Prefix; + this.MinimumCapacity = table.MinimumCapacity; + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected EmployeesDataTable(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : + base(info, context) { + this.InitVars(); + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public System.Data.DataColumn EmployeeIDColumn { + get { + return this.columnEmployeeID; + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public System.Data.DataColumn LastNameColumn { + get { + return this.columnLastName; + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public System.Data.DataColumn FirstNameColumn { + get { + return this.columnFirstName; + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public System.Data.DataColumn TitleColumn { + get { + return this.columnTitle; + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public System.Data.DataColumn PhotoColumn { + get { + return this.columnPhoto; + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public System.Data.DataColumn TagIDColumn { + get { + return this.columnTagID; + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.ComponentModel.Browsable(false)] + public int Count { + get { + return this.Rows.Count; + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public EmployeesRow this[int index] { + get { + return ((EmployeesRow)(this.Rows[index])); + } + } + + public event EmployeesRowChangeEventHandler EmployeesRowChanging; + + public event EmployeesRowChangeEventHandler EmployeesRowChanged; + + public event EmployeesRowChangeEventHandler EmployeesRowDeleting; + + public event EmployeesRowChangeEventHandler EmployeesRowDeleted; + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public void AddEmployeesRow(EmployeesRow row) { + this.Rows.Add(row); + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public EmployeesRow AddEmployeesRow(string LastName, string FirstName, string Title, byte[] Photo, string TagID) { + EmployeesRow rowEmployeesRow = ((EmployeesRow)(this.NewRow())); + rowEmployeesRow.ItemArray = new object[] { + null, + LastName, + FirstName, + Title, + Photo, + TagID}; + this.Rows.Add(rowEmployeesRow); + return rowEmployeesRow; + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public EmployeesRow FindByEmployeeID(int EmployeeID) { + return ((EmployeesRow)(this.Rows.Find(new object[] { + EmployeeID}))); + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public virtual System.Collections.IEnumerator GetEnumerator() { + return this.Rows.GetEnumerator(); + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public override System.Data.DataTable Clone() { + EmployeesDataTable cln = ((EmployeesDataTable)(base.Clone())); + cln.InitVars(); + return cln; + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override System.Data.DataTable CreateInstance() { + return new EmployeesDataTable(); + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal void InitVars() { + this.columnEmployeeID = base.Columns["EmployeeID"]; + this.columnLastName = base.Columns["LastName"]; + this.columnFirstName = base.Columns["FirstName"]; + this.columnTitle = base.Columns["Title"]; + this.columnPhoto = base.Columns["Photo"]; + this.columnTagID = base.Columns["TagID"]; + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + private void InitClass() { + this.columnEmployeeID = new System.Data.DataColumn("EmployeeID", typeof(int), null, System.Data.MappingType.Element); + base.Columns.Add(this.columnEmployeeID); + this.columnLastName = new System.Data.DataColumn("LastName", typeof(string), null, System.Data.MappingType.Element); + base.Columns.Add(this.columnLastName); + this.columnFirstName = new System.Data.DataColumn("FirstName", typeof(string), null, System.Data.MappingType.Element); + base.Columns.Add(this.columnFirstName); + this.columnTitle = new System.Data.DataColumn("Title", typeof(string), null, System.Data.MappingType.Element); + base.Columns.Add(this.columnTitle); + this.columnPhoto = new System.Data.DataColumn("Photo", typeof(byte[]), null, System.Data.MappingType.Element); + base.Columns.Add(this.columnPhoto); + this.columnTagID = new System.Data.DataColumn("TagID", typeof(string), null, System.Data.MappingType.Element); + base.Columns.Add(this.columnTagID); + this.Constraints.Add(new System.Data.UniqueConstraint("Constraint1", new System.Data.DataColumn[] { + this.columnEmployeeID}, true)); + this.columnEmployeeID.AutoIncrement = true; + this.columnEmployeeID.AllowDBNull = false; + this.columnEmployeeID.ReadOnly = true; + this.columnEmployeeID.Unique = true; + this.columnLastName.AllowDBNull = false; + this.columnLastName.MaxLength = 20; + this.columnFirstName.AllowDBNull = false; + this.columnFirstName.MaxLength = 10; + this.columnTitle.MaxLength = 30; + this.columnTagID.MaxLength = 10; + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public EmployeesRow NewEmployeesRow() { + return ((EmployeesRow)(this.NewRow())); + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override System.Data.DataRow NewRowFromBuilder(System.Data.DataRowBuilder builder) { + return new EmployeesRow(builder); + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override System.Type GetRowType() { + return typeof(EmployeesRow); + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void OnRowChanged(System.Data.DataRowChangeEventArgs e) { + base.OnRowChanged(e); + if ((this.EmployeesRowChanged != null)) { + this.EmployeesRowChanged(this, new EmployeesRowChangeEvent(((EmployeesRow)(e.Row)), e.Action)); + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void OnRowChanging(System.Data.DataRowChangeEventArgs e) { + base.OnRowChanging(e); + if ((this.EmployeesRowChanging != null)) { + this.EmployeesRowChanging(this, new EmployeesRowChangeEvent(((EmployeesRow)(e.Row)), e.Action)); + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void OnRowDeleted(System.Data.DataRowChangeEventArgs e) { + base.OnRowDeleted(e); + if ((this.EmployeesRowDeleted != null)) { + this.EmployeesRowDeleted(this, new EmployeesRowChangeEvent(((EmployeesRow)(e.Row)), e.Action)); + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void OnRowDeleting(System.Data.DataRowChangeEventArgs e) { + base.OnRowDeleting(e); + if ((this.EmployeesRowDeleting != null)) { + this.EmployeesRowDeleting(this, new EmployeesRowChangeEvent(((EmployeesRow)(e.Row)), e.Action)); + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public void RemoveEmployeesRow(EmployeesRow row) { + this.Rows.Remove(row); + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(System.Xml.Schema.XmlSchemaSet xs) { + System.Xml.Schema.XmlSchemaComplexType type = new System.Xml.Schema.XmlSchemaComplexType(); + System.Xml.Schema.XmlSchemaSequence sequence = new System.Xml.Schema.XmlSchemaSequence(); + NorthwindDataSet ds = new NorthwindDataSet(); + xs.Add(ds.GetSchemaSerializable()); + System.Xml.Schema.XmlSchemaAny any1 = new System.Xml.Schema.XmlSchemaAny(); + any1.Namespace = "http://www.w3.org/2001/XMLSchema"; + any1.MinOccurs = new decimal(0); + any1.MaxOccurs = decimal.MaxValue; + any1.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax; + sequence.Items.Add(any1); + System.Xml.Schema.XmlSchemaAny any2 = new System.Xml.Schema.XmlSchemaAny(); + any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; + any2.MinOccurs = new decimal(1); + any2.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax; + sequence.Items.Add(any2); + System.Xml.Schema.XmlSchemaAttribute attribute1 = new System.Xml.Schema.XmlSchemaAttribute(); + attribute1.Name = "namespace"; + attribute1.FixedValue = ds.Namespace; + type.Attributes.Add(attribute1); + System.Xml.Schema.XmlSchemaAttribute attribute2 = new System.Xml.Schema.XmlSchemaAttribute(); + attribute2.Name = "tableTypeName"; + attribute2.FixedValue = "EmployeesDataTable"; + type.Attributes.Add(attribute2); + type.Particle = sequence; + return type; + } + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + public partial class EmployeesRow : System.Data.DataRow { + + private EmployeesDataTable tableEmployees; + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal EmployeesRow(System.Data.DataRowBuilder rb) : + base(rb) { + this.tableEmployees = ((EmployeesDataTable)(this.Table)); + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public int EmployeeID { + get { + return ((int)(this[this.tableEmployees.EmployeeIDColumn])); + } + set { + this[this.tableEmployees.EmployeeIDColumn] = value; + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public string LastName { + get { + return ((string)(this[this.tableEmployees.LastNameColumn])); + } + set { + this[this.tableEmployees.LastNameColumn] = value; + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public string FirstName { + get { + return ((string)(this[this.tableEmployees.FirstNameColumn])); + } + set { + this[this.tableEmployees.FirstNameColumn] = value; + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public string Title { + get { + try { + return ((string)(this[this.tableEmployees.TitleColumn])); + } + catch (System.InvalidCastException e) { + throw new System.Data.StrongTypingException("The value for column \'Title\' in table \'Employees\' is DBNull.", e); + } + } + set { + this[this.tableEmployees.TitleColumn] = value; + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public byte[] Photo { + get { + try { + return ((byte[])(this[this.tableEmployees.PhotoColumn])); + } + catch (System.InvalidCastException e) { + throw new System.Data.StrongTypingException("The value for column \'Photo\' in table \'Employees\' is DBNull.", e); + } + } + set { + this[this.tableEmployees.PhotoColumn] = value; + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public string TagID { + get { + try { + return ((string)(this[this.tableEmployees.TagIDColumn])); + } + catch (System.InvalidCastException e) { + throw new System.Data.StrongTypingException("The value for column \'TagID\' in table \'Employees\' is DBNull.", e); + } + } + set { + this[this.tableEmployees.TagIDColumn] = value; + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public bool IsTitleNull() { + return this.IsNull(this.tableEmployees.TitleColumn); + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public void SetTitleNull() { + this[this.tableEmployees.TitleColumn] = System.Convert.DBNull; + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public bool IsPhotoNull() { + return this.IsNull(this.tableEmployees.PhotoColumn); + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public void SetPhotoNull() { + this[this.tableEmployees.PhotoColumn] = System.Convert.DBNull; + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public bool IsTagIDNull() { + return this.IsNull(this.tableEmployees.TagIDColumn); + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public void SetTagIDNull() { + this[this.tableEmployees.TagIDColumn] = System.Convert.DBNull; + } + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + public class EmployeesRowChangeEvent : System.EventArgs { + + private EmployeesRow eventRow; + + private System.Data.DataRowAction eventAction; + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public EmployeesRowChangeEvent(EmployeesRow row, System.Data.DataRowAction action) { + this.eventRow = row; + this.eventAction = action; + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public EmployeesRow Row { + get { + return this.eventRow; + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public System.Data.DataRowAction Action { + get { + return this.eventAction; + } + } + } + } +} +namespace Attendance_CS.NorthwindDataSetTableAdapters { + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.ComponentModel.ToolboxItem(true)] + [System.ComponentModel.DataObjectAttribute(true)] + [System.ComponentModel.DesignerAttribute("Microsoft.VSDesigner.DataSource.Design.TableAdapterDesigner, Microsoft.VSDesigner" + + ", Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] + [System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + public partial class EmployeesTableAdapter : System.ComponentModel.Component { + + private System.Data.SqlClient.SqlDataAdapter _adapter; + + private System.Data.SqlClient.SqlConnection _connection; + + private System.Data.SqlClient.SqlCommand[] _commandCollection; + + private bool _clearBeforeFill; + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public EmployeesTableAdapter() { + this.ClearBeforeFill = true; + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + private System.Data.SqlClient.SqlDataAdapter Adapter { + get { + if ((this._adapter == null)) { + this.InitAdapter(); + } + return this._adapter; + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal System.Data.SqlClient.SqlConnection Connection { + get { + if ((this._connection == null)) { + this.InitConnection(); + } + return this._connection; + } + set { + this._connection = value; + if ((this.Adapter.InsertCommand != null)) { + this.Adapter.InsertCommand.Connection = value; + } + if ((this.Adapter.DeleteCommand != null)) { + this.Adapter.DeleteCommand.Connection = value; + } + if ((this.Adapter.UpdateCommand != null)) { + this.Adapter.UpdateCommand.Connection = value; + } + for (int i = 0; (i < this.CommandCollection.Length); i = (i + 1)) { + if ((this.CommandCollection[i] != null)) { + ((System.Data.SqlClient.SqlCommand)(this.CommandCollection[i])).Connection = value; + } + } + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected System.Data.SqlClient.SqlCommand[] CommandCollection { + get { + if ((this._commandCollection == null)) { + this.InitCommandCollection(); + } + return this._commandCollection; + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + public bool ClearBeforeFill { + get { + return this._clearBeforeFill; + } + set { + this._clearBeforeFill = value; + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + private void InitAdapter() { + this._adapter = new System.Data.SqlClient.SqlDataAdapter(); + System.Data.Common.DataTableMapping tableMapping = new System.Data.Common.DataTableMapping(); + tableMapping.SourceTable = "Table"; + tableMapping.DataSetTable = "Employees"; + tableMapping.ColumnMappings.Add("EmployeeID", "EmployeeID"); + tableMapping.ColumnMappings.Add("LastName", "LastName"); + tableMapping.ColumnMappings.Add("FirstName", "FirstName"); + tableMapping.ColumnMappings.Add("Title", "Title"); + tableMapping.ColumnMappings.Add("Photo", "Photo"); + tableMapping.ColumnMappings.Add("TagID", "TagID"); + this._adapter.TableMappings.Add(tableMapping); + this._adapter.DeleteCommand = new System.Data.SqlClient.SqlCommand(); + this._adapter.DeleteCommand.Connection = this.Connection; + this._adapter.DeleteCommand.CommandText = @"DELETE FROM [dbo].[Employees] WHERE (([EmployeeID] = @Original_EmployeeID) AND ([LastName] = @Original_LastName) AND ([FirstName] = @Original_FirstName) AND ((@IsNull_Title = 1 AND [Title] IS NULL) OR ([Title] = @Original_Title)) AND ((@IsNull_TagID = 1 AND [TagID] IS NULL) OR ([TagID] = @Original_TagID)))"; + this._adapter.DeleteCommand.CommandType = System.Data.CommandType.Text; + this._adapter.DeleteCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_EmployeeID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "EmployeeID", System.Data.DataRowVersion.Original, false, null, "", "", "")); + this._adapter.DeleteCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_LastName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "LastName", System.Data.DataRowVersion.Original, false, null, "", "", "")); + this._adapter.DeleteCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_FirstName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "FirstName", System.Data.DataRowVersion.Original, false, null, "", "", "")); + this._adapter.DeleteCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IsNull_Title", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "Title", System.Data.DataRowVersion.Original, true, null, "", "", "")); + this._adapter.DeleteCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Title", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "Title", System.Data.DataRowVersion.Original, false, null, "", "", "")); + this._adapter.DeleteCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IsNull_TagID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "TagID", System.Data.DataRowVersion.Original, true, null, "", "", "")); + this._adapter.DeleteCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_TagID", System.Data.SqlDbType.NChar, 0, System.Data.ParameterDirection.Input, 0, 0, "TagID", System.Data.DataRowVersion.Original, false, null, "", "", "")); + this._adapter.InsertCommand = new System.Data.SqlClient.SqlCommand(); + this._adapter.InsertCommand.Connection = this.Connection; + this._adapter.InsertCommand.CommandText = "INSERT INTO [dbo].[Employees] ([LastName], [FirstName], [Title], [Photo], [TagID]" + + ") VALUES (@LastName, @FirstName, @Title, @Photo, @TagID);\r\nSELECT EmployeeID, La" + + "stName, FirstName, Title, Photo, TagID FROM Employees WHERE (EmployeeID = SCOPE_" + + "IDENTITY())"; + this._adapter.InsertCommand.CommandType = System.Data.CommandType.Text; + this._adapter.InsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@LastName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "LastName", System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._adapter.InsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@FirstName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "FirstName", System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._adapter.InsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Title", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "Title", System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._adapter.InsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Photo", System.Data.SqlDbType.Image, 0, System.Data.ParameterDirection.Input, 0, 0, "Photo", System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._adapter.InsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@TagID", System.Data.SqlDbType.NChar, 0, System.Data.ParameterDirection.Input, 0, 0, "TagID", System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._adapter.UpdateCommand = new System.Data.SqlClient.SqlCommand(); + this._adapter.UpdateCommand.Connection = this.Connection; + this._adapter.UpdateCommand.CommandText = @"UPDATE [dbo].[Employees] SET [LastName] = @LastName, [FirstName] = @FirstName, [Title] = @Title, [Photo] = @Photo, [TagID] = @TagID WHERE (([EmployeeID] = @Original_EmployeeID) AND ([LastName] = @Original_LastName) AND ([FirstName] = @Original_FirstName) AND ((@IsNull_Title = 1 AND [Title] IS NULL) OR ([Title] = @Original_Title)) AND ((@IsNull_TagID = 1 AND [TagID] IS NULL) OR ([TagID] = @Original_TagID))); +SELECT EmployeeID, LastName, FirstName, Title, Photo, TagID FROM Employees WHERE (EmployeeID = @EmployeeID)"; + this._adapter.UpdateCommand.CommandType = System.Data.CommandType.Text; + this._adapter.UpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@LastName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "LastName", System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._adapter.UpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@FirstName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "FirstName", System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._adapter.UpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Title", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "Title", System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._adapter.UpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Photo", System.Data.SqlDbType.Image, 0, System.Data.ParameterDirection.Input, 0, 0, "Photo", System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._adapter.UpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@TagID", System.Data.SqlDbType.NChar, 0, System.Data.ParameterDirection.Input, 0, 0, "TagID", System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._adapter.UpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_EmployeeID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "EmployeeID", System.Data.DataRowVersion.Original, false, null, "", "", "")); + this._adapter.UpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_LastName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "LastName", System.Data.DataRowVersion.Original, false, null, "", "", "")); + this._adapter.UpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_FirstName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "FirstName", System.Data.DataRowVersion.Original, false, null, "", "", "")); + this._adapter.UpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IsNull_Title", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "Title", System.Data.DataRowVersion.Original, true, null, "", "", "")); + this._adapter.UpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Title", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "Title", System.Data.DataRowVersion.Original, false, null, "", "", "")); + this._adapter.UpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IsNull_TagID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "TagID", System.Data.DataRowVersion.Original, true, null, "", "", "")); + this._adapter.UpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_TagID", System.Data.SqlDbType.NChar, 0, System.Data.ParameterDirection.Input, 0, 0, "TagID", System.Data.DataRowVersion.Original, false, null, "", "", "")); + this._adapter.UpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@EmployeeID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, 0, 0, "EmployeeID", System.Data.DataRowVersion.Current, false, null, "", "", "")); + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + private void InitConnection() { + this._connection = new System.Data.SqlClient.SqlConnection(); + this._connection.ConnectionString = global::Attendance_CS.Properties.Settings.Default.NorthwindConnectionString; + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + private void InitCommandCollection() { + this._commandCollection = new System.Data.SqlClient.SqlCommand[1]; + this._commandCollection[0] = new System.Data.SqlClient.SqlCommand(); + this._commandCollection[0].Connection = this.Connection; + this._commandCollection[0].CommandText = "SELECT EmployeeID, LastName, FirstName, Title, Photo, TagID FROM dbo.Employees"; + this._commandCollection[0].CommandType = System.Data.CommandType.Text; + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Fill, true)] + public virtual int Fill(NorthwindDataSet.EmployeesDataTable dataTable) { + this.Adapter.SelectCommand = this.CommandCollection[0]; + if ((this.ClearBeforeFill == true)) { + dataTable.Clear(); + } + int returnValue = this.Adapter.Fill(dataTable); + return returnValue; + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)] + public virtual NorthwindDataSet.EmployeesDataTable GetData() { + this.Adapter.SelectCommand = this.CommandCollection[0]; + NorthwindDataSet.EmployeesDataTable dataTable = new NorthwindDataSet.EmployeesDataTable(); + this.Adapter.Fill(dataTable); + return dataTable; + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + public virtual int Update(NorthwindDataSet.EmployeesDataTable dataTable) { + return this.Adapter.Update(dataTable); + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + public virtual int Update(NorthwindDataSet dataSet) { + return this.Adapter.Update(dataSet, "Employees"); + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + public virtual int Update(System.Data.DataRow dataRow) { + return this.Adapter.Update(new System.Data.DataRow[] { + dataRow}); + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + public virtual int Update(System.Data.DataRow[] dataRows) { + return this.Adapter.Update(dataRows); + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Delete, true)] + public virtual int Delete(int Original_EmployeeID, string Original_LastName, string Original_FirstName, string Original_Title, string Original_TagID) { + this.Adapter.DeleteCommand.Parameters[0].Value = ((int)(Original_EmployeeID)); + if ((Original_LastName == null)) { + throw new System.ArgumentNullException("Original_LastName"); + } + else { + this.Adapter.DeleteCommand.Parameters[1].Value = ((string)(Original_LastName)); + } + if ((Original_FirstName == null)) { + throw new System.ArgumentNullException("Original_FirstName"); + } + else { + this.Adapter.DeleteCommand.Parameters[2].Value = ((string)(Original_FirstName)); + } + if ((Original_Title == null)) { + this.Adapter.DeleteCommand.Parameters[3].Value = ((object)(1)); + this.Adapter.DeleteCommand.Parameters[4].Value = System.DBNull.Value; + } + else { + this.Adapter.DeleteCommand.Parameters[3].Value = ((object)(0)); + this.Adapter.DeleteCommand.Parameters[4].Value = ((string)(Original_Title)); + } + if ((Original_TagID == null)) { + this.Adapter.DeleteCommand.Parameters[5].Value = ((object)(1)); + this.Adapter.DeleteCommand.Parameters[6].Value = System.DBNull.Value; + } + else { + this.Adapter.DeleteCommand.Parameters[5].Value = ((object)(0)); + this.Adapter.DeleteCommand.Parameters[6].Value = ((string)(Original_TagID)); + } + System.Data.ConnectionState previousConnectionState = this.Adapter.DeleteCommand.Connection.State; + if (((this.Adapter.DeleteCommand.Connection.State & System.Data.ConnectionState.Open) + != System.Data.ConnectionState.Open)) { + this.Adapter.DeleteCommand.Connection.Open(); + } + try { + int returnValue = this.Adapter.DeleteCommand.ExecuteNonQuery(); + return returnValue; + } + finally { + if ((previousConnectionState == System.Data.ConnectionState.Closed)) { + this.Adapter.DeleteCommand.Connection.Close(); + } + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Insert, true)] + public virtual int Insert(string LastName, string FirstName, string Title, byte[] Photo, string TagID) { + if ((LastName == null)) { + throw new System.ArgumentNullException("LastName"); + } + else { + this.Adapter.InsertCommand.Parameters[0].Value = ((string)(LastName)); + } + if ((FirstName == null)) { + throw new System.ArgumentNullException("FirstName"); + } + else { + this.Adapter.InsertCommand.Parameters[1].Value = ((string)(FirstName)); + } + if ((Title == null)) { + this.Adapter.InsertCommand.Parameters[2].Value = System.DBNull.Value; + } + else { + this.Adapter.InsertCommand.Parameters[2].Value = ((string)(Title)); + } + if ((Photo == null)) { + this.Adapter.InsertCommand.Parameters[3].Value = System.DBNull.Value; + } + else { + this.Adapter.InsertCommand.Parameters[3].Value = ((byte[])(Photo)); + } + if ((TagID == null)) { + this.Adapter.InsertCommand.Parameters[4].Value = System.DBNull.Value; + } + else { + this.Adapter.InsertCommand.Parameters[4].Value = ((string)(TagID)); + } + System.Data.ConnectionState previousConnectionState = this.Adapter.InsertCommand.Connection.State; + if (((this.Adapter.InsertCommand.Connection.State & System.Data.ConnectionState.Open) + != System.Data.ConnectionState.Open)) { + this.Adapter.InsertCommand.Connection.Open(); + } + try { + int returnValue = this.Adapter.InsertCommand.ExecuteNonQuery(); + return returnValue; + } + finally { + if ((previousConnectionState == System.Data.ConnectionState.Closed)) { + this.Adapter.InsertCommand.Connection.Close(); + } + } + } + + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)] + public virtual int Update(string LastName, string FirstName, string Title, byte[] Photo, string TagID, int Original_EmployeeID, string Original_LastName, string Original_FirstName, string Original_Title, string Original_TagID, int EmployeeID) { + if ((LastName == null)) { + throw new System.ArgumentNullException("LastName"); + } + else { + this.Adapter.UpdateCommand.Parameters[0].Value = ((string)(LastName)); + } + if ((FirstName == null)) { + throw new System.ArgumentNullException("FirstName"); + } + else { + this.Adapter.UpdateCommand.Parameters[1].Value = ((string)(FirstName)); + } + if ((Title == null)) { + this.Adapter.UpdateCommand.Parameters[2].Value = System.DBNull.Value; + } + else { + this.Adapter.UpdateCommand.Parameters[2].Value = ((string)(Title)); + } + if ((Photo == null)) { + this.Adapter.UpdateCommand.Parameters[3].Value = System.DBNull.Value; + } + else { + this.Adapter.UpdateCommand.Parameters[3].Value = ((byte[])(Photo)); + } + if ((TagID == null)) { + this.Adapter.UpdateCommand.Parameters[4].Value = System.DBNull.Value; + } + else { + this.Adapter.UpdateCommand.Parameters[4].Value = ((string)(TagID)); + } + this.Adapter.UpdateCommand.Parameters[5].Value = ((int)(Original_EmployeeID)); + if ((Original_LastName == null)) { + throw new System.ArgumentNullException("Original_LastName"); + } + else { + this.Adapter.UpdateCommand.Parameters[6].Value = ((string)(Original_LastName)); + } + if ((Original_FirstName == null)) { + throw new System.ArgumentNullException("Original_FirstName"); + } + else { + this.Adapter.UpdateCommand.Parameters[7].Value = ((string)(Original_FirstName)); + } + if ((Original_Title == null)) { + this.Adapter.UpdateCommand.Parameters[8].Value = ((object)(1)); + this.Adapter.UpdateCommand.Parameters[9].Value = System.DBNull.Value; + } + else { + this.Adapter.UpdateCommand.Parameters[8].Value = ((object)(0)); + this.Adapter.UpdateCommand.Parameters[9].Value = ((string)(Original_Title)); + } + if ((Original_TagID == null)) { + this.Adapter.UpdateCommand.Parameters[10].Value = ((object)(1)); + this.Adapter.UpdateCommand.Parameters[11].Value = System.DBNull.Value; + } + else { + this.Adapter.UpdateCommand.Parameters[10].Value = ((object)(0)); + this.Adapter.UpdateCommand.Parameters[11].Value = ((string)(Original_TagID)); + } + this.Adapter.UpdateCommand.Parameters[12].Value = ((int)(EmployeeID)); + System.Data.ConnectionState previousConnectionState = this.Adapter.UpdateCommand.Connection.State; + if (((this.Adapter.UpdateCommand.Connection.State & System.Data.ConnectionState.Open) + != System.Data.ConnectionState.Open)) { + this.Adapter.UpdateCommand.Connection.Open(); + } + try { + int returnValue = this.Adapter.UpdateCommand.ExecuteNonQuery(); + return returnValue; + } + finally { + if ((previousConnectionState == System.Data.ConnectionState.Closed)) { + this.Adapter.UpdateCommand.Connection.Close(); + } + } + } + } +} + +#pragma warning restore 1591 \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/NorthwindDataSet.xsc b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/NorthwindDataSet.xsc new file mode 100644 index 0000000..2dbd3f0 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/NorthwindDataSet.xsc @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/NorthwindDataSet.xsd b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/NorthwindDataSet.xsd new file mode 100644 index 0000000..0874e01 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/NorthwindDataSet.xsd @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + DELETE FROM [dbo].[Employees] WHERE (([EmployeeID] = @Original_EmployeeID) AND ([LastName] = @Original_LastName) AND ([FirstName] = @Original_FirstName) AND ((@IsNull_Title = 1 AND [Title] IS NULL) OR ([Title] = @Original_Title)) AND ((@IsNull_TagID = 1 AND [TagID] IS NULL) OR ([TagID] = @Original_TagID))) + + + + + + + + + + + + + + + + + + + + + INSERT INTO [dbo].[Employees] ([LastName], [FirstName], [Title], [Photo], [TagID]) VALUES (@LastName, @FirstName, @Title, @Photo, @TagID); +SELECT EmployeeID, LastName, FirstName, Title, Photo, TagID FROM Employees WHERE (EmployeeID = SCOPE_IDENTITY()) + + + + + + + + + + + + + + + + + SELECT EmployeeID, LastName, FirstName, Title, Photo, TagID FROM dbo.Employees + + + + + + + UPDATE [dbo].[Employees] SET [LastName] = @LastName, [FirstName] = @FirstName, [Title] = @Title, [Photo] = @Photo, [TagID] = @TagID WHERE (([EmployeeID] = @Original_EmployeeID) AND ([LastName] = @Original_LastName) AND ([FirstName] = @Original_FirstName) AND ((@IsNull_Title = 1 AND [Title] IS NULL) OR ([Title] = @Original_Title)) AND ((@IsNull_TagID = 1 AND [TagID] IS NULL) OR ([TagID] = @Original_TagID))); +SELECT EmployeeID, LastName, FirstName, Title, Photo, TagID FROM Employees WHERE (EmployeeID = @EmployeeID) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/NorthwindDataSet.xss b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/NorthwindDataSet.xss new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/NorthwindDataSet.xss @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Program.cs b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Program.cs new file mode 100644 index 0000000..17e1cd8 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace Attendance_CS +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Properties/AssemblyInfo.cs b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..072f393 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Attendance_CS")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Attendance_CS")] +[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("dd8cf082-2d9a-460a-b23d-d31c000121e5")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Properties/Resources.Designer.cs b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Properties/Resources.Designer.cs new file mode 100644 index 0000000..518af26 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Attendance_CS.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Attendance_CS.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Properties/Resources.resx b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Properties/Settings.Designer.cs b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Properties/Settings.Designer.cs new file mode 100644 index 0000000..6feca3c --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Properties/Settings.Designer.cs @@ -0,0 +1,36 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Attendance_CS.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)] + [global::System.Configuration.DefaultSettingValueAttribute("Data Source=.\\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True")] + public string NorthwindConnectionString { + get { + return ((string)(this["NorthwindConnectionString"])); + } + } + } +} diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Properties/Settings.settings b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Properties/Settings.settings new file mode 100644 index 0000000..4520de8 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/Properties/Settings.settings @@ -0,0 +1,14 @@ + + + + + + <?xml version="1.0" encoding="utf-16"?> +<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <ConnectionString>Data Source=.\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True</ConnectionString> + <ProviderName>System.Data.SqlClient</ProviderName> +</SerializableConnectionString> + Data Source=.\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True + + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/app.config b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/app.config new file mode 100644 index 0000000..3be77bb --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/app.config @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/bin/Debug/Attendance_CS.exe b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/bin/Debug/Attendance_CS.exe new file mode 100644 index 0000000..3c33d6c Binary files /dev/null and b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/bin/Debug/Attendance_CS.exe differ diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/bin/Debug/Attendance_CS.exe.config b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/bin/Debug/Attendance_CS.exe.config new file mode 100644 index 0000000..3be77bb --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/bin/Debug/Attendance_CS.exe.config @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/bin/Debug/Attendance_CS.pdb b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/bin/Debug/Attendance_CS.pdb new file mode 100644 index 0000000..1743d47 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/bin/Debug/Attendance_CS.pdb differ diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/bin/Debug/Attendance_CS.vshost.exe b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/bin/Debug/Attendance_CS.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/bin/Debug/Attendance_CS.vshost.exe differ diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/bin/Debug/Attendance_CS.vshost.exe.config b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/bin/Debug/Attendance_CS.vshost.exe.config new file mode 100644 index 0000000..3be77bb --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/bin/Debug/Attendance_CS.vshost.exe.config @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/obj/Attendance_CS.csproj.FileList.txt b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/obj/Attendance_CS.csproj.FileList.txt new file mode 100644 index 0000000..a5163d6 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/obj/Attendance_CS.csproj.FileList.txt @@ -0,0 +1,9 @@ +bin\Debug\Attendance_CS.exe.config +bin\Debug\Attendance_CS.exe +bin\Debug\Attendance_CS.pdb +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\Attendance_CS.Form1.resources +obj\Debug\Attendance_CS.Properties.Resources.resources +obj\Debug\Attendance_CS.csproj.GenerateResource.Cache +obj\Debug\Attendance_CS.exe +obj\Debug\Attendance_CS.pdb diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/obj/Debug/Attendance_CS.Form1.resources b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/obj/Debug/Attendance_CS.Form1.resources new file mode 100644 index 0000000..801df18 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/obj/Debug/Attendance_CS.Form1.resources differ diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/obj/Debug/Attendance_CS.Properties.Resources.resources b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/obj/Debug/Attendance_CS.Properties.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/obj/Debug/Attendance_CS.Properties.Resources.resources differ diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/obj/Debug/Attendance_CS.csproj.GenerateResource.Cache b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/obj/Debug/Attendance_CS.csproj.GenerateResource.Cache new file mode 100644 index 0000000..c27734d Binary files /dev/null and b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/obj/Debug/Attendance_CS.csproj.GenerateResource.Cache differ diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/obj/Debug/Attendance_CS.exe b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/obj/Debug/Attendance_CS.exe new file mode 100644 index 0000000..3c33d6c Binary files /dev/null and b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/obj/Debug/Attendance_CS.exe differ diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/obj/Debug/Attendance_CS.pdb b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/obj/Debug/Attendance_CS.pdb new file mode 100644 index 0000000..1743d47 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/obj/Debug/Attendance_CS.pdb differ diff --git a/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/obj/Debug/TempPE/NorthwindDataSet.Designer.cs.dll b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/obj/Debug/TempPE/NorthwindDataSet.Designer.cs.dll new file mode 100644 index 0000000..70221fa Binary files /dev/null and b/Chapter05(RFID)/Attendance_Parallax_CS/Attendance_CS/obj/Debug/TempPE/NorthwindDataSet.Designer.cs.dll differ diff --git a/Chapter05(RFID)/Attendance_Phidget/Attendance.sln b/Chapter05(RFID)/Attendance_Phidget/Attendance.sln new file mode 100644 index 0000000..740cc63 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/Attendance.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Attendance", "Attendance.vbproj", "{D86B83B8-5886-4CB1-BCAA-6DD95D8337D7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D86B83B8-5886-4CB1-BCAA-6DD95D8337D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D86B83B8-5886-4CB1-BCAA-6DD95D8337D7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D86B83B8-5886-4CB1-BCAA-6DD95D8337D7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D86B83B8-5886-4CB1-BCAA-6DD95D8337D7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter05(RFID)/Attendance_Phidget/Attendance.suo b/Chapter05(RFID)/Attendance_Phidget/Attendance.suo new file mode 100644 index 0000000..037f718 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget/Attendance.suo differ diff --git a/Chapter05(RFID)/Attendance_Phidget/Attendance.vbproj b/Chapter05(RFID)/Attendance_Phidget/Attendance.vbproj new file mode 100644 index 0000000..58887a7 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/Attendance.vbproj @@ -0,0 +1,137 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {D86B83B8-5886-4CB1-BCAA-6DD95D8337D7} + WinExe + Attendance.My.MyApplication + Attendance + Attendance + WindowsForms + + + true + full + true + true + bin\Debug\ + Attendance.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + Attendance.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + False + ..\..\..\..\..\..\Program Files\Phidgets\PhidgetsNET.dll + + + + + + + + + + + + + + + + + + + + + Form + + + Form1.vb + Form + + + Form2.vb + + + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + True + True + NorthwindDataSet.xsd + + + + + Designer + Form1.vb + + + Designer + Form2.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + NorthwindDataSet.xsd + + + MSDataSetGenerator + NorthwindDataSet.Designer.vb + Designer + + + NorthwindDataSet.xsd + + + + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Phidget/Attendance.vbproj.user b/Chapter05(RFID)/Attendance_Phidget/Attendance.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/Attendance.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Phidget/Form1.Designer.vb b/Chapter05(RFID)/Attendance_Phidget/Form1.Designer.vb new file mode 100644 index 0000000..fbccbea --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/Form1.Designer.vb @@ -0,0 +1,481 @@ + _ +Partial Class Form1 + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.components = New System.ComponentModel.Container + Dim EmployeeIDLabel As System.Windows.Forms.Label + Dim LastNameLabel As System.Windows.Forms.Label + Dim FirstNameLabel As System.Windows.Forms.Label + Dim TitleLabel As System.Windows.Forms.Label + Dim PhotoLabel As System.Windows.Forms.Label + Dim TagIDLabel As System.Windows.Forms.Label + Dim Label2 As System.Windows.Forms.Label + Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1)) + Me.EmployeeIDLabel1 = New System.Windows.Forms.Label + Me.GroupBox1 = New System.Windows.Forms.GroupBox + Me.btnDeassign = New System.Windows.Forms.Button + Me.txtEmployeeID = New System.Windows.Forms.TextBox + Me.btnFind = New System.Windows.Forms.Button + Me.btnAssign = New System.Windows.Forms.Button + Me.txtTagID = New System.Windows.Forms.TextBox + Me.Label1 = New System.Windows.Forms.Label + Me.NorthwindDataSet = New Attendance.NorthwindDataSet + Me.EmployeesBindingSource = New System.Windows.Forms.BindingSource(Me.components) + Me.EmployeesTableAdapter = New Attendance.NorthwindDataSetTableAdapters.EmployeesTableAdapter + Me.EmployeesBindingNavigator = New System.Windows.Forms.BindingNavigator(Me.components) + Me.BindingNavigatorAddNewItem = New System.Windows.Forms.ToolStripButton + Me.BindingNavigatorCountItem = New System.Windows.Forms.ToolStripLabel + Me.BindingNavigatorDeleteItem = New System.Windows.Forms.ToolStripButton + Me.BindingNavigatorMoveFirstItem = New System.Windows.Forms.ToolStripButton + Me.BindingNavigatorMovePreviousItem = New System.Windows.Forms.ToolStripButton + Me.BindingNavigatorSeparator = New System.Windows.Forms.ToolStripSeparator + Me.BindingNavigatorPositionItem = New System.Windows.Forms.ToolStripTextBox + Me.BindingNavigatorSeparator1 = New System.Windows.Forms.ToolStripSeparator + Me.BindingNavigatorMoveNextItem = New System.Windows.Forms.ToolStripButton + Me.BindingNavigatorMoveLastItem = New System.Windows.Forms.ToolStripButton + Me.BindingNavigatorSeparator2 = New System.Windows.Forms.ToolStripSeparator + Me.EmployeesBindingNavigatorSaveItem = New System.Windows.Forms.ToolStripButton + Me.EmployeeIDLabel2 = New System.Windows.Forms.Label + Me.LastNameTextBox = New System.Windows.Forms.TextBox + Me.FirstNameTextBox = New System.Windows.Forms.TextBox + Me.TitleTextBox = New System.Windows.Forms.TextBox + Me.PhotoPictureBox = New System.Windows.Forms.PictureBox + Me.TagIDLabel1 = New System.Windows.Forms.Label + Me.StatusStrip1 = New System.Windows.Forms.StatusStrip + Me.ToolStripStatusLabel1 = New System.Windows.Forms.ToolStripStatusLabel + Me.Timer1 = New System.Windows.Forms.Timer(Me.components) + EmployeeIDLabel = New System.Windows.Forms.Label + LastNameLabel = New System.Windows.Forms.Label + FirstNameLabel = New System.Windows.Forms.Label + TitleLabel = New System.Windows.Forms.Label + PhotoLabel = New System.Windows.Forms.Label + TagIDLabel = New System.Windows.Forms.Label + Label2 = New System.Windows.Forms.Label + Me.GroupBox1.SuspendLayout() + CType(Me.NorthwindDataSet, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.EmployeesBindingSource, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.EmployeesBindingNavigator, System.ComponentModel.ISupportInitialize).BeginInit() + Me.EmployeesBindingNavigator.SuspendLayout() + CType(Me.PhotoPictureBox, System.ComponentModel.ISupportInitialize).BeginInit() + Me.StatusStrip1.SuspendLayout() + Me.SuspendLayout() + ' + 'EmployeeIDLabel + ' + EmployeeIDLabel.AutoSize = True + EmployeeIDLabel.Location = New System.Drawing.Point(10, 58) + EmployeeIDLabel.Name = "EmployeeIDLabel" + EmployeeIDLabel.Size = New System.Drawing.Size(70, 13) + EmployeeIDLabel.TabIndex = 12 + EmployeeIDLabel.Text = "Employee ID:" + ' + 'LastNameLabel + ' + LastNameLabel.AutoSize = True + LastNameLabel.Location = New System.Drawing.Point(10, 81) + LastNameLabel.Name = "LastNameLabel" + LastNameLabel.Size = New System.Drawing.Size(61, 13) + LastNameLabel.TabIndex = 14 + LastNameLabel.Text = "Last Name:" + ' + 'FirstNameLabel + ' + FirstNameLabel.AutoSize = True + FirstNameLabel.Location = New System.Drawing.Point(10, 107) + FirstNameLabel.Name = "FirstNameLabel" + FirstNameLabel.Size = New System.Drawing.Size(60, 13) + FirstNameLabel.TabIndex = 16 + FirstNameLabel.Text = "First Name:" + ' + 'TitleLabel + ' + TitleLabel.AutoSize = True + TitleLabel.Location = New System.Drawing.Point(10, 133) + TitleLabel.Name = "TitleLabel" + TitleLabel.Size = New System.Drawing.Size(30, 13) + TitleLabel.TabIndex = 18 + TitleLabel.Text = "Title:" + ' + 'PhotoLabel + ' + PhotoLabel.AutoSize = True + PhotoLabel.Location = New System.Drawing.Point(10, 156) + PhotoLabel.Name = "PhotoLabel" + PhotoLabel.Size = New System.Drawing.Size(38, 13) + PhotoLabel.TabIndex = 20 + PhotoLabel.Text = "Photo:" + ' + 'TagIDLabel + ' + TagIDLabel.AutoSize = True + TagIDLabel.Location = New System.Drawing.Point(10, 35) + TagIDLabel.Name = "TagIDLabel" + TagIDLabel.Size = New System.Drawing.Size(43, 13) + TagIDLabel.TabIndex = 22 + TagIDLabel.Text = "Tag ID:" + ' + 'Label2 + ' + Label2.AutoSize = True + Label2.Location = New System.Drawing.Point(5, 104) + Label2.Name = "Label2" + Label2.Size = New System.Drawing.Size(139, 13) + Label2.TabIndex = 13 + Label2.Text = "Search for Employee (by ID)" + ' + 'EmployeeIDLabel1 + ' + Me.EmployeeIDLabel1.Location = New System.Drawing.Point(82, 62) + Me.EmployeeIDLabel1.Name = "EmployeeIDLabel1" + Me.EmployeeIDLabel1.Size = New System.Drawing.Size(100, 23) + Me.EmployeeIDLabel1.TabIndex = 2 + ' + 'GroupBox1 + ' + Me.GroupBox1.Controls.Add(Me.btnDeassign) + Me.GroupBox1.Controls.Add(Me.txtEmployeeID) + Me.GroupBox1.Controls.Add(Me.btnFind) + Me.GroupBox1.Controls.Add(Label2) + Me.GroupBox1.Controls.Add(Me.btnAssign) + Me.GroupBox1.Controls.Add(Me.txtTagID) + Me.GroupBox1.Controls.Add(Me.Label1) + Me.GroupBox1.Location = New System.Drawing.Point(224, 34) + Me.GroupBox1.Name = "GroupBox1" + Me.GroupBox1.Size = New System.Drawing.Size(176, 232) + Me.GroupBox1.TabIndex = 11 + Me.GroupBox1.TabStop = False + Me.GroupBox1.Text = "Administrator" + ' + 'btnDeassign + ' + Me.btnDeassign.Location = New System.Drawing.Point(5, 189) + Me.btnDeassign.Name = "btnDeassign" + Me.btnDeassign.Size = New System.Drawing.Size(163, 37) + Me.btnDeassign.TabIndex = 19 + Me.btnDeassign.Text = "Deassign Tag from Employee" + Me.btnDeassign.UseVisualStyleBackColor = True + ' + 'txtEmployeeID + ' + Me.txtEmployeeID.Location = New System.Drawing.Point(5, 120) + Me.txtEmployeeID.Name = "txtEmployeeID" + Me.txtEmployeeID.Size = New System.Drawing.Size(103, 20) + Me.txtEmployeeID.TabIndex = 18 + ' + 'btnFind + ' + Me.btnFind.Location = New System.Drawing.Point(114, 118) + Me.btnFind.Name = "btnFind" + Me.btnFind.Size = New System.Drawing.Size(54, 23) + Me.btnFind.TabIndex = 17 + Me.btnFind.Text = "Find" + Me.btnFind.UseVisualStyleBackColor = True + ' + 'btnAssign + ' + Me.btnAssign.Location = New System.Drawing.Point(5, 146) + Me.btnAssign.Name = "btnAssign" + Me.btnAssign.Size = New System.Drawing.Size(163, 37) + Me.btnAssign.TabIndex = 3 + Me.btnAssign.Text = "Assign Tag to Employee" + Me.btnAssign.UseVisualStyleBackColor = True + ' + 'txtTagID + ' + Me.txtTagID.Location = New System.Drawing.Point(6, 32) + Me.txtTagID.Name = "txtTagID" + Me.txtTagID.ReadOnly = True + Me.txtTagID.Size = New System.Drawing.Size(162, 20) + Me.txtTagID.TabIndex = 2 + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(3, 16) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(40, 13) + Me.Label1.TabIndex = 1 + Me.Label1.Text = "Tag ID" + ' + 'NorthwindDataSet + ' + Me.NorthwindDataSet.DataSetName = "NorthwindDataSet" + Me.NorthwindDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema + ' + 'EmployeesBindingSource + ' + Me.EmployeesBindingSource.DataMember = "Employees" + Me.EmployeesBindingSource.DataSource = Me.NorthwindDataSet + ' + 'EmployeesTableAdapter + ' + Me.EmployeesTableAdapter.ClearBeforeFill = True + ' + 'EmployeesBindingNavigator + ' + Me.EmployeesBindingNavigator.AddNewItem = Me.BindingNavigatorAddNewItem + Me.EmployeesBindingNavigator.BindingSource = Me.EmployeesBindingSource + Me.EmployeesBindingNavigator.CountItem = Me.BindingNavigatorCountItem + Me.EmployeesBindingNavigator.DeleteItem = Me.BindingNavigatorDeleteItem + Me.EmployeesBindingNavigator.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.BindingNavigatorMoveFirstItem, Me.BindingNavigatorMovePreviousItem, Me.BindingNavigatorSeparator, Me.BindingNavigatorPositionItem, Me.BindingNavigatorCountItem, Me.BindingNavigatorSeparator1, Me.BindingNavigatorMoveNextItem, Me.BindingNavigatorMoveLastItem, Me.BindingNavigatorSeparator2, Me.BindingNavigatorAddNewItem, Me.BindingNavigatorDeleteItem, Me.EmployeesBindingNavigatorSaveItem}) + Me.EmployeesBindingNavigator.Location = New System.Drawing.Point(0, 0) + Me.EmployeesBindingNavigator.MoveFirstItem = Me.BindingNavigatorMoveFirstItem + Me.EmployeesBindingNavigator.MoveLastItem = Me.BindingNavigatorMoveLastItem + Me.EmployeesBindingNavigator.MoveNextItem = Me.BindingNavigatorMoveNextItem + Me.EmployeesBindingNavigator.MovePreviousItem = Me.BindingNavigatorMovePreviousItem + Me.EmployeesBindingNavigator.Name = "EmployeesBindingNavigator" + Me.EmployeesBindingNavigator.PositionItem = Me.BindingNavigatorPositionItem + Me.EmployeesBindingNavigator.Size = New System.Drawing.Size(412, 25) + Me.EmployeesBindingNavigator.TabIndex = 12 + Me.EmployeesBindingNavigator.Text = "BindingNavigator1" + ' + 'BindingNavigatorAddNewItem + ' + Me.BindingNavigatorAddNewItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.BindingNavigatorAddNewItem.Image = CType(resources.GetObject("BindingNavigatorAddNewItem.Image"), System.Drawing.Image) + Me.BindingNavigatorAddNewItem.Name = "BindingNavigatorAddNewItem" + Me.BindingNavigatorAddNewItem.RightToLeftAutoMirrorImage = True + Me.BindingNavigatorAddNewItem.Size = New System.Drawing.Size(23, 22) + Me.BindingNavigatorAddNewItem.Text = "Add new" + ' + 'BindingNavigatorCountItem + ' + Me.BindingNavigatorCountItem.Name = "BindingNavigatorCountItem" + Me.BindingNavigatorCountItem.Size = New System.Drawing.Size(36, 22) + Me.BindingNavigatorCountItem.Text = "of {0}" + Me.BindingNavigatorCountItem.ToolTipText = "Total number of items" + ' + 'BindingNavigatorDeleteItem + ' + Me.BindingNavigatorDeleteItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.BindingNavigatorDeleteItem.Image = CType(resources.GetObject("BindingNavigatorDeleteItem.Image"), System.Drawing.Image) + Me.BindingNavigatorDeleteItem.Name = "BindingNavigatorDeleteItem" + Me.BindingNavigatorDeleteItem.RightToLeftAutoMirrorImage = True + Me.BindingNavigatorDeleteItem.Size = New System.Drawing.Size(23, 22) + Me.BindingNavigatorDeleteItem.Text = "Delete" + ' + 'BindingNavigatorMoveFirstItem + ' + Me.BindingNavigatorMoveFirstItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.BindingNavigatorMoveFirstItem.Image = CType(resources.GetObject("BindingNavigatorMoveFirstItem.Image"), System.Drawing.Image) + Me.BindingNavigatorMoveFirstItem.Name = "BindingNavigatorMoveFirstItem" + Me.BindingNavigatorMoveFirstItem.RightToLeftAutoMirrorImage = True + Me.BindingNavigatorMoveFirstItem.Size = New System.Drawing.Size(23, 22) + Me.BindingNavigatorMoveFirstItem.Text = "Move first" + ' + 'BindingNavigatorMovePreviousItem + ' + Me.BindingNavigatorMovePreviousItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.BindingNavigatorMovePreviousItem.Image = CType(resources.GetObject("BindingNavigatorMovePreviousItem.Image"), System.Drawing.Image) + Me.BindingNavigatorMovePreviousItem.Name = "BindingNavigatorMovePreviousItem" + Me.BindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = True + Me.BindingNavigatorMovePreviousItem.Size = New System.Drawing.Size(23, 22) + Me.BindingNavigatorMovePreviousItem.Text = "Move previous" + ' + 'BindingNavigatorSeparator + ' + Me.BindingNavigatorSeparator.Name = "BindingNavigatorSeparator" + Me.BindingNavigatorSeparator.Size = New System.Drawing.Size(6, 25) + ' + 'BindingNavigatorPositionItem + ' + Me.BindingNavigatorPositionItem.AccessibleName = "Position" + Me.BindingNavigatorPositionItem.AutoSize = False + Me.BindingNavigatorPositionItem.Name = "BindingNavigatorPositionItem" + Me.BindingNavigatorPositionItem.Size = New System.Drawing.Size(50, 21) + Me.BindingNavigatorPositionItem.Text = "0" + Me.BindingNavigatorPositionItem.ToolTipText = "Current position" + ' + 'BindingNavigatorSeparator1 + ' + Me.BindingNavigatorSeparator1.Name = "BindingNavigatorSeparator1" + Me.BindingNavigatorSeparator1.Size = New System.Drawing.Size(6, 25) + ' + 'BindingNavigatorMoveNextItem + ' + Me.BindingNavigatorMoveNextItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.BindingNavigatorMoveNextItem.Image = CType(resources.GetObject("BindingNavigatorMoveNextItem.Image"), System.Drawing.Image) + Me.BindingNavigatorMoveNextItem.Name = "BindingNavigatorMoveNextItem" + Me.BindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = True + Me.BindingNavigatorMoveNextItem.Size = New System.Drawing.Size(23, 22) + Me.BindingNavigatorMoveNextItem.Text = "Move next" + ' + 'BindingNavigatorMoveLastItem + ' + Me.BindingNavigatorMoveLastItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.BindingNavigatorMoveLastItem.Image = CType(resources.GetObject("BindingNavigatorMoveLastItem.Image"), System.Drawing.Image) + Me.BindingNavigatorMoveLastItem.Name = "BindingNavigatorMoveLastItem" + Me.BindingNavigatorMoveLastItem.RightToLeftAutoMirrorImage = True + Me.BindingNavigatorMoveLastItem.Size = New System.Drawing.Size(23, 22) + Me.BindingNavigatorMoveLastItem.Text = "Move last" + ' + 'BindingNavigatorSeparator2 + ' + Me.BindingNavigatorSeparator2.Name = "BindingNavigatorSeparator2" + Me.BindingNavigatorSeparator2.Size = New System.Drawing.Size(6, 25) + ' + 'EmployeesBindingNavigatorSaveItem + ' + Me.EmployeesBindingNavigatorSaveItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.EmployeesBindingNavigatorSaveItem.Image = CType(resources.GetObject("EmployeesBindingNavigatorSaveItem.Image"), System.Drawing.Image) + Me.EmployeesBindingNavigatorSaveItem.Name = "EmployeesBindingNavigatorSaveItem" + Me.EmployeesBindingNavigatorSaveItem.Size = New System.Drawing.Size(23, 22) + Me.EmployeesBindingNavigatorSaveItem.Text = "Save Data" + ' + 'EmployeeIDLabel2 + ' + Me.EmployeeIDLabel2.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.EmployeesBindingSource, "EmployeeID", True)) + Me.EmployeeIDLabel2.Location = New System.Drawing.Point(86, 58) + Me.EmployeeIDLabel2.Name = "EmployeeIDLabel2" + Me.EmployeeIDLabel2.Size = New System.Drawing.Size(124, 13) + Me.EmployeeIDLabel2.TabIndex = 13 + ' + 'LastNameTextBox + ' + Me.LastNameTextBox.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.EmployeesBindingSource, "LastName", True)) + Me.LastNameTextBox.Location = New System.Drawing.Point(86, 78) + Me.LastNameTextBox.Name = "LastNameTextBox" + Me.LastNameTextBox.Size = New System.Drawing.Size(124, 20) + Me.LastNameTextBox.TabIndex = 15 + ' + 'FirstNameTextBox + ' + Me.FirstNameTextBox.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.EmployeesBindingSource, "FirstName", True)) + Me.FirstNameTextBox.Location = New System.Drawing.Point(86, 104) + Me.FirstNameTextBox.Name = "FirstNameTextBox" + Me.FirstNameTextBox.Size = New System.Drawing.Size(124, 20) + Me.FirstNameTextBox.TabIndex = 17 + ' + 'TitleTextBox + ' + Me.TitleTextBox.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.EmployeesBindingSource, "Title", True)) + Me.TitleTextBox.Location = New System.Drawing.Point(86, 130) + Me.TitleTextBox.Name = "TitleTextBox" + Me.TitleTextBox.Size = New System.Drawing.Size(124, 20) + Me.TitleTextBox.TabIndex = 19 + ' + 'PhotoPictureBox + ' + Me.PhotoPictureBox.DataBindings.Add(New System.Windows.Forms.Binding("Image", Me.EmployeesBindingSource, "Photo", True)) + Me.PhotoPictureBox.Location = New System.Drawing.Point(86, 156) + Me.PhotoPictureBox.Name = "PhotoPictureBox" + Me.PhotoPictureBox.Size = New System.Drawing.Size(95, 110) + Me.PhotoPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage + Me.PhotoPictureBox.TabIndex = 21 + Me.PhotoPictureBox.TabStop = False + ' + 'TagIDLabel1 + ' + Me.TagIDLabel1.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.EmployeesBindingSource, "TagID", True)) + Me.TagIDLabel1.Location = New System.Drawing.Point(86, 35) + Me.TagIDLabel1.Name = "TagIDLabel1" + Me.TagIDLabel1.Size = New System.Drawing.Size(124, 13) + Me.TagIDLabel1.TabIndex = 23 + ' + 'StatusStrip1 + ' + Me.StatusStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripStatusLabel1}) + Me.StatusStrip1.Location = New System.Drawing.Point(0, 277) + Me.StatusStrip1.Name = "StatusStrip1" + Me.StatusStrip1.Size = New System.Drawing.Size(412, 22) + Me.StatusStrip1.TabIndex = 24 + Me.StatusStrip1.Text = "StatusStrip1" + ' + 'ToolStripStatusLabel1 + ' + Me.ToolStripStatusLabel1.Name = "ToolStripStatusLabel1" + Me.ToolStripStatusLabel1.Size = New System.Drawing.Size(111, 17) + Me.ToolStripStatusLabel1.Text = "ToolStripStatusLabel1" + ' + 'Timer1 + ' + ' + 'Form1 + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(412, 299) + Me.Controls.Add(Me.StatusStrip1) + Me.Controls.Add(EmployeeIDLabel) + Me.Controls.Add(Me.EmployeeIDLabel2) + Me.Controls.Add(LastNameLabel) + Me.Controls.Add(Me.LastNameTextBox) + Me.Controls.Add(FirstNameLabel) + Me.Controls.Add(Me.FirstNameTextBox) + Me.Controls.Add(TitleLabel) + Me.Controls.Add(Me.TitleTextBox) + Me.Controls.Add(PhotoLabel) + Me.Controls.Add(Me.PhotoPictureBox) + Me.Controls.Add(TagIDLabel) + Me.Controls.Add(Me.TagIDLabel1) + Me.Controls.Add(Me.EmployeesBindingNavigator) + Me.Controls.Add(Me.GroupBox1) + Me.Controls.Add(Me.EmployeeIDLabel1) + Me.Name = "Form1" + Me.Text = "Attendance System" + Me.GroupBox1.ResumeLayout(False) + Me.GroupBox1.PerformLayout() + CType(Me.NorthwindDataSet, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.EmployeesBindingSource, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.EmployeesBindingNavigator, System.ComponentModel.ISupportInitialize).EndInit() + Me.EmployeesBindingNavigator.ResumeLayout(False) + Me.EmployeesBindingNavigator.PerformLayout() + CType(Me.PhotoPictureBox, System.ComponentModel.ISupportInitialize).EndInit() + Me.StatusStrip1.ResumeLayout(False) + Me.StatusStrip1.PerformLayout() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents EmployeeIDLabel1 As System.Windows.Forms.Label + Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox + Friend WithEvents btnAssign As System.Windows.Forms.Button + Friend WithEvents txtTagID As System.Windows.Forms.TextBox + Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents NorthwindDataSet As Attendance.NorthwindDataSet + Friend WithEvents EmployeesBindingSource As System.Windows.Forms.BindingSource + Friend WithEvents EmployeesTableAdapter As Attendance.NorthwindDataSetTableAdapters.EmployeesTableAdapter + Friend WithEvents EmployeesBindingNavigator As System.Windows.Forms.BindingNavigator + Friend WithEvents BindingNavigatorAddNewItem As System.Windows.Forms.ToolStripButton + Friend WithEvents BindingNavigatorCountItem As System.Windows.Forms.ToolStripLabel + Friend WithEvents BindingNavigatorDeleteItem As System.Windows.Forms.ToolStripButton + Friend WithEvents BindingNavigatorMoveFirstItem As System.Windows.Forms.ToolStripButton + Friend WithEvents BindingNavigatorMovePreviousItem As System.Windows.Forms.ToolStripButton + Friend WithEvents BindingNavigatorSeparator As System.Windows.Forms.ToolStripSeparator + Friend WithEvents BindingNavigatorPositionItem As System.Windows.Forms.ToolStripTextBox + Friend WithEvents BindingNavigatorSeparator1 As System.Windows.Forms.ToolStripSeparator + Friend WithEvents BindingNavigatorMoveNextItem As System.Windows.Forms.ToolStripButton + Friend WithEvents BindingNavigatorMoveLastItem As System.Windows.Forms.ToolStripButton + Friend WithEvents BindingNavigatorSeparator2 As System.Windows.Forms.ToolStripSeparator + Friend WithEvents EmployeesBindingNavigatorSaveItem As System.Windows.Forms.ToolStripButton + Friend WithEvents EmployeeIDLabel2 As System.Windows.Forms.Label + Friend WithEvents LastNameTextBox As System.Windows.Forms.TextBox + Friend WithEvents FirstNameTextBox As System.Windows.Forms.TextBox + Friend WithEvents TitleTextBox As System.Windows.Forms.TextBox + Friend WithEvents PhotoPictureBox As System.Windows.Forms.PictureBox + Friend WithEvents TagIDLabel1 As System.Windows.Forms.Label + Friend WithEvents btnFind As System.Windows.Forms.Button + Friend WithEvents txtEmployeeID As System.Windows.Forms.TextBox + Friend WithEvents btnDeassign As System.Windows.Forms.Button + Friend WithEvents StatusStrip1 As System.Windows.Forms.StatusStrip + Friend WithEvents ToolStripStatusLabel1 As System.Windows.Forms.ToolStripStatusLabel + Friend WithEvents Timer1 As System.Windows.Forms.Timer + +End Class diff --git a/Chapter05(RFID)/Attendance_Phidget/Form1.resx b/Chapter05(RFID)/Attendance_Phidget/Form1.resx new file mode 100644 index 0000000..93a07fa --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/Form1.resx @@ -0,0 +1,245 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + 17, 17 + + + 159, 17 + + + 335, 17 + + + 506, 17 + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAU1JREFUOE9jYBi0 + 4O4C9v+35nH+vzqH6//FGbz/SXbodaDGP48a//952PD/5GQB0g04P50XbsDBHhHSDTg+SRBoe93/Pw+q + /u9oFydswKWZPP/PTuX7fxKo8Ui/0P993SJAzeX//94r+r++Qeb/qhq5/0srFf/PL1X+P6tIFdPAU0B/ + /nlYD9RUC8SV///cKwHivP9/72b+/3sn+f/f23H//92MAOKQ/5NyNDENONQrDHbu3/ulQI0FQI3ZQI2p + QI0J///digZqDPv/70bQ/3/X/f53peliGrCzXeL/lmap/+vAzpX/v6RC8f/fWzFAjeH/p+Zp/J+QpfW/ + O0P3f3uq/v/mREPCYTIb6E+Qc//dCPjfk6FDWAN6QgH5898NfyD2+9+arE+6Ad3pumD/gnB9nBHpBrQk + GfxviDf8XxNr/L8y2oR0A0hO++RqAAAkI9ieo+gjUwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAW9JREFUOE+tkk0o + w3EYx3dV3kq5uKBWDiPT8hISMiQsMiEyQ9qBg0hoFwcHUi7kgIvkQFJSTrQ4zdvmrTW1/kuT0i74x+X3 + MRal/fEnv8tz+H2fz/N8vz0azX88PG6wmcDp4E881hYR3VUIixF2Nr+FcO2DlbnPGjaWoM+M6DAiOitg + YUoR8rqhsJTBWG/kP6fOMKTegGjKh/7mTyIx0oUw58C0/XubLM8iKtPeQIx2gfcMJgbD0FBVlRE+D7QU + hS2ZshANuTDQqq75fQIHe6GVcxHV6VCr/2VzQIKmAshOQNbHc6+PhTqDOggBP5jzoDCJoLUaLo7fwr3V + hSCr8z8EeHcLbSU8FCfjLU0nuL/70cB4Py5tDLL7UBnC8xMMW6EkhRNdIsGt9QjhTXkGUnsN8rVf4Q72 + tpFzEnGlRiH1NIL8qDjJoY1DdjkVADNjSGnReI2ZIF196VW22+D8SAFw6YLJITjaV5e2qotSIXoBiiMD + HEVvQ/IAAAAASUVORK5CYII= + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAStJREFUOE9jYBg0 + oHDW8/9NC57/z5z4+D8uR4W3P8Apx5A789n/VUfe/8elKL77wf/ghmu4DciY8vT/wn0fsCqK73n4f+n+ + ///9qy/gNiCh58n/aVveYyiKaL8P1pw56/9/r9ITuA2I7Hr0v3f1BxRFoa33wJpb1wFt7/z73yX/AG4D + Apsf/q+b/w6uKLjl7v9Fe///7wBqzpjz879d3c//9hnbcRvgUXX/f/60NyiK7Ipv/0+f8/u/f9e3/zqF + 7/5bJKzHbYB96d3/2ZNfYyjSTzn/36ToxX+VrE//jSOX4TbAIu/O/9T+11gVGSSd+C+b9vW/bvA83AYY + Zt3+H9byEqci/dTL/zV8p+E2QCftxn+/6od4Fal4TMBtgFPulf8gBXgVDZqMh+wQAPB2wKsSwCgmAAAA + AElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAL1JREFUOE9jYBgy + ILz9wX+yHRvf/eB/cMM18gyI73n4f+n+///9qy+QbkBE+32w5sxZ//97lZ4gzYDQ1ntgza3rgLZ3/v3v + kn+AeAOCW+7+X7T3//8OoOaMOT//29X9/G+fsZ14A0ChbVd8+3/6nN///bu+/dcpfPffImE9aQaADNFP + Of/fpOjFf5WsT/+NI5eRbgDIEIOkE/9l077+1w2eR54BYJekXv6v4TuNfANAhqh4TKDMALKTMc01AgDQ + FGCYkuTLEQAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAKtJREFUOE9jYBh0 + oHDW8/8UOSp35rP/Cd33yDckY8rT//P2//6f0HWHPEMSep78n73v1//OrX//u5VeJt2QyK5H/6ds+/W/ + ZOnf/wnT//63yT1LmiGBzQ//t659D9ZsXPLlv3T0tf/GkcuIN8Sj6v7/krnv4JoVXXqI1wyKPvvSu/8D + W56BbSZZM8gAi7w7/20KrpCnGWSAYdZt8jWDDNBJu0GanylKtoNCMwCgfl+gC2KedgAAAABJRU5ErkJg + gg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAATBJREFUOE9jYBhU + oHDW8/+4HASSa1rw/H/mxMc41TDkznz2P6H7HlYFILlVR97/D29/gNuAjClP/8/b//t/QtcdDEUguYX7 + PvwPbriG24CEnif/Z+/79b9z69//bqWXURSC5KZtef/fv/oCbgMiux79n7Lt1/+SpX//J0z/+98m9yxc + MUiud/WH/16lJ3AbENj88H/r2vdgzcYlX/5LR1/7bxy5DKwBJFc3/91/l/wDuA3wqLr/v2TuO7hmRZce + uGKQXP60N//tM7bjNsC+9O7/wJZnYJuRNYNcAJLLnvz6v0XCetwGWOTd+W9TcAVDM8gAkFxq/2u4l7Cm + F8Os21g1gxSD5MJaXv7XDZ6H2wU6aTdwSoLk/Kof/tfwnYbbAHz5yin3yn8VjwlgPKjyHwMAvtG/s0Vm + x8MAAAAASUVORK5CYII= + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAilJREFUOE+tk91L + k3EUx/cvdN9N0EW3NTWGa7EaPOUcyqphWBG9PZEv5dJlmqhYmUYtXyBb4dJJy+kknFT4BqZIjaFMJUsz + V7TEoabYRDD49ju/6Pm1Mm/qB+fy8znPOef7qFT/4z17GgWVr30Zbd4lPHYvoLEhgvuOGdTWfIL9dgg3 + yqdQWjKBwoLXyMsdxYXzQSi9CeztAWqqV7HRW1ldgzGtF4fTnvBSBN7WRS6orPjyV57gyMIKdpufQ62W + YTnkEQL3o3kuKC35vK7gJ/w+vIg4kw8Fl6dxwNwkBM76WS64ZHv3h+BXeGQygm2SF9accaSmOIWg7m6Y + C7KzRmMEv8ODwTA2692Q5QBMJocQVFd95AL5TEARrAf3+D9gU2IDjhx9gaSkWiG4WTmN7i6wUwLHT76C + 5dgA3zYtjGamz6bOP+A+HLR0QpLsQnC1bBIdPrAMAE2ub+zuX1F+fY4vlRZGM2dmBBU4ObUdBkOFEFwp + HIenGXjoXGPBicKYnhNT5hM2pJ8r4p2TUxi83wO9vkwIbHljDAaq7kR5ZxJQSOK0EobezmJsag5y7jXs + NbZxWLvHBZ2uSAgolo57UD6bBASfzb+FN6F5hGaWcLHYjni9i8GNiN/1ANrEfCHIzBhmcy/zmbcaPNiy + Q0JLRz98XYPo7vNj4OUQ9pksUOvqkcDg7Zo6aDTWWMHpU/08npQwCgndmU5F26aF0czUlYrgnQnZQvAv + f/R3bGg6a0rM640AAAAASUVORK5CYII= + + + + 696, 17 + + + 808, 17 + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Phidget/Form1.vb b/Chapter05(RFID)/Attendance_Phidget/Form1.vb new file mode 100644 index 0000000..71358fa --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/Form1.vb @@ -0,0 +1,208 @@ +Imports System.Data +Imports System.Data.SqlClient +Imports System.IO + +Public Class Form1 + + '---tag ID read from the reader--- + Private tagID As String = String.Empty + '---the time that the tag ID was recorded--- + Private timeRecorded As DateTime = Now + + '---COM port to listen to--- + Const COM As String = "COM3" + '---file name of the log file--- + Const FILE_NAME As String = "C:\Attendance.csv" + '---the interval before the employee record is cleared + ' from the screen (in seconds)--- + Const INTERVAL As Integer = 3 + + '*************************************************** + Dim WithEvents RFIDReader As PhidgetsNET.PhidgetRFID + '*************************************************** + + Private Sub Form1_Load( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles MyBase.Load + + 'TODO: This line of code loads data into the + ' 'NorthwindDataSet.Employees' table. You can move, + ' or remove it, as needed. + Me.EmployeesTableAdapter.Fill(Me.NorthwindDataSet.Employees) + + '---Clear the employee when the app is loaded--- + EmployeesBindingSource.Filter = "TAGID='xxxxxxxxxx'" + '---set the timer interval to clear the employee record--- + Timer1.Interval = INTERVAL * 1000 'convert to milliseconds + + + '************************************************ + RFIDReader = New PhidgetsNET.PhidgetRFID + RFIDReader.OpenRemoteIP("localhost", 5001, -1, "pass") + ToolStripStatusLabel1.Text = "Not Connected" + '************************************************ + + End Sub + + '************************************************ + Private Sub RFIDReader_Attach(ByVal sender As Object, ByVal e As PhidgetsNET.AttachEventArgs) Handles RFIDReader.Attach + '---display the status--- + ToolStripStatusLabel1.Text = "Phidget RFID Reader Connected" + '---Enable onboard LED--- + RFIDReader.SetOutputState(2, True) + '---Enable RFID Reader--- + RFIDReader.SetOutputState(3, False) + End Sub + + Private Sub RFIDReader_Detach(ByVal sender As Object, ByVal e As PhidgetsNET.DetachEventArgs) Handles RFIDReader.Detach + '---display the status--- + ToolStripStatusLabel1.Text = "Phidget RFID Reader Not Connected" + End Sub + + Private Sub RFIDReader_Error(ByVal sender As Object, ByVal e As PhidgetsNET.ErrorEventArgs) Handles RFIDReader.Error + '---display the error--- + ToolStripStatusLabel1.Text = e.getError + End Sub + Private Sub RFIDReader_Tag(ByVal sender As Object, ByVal e As PhidgetsNET.TagEventArgs) Handles RFIDReader.Tag + '---save the tag ID--- + Console.WriteLine("tag detected - " & e.getTag) + '---when incoming data is received, update the TagID textbox--- + txtTagID.BeginInvoke(New _ + myDelegate(AddressOf updateTextBox), _ + New Object() {e.getTag}) + End Sub + + '---update the Tag ID textbox--- + Public Delegate Sub myDelegate(ByVal str As String) + Public Sub updateTextBox(ByVal str As String) + '---for receiving plain ASCII text--- + With txtTagID + .Text = "" ' ensure that the TextChanged event is fired + .Text = str + End With + End Sub + + Private Sub txtTagID_TextChanged( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles txtTagID.TextChanged + + '---get the tag ID that is read--- + Dim temptagID As String = txtTagID.Text + '---if no tag ID, exit--- + If temptagID = String.Empty Then + Exit Sub + End If + + '---get the time interval between the last read time + ' and the current time--- + Dim tp As TimeSpan = Now.Subtract(timeRecorded) + Dim timeInterval As Double = tp.Ticks / TimeSpan.TicksPerSecond + + If (temptagID = tagID) And timeInterval < INTERVAL Then + '---if it is the same tag and the time interval + ' is less than 3 seconds, the tag won't be registered--- + Exit Sub + End If + + '---the tag is saved--- + tagID = temptagID + EmployeesBindingSource.RemoveFilter() + + '---find the employee associated with the tag--- + EmployeesBindingSource.Filter = "TAGID='" & tagID & "'" + If EmployeesBindingSource.Count < 1 Then + ToolStripStatusLabel1.Text = "Employee not found." + Else + ToolStripStatusLabel1.Text = "Employee found." + '---write the employee information to log file--- + WriteToLog(EmployeeIDLabel2.Text, _ + LastNameTextBox.Text & ", " & FirstNameTextBox.Text) + '---reset the timer--- + Timer1.Enabled = False + Timer1.Enabled = True + End If + '---save the time this tag was recorded--- + timeRecorded = Now + End Sub + + Private Sub btnAssign_Click( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles btnAssign.Click + '---obtain the tag ID that was read--- + If txtTagID.Text <> String.Empty Then + '---assign the Tag ID to the current employee--- + TagIDLabel1.Text = txtTagID.Text + ToolStripStatusLabel1.Text = "Tag associated with employee." + '---save the record--- + Me.Validate() + Me.EmployeesBindingSource.EndEdit() + Me.EmployeesTableAdapter.Update(Me.NorthwindDataSet.Employees) + Else + ToolStripStatusLabel1.Text = "No tag id scanned." + Exit Sub + End If + End Sub + + + '************************************************ + + Private Sub EmployeesBindingNavigatorSaveItem_Click( _ + ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Handles EmployeesBindingNavigatorSaveItem.Click + Me.Validate() + Me.EmployeesBindingSource.EndEdit() + Me.EmployeesTableAdapter.Update(Me.NorthwindDataSet.Employees) + '------------------------------------------------------------- + End Sub + + Private Sub btnFind_Click( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles btnFind.Click + '---search for employee--- + If txtEmployeeID.Text = String.Empty Then + EmployeesBindingSource.RemoveFilter() + Else + EmployeesBindingSource.Filter = _ + "EmployeeID='" & txtEmployeeID.Text & "'" + End If + End Sub + + Private Sub btnDeassign_Click( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles btnDeassign.Click + + If Trim(TagIDLabel1.Text) = String.Empty Then + ToolStripStatusLabel1.Text = "Current employee has no tag ID." + Exit Sub + End If + '---deassociate tag ID from employee--- + TagIDLabel1.Text = String.Empty + '---save the record--- + Me.Validate() + Me.EmployeesBindingSource.EndEdit() + Me.EmployeesTableAdapter.Update(Me.NorthwindDataSet.Employees) + ToolStripStatusLabel1.Text = "Tag deassociated from employee." + End Sub + + Private Sub WriteToLog( _ + ByVal employeeID As String, _ + ByVal employeeName As String) + '---write to log file--- + Dim str As String = employeeID & "," & _ + employeeName & "," & Now & Chr(13) + My.Computer.FileSystem.WriteAllText(FILE_NAME, str, True) + End Sub + + Private Sub Timer1_Tick( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles Timer1.Tick + '---clear the employee--- + EmployeesBindingSource.Filter = "TAGID='xxxxxxxxxx'" + Timer1.Enabled = False + End Sub +End Class diff --git a/Chapter05(RFID)/Attendance_Phidget/Form2.Designer.vb b/Chapter05(RFID)/Attendance_Phidget/Form2.Designer.vb new file mode 100644 index 0000000..65b30c1 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/Form2.Designer.vb @@ -0,0 +1,106 @@ + _ +Partial Class Form2 + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.StatusStrip1 = New System.Windows.Forms.StatusStrip + Me.ToolStripStatusLabel1 = New System.Windows.Forms.ToolStripStatusLabel + Me.Label1 = New System.Windows.Forms.Label + Me.txtTagID = New System.Windows.Forms.TextBox + Me.chkTurnOnLED = New System.Windows.Forms.CheckBox + Me.chkEnableReader = New System.Windows.Forms.CheckBox + Me.StatusStrip1.SuspendLayout() + Me.SuspendLayout() + ' + 'StatusStrip1 + ' + Me.StatusStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripStatusLabel1}) + Me.StatusStrip1.Location = New System.Drawing.Point(0, 72) + Me.StatusStrip1.Name = "StatusStrip1" + Me.StatusStrip1.Size = New System.Drawing.Size(219, 22) + Me.StatusStrip1.TabIndex = 0 + Me.StatusStrip1.Text = "StatusStrip1" + ' + 'ToolStripStatusLabel1 + ' + Me.ToolStripStatusLabel1.Name = "ToolStripStatusLabel1" + Me.ToolStripStatusLabel1.Size = New System.Drawing.Size(111, 17) + Me.ToolStripStatusLabel1.Text = "ToolStripStatusLabel1" + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(12, 15) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(40, 13) + Me.Label1.TabIndex = 1 + Me.Label1.Text = "Tag ID" + ' + 'txtTagID + ' + Me.txtTagID.Location = New System.Drawing.Point(57, 12) + Me.txtTagID.Name = "txtTagID" + Me.txtTagID.Size = New System.Drawing.Size(146, 20) + Me.txtTagID.TabIndex = 2 + ' + 'chkTurnOnLED + ' + Me.chkTurnOnLED.AutoSize = True + Me.chkTurnOnLED.Location = New System.Drawing.Point(15, 38) + Me.chkTurnOnLED.Name = "chkTurnOnLED" + Me.chkTurnOnLED.Size = New System.Drawing.Size(87, 17) + Me.chkTurnOnLED.TabIndex = 3 + Me.chkTurnOnLED.Text = "Turn on LED" + Me.chkTurnOnLED.UseVisualStyleBackColor = True + ' + 'chkEnableReader + ' + Me.chkEnableReader.AutoSize = True + Me.chkEnableReader.Location = New System.Drawing.Point(106, 38) + Me.chkEnableReader.Name = "chkEnableReader" + Me.chkEnableReader.Size = New System.Drawing.Size(97, 17) + Me.chkEnableReader.TabIndex = 4 + Me.chkEnableReader.Text = "Enable Reader" + Me.chkEnableReader.UseVisualStyleBackColor = True + ' + 'Form2 + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(219, 94) + Me.Controls.Add(Me.chkEnableReader) + Me.Controls.Add(Me.chkTurnOnLED) + Me.Controls.Add(Me.txtTagID) + Me.Controls.Add(Me.Label1) + Me.Controls.Add(Me.StatusStrip1) + Me.Name = "Form2" + Me.Text = "Form1" + Me.StatusStrip1.ResumeLayout(False) + Me.StatusStrip1.PerformLayout() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents StatusStrip1 As System.Windows.Forms.StatusStrip + Friend WithEvents ToolStripStatusLabel1 As System.Windows.Forms.ToolStripStatusLabel + Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents txtTagID As System.Windows.Forms.TextBox + Friend WithEvents chkTurnOnLED As System.Windows.Forms.CheckBox + Friend WithEvents chkEnableReader As System.Windows.Forms.CheckBox +End Class diff --git a/Chapter05(RFID)/Attendance_Phidget/Form2.resx b/Chapter05(RFID)/Attendance_Phidget/Form2.resx new file mode 100644 index 0000000..faac01d --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/Form2.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Phidget/Form2.vb b/Chapter05(RFID)/Attendance_Phidget/Form2.vb new file mode 100644 index 0000000..a1bb312 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/Form2.vb @@ -0,0 +1,73 @@ +Public Class Form2 + '*************************************************** + Dim WithEvents RFIDReader As PhidgetsNET.PhidgetRFID + '*************************************************** + Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load + '************************************************ + RFIDReader = New PhidgetsNET.PhidgetRFID + RFIDReader.OpenRemoteIP("localhost", 5001, -1, "pass") + ToolStripStatusLabel1.Text = "Not Connected" + '************************************************ + End Sub + + Private Sub RFIDReader_Attach( _ + ByVal sender As Object, _ + ByVal e As PhidgetsNET.AttachEventArgs) _ + Handles RFIDReader.Attach + '---display the status--- + ToolStripStatusLabel1.Text = "Phidget RFID Reader Connected" + '---Enable onboard LED--- + chkTurnOnLED.Checked = True + RFIDReader.SetOutputState(2, True) + '---Enable RFID Reader--- + chkEnableReader.Checked = True + RFIDReader.SetOutputState(3, True) + End Sub + + Private Sub RFIDReader_Detach( _ + ByVal sender As Object, _ + ByVal e As PhidgetsNET.DetachEventArgs) _ + Handles RFIDReader.Detach + '---display the status--- + ToolStripStatusLabel1.Text = "Phidget RFID Reader Not Connected" + End Sub + + Private Sub RFIDReader_Error( _ + ByVal sender As Object, _ + ByVal e As PhidgetsNET.ErrorEventArgs) _ + Handles RFIDReader.Error + '---display the error--- + ToolStripStatusLabel1.Text = e.getError + End Sub + + Private Sub RFIDReader_Tag( _ + ByVal sender As Object, _ + ByVal e As PhidgetsNET.TagEventArgs) _ + Handles RFIDReader.Tag + '---save the tag ID--- + Console.WriteLine("tag detected - " & e.getTag) + '---when incoming data is received, update the TagID textbox--- + txtTagID.BeginInvoke(New _ + myDelegate(AddressOf updateTextBox), _ + New Object() {e.getTag}) + End Sub + + '---update the Tag ID textbox--- + Public Delegate Sub myDelegate(ByVal str As String) + Public Sub updateTextBox(ByVal str As String) + '---for receiving plain ASCII text--- + With txtTagID + .Text = str + End With + End Sub + + Private Sub chkTurnOnLED_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkTurnOnLED.CheckedChanged + '---Enable/Disable onboard LED--- + RFIDReader.SetOutputState(2, chkTurnOnLED.Checked) + End Sub + + Private Sub chkEnableReader_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkEnableReader.CheckedChanged + '---Enable RFID Reader--- + RFIDReader.SetOutputState(3, chkEnableReader.Checked) + End Sub +End Class \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Phidget/My Project/Application.Designer.vb b/Chapter05(RFID)/Attendance_Phidget/My Project/Application.Designer.vb new file mode 100644 index 0000000..b25ddc4 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + 'NOTE: This file is auto-generated; do not modify it directly. To make changes, + ' or if you encounter build errors in this file, go to the Project Designer + ' (go to Project Properties or double-click the My Project node in + ' Solution Explorer), and make changes on the Application tab. + ' + Partial Friend Class MyApplication + + _ + Public Sub New() + MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) + Me.IsSingleInstance = false + Me.EnableVisualStyles = true + Me.SaveMySettingsOnExit = true + Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses + End Sub + + _ + Protected Overrides Sub OnCreateMainForm() + Me.MainForm = Global.Attendance.Form2 + End Sub + End Class +End Namespace diff --git a/Chapter05(RFID)/Attendance_Phidget/My Project/Application.myapp b/Chapter05(RFID)/Attendance_Phidget/My Project/Application.myapp new file mode 100644 index 0000000..3d66661 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + Form2 + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Phidget/My Project/AssemblyInfo.vb b/Chapter05(RFID)/Attendance_Phidget/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..6f0671c --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + + diff --git a/Chapter05(RFID)/Attendance_Phidget/My Project/Resources.Designer.vb b/Chapter05(RFID)/Attendance_Phidget/My Project/Resources.Designer.vb new file mode 100644 index 0000000..8aa363f --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ' + ' A strongly-typed resource class, for looking up localized strings, etc. + ' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ' + ' Returns the cached ResourceManager instance used by this class. + ' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Attendance.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ' + ' Overrides the current thread's CurrentUICulture property for all + ' resource lookups using this strongly typed resource class. + ' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Chapter05(RFID)/Attendance_Phidget/My Project/Resources.resx b/Chapter05(RFID)/Attendance_Phidget/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Phidget/My Project/Settings.Designer.vb b/Chapter05(RFID)/Attendance_Phidget/My Project/Settings.Designer.vb new file mode 100644 index 0000000..c3ec89f --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/My Project/Settings.Designer.vb @@ -0,0 +1,83 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings),MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + + _ + Public ReadOnly Property NorthwindConnectionString() As String + Get + Return CType(Me("NorthwindConnectionString"),String) + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.Attendance.My.MySettings + Get + Return Global.Attendance.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Chapter05(RFID)/Attendance_Phidget/My Project/Settings.settings b/Chapter05(RFID)/Attendance_Phidget/My Project/Settings.settings new file mode 100644 index 0000000..52b713c --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/My Project/Settings.settings @@ -0,0 +1,14 @@ + + + + + + <?xml version="1.0" encoding="utf-16"?> +<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <ConnectionString>Data Source=.\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True</ConnectionString> + <ProviderName>System.Data.SqlClient</ProviderName> +</SerializableConnectionString> + Data Source=.\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True + + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Phidget/NorthwindDataSet.Designer.vb b/Chapter05(RFID)/Attendance_Phidget/NorthwindDataSet.Designer.vb new file mode 100644 index 0000000..ada1df6 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/NorthwindDataSet.Designer.vb @@ -0,0 +1,1006 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict Off +Option Explicit On + +Imports System + + + _ +Partial Public Class NorthwindDataSet + Inherits System.Data.DataSet + + Private tableEmployees As EmployeesDataTable + + Private _schemaSerializationMode As System.Data.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema + + _ + Public Sub New() + MyBase.New + Me.BeginInit + Me.InitClass + Dim schemaChangedHandler As System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged + AddHandler MyBase.Tables.CollectionChanged, schemaChangedHandler + AddHandler MyBase.Relations.CollectionChanged, schemaChangedHandler + Me.EndInit + End Sub + + _ + Protected Sub New(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext) + MyBase.New(info, context, false) + If (Me.IsBinarySerialized(info, context) = true) Then + Me.InitVars(false) + Dim schemaChangedHandler1 As System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged + AddHandler Me.Tables.CollectionChanged, schemaChangedHandler1 + AddHandler Me.Relations.CollectionChanged, schemaChangedHandler1 + Return + End If + Dim strSchema As String = CType(info.GetValue("XmlSchema", GetType(String)),String) + If (Me.DetermineSchemaSerializationMode(info, context) = System.Data.SchemaSerializationMode.IncludeSchema) Then + Dim ds As System.Data.DataSet = New System.Data.DataSet + ds.ReadXmlSchema(New System.Xml.XmlTextReader(New System.IO.StringReader(strSchema))) + If (Not (ds.Tables("Employees")) Is Nothing) Then + MyBase.Tables.Add(New EmployeesDataTable(ds.Tables("Employees"))) + End If + Me.DataSetName = ds.DataSetName + Me.Prefix = ds.Prefix + Me.Namespace = ds.Namespace + Me.Locale = ds.Locale + Me.CaseSensitive = ds.CaseSensitive + Me.EnforceConstraints = ds.EnforceConstraints + Me.Merge(ds, false, System.Data.MissingSchemaAction.Add) + Me.InitVars + Else + Me.ReadXmlSchema(New System.Xml.XmlTextReader(New System.IO.StringReader(strSchema))) + End If + Me.GetSerializationData(info, context) + Dim schemaChangedHandler As System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged + AddHandler MyBase.Tables.CollectionChanged, schemaChangedHandler + AddHandler Me.Relations.CollectionChanged, schemaChangedHandler + End Sub + + _ + Public ReadOnly Property Employees() As EmployeesDataTable + Get + Return Me.tableEmployees + End Get + End Property + + _ + Public Overrides Property SchemaSerializationMode() As System.Data.SchemaSerializationMode + Get + Return Me._schemaSerializationMode + End Get + Set + Me._schemaSerializationMode = value + End Set + End Property + + _ + Public Shadows ReadOnly Property Tables() As System.Data.DataTableCollection + Get + Return MyBase.Tables + End Get + End Property + + _ + Public Shadows ReadOnly Property Relations() As System.Data.DataRelationCollection + Get + Return MyBase.Relations + End Get + End Property + + _ + Protected Overrides Sub InitializeDerivedDataSet() + Me.BeginInit + Me.InitClass + Me.EndInit + End Sub + + _ + Public Overrides Function Clone() As System.Data.DataSet + Dim cln As NorthwindDataSet = CType(MyBase.Clone,NorthwindDataSet) + cln.InitVars + cln.SchemaSerializationMode = Me.SchemaSerializationMode + Return cln + End Function + + _ + Protected Overrides Function ShouldSerializeTables() As Boolean + Return false + End Function + + _ + Protected Overrides Function ShouldSerializeRelations() As Boolean + Return false + End Function + + _ + Protected Overrides Sub ReadXmlSerializable(ByVal reader As System.Xml.XmlReader) + If (Me.DetermineSchemaSerializationMode(reader) = System.Data.SchemaSerializationMode.IncludeSchema) Then + Me.Reset + Dim ds As System.Data.DataSet = New System.Data.DataSet + ds.ReadXml(reader) + If (Not (ds.Tables("Employees")) Is Nothing) Then + MyBase.Tables.Add(New EmployeesDataTable(ds.Tables("Employees"))) + End If + Me.DataSetName = ds.DataSetName + Me.Prefix = ds.Prefix + Me.Namespace = ds.Namespace + Me.Locale = ds.Locale + Me.CaseSensitive = ds.CaseSensitive + Me.EnforceConstraints = ds.EnforceConstraints + Me.Merge(ds, false, System.Data.MissingSchemaAction.Add) + Me.InitVars + Else + Me.ReadXml(reader) + Me.InitVars + End If + End Sub + + _ + Protected Overrides Function GetSchemaSerializable() As System.Xml.Schema.XmlSchema + Dim stream As System.IO.MemoryStream = New System.IO.MemoryStream + Me.WriteXmlSchema(New System.Xml.XmlTextWriter(stream, Nothing)) + stream.Position = 0 + Return System.Xml.Schema.XmlSchema.Read(New System.Xml.XmlTextReader(stream), Nothing) + End Function + + _ + Friend Overloads Sub InitVars() + Me.InitVars(true) + End Sub + + _ + Friend Overloads Sub InitVars(ByVal initTable As Boolean) + Me.tableEmployees = CType(MyBase.Tables("Employees"),EmployeesDataTable) + If (initTable = true) Then + If (Not (Me.tableEmployees) Is Nothing) Then + Me.tableEmployees.InitVars + End If + End If + End Sub + + _ + Private Sub InitClass() + Me.DataSetName = "NorthwindDataSet" + Me.Prefix = "" + Me.Namespace = "http://tempuri.org/NorthwindDataSet.xsd" + Me.EnforceConstraints = true + Me.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema + Me.tableEmployees = New EmployeesDataTable + MyBase.Tables.Add(Me.tableEmployees) + End Sub + + _ + Private Function ShouldSerializeEmployees() As Boolean + Return false + End Function + + _ + Private Sub SchemaChanged(ByVal sender As Object, ByVal e As System.ComponentModel.CollectionChangeEventArgs) + If (e.Action = System.ComponentModel.CollectionChangeAction.Remove) Then + Me.InitVars + End If + End Sub + + _ + Public Shared Function GetTypedDataSetSchema(ByVal xs As System.Xml.Schema.XmlSchemaSet) As System.Xml.Schema.XmlSchemaComplexType + Dim ds As NorthwindDataSet = New NorthwindDataSet + Dim type As System.Xml.Schema.XmlSchemaComplexType = New System.Xml.Schema.XmlSchemaComplexType + Dim sequence As System.Xml.Schema.XmlSchemaSequence = New System.Xml.Schema.XmlSchemaSequence + xs.Add(ds.GetSchemaSerializable) + Dim any As System.Xml.Schema.XmlSchemaAny = New System.Xml.Schema.XmlSchemaAny + any.Namespace = ds.Namespace + sequence.Items.Add(any) + type.Particle = sequence + Return type + End Function + + Public Delegate Sub EmployeesRowChangeEventHandler(ByVal sender As Object, ByVal e As EmployeesRowChangeEvent) + + _ + Partial Public Class EmployeesDataTable + Inherits System.Data.DataTable + Implements System.Collections.IEnumerable + + Private columnEmployeeID As System.Data.DataColumn + + Private columnLastName As System.Data.DataColumn + + Private columnFirstName As System.Data.DataColumn + + Private columnTitle As System.Data.DataColumn + + Private columnPhoto As System.Data.DataColumn + + Private columnTagID As System.Data.DataColumn + + _ + Public Sub New() + MyBase.New + Me.TableName = "Employees" + Me.BeginInit + Me.InitClass + Me.EndInit + End Sub + + _ + Friend Sub New(ByVal table As System.Data.DataTable) + MyBase.New + Me.TableName = table.TableName + If (table.CaseSensitive <> table.DataSet.CaseSensitive) Then + Me.CaseSensitive = table.CaseSensitive + End If + If (table.Locale.ToString <> table.DataSet.Locale.ToString) Then + Me.Locale = table.Locale + End If + If (table.Namespace <> table.DataSet.Namespace) Then + Me.Namespace = table.Namespace + End If + Me.Prefix = table.Prefix + Me.MinimumCapacity = table.MinimumCapacity + End Sub + + _ + Protected Sub New(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext) + MyBase.New(info, context) + Me.InitVars + End Sub + + _ + Public ReadOnly Property EmployeeIDColumn() As System.Data.DataColumn + Get + Return Me.columnEmployeeID + End Get + End Property + + _ + Public ReadOnly Property LastNameColumn() As System.Data.DataColumn + Get + Return Me.columnLastName + End Get + End Property + + _ + Public ReadOnly Property FirstNameColumn() As System.Data.DataColumn + Get + Return Me.columnFirstName + End Get + End Property + + _ + Public ReadOnly Property TitleColumn() As System.Data.DataColumn + Get + Return Me.columnTitle + End Get + End Property + + _ + Public ReadOnly Property PhotoColumn() As System.Data.DataColumn + Get + Return Me.columnPhoto + End Get + End Property + + _ + Public ReadOnly Property TagIDColumn() As System.Data.DataColumn + Get + Return Me.columnTagID + End Get + End Property + + _ + Public ReadOnly Property Count() As Integer + Get + Return Me.Rows.Count + End Get + End Property + + _ + Public Default ReadOnly Property Item(ByVal index As Integer) As EmployeesRow + Get + Return CType(Me.Rows(index),EmployeesRow) + End Get + End Property + + Public Event EmployeesRowChanging As EmployeesRowChangeEventHandler + + Public Event EmployeesRowChanged As EmployeesRowChangeEventHandler + + Public Event EmployeesRowDeleting As EmployeesRowChangeEventHandler + + Public Event EmployeesRowDeleted As EmployeesRowChangeEventHandler + + _ + Public Overloads Sub AddEmployeesRow(ByVal row As EmployeesRow) + Me.Rows.Add(row) + End Sub + + _ + Public Overloads Function AddEmployeesRow(ByVal LastName As String, ByVal FirstName As String, ByVal Title As String, ByVal Photo() As Byte, ByVal TagID As String) As EmployeesRow + Dim rowEmployeesRow As EmployeesRow = CType(Me.NewRow,EmployeesRow) + rowEmployeesRow.ItemArray = New Object() {Nothing, LastName, FirstName, Title, Photo, TagID} + Me.Rows.Add(rowEmployeesRow) + Return rowEmployeesRow + End Function + + _ + Public Function FindByEmployeeID(ByVal EmployeeID As Integer) As EmployeesRow + Return CType(Me.Rows.Find(New Object() {EmployeeID}),EmployeesRow) + End Function + + _ + Public Overridable Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator + Return Me.Rows.GetEnumerator + End Function + + _ + Public Overrides Function Clone() As System.Data.DataTable + Dim cln As EmployeesDataTable = CType(MyBase.Clone,EmployeesDataTable) + cln.InitVars + Return cln + End Function + + _ + Protected Overrides Function CreateInstance() As System.Data.DataTable + Return New EmployeesDataTable + End Function + + _ + Friend Sub InitVars() + Me.columnEmployeeID = MyBase.Columns("EmployeeID") + Me.columnLastName = MyBase.Columns("LastName") + Me.columnFirstName = MyBase.Columns("FirstName") + Me.columnTitle = MyBase.Columns("Title") + Me.columnPhoto = MyBase.Columns("Photo") + Me.columnTagID = MyBase.Columns("TagID") + End Sub + + _ + Private Sub InitClass() + Me.columnEmployeeID = New System.Data.DataColumn("EmployeeID", GetType(Integer), Nothing, System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnEmployeeID) + Me.columnLastName = New System.Data.DataColumn("LastName", GetType(String), Nothing, System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnLastName) + Me.columnFirstName = New System.Data.DataColumn("FirstName", GetType(String), Nothing, System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnFirstName) + Me.columnTitle = New System.Data.DataColumn("Title", GetType(String), Nothing, System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnTitle) + Me.columnPhoto = New System.Data.DataColumn("Photo", GetType(Byte()), Nothing, System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnPhoto) + Me.columnTagID = New System.Data.DataColumn("TagID", GetType(String), Nothing, System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnTagID) + Me.Constraints.Add(New System.Data.UniqueConstraint("Constraint1", New System.Data.DataColumn() {Me.columnEmployeeID}, true)) + Me.columnEmployeeID.AutoIncrement = true + Me.columnEmployeeID.AllowDBNull = false + Me.columnEmployeeID.ReadOnly = true + Me.columnEmployeeID.Unique = true + Me.columnLastName.AllowDBNull = false + Me.columnLastName.MaxLength = 20 + Me.columnFirstName.AllowDBNull = false + Me.columnFirstName.MaxLength = 10 + Me.columnTitle.MaxLength = 30 + Me.columnTagID.MaxLength = 10 + End Sub + + _ + Public Function NewEmployeesRow() As EmployeesRow + Return CType(Me.NewRow,EmployeesRow) + End Function + + _ + Protected Overrides Function NewRowFromBuilder(ByVal builder As System.Data.DataRowBuilder) As System.Data.DataRow + Return New EmployeesRow(builder) + End Function + + _ + Protected Overrides Function GetRowType() As System.Type + Return GetType(EmployeesRow) + End Function + + _ + Protected Overrides Sub OnRowChanged(ByVal e As System.Data.DataRowChangeEventArgs) + MyBase.OnRowChanged(e) + If (Not (Me.EmployeesRowChangedEvent) Is Nothing) Then + RaiseEvent EmployeesRowChanged(Me, New EmployeesRowChangeEvent(CType(e.Row,EmployeesRow), e.Action)) + End If + End Sub + + _ + Protected Overrides Sub OnRowChanging(ByVal e As System.Data.DataRowChangeEventArgs) + MyBase.OnRowChanging(e) + If (Not (Me.EmployeesRowChangingEvent) Is Nothing) Then + RaiseEvent EmployeesRowChanging(Me, New EmployeesRowChangeEvent(CType(e.Row,EmployeesRow), e.Action)) + End If + End Sub + + _ + Protected Overrides Sub OnRowDeleted(ByVal e As System.Data.DataRowChangeEventArgs) + MyBase.OnRowDeleted(e) + If (Not (Me.EmployeesRowDeletedEvent) Is Nothing) Then + RaiseEvent EmployeesRowDeleted(Me, New EmployeesRowChangeEvent(CType(e.Row,EmployeesRow), e.Action)) + End If + End Sub + + _ + Protected Overrides Sub OnRowDeleting(ByVal e As System.Data.DataRowChangeEventArgs) + MyBase.OnRowDeleting(e) + If (Not (Me.EmployeesRowDeletingEvent) Is Nothing) Then + RaiseEvent EmployeesRowDeleting(Me, New EmployeesRowChangeEvent(CType(e.Row,EmployeesRow), e.Action)) + End If + End Sub + + _ + Public Sub RemoveEmployeesRow(ByVal row As EmployeesRow) + Me.Rows.Remove(row) + End Sub + + _ + Public Shared Function GetTypedTableSchema(ByVal xs As System.Xml.Schema.XmlSchemaSet) As System.Xml.Schema.XmlSchemaComplexType + Dim type As System.Xml.Schema.XmlSchemaComplexType = New System.Xml.Schema.XmlSchemaComplexType + Dim sequence As System.Xml.Schema.XmlSchemaSequence = New System.Xml.Schema.XmlSchemaSequence + Dim ds As NorthwindDataSet = New NorthwindDataSet + xs.Add(ds.GetSchemaSerializable) + Dim any1 As System.Xml.Schema.XmlSchemaAny = New System.Xml.Schema.XmlSchemaAny + any1.Namespace = "http://www.w3.org/2001/XMLSchema" + any1.MinOccurs = New Decimal(0) + any1.MaxOccurs = Decimal.MaxValue + any1.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax + sequence.Items.Add(any1) + Dim any2 As System.Xml.Schema.XmlSchemaAny = New System.Xml.Schema.XmlSchemaAny + any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1" + any2.MinOccurs = New Decimal(1) + any2.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax + sequence.Items.Add(any2) + Dim attribute1 As System.Xml.Schema.XmlSchemaAttribute = New System.Xml.Schema.XmlSchemaAttribute + attribute1.Name = "namespace" + attribute1.FixedValue = ds.Namespace + type.Attributes.Add(attribute1) + Dim attribute2 As System.Xml.Schema.XmlSchemaAttribute = New System.Xml.Schema.XmlSchemaAttribute + attribute2.Name = "tableTypeName" + attribute2.FixedValue = "EmployeesDataTable" + type.Attributes.Add(attribute2) + type.Particle = sequence + Return type + End Function + End Class + + _ + Partial Public Class EmployeesRow + Inherits System.Data.DataRow + + Private tableEmployees As EmployeesDataTable + + _ + Friend Sub New(ByVal rb As System.Data.DataRowBuilder) + MyBase.New(rb) + Me.tableEmployees = CType(Me.Table,EmployeesDataTable) + End Sub + + _ + Public Property EmployeeID() As Integer + Get + Return CType(Me(Me.tableEmployees.EmployeeIDColumn),Integer) + End Get + Set + Me(Me.tableEmployees.EmployeeIDColumn) = value + End Set + End Property + + _ + Public Property LastName() As String + Get + Return CType(Me(Me.tableEmployees.LastNameColumn),String) + End Get + Set + Me(Me.tableEmployees.LastNameColumn) = value + End Set + End Property + + _ + Public Property FirstName() As String + Get + Return CType(Me(Me.tableEmployees.FirstNameColumn),String) + End Get + Set + Me(Me.tableEmployees.FirstNameColumn) = value + End Set + End Property + + _ + Public Property Title() As String + Get + Try + Return CType(Me(Me.tableEmployees.TitleColumn),String) + Catch e As System.InvalidCastException + Throw New System.Data.StrongTypingException("The value for column 'Title' in table 'Employees' is DBNull.", e) + End Try + End Get + Set + Me(Me.tableEmployees.TitleColumn) = value + End Set + End Property + + _ + Public Property Photo() As Byte() + Get + Try + Return CType(Me(Me.tableEmployees.PhotoColumn),Byte()) + Catch e As System.InvalidCastException + Throw New System.Data.StrongTypingException("The value for column 'Photo' in table 'Employees' is DBNull.", e) + End Try + End Get + Set + Me(Me.tableEmployees.PhotoColumn) = value + End Set + End Property + + _ + Public Property TagID() As String + Get + Try + Return CType(Me(Me.tableEmployees.TagIDColumn),String) + Catch e As System.InvalidCastException + Throw New System.Data.StrongTypingException("The value for column 'TagID' in table 'Employees' is DBNull.", e) + End Try + End Get + Set + Me(Me.tableEmployees.TagIDColumn) = value + End Set + End Property + + _ + Public Function IsTitleNull() As Boolean + Return Me.IsNull(Me.tableEmployees.TitleColumn) + End Function + + _ + Public Sub SetTitleNull() + Me(Me.tableEmployees.TitleColumn) = System.Convert.DBNull + End Sub + + _ + Public Function IsPhotoNull() As Boolean + Return Me.IsNull(Me.tableEmployees.PhotoColumn) + End Function + + _ + Public Sub SetPhotoNull() + Me(Me.tableEmployees.PhotoColumn) = System.Convert.DBNull + End Sub + + _ + Public Function IsTagIDNull() As Boolean + Return Me.IsNull(Me.tableEmployees.TagIDColumn) + End Function + + _ + Public Sub SetTagIDNull() + Me(Me.tableEmployees.TagIDColumn) = System.Convert.DBNull + End Sub + End Class + + _ + Public Class EmployeesRowChangeEvent + Inherits System.EventArgs + + Private eventRow As EmployeesRow + + Private eventAction As System.Data.DataRowAction + + _ + Public Sub New(ByVal row As EmployeesRow, ByVal action As System.Data.DataRowAction) + MyBase.New + Me.eventRow = row + Me.eventAction = action + End Sub + + _ + Public ReadOnly Property Row() As EmployeesRow + Get + Return Me.eventRow + End Get + End Property + + _ + Public ReadOnly Property Action() As System.Data.DataRowAction + Get + Return Me.eventAction + End Get + End Property + End Class +End Class + +Namespace NorthwindDataSetTableAdapters + + _ + Partial Public Class EmployeesTableAdapter + Inherits System.ComponentModel.Component + + Private WithEvents _adapter As System.Data.SqlClient.SqlDataAdapter + + Private _connection As System.Data.SqlClient.SqlConnection + + Private _commandCollection() As System.Data.SqlClient.SqlCommand + + Private _clearBeforeFill As Boolean + + _ + Public Sub New() + MyBase.New + Me.ClearBeforeFill = true + End Sub + + _ + Private ReadOnly Property Adapter() As System.Data.SqlClient.SqlDataAdapter + Get + If (Me._adapter Is Nothing) Then + Me.InitAdapter + End If + Return Me._adapter + End Get + End Property + + _ + Friend Property Connection() As System.Data.SqlClient.SqlConnection + Get + If (Me._connection Is Nothing) Then + Me.InitConnection + End If + Return Me._connection + End Get + Set + Me._connection = value + If (Not (Me.Adapter.InsertCommand) Is Nothing) Then + Me.Adapter.InsertCommand.Connection = value + End If + If (Not (Me.Adapter.DeleteCommand) Is Nothing) Then + Me.Adapter.DeleteCommand.Connection = value + End If + If (Not (Me.Adapter.UpdateCommand) Is Nothing) Then + Me.Adapter.UpdateCommand.Connection = value + End If + Dim i As Integer = 0 + Do While (i < Me.CommandCollection.Length) + If (Not (Me.CommandCollection(i)) Is Nothing) Then + CType(Me.CommandCollection(i),System.Data.SqlClient.SqlCommand).Connection = value + End If + i = (i + 1) + Loop + End Set + End Property + + _ + Protected ReadOnly Property CommandCollection() As System.Data.SqlClient.SqlCommand() + Get + If (Me._commandCollection Is Nothing) Then + Me.InitCommandCollection + End If + Return Me._commandCollection + End Get + End Property + + _ + Public Property ClearBeforeFill() As Boolean + Get + Return Me._clearBeforeFill + End Get + Set + Me._clearBeforeFill = value + End Set + End Property + + _ + Private Sub InitAdapter() + Me._adapter = New System.Data.SqlClient.SqlDataAdapter + Dim tableMapping As System.Data.Common.DataTableMapping = New System.Data.Common.DataTableMapping + tableMapping.SourceTable = "Table" + tableMapping.DataSetTable = "Employees" + tableMapping.ColumnMappings.Add("EmployeeID", "EmployeeID") + tableMapping.ColumnMappings.Add("LastName", "LastName") + tableMapping.ColumnMappings.Add("FirstName", "FirstName") + tableMapping.ColumnMappings.Add("Title", "Title") + tableMapping.ColumnMappings.Add("Photo", "Photo") + tableMapping.ColumnMappings.Add("TagID", "TagID") + Me._adapter.TableMappings.Add(tableMapping) + Me._adapter.DeleteCommand = New System.Data.SqlClient.SqlCommand + Me._adapter.DeleteCommand.Connection = Me.Connection + Me._adapter.DeleteCommand.CommandText = "DELETE FROM [dbo].[Employees] WHERE (([EmployeeID] = @Original_EmployeeID) AND (["& _ + "LastName] = @Original_LastName) AND ([FirstName] = @Original_FirstName) AND ((@I"& _ + "sNull_Title = 1 AND [Title] IS NULL) OR ([Title] = @Original_Title)) AND ((@IsNu"& _ + "ll_TagID = 1 AND [TagID] IS NULL) OR ([TagID] = @Original_TagID)))" + Me._adapter.DeleteCommand.CommandType = System.Data.CommandType.Text + Me._adapter.DeleteCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_EmployeeID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "EmployeeID", System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.DeleteCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_LastName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "LastName", System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.DeleteCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_FirstName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "FirstName", System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.DeleteCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@IsNull_Title", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "Title", System.Data.DataRowVersion.Original, true, Nothing, "", "", "")) + Me._adapter.DeleteCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Title", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "Title", System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.DeleteCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@IsNull_TagID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "TagID", System.Data.DataRowVersion.Original, true, Nothing, "", "", "")) + Me._adapter.DeleteCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_TagID", System.Data.SqlDbType.NChar, 0, System.Data.ParameterDirection.Input, 0, 0, "TagID", System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.InsertCommand = New System.Data.SqlClient.SqlCommand + Me._adapter.InsertCommand.Connection = Me.Connection + Me._adapter.InsertCommand.CommandText = "INSERT INTO [dbo].[Employees] ([LastName], [FirstName], [Title], [Photo], [TagID]"& _ + ") VALUES (@LastName, @FirstName, @Title, @Photo, @TagID);"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"SELECT EmployeeID, La"& _ + "stName, FirstName, Title, Photo, TagID FROM Employees WHERE (EmployeeID = SCOPE_"& _ + "IDENTITY())" + Me._adapter.InsertCommand.CommandType = System.Data.CommandType.Text + Me._adapter.InsertCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@LastName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "LastName", System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.InsertCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@FirstName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "FirstName", System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.InsertCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Title", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "Title", System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.InsertCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Photo", System.Data.SqlDbType.Image, 0, System.Data.ParameterDirection.Input, 0, 0, "Photo", System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.InsertCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@TagID", System.Data.SqlDbType.NChar, 0, System.Data.ParameterDirection.Input, 0, 0, "TagID", System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand = New System.Data.SqlClient.SqlCommand + Me._adapter.UpdateCommand.Connection = Me.Connection + Me._adapter.UpdateCommand.CommandText = "UPDATE [dbo].[Employees] SET [LastName] = @LastName, [FirstName] = @FirstName, [T"& _ + "itle] = @Title, [Photo] = @Photo, [TagID] = @TagID WHERE (([EmployeeID] = @Origi"& _ + "nal_EmployeeID) AND ([LastName] = @Original_LastName) AND ([FirstName] = @Origin"& _ + "al_FirstName) AND ((@IsNull_Title = 1 AND [Title] IS NULL) OR ([Title] = @Origin"& _ + "al_Title)) AND ((@IsNull_TagID = 1 AND [TagID] IS NULL) OR ([TagID] = @Original_"& _ + "TagID)));"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"SELECT EmployeeID, LastName, FirstName, Title, Photo, TagID FROM Empl"& _ + "oyees WHERE (EmployeeID = @EmployeeID)" + Me._adapter.UpdateCommand.CommandType = System.Data.CommandType.Text + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@LastName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "LastName", System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@FirstName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "FirstName", System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Title", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "Title", System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Photo", System.Data.SqlDbType.Image, 0, System.Data.ParameterDirection.Input, 0, 0, "Photo", System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@TagID", System.Data.SqlDbType.NChar, 0, System.Data.ParameterDirection.Input, 0, 0, "TagID", System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_EmployeeID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "EmployeeID", System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_LastName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "LastName", System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_FirstName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "FirstName", System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@IsNull_Title", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "Title", System.Data.DataRowVersion.Original, true, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Title", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "Title", System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@IsNull_TagID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, 0, 0, "TagID", System.Data.DataRowVersion.Original, true, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_TagID", System.Data.SqlDbType.NChar, 0, System.Data.ParameterDirection.Input, 0, 0, "TagID", System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@EmployeeID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, 0, 0, "EmployeeID", System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + End Sub + + _ + Private Sub InitConnection() + Me._connection = New System.Data.SqlClient.SqlConnection + Me._connection.ConnectionString = Global.Attendance.My.MySettings.Default.NorthwindConnectionString + End Sub + + _ + Private Sub InitCommandCollection() + Me._commandCollection = New System.Data.SqlClient.SqlCommand(0) {} + Me._commandCollection(0) = New System.Data.SqlClient.SqlCommand + Me._commandCollection(0).Connection = Me.Connection + Me._commandCollection(0).CommandText = "SELECT EmployeeID, LastName, FirstName, Title, Photo, TagID FROM dbo.Employees" + Me._commandCollection(0).CommandType = System.Data.CommandType.Text + End Sub + + _ + Public Overloads Overridable Function Fill(ByVal dataTable As NorthwindDataSet.EmployeesDataTable) As Integer + Me.Adapter.SelectCommand = Me.CommandCollection(0) + If (Me.ClearBeforeFill = true) Then + dataTable.Clear + End If + Dim returnValue As Integer = Me.Adapter.Fill(dataTable) + Return returnValue + End Function + + _ + Public Overloads Overridable Function GetData() As NorthwindDataSet.EmployeesDataTable + Me.Adapter.SelectCommand = Me.CommandCollection(0) + Dim dataTable As NorthwindDataSet.EmployeesDataTable = New NorthwindDataSet.EmployeesDataTable + Me.Adapter.Fill(dataTable) + Return dataTable + End Function + + _ + Public Overloads Overridable Function Update(ByVal dataTable As NorthwindDataSet.EmployeesDataTable) As Integer + Return Me.Adapter.Update(dataTable) + End Function + + _ + Public Overloads Overridable Function Update(ByVal dataSet As NorthwindDataSet) As Integer + Return Me.Adapter.Update(dataSet, "Employees") + End Function + + _ + Public Overloads Overridable Function Update(ByVal dataRow As System.Data.DataRow) As Integer + Return Me.Adapter.Update(New System.Data.DataRow() {dataRow}) + End Function + + _ + Public Overloads Overridable Function Update(ByVal dataRows() As System.Data.DataRow) As Integer + Return Me.Adapter.Update(dataRows) + End Function + + _ + Public Overloads Overridable Function Delete(ByVal Original_EmployeeID As Integer, ByVal Original_LastName As String, ByVal Original_FirstName As String, ByVal Original_Title As String, ByVal Original_TagID As String) As Integer + Me.Adapter.DeleteCommand.Parameters(0).Value = CType(Original_EmployeeID,Integer) + If (Original_LastName Is Nothing) Then + Throw New System.ArgumentNullException("Original_LastName") + Else + Me.Adapter.DeleteCommand.Parameters(1).Value = CType(Original_LastName,String) + End If + If (Original_FirstName Is Nothing) Then + Throw New System.ArgumentNullException("Original_FirstName") + Else + Me.Adapter.DeleteCommand.Parameters(2).Value = CType(Original_FirstName,String) + End If + If (Original_Title Is Nothing) Then + Me.Adapter.DeleteCommand.Parameters(3).Value = CType(1,Object) + Me.Adapter.DeleteCommand.Parameters(4).Value = System.DBNull.Value + Else + Me.Adapter.DeleteCommand.Parameters(3).Value = CType(0,Object) + Me.Adapter.DeleteCommand.Parameters(4).Value = CType(Original_Title,String) + End If + If (Original_TagID Is Nothing) Then + Me.Adapter.DeleteCommand.Parameters(5).Value = CType(1,Object) + Me.Adapter.DeleteCommand.Parameters(6).Value = System.DBNull.Value + Else + Me.Adapter.DeleteCommand.Parameters(5).Value = CType(0,Object) + Me.Adapter.DeleteCommand.Parameters(6).Value = CType(Original_TagID,String) + End If + Dim previousConnectionState As System.Data.ConnectionState = Me.Adapter.DeleteCommand.Connection.State + If ((Me.Adapter.DeleteCommand.Connection.State And System.Data.ConnectionState.Open) _ + <> System.Data.ConnectionState.Open) Then + Me.Adapter.DeleteCommand.Connection.Open + End If + Try + Dim returnValue As Integer = Me.Adapter.DeleteCommand.ExecuteNonQuery + Return returnValue + Finally + If (previousConnectionState = System.Data.ConnectionState.Closed) Then + Me.Adapter.DeleteCommand.Connection.Close + End If + End Try + End Function + + _ + Public Overloads Overridable Function Insert(ByVal LastName As String, ByVal FirstName As String, ByVal Title As String, ByVal Photo() As Byte, ByVal TagID As String) As Integer + If (LastName Is Nothing) Then + Throw New System.ArgumentNullException("LastName") + Else + Me.Adapter.InsertCommand.Parameters(0).Value = CType(LastName,String) + End If + If (FirstName Is Nothing) Then + Throw New System.ArgumentNullException("FirstName") + Else + Me.Adapter.InsertCommand.Parameters(1).Value = CType(FirstName,String) + End If + If (Title Is Nothing) Then + Me.Adapter.InsertCommand.Parameters(2).Value = System.DBNull.Value + Else + Me.Adapter.InsertCommand.Parameters(2).Value = CType(Title,String) + End If + If (Photo Is Nothing) Then + Me.Adapter.InsertCommand.Parameters(3).Value = System.DBNull.Value + Else + Me.Adapter.InsertCommand.Parameters(3).Value = CType(Photo,Byte()) + End If + If (TagID Is Nothing) Then + Me.Adapter.InsertCommand.Parameters(4).Value = System.DBNull.Value + Else + Me.Adapter.InsertCommand.Parameters(4).Value = CType(TagID,String) + End If + Dim previousConnectionState As System.Data.ConnectionState = Me.Adapter.InsertCommand.Connection.State + If ((Me.Adapter.InsertCommand.Connection.State And System.Data.ConnectionState.Open) _ + <> System.Data.ConnectionState.Open) Then + Me.Adapter.InsertCommand.Connection.Open + End If + Try + Dim returnValue As Integer = Me.Adapter.InsertCommand.ExecuteNonQuery + Return returnValue + Finally + If (previousConnectionState = System.Data.ConnectionState.Closed) Then + Me.Adapter.InsertCommand.Connection.Close + End If + End Try + End Function + + _ + Public Overloads Overridable Function Update(ByVal LastName As String, ByVal FirstName As String, ByVal Title As String, ByVal Photo() As Byte, ByVal TagID As String, ByVal Original_EmployeeID As Integer, ByVal Original_LastName As String, ByVal Original_FirstName As String, ByVal Original_Title As String, ByVal Original_TagID As String, ByVal EmployeeID As Integer) As Integer + If (LastName Is Nothing) Then + Throw New System.ArgumentNullException("LastName") + Else + Me.Adapter.UpdateCommand.Parameters(0).Value = CType(LastName,String) + End If + If (FirstName Is Nothing) Then + Throw New System.ArgumentNullException("FirstName") + Else + Me.Adapter.UpdateCommand.Parameters(1).Value = CType(FirstName,String) + End If + If (Title Is Nothing) Then + Me.Adapter.UpdateCommand.Parameters(2).Value = System.DBNull.Value + Else + Me.Adapter.UpdateCommand.Parameters(2).Value = CType(Title,String) + End If + If (Photo Is Nothing) Then + Me.Adapter.UpdateCommand.Parameters(3).Value = System.DBNull.Value + Else + Me.Adapter.UpdateCommand.Parameters(3).Value = CType(Photo,Byte()) + End If + If (TagID Is Nothing) Then + Me.Adapter.UpdateCommand.Parameters(4).Value = System.DBNull.Value + Else + Me.Adapter.UpdateCommand.Parameters(4).Value = CType(TagID,String) + End If + Me.Adapter.UpdateCommand.Parameters(5).Value = CType(Original_EmployeeID,Integer) + If (Original_LastName Is Nothing) Then + Throw New System.ArgumentNullException("Original_LastName") + Else + Me.Adapter.UpdateCommand.Parameters(6).Value = CType(Original_LastName,String) + End If + If (Original_FirstName Is Nothing) Then + Throw New System.ArgumentNullException("Original_FirstName") + Else + Me.Adapter.UpdateCommand.Parameters(7).Value = CType(Original_FirstName,String) + End If + If (Original_Title Is Nothing) Then + Me.Adapter.UpdateCommand.Parameters(8).Value = CType(1,Object) + Me.Adapter.UpdateCommand.Parameters(9).Value = System.DBNull.Value + Else + Me.Adapter.UpdateCommand.Parameters(8).Value = CType(0,Object) + Me.Adapter.UpdateCommand.Parameters(9).Value = CType(Original_Title,String) + End If + If (Original_TagID Is Nothing) Then + Me.Adapter.UpdateCommand.Parameters(10).Value = CType(1,Object) + Me.Adapter.UpdateCommand.Parameters(11).Value = System.DBNull.Value + Else + Me.Adapter.UpdateCommand.Parameters(10).Value = CType(0,Object) + Me.Adapter.UpdateCommand.Parameters(11).Value = CType(Original_TagID,String) + End If + Me.Adapter.UpdateCommand.Parameters(12).Value = CType(EmployeeID,Integer) + Dim previousConnectionState As System.Data.ConnectionState = Me.Adapter.UpdateCommand.Connection.State + If ((Me.Adapter.UpdateCommand.Connection.State And System.Data.ConnectionState.Open) _ + <> System.Data.ConnectionState.Open) Then + Me.Adapter.UpdateCommand.Connection.Open + End If + Try + Dim returnValue As Integer = Me.Adapter.UpdateCommand.ExecuteNonQuery + Return returnValue + Finally + If (previousConnectionState = System.Data.ConnectionState.Closed) Then + Me.Adapter.UpdateCommand.Connection.Close + End If + End Try + End Function + End Class +End Namespace diff --git a/Chapter05(RFID)/Attendance_Phidget/NorthwindDataSet.xsc b/Chapter05(RFID)/Attendance_Phidget/NorthwindDataSet.xsc new file mode 100644 index 0000000..2dbd3f0 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/NorthwindDataSet.xsc @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Phidget/NorthwindDataSet.xsd b/Chapter05(RFID)/Attendance_Phidget/NorthwindDataSet.xsd new file mode 100644 index 0000000..2ad06dc --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/NorthwindDataSet.xsd @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + DELETE FROM [dbo].[Employees] WHERE (([EmployeeID] = @Original_EmployeeID) AND ([LastName] = @Original_LastName) AND ([FirstName] = @Original_FirstName) AND ((@IsNull_Title = 1 AND [Title] IS NULL) OR ([Title] = @Original_Title)) AND ((@IsNull_TagID = 1 AND [TagID] IS NULL) OR ([TagID] = @Original_TagID))) + + + + + + + + + + + + + + + + + + + + + INSERT INTO [dbo].[Employees] ([LastName], [FirstName], [Title], [Photo], [TagID]) VALUES (@LastName, @FirstName, @Title, @Photo, @TagID); +SELECT EmployeeID, LastName, FirstName, Title, Photo, TagID FROM Employees WHERE (EmployeeID = SCOPE_IDENTITY()) + + + + + + + + + + + + + + + + + SELECT EmployeeID, LastName, FirstName, Title, Photo, TagID FROM dbo.Employees + + + + + + + UPDATE [dbo].[Employees] SET [LastName] = @LastName, [FirstName] = @FirstName, [Title] = @Title, [Photo] = @Photo, [TagID] = @TagID WHERE (([EmployeeID] = @Original_EmployeeID) AND ([LastName] = @Original_LastName) AND ([FirstName] = @Original_FirstName) AND ((@IsNull_Title = 1 AND [Title] IS NULL) OR ([Title] = @Original_Title)) AND ((@IsNull_TagID = 1 AND [TagID] IS NULL) OR ([TagID] = @Original_TagID))); +SELECT EmployeeID, LastName, FirstName, Title, Photo, TagID FROM Employees WHERE (EmployeeID = @EmployeeID) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Phidget/NorthwindDataSet.xss b/Chapter05(RFID)/Attendance_Phidget/NorthwindDataSet.xss new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/NorthwindDataSet.xss @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Phidget/app.config b/Chapter05(RFID)/Attendance_Phidget/app.config new file mode 100644 index 0000000..f541ced --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/app.config @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter05(RFID)/Attendance_Phidget/bin/Debug/Attendance.exe b/Chapter05(RFID)/Attendance_Phidget/bin/Debug/Attendance.exe new file mode 100644 index 0000000..8483fc2 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget/bin/Debug/Attendance.exe differ diff --git a/Chapter05(RFID)/Attendance_Phidget/bin/Debug/Attendance.exe.config b/Chapter05(RFID)/Attendance_Phidget/bin/Debug/Attendance.exe.config new file mode 100644 index 0000000..f541ced --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/bin/Debug/Attendance.exe.config @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter05(RFID)/Attendance_Phidget/bin/Debug/Attendance.pdb b/Chapter05(RFID)/Attendance_Phidget/bin/Debug/Attendance.pdb new file mode 100644 index 0000000..5e72a79 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget/bin/Debug/Attendance.pdb differ diff --git a/Chapter05(RFID)/Attendance_Phidget/bin/Debug/Attendance.vshost.exe b/Chapter05(RFID)/Attendance_Phidget/bin/Debug/Attendance.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget/bin/Debug/Attendance.vshost.exe differ diff --git a/Chapter05(RFID)/Attendance_Phidget/bin/Debug/Attendance.vshost.exe.config b/Chapter05(RFID)/Attendance_Phidget/bin/Debug/Attendance.vshost.exe.config new file mode 100644 index 0000000..f541ced --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/bin/Debug/Attendance.vshost.exe.config @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter05(RFID)/Attendance_Phidget/bin/Debug/Attendance.xml b/Chapter05(RFID)/Attendance_Phidget/bin/Debug/Attendance.xml new file mode 100644 index 0000000..afe0f32 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/bin/Debug/Attendance.xml @@ -0,0 +1,11 @@ + + + + +Attendance + + + + + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Phidget/bin/Debug/PhidgetsNET.dll b/Chapter05(RFID)/Attendance_Phidget/bin/Debug/PhidgetsNET.dll new file mode 100644 index 0000000..c6f8b49 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget/bin/Debug/PhidgetsNET.dll differ diff --git a/Chapter05(RFID)/Attendance_Phidget/obj/Attendance.vbproj.FileList.txt b/Chapter05(RFID)/Attendance_Phidget/obj/Attendance.vbproj.FileList.txt new file mode 100644 index 0000000..4bb4343 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/obj/Attendance.vbproj.FileList.txt @@ -0,0 +1,13 @@ +bin\Debug\Attendance.exe.config +bin\Debug\Attendance.exe +bin\Debug\Attendance.pdb +bin\Debug\Attendance.xml +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\Attendance.Form1.resources +obj\Debug\Attendance.Resources.resources +obj\Debug\Attendance.vbproj.GenerateResource.Cache +obj\Debug\Attendance.exe +obj\Debug\Attendance.xml +obj\Debug\Attendance.pdb +bin\Debug\PhidgetsNET.dll +obj\Debug\Attendance.Form2.resources diff --git a/Chapter05(RFID)/Attendance_Phidget/obj/Debug/Attendance.Form1.resources b/Chapter05(RFID)/Attendance_Phidget/obj/Debug/Attendance.Form1.resources new file mode 100644 index 0000000..1aa111d Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget/obj/Debug/Attendance.Form1.resources differ diff --git a/Chapter05(RFID)/Attendance_Phidget/obj/Debug/Attendance.Form2.resources b/Chapter05(RFID)/Attendance_Phidget/obj/Debug/Attendance.Form2.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget/obj/Debug/Attendance.Form2.resources differ diff --git a/Chapter05(RFID)/Attendance_Phidget/obj/Debug/Attendance.Resources.resources b/Chapter05(RFID)/Attendance_Phidget/obj/Debug/Attendance.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget/obj/Debug/Attendance.Resources.resources differ diff --git a/Chapter05(RFID)/Attendance_Phidget/obj/Debug/Attendance.exe b/Chapter05(RFID)/Attendance_Phidget/obj/Debug/Attendance.exe new file mode 100644 index 0000000..8483fc2 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget/obj/Debug/Attendance.exe differ diff --git a/Chapter05(RFID)/Attendance_Phidget/obj/Debug/Attendance.pdb b/Chapter05(RFID)/Attendance_Phidget/obj/Debug/Attendance.pdb new file mode 100644 index 0000000..5e72a79 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget/obj/Debug/Attendance.pdb differ diff --git a/Chapter05(RFID)/Attendance_Phidget/obj/Debug/Attendance.vbproj.GenerateResource.Cache b/Chapter05(RFID)/Attendance_Phidget/obj/Debug/Attendance.vbproj.GenerateResource.Cache new file mode 100644 index 0000000..121728d Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget/obj/Debug/Attendance.vbproj.GenerateResource.Cache differ diff --git a/Chapter05(RFID)/Attendance_Phidget/obj/Debug/Attendance.xml b/Chapter05(RFID)/Attendance_Phidget/obj/Debug/Attendance.xml new file mode 100644 index 0000000..afe0f32 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget/obj/Debug/Attendance.xml @@ -0,0 +1,11 @@ + + + + +Attendance + + + + + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Phidget/obj/Debug/ResolveAssemblyReference.cache b/Chapter05(RFID)/Attendance_Phidget/obj/Debug/ResolveAssemblyReference.cache new file mode 100644 index 0000000..dc75300 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget/obj/Debug/ResolveAssemblyReference.cache differ diff --git a/Chapter05(RFID)/Attendance_Phidget/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll b/Chapter05(RFID)/Attendance_Phidget/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll new file mode 100644 index 0000000..2840e96 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll differ diff --git a/Chapter05(RFID)/Attendance_Phidget/obj/Debug/TempPE/NorthwindDataSet.Designer.vb.dll b/Chapter05(RFID)/Attendance_Phidget/obj/Debug/TempPE/NorthwindDataSet.Designer.vb.dll new file mode 100644 index 0000000..50c198a Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget/obj/Debug/TempPE/NorthwindDataSet.Designer.vb.dll differ diff --git a/Chapter05(RFID)/Attendance_Phidget/obj/Debug/TempPE/NorthwindDataSet1.Designer.vb.dll b/Chapter05(RFID)/Attendance_Phidget/obj/Debug/TempPE/NorthwindDataSet1.Designer.vb.dll new file mode 100644 index 0000000..bea0ead Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget/obj/Debug/TempPE/NorthwindDataSet1.Designer.vb.dll differ diff --git a/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS.sln b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS.sln new file mode 100644 index 0000000..b7ce8fc --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Attendance_CS", "Attendance_CS\Attendance_CS.csproj", "{4DC5DE6C-DF8B-449A-9726-9E661436EF86}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4DC5DE6C-DF8B-449A-9726-9E661436EF86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4DC5DE6C-DF8B-449A-9726-9E661436EF86}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4DC5DE6C-DF8B-449A-9726-9E661436EF86}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4DC5DE6C-DF8B-449A-9726-9E661436EF86}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS.suo b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS.suo new file mode 100644 index 0000000..d29185c Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS.suo differ diff --git a/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Attendance_CS.csproj b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Attendance_CS.csproj new file mode 100644 index 0000000..511178d --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Attendance_CS.csproj @@ -0,0 +1,79 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {4DC5DE6C-DF8B-449A-9726-9E661436EF86} + WinExe + Properties + Attendance_CS + Attendance_CS + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Designer + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Attendance_CS.csproj.user b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Attendance_CS.csproj.user new file mode 100644 index 0000000..6a34e7d --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Attendance_CS.csproj.user @@ -0,0 +1,5 @@ + + + ShowAllFiles + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Form1.Designer.cs b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Form1.Designer.cs new file mode 100644 index 0000000..2d6fb25 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Form1.Designer.cs @@ -0,0 +1,124 @@ +namespace Attendance_CS +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.chkEnableReader = new System.Windows.Forms.CheckBox(); + this.chkTurnOnLED = new System.Windows.Forms.CheckBox(); + this.txtTagID = new System.Windows.Forms.TextBox(); + this.ToolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); + this.Label1 = new System.Windows.Forms.Label(); + this.StatusStrip1 = new System.Windows.Forms.StatusStrip(); + this.StatusStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // chkEnableReader + // + this.chkEnableReader.AutoSize = true; + this.chkEnableReader.Location = new System.Drawing.Point(106, 32); + this.chkEnableReader.Name = "chkEnableReader"; + this.chkEnableReader.Size = new System.Drawing.Size(97, 17); + this.chkEnableReader.TabIndex = 9; + this.chkEnableReader.Text = "Enable Reader"; + this.chkEnableReader.UseVisualStyleBackColor = true; + this.chkEnableReader.CheckedChanged += new System.EventHandler(this.chkEnableReader_CheckedChanged); + // + // chkTurnOnLED + // + this.chkTurnOnLED.AutoSize = true; + this.chkTurnOnLED.Location = new System.Drawing.Point(15, 32); + this.chkTurnOnLED.Name = "chkTurnOnLED"; + this.chkTurnOnLED.Size = new System.Drawing.Size(87, 17); + this.chkTurnOnLED.TabIndex = 8; + this.chkTurnOnLED.Text = "Turn on LED"; + this.chkTurnOnLED.UseVisualStyleBackColor = true; + this.chkTurnOnLED.CheckedChanged += new System.EventHandler(this.chkTurnOnLED_CheckedChanged); + // + // txtTagID + // + this.txtTagID.Location = new System.Drawing.Point(57, 6); + this.txtTagID.Name = "txtTagID"; + this.txtTagID.Size = new System.Drawing.Size(146, 20); + this.txtTagID.TabIndex = 7; + // + // ToolStripStatusLabel1 + // + this.ToolStripStatusLabel1.Name = "ToolStripStatusLabel1"; + this.ToolStripStatusLabel1.Size = new System.Drawing.Size(111, 17); + this.ToolStripStatusLabel1.Text = "ToolStripStatusLabel1"; + // + // Label1 + // + this.Label1.AutoSize = true; + this.Label1.Location = new System.Drawing.Point(12, 9); + this.Label1.Name = "Label1"; + this.Label1.Size = new System.Drawing.Size(40, 13); + this.Label1.TabIndex = 6; + this.Label1.Text = "Tag ID"; + // + // StatusStrip1 + // + this.StatusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.ToolStripStatusLabel1}); + this.StatusStrip1.Location = new System.Drawing.Point(0, 72); + this.StatusStrip1.Name = "StatusStrip1"; + this.StatusStrip1.Size = new System.Drawing.Size(219, 22); + this.StatusStrip1.TabIndex = 5; + this.StatusStrip1.Text = "StatusStrip1"; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(219, 94); + this.Controls.Add(this.chkEnableReader); + this.Controls.Add(this.chkTurnOnLED); + this.Controls.Add(this.txtTagID); + this.Controls.Add(this.Label1); + this.Controls.Add(this.StatusStrip1); + this.Name = "Form1"; + this.Text = "Form1"; + this.Load += new System.EventHandler(this.Form1_Load); + this.StatusStrip1.ResumeLayout(false); + this.StatusStrip1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + internal System.Windows.Forms.CheckBox chkEnableReader; + internal System.Windows.Forms.CheckBox chkTurnOnLED; + internal System.Windows.Forms.TextBox txtTagID; + internal System.Windows.Forms.ToolStripStatusLabel ToolStripStatusLabel1; + internal System.Windows.Forms.Label Label1; + internal System.Windows.Forms.StatusStrip StatusStrip1; + } +} + diff --git a/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Form1.cs b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Form1.cs new file mode 100644 index 0000000..4d64457 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Form1.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace Attendance_CS +{ + public partial class Form1 : Form + { + PhidgetsNET.PhidgetRFID RFIDReader; + + public Form1() + { + InitializeComponent(); + } + + private void RFIDReader_Attach(object sender, PhidgetsNET.AttachEventArgs e) + { + ToolStripStatusLabel1.Text = "Phidget RFID Reader Connected"; + chkTurnOnLED.Checked = true; + RFIDReader.SetOutputState(2, true); + chkEnableReader.Checked = true; + RFIDReader.SetOutputState(3, true); + } + + private void RFIDReader_Detach(object sender, PhidgetsNET.DetachEventArgs e) + { + ToolStripStatusLabel1.Text = "Phidget RFID Reader Not Connected"; + } + + private void RFIDReader_Error(object sender, PhidgetsNET.ErrorEventArgs e) + { + //---display the error--- + ToolStripStatusLabel1.Text = e.getError(); + } + + private void RFIDReader_Tag(object sender, PhidgetsNET.TagEventArgs e) + { + Console.WriteLine("tag detected - " + e.getTag()); + txtTagID.BeginInvoke(new myDelegate(updateTextBox), new object[] { e.getTag() }); + } + + public delegate void myDelegate(string str); + public void updateTextBox(string str) + { + txtTagID.Text = str; + } + + private void Form1_Load(object sender, EventArgs e) + { + RFIDReader = new PhidgetsNET.PhidgetRFID(); + + RFIDReader.Attach += new PhidgetsNET.AttachEventHandler(this.RFIDReader_Attach); + RFIDReader.Detach += new PhidgetsNET.DetachEventHandler(this.RFIDReader_Detach); + RFIDReader.Tag += new PhidgetsNET.TagEventHandler(this.RFIDReader_Tag); + RFIDReader.Error += new PhidgetsNET.ErrorEventHandler(this.RFIDReader_Error); + + RFIDReader.OpenRemoteIP("localhost", 5001, -1, "pass"); + ToolStripStatusLabel1.Text = "Not Connected"; + } + + private void chkTurnOnLED_CheckedChanged(object sender, EventArgs e) + { + RFIDReader.SetOutputState(2, chkTurnOnLED.Checked); + } + + private void chkEnableReader_CheckedChanged(object sender, EventArgs e) + { + RFIDReader.SetOutputState(3, chkEnableReader.Checked); + } + } +} \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Form1.resx b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Form1.resx new file mode 100644 index 0000000..faac01d --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Form1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Program.cs b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Program.cs new file mode 100644 index 0000000..17e1cd8 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace Attendance_CS +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Properties/AssemblyInfo.cs b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..6b77ca2 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Attendance_CS")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Attendance_CS")] +[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("60aee91f-0a12-4a77-b9f1-4c5c2275adfc")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Properties/Resources.Designer.cs b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Properties/Resources.Designer.cs new file mode 100644 index 0000000..518af26 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Attendance_CS.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Attendance_CS.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Properties/Resources.resx b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Properties/Settings.Designer.cs b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Properties/Settings.Designer.cs new file mode 100644 index 0000000..6c076dc --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Attendance_CS.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Properties/Settings.settings b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/bin/Debug/Attendance_CS.exe b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/bin/Debug/Attendance_CS.exe new file mode 100644 index 0000000..07c064f Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/bin/Debug/Attendance_CS.exe differ diff --git a/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/bin/Debug/Attendance_CS.pdb b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/bin/Debug/Attendance_CS.pdb new file mode 100644 index 0000000..5bd325c Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/bin/Debug/Attendance_CS.pdb differ diff --git a/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/bin/Debug/Attendance_CS.vshost.exe b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/bin/Debug/Attendance_CS.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/bin/Debug/Attendance_CS.vshost.exe differ diff --git a/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/bin/Debug/PhidgetsNET.dll b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/bin/Debug/PhidgetsNET.dll new file mode 100644 index 0000000..c6f8b49 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/bin/Debug/PhidgetsNET.dll differ diff --git a/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/obj/Attendance_CS.csproj.FileList.txt b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/obj/Attendance_CS.csproj.FileList.txt new file mode 100644 index 0000000..5253353 --- /dev/null +++ b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/obj/Attendance_CS.csproj.FileList.txt @@ -0,0 +1,9 @@ +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\Attendance_CS.Form1.resources +obj\Debug\Attendance_CS.Properties.Resources.resources +obj\Debug\Attendance_CS.csproj.GenerateResource.Cache +bin\Debug\Attendance_CS.exe +bin\Debug\Attendance_CS.pdb +bin\Debug\PhidgetsNET.dll +obj\Debug\Attendance_CS.exe +obj\Debug\Attendance_CS.pdb diff --git a/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/obj/Debug/Attendance_CS.Form1.resources b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/obj/Debug/Attendance_CS.Form1.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/obj/Debug/Attendance_CS.Form1.resources differ diff --git a/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/obj/Debug/Attendance_CS.Properties.Resources.resources b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/obj/Debug/Attendance_CS.Properties.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/obj/Debug/Attendance_CS.Properties.Resources.resources differ diff --git a/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/obj/Debug/Attendance_CS.csproj.GenerateResource.Cache b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/obj/Debug/Attendance_CS.csproj.GenerateResource.Cache new file mode 100644 index 0000000..28239a0 Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/obj/Debug/Attendance_CS.csproj.GenerateResource.Cache differ diff --git a/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/obj/Debug/Attendance_CS.exe b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/obj/Debug/Attendance_CS.exe new file mode 100644 index 0000000..07c064f Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/obj/Debug/Attendance_CS.exe differ diff --git a/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/obj/Debug/Attendance_CS.pdb b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/obj/Debug/Attendance_CS.pdb new file mode 100644 index 0000000..5bd325c Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/obj/Debug/Attendance_CS.pdb differ diff --git a/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/obj/Debug/ResolveAssemblyReference.cache b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/obj/Debug/ResolveAssemblyReference.cache new file mode 100644 index 0000000..4d1f0af Binary files /dev/null and b/Chapter05(RFID)/Attendance_Phidget_CS/Attendance_CS/obj/Debug/ResolveAssemblyReference.cache differ diff --git a/Chapter06(ExternalDevices)/PING.bs2 b/Chapter06(ExternalDevices)/PING.bs2 new file mode 100644 index 0000000..5812410 --- /dev/null +++ b/Chapter06(ExternalDevices)/PING.bs2 @@ -0,0 +1,39 @@ +' {$STAMP BS2} +' {$PBASIC 2.5} + +'---duration of the trigger; 1 represents 2 micro-seconds--- +Trigger CON 1 '---CON represents constant--- + +'---variable to measure the pulse--- +rawDist VAR Word '---VAR represents variable--- + +'---the I/O Pin connected to the PING))) sensor--- +Ping PIN 15 '---PIN represents pin on the BS2--- + +DO + '---Set the pin to low first--- + Ping = 0 + + '---trigger the sensor by sending a pulse --- + PULSOUT Ping, Trigger + + '---measure the echo pulse by reading it--- + PULSIN Ping, 1, rawDist + + '---convert pulses to micro-seconds--- + rawDist = rawDist * 2 + + '---get the single-trip timing--- + rawDist = rawDist / 2 + + '---convert the distance to cm--- + rawDist = rawDist /30 + + '---print out the distance in cm--- + 'DEBUG DEC rawDist, CR, LF + SEROUT 16, 16468, [DEC RawDist] + SEROUT 16, 16468, [LF] + + '---delay for 100 milliseconds--- + PAUSE 100 +LOOP diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem.sln b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem.sln new file mode 100644 index 0000000..4b5b7ca --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SecuritySystem", "SecuritySystem\SecuritySystem.vbproj", "{F03022DD-1D92-41B1-B63A-64BB6A380D3B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F03022DD-1D92-41B1-B63A-64BB6A380D3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F03022DD-1D92-41B1-B63A-64BB6A380D3B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F03022DD-1D92-41B1-B63A-64BB6A380D3B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F03022DD-1D92-41B1-B63A-64BB6A380D3B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem.suo b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem.suo new file mode 100644 index 0000000..0caf9e7 Binary files /dev/null and b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem.suo differ diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/Form1.Designer.vb b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/Form1.Designer.vb new file mode 100644 index 0000000..662dadf --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/Form1.Designer.vb @@ -0,0 +1,109 @@ + _ +Partial Class Form1 + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.PictureBox1 = New System.Windows.Forms.PictureBox + Me.btnStartRecording = New System.Windows.Forms.Button + Me.btnTakeSnapshot = New System.Windows.Forms.Button + Me.btnStopRecording = New System.Windows.Forms.Button + Me.ProgressBar1 = New System.Windows.Forms.ProgressBar + Me.lblProximity = New System.Windows.Forms.Label + CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'PictureBox1 + ' + Me.PictureBox1.Location = New System.Drawing.Point(12, 41) + Me.PictureBox1.Name = "PictureBox1" + Me.PictureBox1.Size = New System.Drawing.Size(336, 253) + Me.PictureBox1.TabIndex = 2 + Me.PictureBox1.TabStop = False + ' + 'btnStartRecording + ' + Me.btnStartRecording.Location = New System.Drawing.Point(12, 300) + Me.btnStartRecording.Name = "btnStartRecording" + Me.btnStartRecording.Size = New System.Drawing.Size(108, 23) + Me.btnStartRecording.TabIndex = 3 + Me.btnStartRecording.Text = "Start Recording" + Me.btnStartRecording.UseVisualStyleBackColor = True + ' + 'btnTakeSnapshot + ' + Me.btnTakeSnapshot.Location = New System.Drawing.Point(240, 300) + Me.btnTakeSnapshot.Name = "btnTakeSnapshot" + Me.btnTakeSnapshot.Size = New System.Drawing.Size(108, 23) + Me.btnTakeSnapshot.TabIndex = 4 + Me.btnTakeSnapshot.Text = "Take Snapshot" + Me.btnTakeSnapshot.UseVisualStyleBackColor = True + ' + 'btnStopRecording + ' + Me.btnStopRecording.Location = New System.Drawing.Point(126, 300) + Me.btnStopRecording.Name = "btnStopRecording" + Me.btnStopRecording.Size = New System.Drawing.Size(108, 23) + Me.btnStopRecording.TabIndex = 7 + Me.btnStopRecording.Text = "Stop Recording" + Me.btnStopRecording.UseVisualStyleBackColor = True + ' + 'ProgressBar1 + ' + Me.ProgressBar1.Location = New System.Drawing.Point(12, 12) + Me.ProgressBar1.Maximum = 160 + Me.ProgressBar1.Name = "ProgressBar1" + Me.ProgressBar1.Size = New System.Drawing.Size(291, 23) + Me.ProgressBar1.Step = 1 + Me.ProgressBar1.TabIndex = 9 + ' + 'lblProximity + ' + Me.lblProximity.AutoSize = True + Me.lblProximity.Location = New System.Drawing.Point(309, 22) + Me.lblProximity.Name = "lblProximity" + Me.lblProximity.Size = New System.Drawing.Size(39, 13) + Me.lblProximity.TabIndex = 10 + Me.lblProximity.Text = "Label1" + ' + 'Form1 + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(360, 333) + Me.Controls.Add(Me.lblProximity) + Me.Controls.Add(Me.ProgressBar1) + Me.Controls.Add(Me.btnStopRecording) + Me.Controls.Add(Me.btnTakeSnapshot) + Me.Controls.Add(Me.btnStartRecording) + Me.Controls.Add(Me.PictureBox1) + Me.Name = "Form1" + Me.Text = "Security System" + CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox + Friend WithEvents btnStartRecording As System.Windows.Forms.Button + Friend WithEvents btnTakeSnapshot As System.Windows.Forms.Button + Friend WithEvents btnStopRecording As System.Windows.Forms.Button + Friend WithEvents ProgressBar1 As System.Windows.Forms.ProgressBar + Friend WithEvents lblProximity As System.Windows.Forms.Label + +End Class diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/Form1.resx b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/Form1.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/Form1.vb b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/Form1.vb new file mode 100644 index 0000000..809f013 --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/Form1.vb @@ -0,0 +1,185 @@ +Imports System.Runtime.InteropServices + +Public Class Form1 + Private WithEvents serialPort As New IO.Ports.SerialPort + Private proximity As Integer + + Const WM_CAP_START = &H400S + Const WS_CHILD = &H40000000 + Const WS_VISIBLE = &H10000000 + + Const WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10 + Const WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11 + Const WM_CAP_EDIT_COPY = WM_CAP_START + 30 + Const WM_CAP_SEQUENCE = WM_CAP_START + 62 + Const WM_CAP_FILE_SAVEAS = WM_CAP_START + 23 + + Const WM_CAP_SET_SCALE = WM_CAP_START + 53 + Const WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52 + Const WM_CAP_SET_PREVIEW = WM_CAP_START + 50 + + Const SWP_NOMOVE = &H2S + Const SWP_NOSIZE = 1 + Const SWP_NOZORDER = &H4S + Const HWND_BOTTOM = 1 + + '--The capGetDriverDescription function retrieves the version + ' description of the capture driver-- + Declare Function capGetDriverDescriptionA Lib "avicap32.dll" _ + (ByVal wDriverIndex As Short, _ + ByVal lpszName As String, ByVal cbName As Integer, _ + ByVal lpszVer As String, _ + ByVal cbVer As Integer) As Boolean + + '--The capCreateCaptureWindow function creates a capture window-- + Declare Function capCreateCaptureWindowA Lib "avicap32.dll" _ + (ByVal lpszWindowName As String, ByVal dwStyle As Integer, _ + ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, _ + ByVal nHeight As Short, ByVal hWnd As Integer, _ + ByVal nID As Integer) As Integer + + '--This function sends the specified message to a window or windows-- + Declare Function SendMessage Lib "user32" Alias "SendMessageA" _ + (ByVal hwnd As Integer, ByVal Msg As Integer, _ + ByVal wParam As Integer, _ + ByVal lParam As Object) As Integer + + '--Sets the position of the window relative to the screen buffer-- + Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" _ + (ByVal hwnd As Integer, _ + ByVal hWndInsertAfter As Integer, ByVal x As Integer, _ + ByVal y As Integer, _ + ByVal cx As Integer, ByVal cy As Integer, _ + ByVal wFlags As Integer) As Integer + + '--This function destroys the specified window-- + Declare Function DestroyWindow Lib "user32" _ + (ByVal hndw As Integer) As Boolean + + '---used as a window handle--- + Private hWnd As Integer + + Private Sub Form1_Load( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles MyBase.Load + + If serialPort.IsOpen Then + serialPort.Close() + End If + Try + With serialPort + .PortName = "COM3" + .BaudRate = 9600 + .Parity = IO.Ports.Parity.None + .DataBits = 8 + .StopBits = IO.Ports.StopBits.One + .Handshake = IO.Ports.Handshake.None + End With + serialPort.Open() + serialPort.DiscardInBuffer() + Catch ex As Exception + MsgBox(ex.ToString) + End Try + + '---preview the selected video source + PreviewVideo(PictureBox1) + End Sub + + '---preview the selected video source--- + Private Sub PreviewVideo(ByVal pbCtrl As PictureBox) + hWnd = capCreateCaptureWindowA(0, _ + WS_VISIBLE Or WS_CHILD, 0, 0, 0, _ + 0, pbCtrl.Handle.ToInt32, 0) + If SendMessage( _ + hWnd, WM_CAP_DRIVER_CONNECT, _ + 0, 0) Then + '---set the preview scale--- + SendMessage(hWnd, WM_CAP_SET_SCALE, True, 0) + '---set the preview rate (ms)--- + SendMessage(hWnd, WM_CAP_SET_PREVIEWRATE, 30, 0) + '---start previewing the image--- + SendMessage(hWnd, WM_CAP_SET_PREVIEW, True, 0) + '---resize window to fit in PictureBox control--- + SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, _ + pbCtrl.Width, pbCtrl.Height, _ + SWP_NOMOVE Or SWP_NOZORDER) + Else + '--error connecting to video source--- + DestroyWindow(hWnd) + End If + End Sub + + Private Sub DataReceived( _ + ByVal sender As Object, _ + ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) _ + Handles serialPort.DataReceived + + Dim str As String = serialPort.ReadLine + If str <> String.Empty Then + proximity = CInt(str) + ProgressBar1.BeginInvoke(New _ + myDelegate(AddressOf updateControl), _ + New Object() {}) + Console.WriteLine(proximity) + End If + End Sub + + Public Delegate Sub myDelegate() + Public Sub updateControl() + Try + If proximity <= 160 Then + ProgressBar1.Value = proximity + lblProximity.Text = proximity & " cm" + End If + Catch ex As Exception + MsgBox(ex.ToString) + End Try + End Sub + + Private Sub btnStartRecording_Click( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles btnStartRecording.Click + btnStartRecording.Enabled = False + btnStopRecording.Enabled = True + Application.DoEvents() + '---start recording--- + SendMessage(hWnd, WM_CAP_SEQUENCE, 0, 0) + + End Sub + + Private Sub btnStopRecording_Click( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles btnStopRecording.Click + btnStartRecording.Enabled = True + btnStopRecording.Enabled = False + Application.DoEvents() + '---save the recording to file--- + SendMessage(hWnd, WM_CAP_FILE_SAVEAS, 0, _ + "C:\" & Now.ToFileTime & ".avi") + End Sub + + Private Sub btnTakeSnapshot_Click( _ + ByVal sender As System.Object, _ + ByVal e As System.EventArgs) _ + Handles btnTakeSnapshot.Click + + Dim data As IDataObject + Dim bmap As Image + + '---copy the image to the clipboard--- + SendMessage(hWnd, WM_CAP_EDIT_COPY, 0, 0) + + '---retrieve the image from clipboard and convert it + ' to the bitmap format + data = Clipboard.GetDataObject() + If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then + bmap = _ + CType(data.GetData(GetType(System.Drawing.Bitmap)), _ + Image) + bmap.Save("C:\" & Now.ToFileTime & ".bmp") + End If + End Sub +End Class diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/My Project/Application.Designer.vb b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/My Project/Application.Designer.vb new file mode 100644 index 0000000..d09a16c --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + 'NOTE: This file is auto-generated; do not modify it directly. To make changes, + ' or if you encounter build errors in this file, go to the Project Designer + ' (go to Project Properties or double-click the My Project node in + ' Solution Explorer), and make changes on the Application tab. + ' + Partial Friend Class MyApplication + + _ + Public Sub New() + MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) + Me.IsSingleInstance = false + Me.EnableVisualStyles = true + Me.SaveMySettingsOnExit = true + Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses + End Sub + + _ + Protected Overrides Sub OnCreateMainForm() + Me.MainForm = Global.SecuritySystem.Form1 + End Sub + End Class +End Namespace diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/My Project/Application.myapp b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/My Project/Application.myapp new file mode 100644 index 0000000..1243847 --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/My Project/Application.myapp @@ -0,0 +1,11 @@ + + + true + Form1 + false + 0 + true + 0 + 0 + true + diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/My Project/AssemblyInfo.vb b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..44f8448 --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + + diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/My Project/Resources.Designer.vb b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/My Project/Resources.Designer.vb new file mode 100644 index 0000000..222718f --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ' + ' A strongly-typed resource class, for looking up localized strings, etc. + ' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ' + ' Returns the cached ResourceManager instance used by this class. + ' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("SecuritySystem.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ' + ' Overrides the current thread's CurrentUICulture property for all + ' resource lookups using this strongly typed resource class. + ' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/My Project/Resources.resx b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/My Project/Settings.Designer.vb b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/My Project/Settings.Designer.vb new file mode 100644 index 0000000..f54a954 --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.42 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.SecuritySystem.My.MySettings + Get + Return Global.SecuritySystem.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/My Project/Settings.settings b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/SecuritySystem.vbproj b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/SecuritySystem.vbproj new file mode 100644 index 0000000..e1637d7 --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/SecuritySystem.vbproj @@ -0,0 +1,106 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {F03022DD-1D92-41B1-B63A-64BB6A380D3B} + WinExe + SecuritySystem.My.MyApplication + SecuritySystem + SecuritySystem + WindowsForms + + + true + full + true + true + bin\Debug\ + SecuritySystem.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SecuritySystem.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + + + + + + + + + + + + + Form + + + Form1.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + Form1.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + \ No newline at end of file diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/SecuritySystem.vbproj.user b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/SecuritySystem.vbproj.user new file mode 100644 index 0000000..6a34e7d --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/SecuritySystem.vbproj.user @@ -0,0 +1,5 @@ + + + ShowAllFiles + + \ No newline at end of file diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/bin/Debug/SecuritySystem.exe b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/bin/Debug/SecuritySystem.exe new file mode 100644 index 0000000..86441aa Binary files /dev/null and b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/bin/Debug/SecuritySystem.exe differ diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/bin/Debug/SecuritySystem.pdb b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/bin/Debug/SecuritySystem.pdb new file mode 100644 index 0000000..7c8aca3 Binary files /dev/null and b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/bin/Debug/SecuritySystem.pdb differ diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/bin/Debug/SecuritySystem.vshost.exe b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/bin/Debug/SecuritySystem.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/bin/Debug/SecuritySystem.vshost.exe differ diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/bin/Debug/SecuritySystem.xml b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/bin/Debug/SecuritySystem.xml new file mode 100644 index 0000000..440d3fe --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/bin/Debug/SecuritySystem.xml @@ -0,0 +1,11 @@ + + + + +SecuritySystem + + + + + + \ No newline at end of file diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/obj/Debug/SecuritySystem.Form1.resources b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/obj/Debug/SecuritySystem.Form1.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/obj/Debug/SecuritySystem.Form1.resources differ diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/obj/Debug/SecuritySystem.Resources.resources b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/obj/Debug/SecuritySystem.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/obj/Debug/SecuritySystem.Resources.resources differ diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/obj/Debug/SecuritySystem.exe b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/obj/Debug/SecuritySystem.exe new file mode 100644 index 0000000..86441aa Binary files /dev/null and b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/obj/Debug/SecuritySystem.exe differ diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/obj/Debug/SecuritySystem.pdb b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/obj/Debug/SecuritySystem.pdb new file mode 100644 index 0000000..7c8aca3 Binary files /dev/null and b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/obj/Debug/SecuritySystem.pdb differ diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/obj/Debug/SecuritySystem.vbproj.GenerateResource.Cache b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/obj/Debug/SecuritySystem.vbproj.GenerateResource.Cache new file mode 100644 index 0000000..4331c4f Binary files /dev/null and b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/obj/Debug/SecuritySystem.vbproj.GenerateResource.Cache differ diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/obj/Debug/SecuritySystem.xml b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/obj/Debug/SecuritySystem.xml new file mode 100644 index 0000000..440d3fe --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/obj/Debug/SecuritySystem.xml @@ -0,0 +1,11 @@ + + + + +SecuritySystem + + + + + + \ No newline at end of file diff --git a/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/obj/SecuritySystem.vbproj.FileList.txt b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/obj/SecuritySystem.vbproj.FileList.txt new file mode 100644 index 0000000..4ed3a00 --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem/SecuritySystem/obj/SecuritySystem.vbproj.FileList.txt @@ -0,0 +1,10 @@ +bin\Debug\SecuritySystem.exe +bin\Debug\SecuritySystem.pdb +bin\Debug\SecuritySystem.xml +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\SecuritySystem.Form1.resources +obj\Debug\SecuritySystem.Resources.resources +obj\Debug\SecuritySystem.vbproj.GenerateResource.Cache +obj\Debug\SecuritySystem.exe +obj\Debug\SecuritySystem.xml +obj\Debug\SecuritySystem.pdb diff --git a/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS.sln b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS.sln new file mode 100644 index 0000000..173df46 --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystem_CS", "SecuritySystem_CS\SecuritySystem_CS.csproj", "{FDA46139-B096-42D3-B8E6-AAC2F11DEB3E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FDA46139-B096-42D3-B8E6-AAC2F11DEB3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FDA46139-B096-42D3-B8E6-AAC2F11DEB3E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FDA46139-B096-42D3-B8E6-AAC2F11DEB3E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FDA46139-B096-42D3-B8E6-AAC2F11DEB3E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS.suo b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS.suo new file mode 100644 index 0000000..9b06766 Binary files /dev/null and b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS.suo differ diff --git a/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Form1.Designer.cs b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Form1.Designer.cs new file mode 100644 index 0000000..0c3449e --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Form1.Designer.cs @@ -0,0 +1,126 @@ +namespace SecuritySystem_CS +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.lblProximity = new System.Windows.Forms.Label(); + this.ProgressBar1 = new System.Windows.Forms.ProgressBar(); + this.btnStopRecording = new System.Windows.Forms.Button(); + this.btnTakeSnapshot = new System.Windows.Forms.Button(); + this.btnStartRecording = new System.Windows.Forms.Button(); + this.PictureBox1 = new System.Windows.Forms.PictureBox(); + ((System.ComponentModel.ISupportInitialize)(this.PictureBox1)).BeginInit(); + this.SuspendLayout(); + // + // lblProximity + // + this.lblProximity.AutoSize = true; + this.lblProximity.Location = new System.Drawing.Point(309, 23); + this.lblProximity.Name = "lblProximity"; + this.lblProximity.Size = new System.Drawing.Size(39, 13); + this.lblProximity.TabIndex = 16; + this.lblProximity.Text = "Label1"; + // + // ProgressBar1 + // + this.ProgressBar1.Location = new System.Drawing.Point(12, 13); + this.ProgressBar1.Maximum = 160; + this.ProgressBar1.Name = "ProgressBar1"; + this.ProgressBar1.Size = new System.Drawing.Size(291, 23); + this.ProgressBar1.Step = 1; + this.ProgressBar1.TabIndex = 15; + // + // btnStopRecording + // + this.btnStopRecording.Location = new System.Drawing.Point(126, 301); + this.btnStopRecording.Name = "btnStopRecording"; + this.btnStopRecording.Size = new System.Drawing.Size(108, 23); + this.btnStopRecording.TabIndex = 14; + this.btnStopRecording.Text = "Stop Recording"; + this.btnStopRecording.UseVisualStyleBackColor = true; + this.btnStopRecording.Click += new System.EventHandler(this.btnStopRecording_Click); + // + // btnTakeSnapshot + // + this.btnTakeSnapshot.Location = new System.Drawing.Point(240, 301); + this.btnTakeSnapshot.Name = "btnTakeSnapshot"; + this.btnTakeSnapshot.Size = new System.Drawing.Size(108, 23); + this.btnTakeSnapshot.TabIndex = 13; + this.btnTakeSnapshot.Text = "Take Snapshot"; + this.btnTakeSnapshot.UseVisualStyleBackColor = true; + this.btnTakeSnapshot.Click += new System.EventHandler(this.btnTakeSnapshot_Click); + // + // btnStartRecording + // + this.btnStartRecording.Location = new System.Drawing.Point(12, 301); + this.btnStartRecording.Name = "btnStartRecording"; + this.btnStartRecording.Size = new System.Drawing.Size(108, 23); + this.btnStartRecording.TabIndex = 12; + this.btnStartRecording.Text = "Start Recording"; + this.btnStartRecording.UseVisualStyleBackColor = true; + this.btnStartRecording.Click += new System.EventHandler(this.btnStartRecording_Click); + // + // PictureBox1 + // + this.PictureBox1.Location = new System.Drawing.Point(12, 42); + this.PictureBox1.Name = "PictureBox1"; + this.PictureBox1.Size = new System.Drawing.Size(336, 253); + this.PictureBox1.TabIndex = 11; + this.PictureBox1.TabStop = false; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(360, 336); + this.Controls.Add(this.lblProximity); + this.Controls.Add(this.ProgressBar1); + this.Controls.Add(this.btnStopRecording); + this.Controls.Add(this.btnTakeSnapshot); + this.Controls.Add(this.btnStartRecording); + this.Controls.Add(this.PictureBox1); + this.Name = "Form1"; + this.Text = "Form1"; + this.Load += new System.EventHandler(this.Form1_Load); + ((System.ComponentModel.ISupportInitialize)(this.PictureBox1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + internal System.Windows.Forms.Label lblProximity; + internal System.Windows.Forms.ProgressBar ProgressBar1; + internal System.Windows.Forms.Button btnStopRecording; + internal System.Windows.Forms.Button btnTakeSnapshot; + internal System.Windows.Forms.Button btnStartRecording; + internal System.Windows.Forms.PictureBox PictureBox1; + } +} + diff --git a/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Form1.cs b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Form1.cs new file mode 100644 index 0000000..69b725a --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Form1.cs @@ -0,0 +1,154 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +using System.Runtime.InteropServices; + +namespace SecuritySystem_CS +{ + public partial class Form1 : Form + { + System.IO.Ports.SerialPort serialPort = new System.IO.Ports.SerialPort(); + int proximity; + + const int WM_CAP_START = 1024; + const int WS_CHILD = 1073741824; + const int WS_VISIBLE = 268435456; + const int WM_CAP_DRIVER_CONNECT = (WM_CAP_START + 10); + const int WM_CAP_DRIVER_DISCONNECT = (WM_CAP_START + 11); + const int WM_CAP_EDIT_COPY = (WM_CAP_START + 30); + const int WM_CAP_SEQUENCE = (WM_CAP_START + 62); + const int WM_CAP_FILE_SAVEAS = (WM_CAP_START + 23); + const int WM_CAP_SET_SCALE = (WM_CAP_START + 53); + const int WM_CAP_SET_PREVIEWRATE = (WM_CAP_START + 52); + const int WM_CAP_SET_PREVIEW = (WM_CAP_START + 50); + const int SWP_NOMOVE = 2; + const int SWP_NOSIZE = 1; + const int SWP_NOZORDER = 4; + const int HWND_BOTTOM = 1; + + [System.Runtime.InteropServices.DllImport("avicap32.dll")] + static extern bool capGetDriverDescriptionA(short wDriverIndex, string lpszName, int cbName, string lpszVer, int cbVer); + [System.Runtime.InteropServices.DllImport("avicap32.dll")] + + static extern int capCreateCaptureWindowA(string lpszWindowName, int dwStyle, int x, int y, int nWidth, short nHeight, int hWnd, int nID); + [System.Runtime.InteropServices.DllImport("user32", EntryPoint = "SendMessageA")] + + static extern int SendMessage(int hwnd, int Msg, int wParam, [MarshalAs(UnmanagedType.AsAny)] +object lParam); + [System.Runtime.InteropServices.DllImport("user32", EntryPoint = "SetWindowPos")] + static extern int SetWindowPos(int hwnd, int hWndInsertAfter, int x, int y, int cx, int cy, int wFlags); + [System.Runtime.InteropServices.DllImport("user32")] + static extern bool DestroyWindow(int hndw); + private int hWnd; + + public Form1() + { + InitializeComponent(); + } + + private void PreviewVideo(PictureBox pbCtrl) + { + hWnd = capCreateCaptureWindowA("0", WS_VISIBLE | WS_CHILD, 0, 0, 0, 0, pbCtrl.Handle.ToInt32(), 0); + if (SendMessage(hWnd, WM_CAP_DRIVER_CONNECT, 0, 0) != 0) + { + SendMessage(hWnd, WM_CAP_SET_SCALE, 1, 0); + SendMessage(hWnd, WM_CAP_SET_PREVIEWRATE, 30, 0); + SendMessage(hWnd, WM_CAP_SET_PREVIEW, 1, 0); + SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, pbCtrl.Width, pbCtrl.Height, SWP_NOMOVE | SWP_NOZORDER); + } + else + { + DestroyWindow(hWnd); + } + } + + private void DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) + { + string str = serialPort.ReadLine(); + if (str != string.Empty) + { + proximity = System.Convert.ToInt32(str); + ProgressBar1.BeginInvoke(new myDelegate(updateControl)); + Console.WriteLine(proximity); + } + } + + public delegate void myDelegate(); + public void updateControl() + { + try + { + if (proximity <= 160) + { + ProgressBar1.Value = proximity; + lblProximity.Text = proximity + " cm"; + } + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + } + + private void btnStartRecording_Click(object sender, EventArgs e) + { + btnStartRecording.Enabled = false; + btnStopRecording.Enabled = true; + Application.DoEvents(); + SendMessage(hWnd, WM_CAP_SEQUENCE, 0, 0); + } + + private void btnStopRecording_Click(object sender, EventArgs e) + { + btnStartRecording.Enabled = true; + btnStopRecording.Enabled = false; + Application.DoEvents(); + SendMessage(hWnd, WM_CAP_FILE_SAVEAS, 0, "C:\\" + System.DateTime.Now.ToFileTime() + ".avi"); + } + + private void btnTakeSnapshot_Click(object sender, EventArgs e) + { + IDataObject data; + Image bmap; + SendMessage(hWnd, WM_CAP_EDIT_COPY, 0, 0); + data = Clipboard.GetDataObject(); + if (data.GetDataPresent(typeof(System.Drawing.Bitmap))) + { + bmap = ((Image)(data.GetData(typeof(System.Drawing.Bitmap)))); + bmap.Save("C:\\" + System.DateTime.Now.ToFileTime() + ".bmp"); + } + } + + private void Form1_Load(object sender, EventArgs e) + { + if (serialPort.IsOpen) + { + serialPort.Close(); + } + try + { + serialPort.PortName = "COM3"; + serialPort.BaudRate = 9600; + serialPort.Parity = System.IO.Ports.Parity.None; + serialPort.DataBits = 8; + serialPort.StopBits = System.IO.Ports.StopBits.One; + serialPort.Handshake = System.IO.Ports.Handshake.None; + serialPort.DataReceived += + new System.IO.Ports.SerialDataReceivedEventHandler(DataReceived); + serialPort.Open(); + serialPort.DiscardInBuffer(); + + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + PreviewVideo(PictureBox1); + } + } +} \ No newline at end of file diff --git a/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Form1.resx b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Form1.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Program.cs b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Program.cs new file mode 100644 index 0000000..d6de0a1 --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace SecuritySystem_CS +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} \ No newline at end of file diff --git a/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Properties/AssemblyInfo.cs b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..6d68b17 --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SecuritySystem_CS")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SecuritySystem_CS")] +[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("9f9202f0-f215-430f-9ec8-98bc1b427df7")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Properties/Resources.Designer.cs b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Properties/Resources.Designer.cs new file mode 100644 index 0000000..cd27771 --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SecuritySystem_CS.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SecuritySystem_CS.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Properties/Resources.resx b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Properties/Settings.Designer.cs b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Properties/Settings.Designer.cs new file mode 100644 index 0000000..0c1d1c1 --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SecuritySystem_CS.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Properties/Settings.settings b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/SecuritySystem_CS.csproj b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/SecuritySystem_CS.csproj new file mode 100644 index 0000000..21dab8e --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/SecuritySystem_CS.csproj @@ -0,0 +1,78 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {FDA46139-B096-42D3-B8E6-AAC2F11DEB3E} + WinExe + Properties + SecuritySystem_CS + SecuritySystem_CS + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + Form + + + Form1.cs + + + + + Designer + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + \ No newline at end of file diff --git a/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/bin/Debug/SecuritySystem_CS.exe b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/bin/Debug/SecuritySystem_CS.exe new file mode 100644 index 0000000..b02c862 Binary files /dev/null and b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/bin/Debug/SecuritySystem_CS.exe differ diff --git a/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/bin/Debug/SecuritySystem_CS.pdb b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/bin/Debug/SecuritySystem_CS.pdb new file mode 100644 index 0000000..5191abe Binary files /dev/null and b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/bin/Debug/SecuritySystem_CS.pdb differ diff --git a/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/bin/Debug/SecuritySystem_CS.vshost.exe b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/bin/Debug/SecuritySystem_CS.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/bin/Debug/SecuritySystem_CS.vshost.exe differ diff --git a/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/obj/Debug/SecuritySystem_CS.Form1.resources b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/obj/Debug/SecuritySystem_CS.Form1.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/obj/Debug/SecuritySystem_CS.Form1.resources differ diff --git a/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/obj/Debug/SecuritySystem_CS.Properties.Resources.resources b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/obj/Debug/SecuritySystem_CS.Properties.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/obj/Debug/SecuritySystem_CS.Properties.Resources.resources differ diff --git a/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/obj/Debug/SecuritySystem_CS.csproj.GenerateResource.Cache b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/obj/Debug/SecuritySystem_CS.csproj.GenerateResource.Cache new file mode 100644 index 0000000..a0bad73 Binary files /dev/null and b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/obj/Debug/SecuritySystem_CS.csproj.GenerateResource.Cache differ diff --git a/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/obj/Debug/SecuritySystem_CS.exe b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/obj/Debug/SecuritySystem_CS.exe new file mode 100644 index 0000000..b02c862 Binary files /dev/null and b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/obj/Debug/SecuritySystem_CS.exe differ diff --git a/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/obj/Debug/SecuritySystem_CS.pdb b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/obj/Debug/SecuritySystem_CS.pdb new file mode 100644 index 0000000..5191abe Binary files /dev/null and b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/obj/Debug/SecuritySystem_CS.pdb differ diff --git a/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/obj/SecuritySystem_CS.csproj.FileList.txt b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/obj/SecuritySystem_CS.csproj.FileList.txt new file mode 100644 index 0000000..7e629b0 --- /dev/null +++ b/Chapter06(ExternalDevices)/SecuritySystem_CS/SecuritySystem_CS/obj/SecuritySystem_CS.csproj.FileList.txt @@ -0,0 +1,8 @@ +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\SecuritySystem_CS.Form1.resources +obj\Debug\SecuritySystem_CS.Properties.Resources.resources +obj\Debug\SecuritySystem_CS.csproj.GenerateResource.Cache +bin\Debug\SecuritySystem_CS.exe +bin\Debug\SecuritySystem_CS.pdb +obj\Debug\SecuritySystem_CS.exe +obj\Debug\SecuritySystem_CS.pdb diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..b6a19a9 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,27 @@ +Freeware License, some rights reserved + +Copyright (c) 2007 Wei-Meng Lee + +Permission is hereby granted, free of charge, to anyone obtaining a copy +of this software and associated documentation files (the "Software"), +to work with the Software within the limits of freeware distribution and fair use. +This includes the rights to use, copy, and modify the Software for personal use. +Users are also allowed and encouraged to submit corrections and modifications +to the Software for the benefit of other users. + +It is not allowed to reuse, modify, or redistribute the Software for +commercial use in any way, or for a user’s educational materials such as books +or blog articles without prior permission from the copyright holder. + +The above copyright notice and this permission notice need to be included +in all copies or substantial portions of the software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..e5dca15 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +#Apress Source Code + +This repository accompanies [*Practical .NET 2.0 Networking Projects*](http://www.apress.com/9781590597903) by Wei-Meng Lee (Apress, 2007). + +![Cover image](9781590597903.jpg) + +Download the files as a zip using the green button, or clone the repository to your machine using Git. + +##Releases + +Release v1.0 corresponds to the code in the published book, without corrections or updates. + +##Contributions + +See the file Contributing.md for more information on how you can contribute to this repository. diff --git a/contributing.md b/contributing.md new file mode 100644 index 0000000..f6005ad --- /dev/null +++ b/contributing.md @@ -0,0 +1,14 @@ +# Contributing to Apress Source Code + +Copyright for Apress source code belongs to the author(s). However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers. + +## How to Contribute + +1. Make sure you have a GitHub account. +2. Fork the repository for the relevant book. +3. Create a new branch on which to make your change, e.g. +`git checkout -b my_code_contribution` +4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted. +5. Submit a pull request. + +Thank you for your contribution! \ No newline at end of file