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 .
+
+