diff --git a/9781590598221.jpg b/9781590598221.jpg new file mode 100644 index 0000000..d56a426 Binary files /dev/null and b/9781590598221.jpg differ diff --git a/Code/Chapter 1/Calc.cs b/Code/Chapter 1/Calc.cs new file mode 100644 index 0000000..911b212 --- /dev/null +++ b/Code/Chapter 1/Calc.cs @@ -0,0 +1,26 @@ +// Calc.cs +using System; + +namespace CalculatorExample +{ + // This class contains the app's entry point. + public class Program + { + static void Main() + { + Calc c = new Calc(); + int ans = c.Add(10, 84); + Console.WriteLine("10 + 84 is {0}.", ans); + + // Wait for user to press the Enter key before shutting down. + Console.ReadLine(); + } + } + + // The C# calculator. + public class Calc + { + public int Add(int x, int y) + { return x + y; } + } +} diff --git a/Code/Chapter 1/Calc.vb b/Code/Chapter 1/Calc.vb new file mode 100644 index 0000000..697c4f5 --- /dev/null +++ b/Code/Chapter 1/Calc.vb @@ -0,0 +1,21 @@ +' Calc.vb +Imports System + +Namespace CalculatorExample + ' A VB .NET 'Module' is a class that only contains + ' static members. + Module Program + Sub Main() + Dim c As New Calc + Dim ans As Integer = c.Add(10, 84) + Console.WriteLine("10 + 84 is {0}.", ans) + Console.ReadLine() + End Sub + End Module + + Class Calc + Public Function Add(ByVal x As Integer, ByVal y As Integer) As Integer + Return x + y + End Function + End Class +End Namespace diff --git a/Code/Chapter 1/ReadMe.txt b/Code/Chapter 1/ReadMe.txt new file mode 100644 index 0000000..f8bd46d --- /dev/null +++ b/Code/Chapter 1/ReadMe.txt @@ -0,0 +1,8 @@ +These files have been provided simply +because they were mentioned in Chapter 1. + +However, Chapter 2 explains how to compile +VB source code. If you want to compile Calc.vb +code into a .NET executable, check out Ch. 2. + +- Andrew \ No newline at end of file diff --git a/Code/Chapter 10/Boxing/Boxing.sln b/Code/Chapter 10/Boxing/Boxing.sln new file mode 100644 index 0000000..3988576 --- /dev/null +++ b/Code/Chapter 10/Boxing/Boxing.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Boxing", "Boxing.vbproj", "{6106329D-4867-4612-AB9C-689998AFEE8D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6106329D-4867-4612-AB9C-689998AFEE8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6106329D-4867-4612-AB9C-689998AFEE8D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6106329D-4867-4612-AB9C-689998AFEE8D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6106329D-4867-4612-AB9C-689998AFEE8D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 10/Boxing/Boxing.suo b/Code/Chapter 10/Boxing/Boxing.suo new file mode 100644 index 0000000..1dead89 Binary files /dev/null and b/Code/Chapter 10/Boxing/Boxing.suo differ diff --git a/Code/Chapter 10/Boxing/Boxing.vbproj b/Code/Chapter 10/Boxing/Boxing.vbproj new file mode 100644 index 0000000..9c56499 --- /dev/null +++ b/Code/Chapter 10/Boxing/Boxing.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {6106329D-4867-4612-AB9C-689998AFEE8D} + Exe + Boxing.Program + Boxing + Boxing + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + Boxing.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + Boxing.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 10/Boxing/Boxing.vbproj.user b/Code/Chapter 10/Boxing/Boxing.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 10/Boxing/Boxing.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 10/Boxing/My Project/Application.Designer.vb b/Code/Chapter 10/Boxing/My Project/Application.Designer.vb new file mode 100644 index 0000000..bf69971 --- /dev/null +++ b/Code/Chapter 10/Boxing/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1434 +' +' 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/Code/Chapter 10/Boxing/My Project/Application.myapp b/Code/Chapter 10/Boxing/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 10/Boxing/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 10/Boxing/My Project/AssemblyInfo.vb b/Code/Chapter 10/Boxing/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..c6b9a19 --- /dev/null +++ b/Code/Chapter 10/Boxing/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/Code/Chapter 10/Boxing/My Project/Resources.Designer.vb b/Code/Chapter 10/Boxing/My Project/Resources.Designer.vb new file mode 100644 index 0000000..9d03e5c --- /dev/null +++ b/Code/Chapter 10/Boxing/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1434 +' +' 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("Boxing.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/Code/Chapter 10/Boxing/My Project/Resources.resx b/Code/Chapter 10/Boxing/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 10/Boxing/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/Code/Chapter 10/Boxing/My Project/Settings.Designer.vb b/Code/Chapter 10/Boxing/My Project/Settings.Designer.vb new file mode 100644 index 0000000..d3b6f10 --- /dev/null +++ b/Code/Chapter 10/Boxing/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1434 +' +' 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.Boxing.My.MySettings + Get + Return Global.Boxing.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 10/Boxing/My Project/Settings.settings b/Code/Chapter 10/Boxing/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 10/Boxing/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 10/Boxing/Program.vb b/Code/Chapter 10/Boxing/Program.vb new file mode 100644 index 0000000..f25cd7f --- /dev/null +++ b/Code/Chapter 10/Boxing/Program.vb @@ -0,0 +1,52 @@ +Option Explicit On +Option Strict On + +' Structures are value types! +Structure MyPoint + Public x, y As Integer +End Structure + +Module Program + + Sub Main() + Console.WriteLine("***** Fun with Boxing / Unboxing *****") + Console.WriteLine() + + ' Make a short value type. + Dim s As Short = 25 + + ' Because s is passed into a + ' method prototyped to take an Object, + ' it is 'boxed' automatically. + UseThisObject(s) + + Dim myData As New ArrayList() + myData.Add(88) + myData.Add(3.33) + myData.Add(False) + + ' Unbox first item from ArrayList. + Dim firstItem As Integer = CType(myData(0), Integer) + Console.WriteLine("First item is {0} ", firstItem) + + Dim p As MyPoint + p.x = 10 + p.y = 20 + UseBoxedMyPoint(p) + + Console.ReadLine() + End Sub + + Sub UseThisObject(ByVal o As Object) + Console.WriteLine("Value of o is: {0} ", o) + End Sub + + Sub UseBoxedMyPoint(ByVal o As Object) + ' Error! System.Object does not have + ' member variables named 'x' or 'y'. + If TypeOf o Is MyPoint Then + Dim p As MyPoint = CType(o, MyPoint) + Console.WriteLine("{0}, {1}", p.x, p.y) + End If + End Sub +End Module diff --git a/Code/Chapter 10/CollectionTypes/Car.vb b/Code/Chapter 10/CollectionTypes/Car.vb new file mode 100644 index 0000000..ebc309f --- /dev/null +++ b/Code/Chapter 10/CollectionTypes/Car.vb @@ -0,0 +1,104 @@ +Option Explicit On +Option Strict On + +Public Class Car + Implements IComparable + + ' Constant for maximum speed. + Public Const maxSpeed As Integer = 100 + + 'Internal state data. + Private currSpeed As Integer + Private petName As String + Private carID As Integer + + 'Is the car still operational? + Private carIsDead As Boolean + + 'A car has a radio. + Private theMusicBox As Radio = New Radio + +#Region "Properties & constructors" + ' Properties. + Public Property Name() As String + Get + Return petName + End Get + Set(ByVal value As String) + petName = value + End Set + End Property + Public Property Speed() As Integer + Get + Return currSpeed + End Get + Set(ByVal value As Integer) + currSpeed = value + End Set + End Property + Public Property ID() As Integer + Get + Return carID + End Get + Set(ByVal value As Integer) + carID = value + End Set + End Property + + ' Constructors. + Public Sub New() + End Sub + Public Sub New(ByVal name As String, ByVal currSp As Integer, ByVal id As Integer) + currSpeed = currSp + petName = name + carID = id + End Sub +#End Region + + Public Sub CrankTunes(ByVal state As Boolean) + theMusicBox.TurnOn(state) + End Sub + + ' See if Car has overheated. + Public Sub Accelerate(ByVal delta As Integer) + If carIsDead Then + Console.WriteLine("{0} is out of order...", petName) + Else + currSpeed += delta + If currSpeed >= maxSpeed Then + carIsDead = True + currSpeed = 0 + + ' We need to call the HelpLink property, thus we need to + ' create a local variable before throwing the Exception object. + Dim ex As New Exception(String.Format("{0} has overheated!", petName)) + ex.HelpLink = "http://www.CarsRUs.com" + ' Stuff in custom data regarding the error. + ex.Data.Add("TimeStamp", _ + String.Format("The car exploded at {0} ", DateTime.Now)) + ex.Data.Add("Cause", "You have a lead foot.") + Throw ex + Else + Console.WriteLine("=> CurrSpeed = {0} ", currSpeed) + End If + End If + End Sub + + Public Function CompareTo(ByVal obj As Object) As Integer Implements System.IComparable.CompareTo + Dim temp As Car = CType(obj, Car) + If Me.carID > temp.carID Then + Return 1 + End If + If Me.carID < temp.carID Then + Return -1 + Else + Return 0 + End If + End Function + + Public Shared ReadOnly Property SortByPetName() As IComparer + Get + Return CType(New PetNameComparer(), IComparer) + End Get + End Property +End Class \ No newline at end of file diff --git a/Code/Chapter 10/CollectionTypes/CollectionTypes.sln b/Code/Chapter 10/CollectionTypes/CollectionTypes.sln new file mode 100644 index 0000000..309ad5a --- /dev/null +++ b/Code/Chapter 10/CollectionTypes/CollectionTypes.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CollectionTypes", "CollectionTypes.vbproj", "{13AF3C0E-433A-4DB1-BC39-2395E1207D7F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {13AF3C0E-433A-4DB1-BC39-2395E1207D7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {13AF3C0E-433A-4DB1-BC39-2395E1207D7F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {13AF3C0E-433A-4DB1-BC39-2395E1207D7F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {13AF3C0E-433A-4DB1-BC39-2395E1207D7F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 10/CollectionTypes/CollectionTypes.suo b/Code/Chapter 10/CollectionTypes/CollectionTypes.suo new file mode 100644 index 0000000..de93f9f Binary files /dev/null and b/Code/Chapter 10/CollectionTypes/CollectionTypes.suo differ diff --git a/Code/Chapter 10/CollectionTypes/CollectionTypes.vbproj b/Code/Chapter 10/CollectionTypes/CollectionTypes.vbproj new file mode 100644 index 0000000..b784c07 --- /dev/null +++ b/Code/Chapter 10/CollectionTypes/CollectionTypes.vbproj @@ -0,0 +1,112 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {13AF3C0E-433A-4DB1-BC39-2395E1207D7F} + Exe + CollectionTypes.Program + CollectionTypes + CollectionTypes + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + CollectionTypes.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + CollectionTypes.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + + + 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/Code/Chapter 10/CollectionTypes/My Project/Application.Designer.vb b/Code/Chapter 10/CollectionTypes/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 10/CollectionTypes/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 10/CollectionTypes/My Project/Application.myapp b/Code/Chapter 10/CollectionTypes/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 10/CollectionTypes/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 10/CollectionTypes/My Project/AssemblyInfo.vb b/Code/Chapter 10/CollectionTypes/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..68f3060 --- /dev/null +++ b/Code/Chapter 10/CollectionTypes/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/Code/Chapter 10/CollectionTypes/My Project/Resources.Designer.vb b/Code/Chapter 10/CollectionTypes/My Project/Resources.Designer.vb new file mode 100644 index 0000000..2c02509 --- /dev/null +++ b/Code/Chapter 10/CollectionTypes/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("CollectionTypes.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/Code/Chapter 10/CollectionTypes/My Project/Resources.resx b/Code/Chapter 10/CollectionTypes/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 10/CollectionTypes/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/Code/Chapter 10/CollectionTypes/My Project/Settings.Designer.vb b/Code/Chapter 10/CollectionTypes/My Project/Settings.Designer.vb new file mode 100644 index 0000000..8d6d095 --- /dev/null +++ b/Code/Chapter 10/CollectionTypes/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CollectionTypes.My.MySettings + Get + Return Global.CollectionTypes.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 10/CollectionTypes/My Project/Settings.settings b/Code/Chapter 10/CollectionTypes/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 10/CollectionTypes/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 10/CollectionTypes/PetNameComparer.vb b/Code/Chapter 10/CollectionTypes/PetNameComparer.vb new file mode 100644 index 0000000..487f77d --- /dev/null +++ b/Code/Chapter 10/CollectionTypes/PetNameComparer.vb @@ -0,0 +1,13 @@ +Imports System.Collections + +Public Class PetNameComparer + Implements IComparer + + Public Sub New() + End Sub + Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compare + Dim t1 As Car = CType(x, Car) + Dim t2 As Car = CType(y, Car) + Return String.Compare(t1.Name, t2.Name) + End Function +End Class diff --git a/Code/Chapter 10/CollectionTypes/Program.vb b/Code/Chapter 10/CollectionTypes/Program.vb new file mode 100644 index 0000000..fa8f458 --- /dev/null +++ b/Code/Chapter 10/CollectionTypes/Program.vb @@ -0,0 +1,102 @@ +Option Explicit On +Option Strict On + +Module Program + + Sub Main() + Console.WriteLine("***** Fun with System.Collections *****" & vbLf) + ArrayListTest() + Console.WriteLine() + QueueTest() + Console.WriteLine() + StackTest() + Console.ReadLine() + End Sub + +#Region "ArrayList Test" + Sub ArrayListTest() + ' Make ArrayList and add a range of Cars. + Dim carArList As New ArrayList() + carArList.AddRange(New Car() {New Car("Fred", 90, 10), _ + New Car("Mary", 100, 50), New Car("MB", 190, 11)}) + Console.WriteLine("Items in carArList: {0}", carArList.Count) + + ' Iterate over contents using For / Each. + For Each c As Car In carArList + Console.WriteLine("Car pet name: {0}", c.Name) + Next + + ' Insert new car. + Console.WriteLine("->Inserting new Car.") + carArList.Insert(2, New Car("TheNewCar", 0, 12)) + Console.WriteLine("Items in carArList: {0}", carArList.Count) + + ' Get the subobjects as an array. + Dim arrayOfCars As Object() = carArList.ToArray() + Dim i As Integer = 0 + + ' Now iterate over array using While loop / Length property. + While i < arrayOfCars.Length + Console.WriteLine("Car pet name: {0}", CType(arrayOfCars(i), Car).Name) + i = i + 1 + End While + End Sub + +#End Region + +#Region "Queue Test" + Public Sub WashCar(ByVal c As Car) + Console.WriteLine("Cleaning {0}", c.Name) + End Sub + + Sub QueueTest() + ' Make a Q with three items. + Dim carWashQ As New Queue() + carWashQ.Enqueue(New Car("FirstCar", 0, 1)) + carWashQ.Enqueue(New Car("SecondCar", 0, 2)) + carWashQ.Enqueue(New Car("ThirdCar", 0, 3)) + + ' Peek at first car in Q. + Console.WriteLine("First in Q is {0}", _ + CType(carWashQ.Peek(), Car).Name) + + ' Remove each item from Q. + WashCar(CType(carWashQ.Dequeue(), Car)) + WashCar(CType(carWashQ.Dequeue(), Car)) + WashCar(CType(carWashQ.Dequeue(), Car)) + + ' Try to de-Q again? + Try + WashCar(CType(carWashQ.Dequeue(), Car)) + Catch ex As Exception + Console.WriteLine("Error!! {0}", ex.Message) + End Try + End Sub +#End Region + +#Region "Stack Test" + Sub StackTest() + Dim stringStack As New Stack() + stringStack.Push("One") + stringStack.Push("Two") + stringStack.Push("Three") + + ' Now look at the top item, pop it, and look again. + Console.WriteLine("Top item is: {0}", stringStack.Peek()) + Console.WriteLine("Popped off {0}", stringStack.Pop()) + Console.WriteLine("Top item is: {0}", stringStack.Peek()) + Console.WriteLine("Popped off {0}", stringStack.Pop()) + Console.WriteLine("Top item is: {0}", stringStack.Peek()) + Console.WriteLine("Popped off {0}", stringStack.Pop()) + + Try + Console.WriteLine("Top item is: {0} ", stringStack.Peek()) + Console.WriteLine("Popped off {0} ", stringStack.Pop()) + Catch ex As Exception + Console.WriteLine("Error!! {0} ", ex.Message) + End Try + End Sub + +#End Region + +End Module diff --git a/Code/Chapter 10/CollectionTypes/Radio.vb b/Code/Chapter 10/CollectionTypes/Radio.vb new file mode 100644 index 0000000..1bfec88 --- /dev/null +++ b/Code/Chapter 10/CollectionTypes/Radio.vb @@ -0,0 +1,13 @@ +Option Explicit On +Option Strict On + +Public Class Radio + Public Sub TurnOn(ByVal state As Boolean) + If state = True Then + Console.WriteLine("Jamming...") + Else + Console.WriteLine("Quiet time...") + End If + End Sub +End Class + diff --git a/Code/Chapter 10/CustomGenericCollection/CarCollection.vb b/Code/Chapter 10/CustomGenericCollection/CarCollection.vb new file mode 100644 index 0000000..ba9cc35 --- /dev/null +++ b/Code/Chapter 10/CustomGenericCollection/CarCollection.vb @@ -0,0 +1,45 @@ +Option Explicit On +Option Strict On + +Public Class CarCollection(Of T As Car) + Implements IEnumerable(Of T) + + Private myCars As New List(Of T) + + ' Error! System.Object does not have a + ' property named PetName. + Public Sub PrintPetName(ByVal pos As Integer) + Console.WriteLine(myCars(pos).PetName) + End Sub + + ' Type indexer. + Default Public Property Item(ByVal index As Integer) As T + Get + Return myCars(index) + End Get + Set(ByVal value As T) + myCars.Add(value) + End Set + End Property + + Public Sub ClearCars() + myCars.Clear() + End Sub + + Public Function CarCount() As Integer + Return myCars.Count() + End Function + +#Region "Interface implementations" + Public Function GetEnumeratorGeneric() As IEnumerator(Of T) _ + Implements IEnumerable(Of T).GetEnumerator + Return myCars.GetEnumerator() + End Function + + Public Function GetEnumerator() As IEnumerator _ + Implements IEnumerable.GetEnumerator + Return myCars.GetEnumerator() + End Function +#End Region + +End Class diff --git a/Code/Chapter 10/CustomGenericCollection/CustomGenericCollection.sln b/Code/Chapter 10/CustomGenericCollection/CustomGenericCollection.sln new file mode 100644 index 0000000..c016d0c --- /dev/null +++ b/Code/Chapter 10/CustomGenericCollection/CustomGenericCollection.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CustomGenericCollection", "CustomGenericCollection.vbproj", "{08AC02C1-15A2-4BB6-AA86-790A6785673A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {08AC02C1-15A2-4BB6-AA86-790A6785673A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {08AC02C1-15A2-4BB6-AA86-790A6785673A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {08AC02C1-15A2-4BB6-AA86-790A6785673A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {08AC02C1-15A2-4BB6-AA86-790A6785673A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 10/CustomGenericCollection/CustomGenericCollection.suo b/Code/Chapter 10/CustomGenericCollection/CustomGenericCollection.suo new file mode 100644 index 0000000..e643d2a Binary files /dev/null and b/Code/Chapter 10/CustomGenericCollection/CustomGenericCollection.suo differ diff --git a/Code/Chapter 10/CustomGenericCollection/CustomGenericCollection.vbproj b/Code/Chapter 10/CustomGenericCollection/CustomGenericCollection.vbproj new file mode 100644 index 0000000..4b73cbb --- /dev/null +++ b/Code/Chapter 10/CustomGenericCollection/CustomGenericCollection.vbproj @@ -0,0 +1,137 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {08AC02C1-15A2-4BB6-AA86-790A6785673A} + Exe + CustomGenericCollection.Program + CustomGenericCollection + CustomGenericCollection + Console + + + 2.0 + + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + v3.5 + + + true + full + true + true + bin\Debug\ + CustomGenericCollection.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + CustomGenericCollection.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 10/CustomGenericCollection/CustomGenericCollection.vbproj.user b/Code/Chapter 10/CustomGenericCollection/CustomGenericCollection.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 10/CustomGenericCollection/CustomGenericCollection.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 10/CustomGenericCollection/ExampleConstraints.vb b/Code/Chapter 10/CustomGenericCollection/ExampleConstraints.vb new file mode 100644 index 0000000..4b4b0ed --- /dev/null +++ b/Code/Chapter 10/CustomGenericCollection/ExampleConstraints.vb @@ -0,0 +1,31 @@ +Option Explicit On +Option Strict On + +' Contained items must have a default ctor. +Public Class MyGenericClass(Of T As New) +End Class + +' Contained items must implement ICloneable +' and support a default ctor. +Public Class MyGenericClass2(Of T As {ICloneable, New}) +End Class + +' MyGenericClass derives from SomBaseClass and implements ISomeInterface, +' while the contained items must be structures. +Public Class MyGenericClass3(Of T As Structure) + Inherits SomeBaseClass + Implements ISomeInterface +End Class + +' (Of K) must have a default ctor, while (Of T) must +' implement the generic IComparable interface. +Public Class MyGenericClass(Of K As New, T As IComparable(Of T)) +End Class + +#Region "Just so the previous code compiles..." +Public Class SomeBaseClass +End Class + +Public Interface ISomeInterface +End Interface +#End Region diff --git a/Code/Chapter 10/CustomGenericCollection/My Project/Application.Designer.vb b/Code/Chapter 10/CustomGenericCollection/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 10/CustomGenericCollection/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 10/CustomGenericCollection/My Project/Application.myapp b/Code/Chapter 10/CustomGenericCollection/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 10/CustomGenericCollection/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 10/CustomGenericCollection/My Project/AssemblyInfo.vb b/Code/Chapter 10/CustomGenericCollection/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..ece720b --- /dev/null +++ b/Code/Chapter 10/CustomGenericCollection/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/Code/Chapter 10/CustomGenericCollection/My Project/Resources.Designer.vb b/Code/Chapter 10/CustomGenericCollection/My Project/Resources.Designer.vb new file mode 100644 index 0000000..bd81d07 --- /dev/null +++ b/Code/Chapter 10/CustomGenericCollection/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("CustomGenericCollection.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/Code/Chapter 10/CustomGenericCollection/My Project/Resources.resx b/Code/Chapter 10/CustomGenericCollection/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 10/CustomGenericCollection/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/Code/Chapter 10/CustomGenericCollection/My Project/Settings.Designer.vb b/Code/Chapter 10/CustomGenericCollection/My Project/Settings.Designer.vb new file mode 100644 index 0000000..83aa75e --- /dev/null +++ b/Code/Chapter 10/CustomGenericCollection/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CustomGenericCollection.My.MySettings + Get + Return Global.CustomGenericCollection.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 10/CustomGenericCollection/My Project/Settings.settings b/Code/Chapter 10/CustomGenericCollection/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 10/CustomGenericCollection/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 10/CustomGenericCollection/Program.vb b/Code/Chapter 10/CustomGenericCollection/Program.vb new file mode 100644 index 0000000..21f5838 --- /dev/null +++ b/Code/Chapter 10/CustomGenericCollection/Program.vb @@ -0,0 +1,29 @@ +Option Explicit On +Option Strict On + +Module Program + Sub Main() + Console.WriteLine("***** Custom Generic Collection *****") + Console.WriteLine() + + ' Make a collection of Cars. + Dim myCars As New CarCollection(Of Car) + myCars(0) = New Car("Rusty", 20) + myCars(1) = New Car("Zippy", 90) + + For Each c As Car In myCars + Console.WriteLine("PetName: {0} , Speed: {1} ", _ + c.PetName, c.Speed) + Next + + Console.WriteLine() + + Dim otherCars As New CarCollection(Of Car) + otherCars(0) = New MiniVan("Mel", 10) + otherCars(1) = New SportsCar("Suzy", 30) + For i As Integer = 0 To otherCars.CarCount - 1 + otherCars.PrintPetName(i) + Next + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 10/CustomGenericCollection/SimpleCars.vb b/Code/Chapter 10/CustomGenericCollection/SimpleCars.vb new file mode 100644 index 0000000..0e46760 --- /dev/null +++ b/Code/Chapter 10/CustomGenericCollection/SimpleCars.vb @@ -0,0 +1,29 @@ +Option Explicit On +Option Strict On + +' A simple Car type for testing +Public Class Car + Public PetName As String + Public Speed As Integer + Public Sub New(ByVal name As String, ByVal sp As Integer) + PetName = name : Speed = sp + End Sub + Public Sub New() + End Sub +End Class + +Public Class SportsCar + Inherits Car + Public Sub New(ByVal p As String, ByVal s As Integer) + MyBase.New(p, s) + End Sub + ' Assume additional SportsCar methods. +End Class + +Public Class MiniVan + Inherits Car + Public Sub New(ByVal p As String, ByVal s As Integer) + MyBase.New(p, s) + End Sub + ' Assume additional MiniVan methods. +End Class diff --git a/Code/Chapter 10/GenericDelegate/GenericDelegate.sln b/Code/Chapter 10/GenericDelegate/GenericDelegate.sln new file mode 100644 index 0000000..8ef7295 --- /dev/null +++ b/Code/Chapter 10/GenericDelegate/GenericDelegate.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "GenericDelegate", "GenericDelegate.vbproj", "{EA004E11-FF3F-43BD-BB64-404DCE200AF8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EA004E11-FF3F-43BD-BB64-404DCE200AF8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EA004E11-FF3F-43BD-BB64-404DCE200AF8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EA004E11-FF3F-43BD-BB64-404DCE200AF8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EA004E11-FF3F-43BD-BB64-404DCE200AF8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 10/GenericDelegate/GenericDelegate.suo b/Code/Chapter 10/GenericDelegate/GenericDelegate.suo new file mode 100644 index 0000000..141cc18 Binary files /dev/null and b/Code/Chapter 10/GenericDelegate/GenericDelegate.suo differ diff --git a/Code/Chapter 10/GenericDelegate/GenericDelegate.vbproj b/Code/Chapter 10/GenericDelegate/GenericDelegate.vbproj new file mode 100644 index 0000000..9303ca0 --- /dev/null +++ b/Code/Chapter 10/GenericDelegate/GenericDelegate.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {EA004E11-FF3F-43BD-BB64-404DCE200AF8} + Exe + GenericDelegate.Program + GenericDelegate + GenericDelegate + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + GenericDelegate.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + GenericDelegate.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 10/GenericDelegate/GenericDelegate.vbproj.user b/Code/Chapter 10/GenericDelegate/GenericDelegate.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 10/GenericDelegate/GenericDelegate.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 10/GenericDelegate/My Project/Application.Designer.vb b/Code/Chapter 10/GenericDelegate/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 10/GenericDelegate/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 10/GenericDelegate/My Project/Application.myapp b/Code/Chapter 10/GenericDelegate/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 10/GenericDelegate/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 10/GenericDelegate/My Project/AssemblyInfo.vb b/Code/Chapter 10/GenericDelegate/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..81801a0 --- /dev/null +++ b/Code/Chapter 10/GenericDelegate/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/Code/Chapter 10/GenericDelegate/My Project/Resources.Designer.vb b/Code/Chapter 10/GenericDelegate/My Project/Resources.Designer.vb new file mode 100644 index 0000000..42b525c --- /dev/null +++ b/Code/Chapter 10/GenericDelegate/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("GenericDelegate.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/Code/Chapter 10/GenericDelegate/My Project/Resources.resx b/Code/Chapter 10/GenericDelegate/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 10/GenericDelegate/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/Code/Chapter 10/GenericDelegate/My Project/Settings.Designer.vb b/Code/Chapter 10/GenericDelegate/My Project/Settings.Designer.vb new file mode 100644 index 0000000..1445d02 --- /dev/null +++ b/Code/Chapter 10/GenericDelegate/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.GenericDelegate.My.MySettings + Get + Return Global.GenericDelegate.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 10/GenericDelegate/My Project/Settings.settings b/Code/Chapter 10/GenericDelegate/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 10/GenericDelegate/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 10/GenericDelegate/Program.vb b/Code/Chapter 10/GenericDelegate/Program.vb new file mode 100644 index 0000000..9d2dfc3 --- /dev/null +++ b/Code/Chapter 10/GenericDelegate/Program.vb @@ -0,0 +1,62 @@ +Option Explicit On +Option Strict On + +' This generic delegate can point to any method +' taking a single argument (specified at the time +' of creation). +Public Delegate Sub MyGenericDelegate(Of T)(ByVal arg As T) + +#Region "Simulating generic delegates with Object." +Public Delegate Sub MyDelegate(ByVal arg As Object) + +Module NonGenericDelegateTest + Sub TestMethod() + ' Register target with 'traditional' delegate syntax. + Dim d As New MyDelegate(AddressOf MyTarget) + d("More string data") + + ' Register target using method group conversion. + Dim d2 As New MyDelegate(AddressOf MyTarget) + d2(9) ' Boxing penalty! + End Sub + + ' Due to a lack of type safety, we must + ' determine the underlying type before casting. + Sub MyTarget(ByVal arg As Object) + If TypeOf arg Is Integer Then + Dim i As Integer = CType(arg, Integer) ' Unboxing penalty! + Console.WriteLine("++arg is: {0}", ++i) + End If + If TypeOf arg Is String Then + Dim s As String = CType(arg, String) + Console.WriteLine("arg in uppercase is: {0}", s.ToUpper()) + End If + End Sub +End Module +#End Region + +Module Program + Sub Main() + Console.WriteLine("***** Fun with generic delegates *****") + Console.WriteLine() + + ' Make instance of delegate pointing to method taking an + ' integer. + Dim d As New MyGenericDelegate(Of Integer)(AddressOf IntegerTarget) + d(100) + + ' Now pointing to a method taking a string. + Dim d2 As New MyGenericDelegate(Of String)(AddressOf StringTarget) + d2("Cool!") + End Sub + + Public Sub IntegerTarget(ByVal arg As Integer) + Console.WriteLine("You passed me a {0} with the value of {1}", _ + arg.GetType().Name, arg) + End Sub + + Public Sub StringTarget(ByVal arg As String) + Console.WriteLine("You passed me a {0} with the value of {1}", _ + arg.GetType().Name, arg) + End Sub +End Module diff --git a/Code/Chapter 10/GenericInterface/GenericInterface.sln b/Code/Chapter 10/GenericInterface/GenericInterface.sln new file mode 100644 index 0000000..9291376 --- /dev/null +++ b/Code/Chapter 10/GenericInterface/GenericInterface.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "GenericInterface", "GenericInterface.vbproj", "{4E436B31-4279-48BD-BB6E-603F6AC5C7E2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4E436B31-4279-48BD-BB6E-603F6AC5C7E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4E436B31-4279-48BD-BB6E-603F6AC5C7E2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4E436B31-4279-48BD-BB6E-603F6AC5C7E2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4E436B31-4279-48BD-BB6E-603F6AC5C7E2}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 10/GenericInterface/GenericInterface.suo b/Code/Chapter 10/GenericInterface/GenericInterface.suo new file mode 100644 index 0000000..da9957a Binary files /dev/null and b/Code/Chapter 10/GenericInterface/GenericInterface.suo differ diff --git a/Code/Chapter 10/GenericInterface/GenericInterface.vbproj b/Code/Chapter 10/GenericInterface/GenericInterface.vbproj new file mode 100644 index 0000000..022020a --- /dev/null +++ b/Code/Chapter 10/GenericInterface/GenericInterface.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {4E436B31-4279-48BD-BB6E-603F6AC5C7E2} + Exe + GenericInterface.Program + GenericInterface + GenericInterface + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + GenericInterface.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + GenericInterface.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 10/GenericInterface/GenericInterface.vbproj.user b/Code/Chapter 10/GenericInterface/GenericInterface.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 10/GenericInterface/GenericInterface.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 10/GenericInterface/My Project/Application.Designer.vb b/Code/Chapter 10/GenericInterface/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 10/GenericInterface/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 10/GenericInterface/My Project/Application.myapp b/Code/Chapter 10/GenericInterface/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 10/GenericInterface/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 10/GenericInterface/My Project/AssemblyInfo.vb b/Code/Chapter 10/GenericInterface/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..25e4e52 --- /dev/null +++ b/Code/Chapter 10/GenericInterface/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/Code/Chapter 10/GenericInterface/My Project/Resources.Designer.vb b/Code/Chapter 10/GenericInterface/My Project/Resources.Designer.vb new file mode 100644 index 0000000..1fe2daf --- /dev/null +++ b/Code/Chapter 10/GenericInterface/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("GenericInterface.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/Code/Chapter 10/GenericInterface/My Project/Resources.resx b/Code/Chapter 10/GenericInterface/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 10/GenericInterface/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/Code/Chapter 10/GenericInterface/My Project/Settings.Designer.vb b/Code/Chapter 10/GenericInterface/My Project/Settings.Designer.vb new file mode 100644 index 0000000..c49377c --- /dev/null +++ b/Code/Chapter 10/GenericInterface/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.GenericInterface.My.MySettings + Get + Return Global.GenericInterface.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 10/GenericInterface/My Project/Settings.settings b/Code/Chapter 10/GenericInterface/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 10/GenericInterface/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 10/GenericInterface/Program.vb b/Code/Chapter 10/GenericInterface/Program.vb new file mode 100644 index 0000000..df76a70 --- /dev/null +++ b/Code/Chapter 10/GenericInterface/Program.vb @@ -0,0 +1,44 @@ +Option Explicit On +Option Strict On + +#Region "Generic interface and implementation class" +Public Interface IBasicMath(Of T) + Function Add(ByVal a As T, ByVal b As T) As T + Function Subtract(ByVal a As T, ByVal b As T) As T + Function Multiply(ByVal a As T, ByVal b As T) As T + Function Divide(ByVal a As T, ByVal b As T) As T +End Interface + +Public Class BasicMath + Implements IBasicMath(Of Integer) + + Public Function Add(ByVal a As Integer, ByVal b As Integer) _ + As Integer Implements IBasicMath(Of Integer).Add + Return a + b + End Function + + Public Function Divide(ByVal a As Integer, ByVal b As Integer) _ + As Integer Implements IBasicMath(Of Integer).Divide + Return CInt(a / b) + End Function + + Public Function Multiply(ByVal a As Integer, ByVal b As Integer) _ + As Integer Implements IBasicMath(Of Integer).Multiply + Return a * b + End Function + + Public Function Subtract(ByVal a As Integer, ByVal b As Integer) _ + As Integer Implements IBasicMath(Of Integer).Subtract + Return a - b + End Function +End Class +#End Region + +Module Program + Sub Main() + Console.WriteLine("***** Generic Interfaces *****") + Dim m As New BasicMath() + Console.WriteLine("1 + 1 = {0} ", m.Add(1, 1)) + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 10/GenericStructure/GenericStructure.sln b/Code/Chapter 10/GenericStructure/GenericStructure.sln new file mode 100644 index 0000000..3aaa334 --- /dev/null +++ b/Code/Chapter 10/GenericStructure/GenericStructure.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "GenericStructure", "GenericStructure.vbproj", "{2693150F-59DE-4049-8206-0DE13BA28B62}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2693150F-59DE-4049-8206-0DE13BA28B62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2693150F-59DE-4049-8206-0DE13BA28B62}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2693150F-59DE-4049-8206-0DE13BA28B62}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2693150F-59DE-4049-8206-0DE13BA28B62}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 10/GenericStructure/GenericStructure.suo b/Code/Chapter 10/GenericStructure/GenericStructure.suo new file mode 100644 index 0000000..cd4e4f1 Binary files /dev/null and b/Code/Chapter 10/GenericStructure/GenericStructure.suo differ diff --git a/Code/Chapter 10/GenericStructure/GenericStructure.vbproj b/Code/Chapter 10/GenericStructure/GenericStructure.vbproj new file mode 100644 index 0000000..5b73753 --- /dev/null +++ b/Code/Chapter 10/GenericStructure/GenericStructure.vbproj @@ -0,0 +1,135 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {2693150F-59DE-4049-8206-0DE13BA28B62} + Exe + GenericStructure.Program + GenericStructure + GenericStructure + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + GenericStructure.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + GenericStructure.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 10/GenericStructure/GenericStructure.vbproj.user b/Code/Chapter 10/GenericStructure/GenericStructure.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 10/GenericStructure/GenericStructure.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 10/GenericStructure/My Project/Application.Designer.vb b/Code/Chapter 10/GenericStructure/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 10/GenericStructure/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 10/GenericStructure/My Project/Application.myapp b/Code/Chapter 10/GenericStructure/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 10/GenericStructure/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 10/GenericStructure/My Project/AssemblyInfo.vb b/Code/Chapter 10/GenericStructure/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..ed084fc --- /dev/null +++ b/Code/Chapter 10/GenericStructure/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/Code/Chapter 10/GenericStructure/My Project/Resources.Designer.vb b/Code/Chapter 10/GenericStructure/My Project/Resources.Designer.vb new file mode 100644 index 0000000..d48cb89 --- /dev/null +++ b/Code/Chapter 10/GenericStructure/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("GenericStructure.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/Code/Chapter 10/GenericStructure/My Project/Resources.resx b/Code/Chapter 10/GenericStructure/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 10/GenericStructure/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/Code/Chapter 10/GenericStructure/My Project/Settings.Designer.vb b/Code/Chapter 10/GenericStructure/My Project/Settings.Designer.vb new file mode 100644 index 0000000..2265a71 --- /dev/null +++ b/Code/Chapter 10/GenericStructure/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.GenericStructure.My.MySettings + Get + Return Global.GenericStructure.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 10/GenericStructure/My Project/Settings.settings b/Code/Chapter 10/GenericStructure/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 10/GenericStructure/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 10/GenericStructure/Point.vb b/Code/Chapter 10/GenericStructure/Point.vb new file mode 100644 index 0000000..894bc85 --- /dev/null +++ b/Code/Chapter 10/GenericStructure/Point.vb @@ -0,0 +1,33 @@ +Option Explicit On +Option Strict On + +Public Structure Point(Of T) + Private xPos, yPos As T + + Public Sub New(ByVal x As T, ByVal y As T) + xPos = x : yPos = y + End Sub + +#Region "Properties for (x, y) values" + Public Property X() As T + Get + Return xPos + End Get + Set(ByVal value As T) + xPos = value + End Set + End Property + Public Property Y() As T + Get + Return xPos + End Get + Set(ByVal value As T) + yPos = value + End Set + End Property +#End Region + + Public Overrides Function ToString() As String + Return String.Format("({0}, {1})", xPos, yPos) + End Function +End Structure \ No newline at end of file diff --git a/Code/Chapter 10/GenericStructure/Program.vb b/Code/Chapter 10/GenericStructure/Program.vb new file mode 100644 index 0000000..addb99a --- /dev/null +++ b/Code/Chapter 10/GenericStructure/Program.vb @@ -0,0 +1,43 @@ +Option Explicit On +Option Strict On + +Module Program + Sub Main() + Console.WriteLine("***** Fun with Custom Generic Types *****") + Console.WriteLine() + + ' Make a Point Integers. + Dim intPt As New Point(Of Integer)(100, 100) + Console.WriteLine("intPt.ToString()={0} ", intPt.ToString()) + Console.WriteLine() + + ' Point using double. + Dim dblPt As New Point(Of Double)(5.6, 3.23) + Console.WriteLine("dblPt.ToString()={0} ", dblPt.ToString()) + Console.WriteLine() + + ' Swap 2 Points. + Dim p1 As New Point(Of Integer)(10, 43) + Dim p2 As New Point(Of Integer)(6, 987) + Console.WriteLine("Before swap: {0} , {1} ", p1, p2) + + ' Here we are swapping two points of type Integer. + Swap(Of Point(Of Integer))(p1, p2) + + ' Could also simply write the following + ' given type inference. + ' Swap(p1, p2) + + Console.WriteLine("After swap: {0} , {1} ", p1, p2) + Console.ReadLine() + End Sub + + ' This generic method can swap any two items of type 'T' + Public Function Swap(Of T)(ByRef a As T, ByRef b As T) As T + Console.WriteLine("T is a {0}.", GetType(T)) + Dim temp As T + temp = a + a = b + b = temp + End Function +End Module diff --git a/Code/Chapter 10/GenericSwapMethod/GenericSwapMethod.sln b/Code/Chapter 10/GenericSwapMethod/GenericSwapMethod.sln new file mode 100644 index 0000000..6b31c57 --- /dev/null +++ b/Code/Chapter 10/GenericSwapMethod/GenericSwapMethod.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "GenericSwapMethod", "GenericSwapMethod.vbproj", "{E03E5102-4B92-4518-8A6D-0DBBF08B07F8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E03E5102-4B92-4518-8A6D-0DBBF08B07F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E03E5102-4B92-4518-8A6D-0DBBF08B07F8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E03E5102-4B92-4518-8A6D-0DBBF08B07F8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E03E5102-4B92-4518-8A6D-0DBBF08B07F8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 10/GenericSwapMethod/GenericSwapMethod.suo b/Code/Chapter 10/GenericSwapMethod/GenericSwapMethod.suo new file mode 100644 index 0000000..739a131 Binary files /dev/null and b/Code/Chapter 10/GenericSwapMethod/GenericSwapMethod.suo differ diff --git a/Code/Chapter 10/GenericSwapMethod/GenericSwapMethod.vbproj b/Code/Chapter 10/GenericSwapMethod/GenericSwapMethod.vbproj new file mode 100644 index 0000000..ceb22ae --- /dev/null +++ b/Code/Chapter 10/GenericSwapMethod/GenericSwapMethod.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {E03E5102-4B92-4518-8A6D-0DBBF08B07F8} + Exe + GenericSwapMethod.Program + GenericSwapMethod + GenericSwapMethod + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + GenericSwapMethod.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + GenericSwapMethod.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 10/GenericSwapMethod/GenericSwapMethod.vbproj.user b/Code/Chapter 10/GenericSwapMethod/GenericSwapMethod.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 10/GenericSwapMethod/GenericSwapMethod.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 10/GenericSwapMethod/My Project/Application.Designer.vb b/Code/Chapter 10/GenericSwapMethod/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 10/GenericSwapMethod/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 10/GenericSwapMethod/My Project/Application.myapp b/Code/Chapter 10/GenericSwapMethod/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 10/GenericSwapMethod/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 10/GenericSwapMethod/My Project/AssemblyInfo.vb b/Code/Chapter 10/GenericSwapMethod/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..c5ce070 --- /dev/null +++ b/Code/Chapter 10/GenericSwapMethod/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/Code/Chapter 10/GenericSwapMethod/My Project/Resources.Designer.vb b/Code/Chapter 10/GenericSwapMethod/My Project/Resources.Designer.vb new file mode 100644 index 0000000..5a7a214 --- /dev/null +++ b/Code/Chapter 10/GenericSwapMethod/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("GenericSwapMethod.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/Code/Chapter 10/GenericSwapMethod/My Project/Resources.resx b/Code/Chapter 10/GenericSwapMethod/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 10/GenericSwapMethod/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/Code/Chapter 10/GenericSwapMethod/My Project/Settings.Designer.vb b/Code/Chapter 10/GenericSwapMethod/My Project/Settings.Designer.vb new file mode 100644 index 0000000..442439d --- /dev/null +++ b/Code/Chapter 10/GenericSwapMethod/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.GenericSwapMethod.My.MySettings + Get + Return Global.GenericSwapMethod.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 10/GenericSwapMethod/My Project/Settings.settings b/Code/Chapter 10/GenericSwapMethod/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 10/GenericSwapMethod/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 10/GenericSwapMethod/Program.vb b/Code/Chapter 10/GenericSwapMethod/Program.vb new file mode 100644 index 0000000..249fed1 --- /dev/null +++ b/Code/Chapter 10/GenericSwapMethod/Program.vb @@ -0,0 +1,74 @@ +Option Explicit On +Option Strict On + +#Region "Non-generic members" +Module NonGenericMethods + Public Function Swap(ByRef a As Integer, ByRef b As Integer) As Integer + Dim temp As Integer + temp = a + a = b + b = temp + End Function + Public Function Swap(ByRef a As Double, ByRef b As Double) As Double + Dim temp As Double + temp = a + a = b + b = temp + End Function +End Module +#End Region + +Module Program + +#Region "Generic methods" + ' This generic method can swap any two items of type 'T'. + Public Function Swap(Of T)(ByRef a As T, ByRef b As T) As T + Console.WriteLine("T is a {0}.", GetType(T)) + Dim temp As T + temp = a + a = b + b = temp + End Function + + ' Display the base class of 'T'. + Sub DisplayBaseClass(Of T)() + Console.WriteLine("Base class of {0} is: {1}.", _ + GetType(T), GetType(T).BaseType) + End Sub +#End Region + + Sub Main() + Console.WriteLine("***** Fun with Generic Methods *****" & vbLf) + + ' Swap two Integers. + Dim a, b As Integer + a = 10 : b = 40 + Console.WriteLine("Before swap: a={0}, b={1}", a, b) + Swap(Of Integer)(a, b) + Console.WriteLine("After swap: a={0}, b={1}", a, b) + Console.WriteLine() + + ' Swap two Strings. + Dim s1, s2 As String + s1 = "Generics" : s2 = "Rock" + Console.WriteLine("Before swap: s1={0}, s2={1}", s1, s2) + Swap(Of String)(s1, s2) + Console.WriteLine("After swap: s1={0}, s2={1}", s1, s2) + Console.WriteLine() + + ' Compiler will infer System.Boolean. + Dim b1, b2 As Boolean + b1 = True : b2 = False + Console.WriteLine("Before swap: b1={0}, b2={1}", b1, b2) + Swap(b1, b2) + Console.WriteLine("Before swap: b1={0}, b2={1}", b1, b2) + Console.WriteLine() + + ' Must specify 'T' when a generic + ' method takes no parameters. + DisplayBaseClass(Of Boolean)() + DisplayBaseClass(Of String)() + DisplayBaseClass(Of Integer)() + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 10/NullableData/My Project/Application.Designer.vb b/Code/Chapter 10/NullableData/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 10/NullableData/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 10/NullableData/My Project/Application.myapp b/Code/Chapter 10/NullableData/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 10/NullableData/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 10/NullableData/My Project/AssemblyInfo.vb b/Code/Chapter 10/NullableData/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..56816d9 --- /dev/null +++ b/Code/Chapter 10/NullableData/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/Code/Chapter 10/NullableData/My Project/Resources.Designer.vb b/Code/Chapter 10/NullableData/My Project/Resources.Designer.vb new file mode 100644 index 0000000..d8c41ad --- /dev/null +++ b/Code/Chapter 10/NullableData/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("NullableData.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/Code/Chapter 10/NullableData/My Project/Resources.resx b/Code/Chapter 10/NullableData/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 10/NullableData/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/Code/Chapter 10/NullableData/My Project/Settings.Designer.vb b/Code/Chapter 10/NullableData/My Project/Settings.Designer.vb new file mode 100644 index 0000000..7bc48f7 --- /dev/null +++ b/Code/Chapter 10/NullableData/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.NullableData.My.MySettings + Get + Return Global.NullableData.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 10/NullableData/My Project/Settings.settings b/Code/Chapter 10/NullableData/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 10/NullableData/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 10/NullableData/NullableData.sln b/Code/Chapter 10/NullableData/NullableData.sln new file mode 100644 index 0000000..a3f6b60 --- /dev/null +++ b/Code/Chapter 10/NullableData/NullableData.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "NullableData", "NullableData.vbproj", "{0E8206B7-765B-45EB-80A2-0CC6CB922CC7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0E8206B7-765B-45EB-80A2-0CC6CB922CC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0E8206B7-765B-45EB-80A2-0CC6CB922CC7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0E8206B7-765B-45EB-80A2-0CC6CB922CC7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0E8206B7-765B-45EB-80A2-0CC6CB922CC7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 10/NullableData/NullableData.suo b/Code/Chapter 10/NullableData/NullableData.suo new file mode 100644 index 0000000..5bab480 Binary files /dev/null and b/Code/Chapter 10/NullableData/NullableData.suo differ diff --git a/Code/Chapter 10/NullableData/NullableData.vbproj b/Code/Chapter 10/NullableData/NullableData.vbproj new file mode 100644 index 0000000..6aea4d5 --- /dev/null +++ b/Code/Chapter 10/NullableData/NullableData.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {0E8206B7-765B-45EB-80A2-0CC6CB922CC7} + Exe + NullableData.Program + NullableData + NullableData + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + NullableData.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + NullableData.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 10/NullableData/NullableData.vbproj.user b/Code/Chapter 10/NullableData/NullableData.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 10/NullableData/NullableData.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 10/NullableData/Program.vb b/Code/Chapter 10/NullableData/Program.vb new file mode 100644 index 0000000..1c087c5 --- /dev/null +++ b/Code/Chapter 10/NullableData/Program.vb @@ -0,0 +1,89 @@ +Option Explicit On +Option Strict On + +#Region "Helper classes" +'Class DatabaseReader +' ' Nullable data fields. +' Public numericValue As Nullable(Of Integer) +' Public boolValue As Nullable(Of Boolean) = True + +' ' Note the nullable return type. +' Public Function GetIntFromDatabase() As Nullable(Of Integer) +' Return numericValue +' End Function + +' ' Note the nullable return type. +' Public Function GetBoolFromDatabase() As Nullable(Of Boolean) +' Return boolValue +' End Function +'End Class + +Class DatabaseReader + ' Note the use of the ? operator in the class + ' definition. + Public numericValue As Integer? + Public boolValue As Boolean? = True + + ' Note the nullable return type. + Public Function GetIntFromDatabase() As Integer? + Return numericValue + End Function + + ' Note the nullable return type. + Public Function GetBoolFromDatabase() As Boolean? + Return boolValue + End Function +End Class +#End Region + +Module Program + + Sub Main() + Console.WriteLine("***** Fun with Nullable Data *****" & vbLf) + Dim dr As New DatabaseReader() + + ' Get int from 'database'. + Dim i As Integer? = dr.GetIntFromDatabase() + If (i.HasValue) Then + Console.WriteLine("Value of 'i' is: {0}", i.Value) + Else + Console.WriteLine("Value of 'i' is undefined.") + End If + + ' Get bool from 'database'. + Dim b As Boolean? = dr.GetBoolFromDatabase() + If (b.HasValue) Then + Console.WriteLine("Value of 'b' is: {0}", b.Value) + Else + Console.WriteLine("Value of 'b' is undefined.") + End If + + Console.ReadLine() + End Sub + +#Region "Main with Nullable (Of T)" + 'Sub Main() + ' Console.WriteLine("***** Fun with Nullable Data *****") + ' Console.WriteLine() + ' Dim dr As New DatabaseReader() + + ' ' Get int from 'database'. + ' Dim i As Nullable(Of Integer) = dr.GetIntFromDatabase() + ' If (i.HasValue) Then + ' Console.WriteLine("Value of 'i' is: {0}", i.Value) + ' Else + ' Console.WriteLine("Value of 'i' is undefined.") + ' End If + + ' ' Get bool from 'database'. + ' Dim b As Nullable(Of Boolean) = dr.GetBoolFromDatabase() + ' If (b.HasValue) Then + ' Console.WriteLine("Value of 'b' is: {0}", b.Value) + ' Else + ' Console.WriteLine("Value of 'b' is undefined.") + ' End If + ' Console.ReadLine() + 'End Sub +#End Region + +End Module diff --git a/Code/Chapter 10/SimpleGenerics/My Project/Application.Designer.vb b/Code/Chapter 10/SimpleGenerics/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 10/SimpleGenerics/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 10/SimpleGenerics/My Project/Application.myapp b/Code/Chapter 10/SimpleGenerics/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 10/SimpleGenerics/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 10/SimpleGenerics/My Project/AssemblyInfo.vb b/Code/Chapter 10/SimpleGenerics/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..7a0613e --- /dev/null +++ b/Code/Chapter 10/SimpleGenerics/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/Code/Chapter 10/SimpleGenerics/My Project/Resources.Designer.vb b/Code/Chapter 10/SimpleGenerics/My Project/Resources.Designer.vb new file mode 100644 index 0000000..31a00ff --- /dev/null +++ b/Code/Chapter 10/SimpleGenerics/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("SimpleGenerics.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/Code/Chapter 10/SimpleGenerics/My Project/Resources.resx b/Code/Chapter 10/SimpleGenerics/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 10/SimpleGenerics/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/Code/Chapter 10/SimpleGenerics/My Project/Settings.Designer.vb b/Code/Chapter 10/SimpleGenerics/My Project/Settings.Designer.vb new file mode 100644 index 0000000..971c962 --- /dev/null +++ b/Code/Chapter 10/SimpleGenerics/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SimpleGenerics.My.MySettings + Get + Return Global.SimpleGenerics.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 10/SimpleGenerics/My Project/Settings.settings b/Code/Chapter 10/SimpleGenerics/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 10/SimpleGenerics/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 10/SimpleGenerics/Program.vb b/Code/Chapter 10/SimpleGenerics/Program.vb new file mode 100644 index 0000000..c446292 --- /dev/null +++ b/Code/Chapter 10/SimpleGenerics/Program.vb @@ -0,0 +1,28 @@ +Option Explicit On +Option Strict On + +Public Class Car +End Class + +Module Program + Sub Main() + Console.WriteLine("***** This example does not do much beyond showing *****") + Console.WriteLine("***** how to declare a generic type *****") + Console.WriteLine() + + ' A list of Cars. + Dim myCars As New List(Of Car) + myCars.Add(New Car()) + Console.WriteLine("myCars contains {0} items", _ + myCars.Count) + + ' A list of Integers. + Dim MyInts As New List(Of Integer) + MyInts.Add(50) + ' No unboxing! + Dim val As Integer = MyInts.Count + Console.WriteLine("myInts contains {0} items", MyInts.Count) + Console.ReadLine() + End Sub +End Module + diff --git a/Code/Chapter 10/SimpleGenerics/SimpleGenerics.sln b/Code/Chapter 10/SimpleGenerics/SimpleGenerics.sln new file mode 100644 index 0000000..29ff854 --- /dev/null +++ b/Code/Chapter 10/SimpleGenerics/SimpleGenerics.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SimpleGenerics", "SimpleGenerics.vbproj", "{1BFBC666-99B9-40B4-96AA-104434CCE728}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1BFBC666-99B9-40B4-96AA-104434CCE728}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1BFBC666-99B9-40B4-96AA-104434CCE728}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1BFBC666-99B9-40B4-96AA-104434CCE728}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1BFBC666-99B9-40B4-96AA-104434CCE728}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 10/SimpleGenerics/SimpleGenerics.suo b/Code/Chapter 10/SimpleGenerics/SimpleGenerics.suo new file mode 100644 index 0000000..f007442 Binary files /dev/null and b/Code/Chapter 10/SimpleGenerics/SimpleGenerics.suo differ diff --git a/Code/Chapter 10/SimpleGenerics/SimpleGenerics.vbproj b/Code/Chapter 10/SimpleGenerics/SimpleGenerics.vbproj new file mode 100644 index 0000000..c50aec5 --- /dev/null +++ b/Code/Chapter 10/SimpleGenerics/SimpleGenerics.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {1BFBC666-99B9-40B4-96AA-104434CCE728} + Exe + SimpleGenerics.Program + SimpleGenerics + SimpleGenerics + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + SimpleGenerics.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SimpleGenerics.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 10/SimpleGenerics/SimpleGenerics.vbproj.user b/Code/Chapter 10/SimpleGenerics/SimpleGenerics.vbproj.user new file mode 100644 index 0000000..fdcb14e --- /dev/null +++ b/Code/Chapter 10/SimpleGenerics/SimpleGenerics.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ShowAllFiles + + \ No newline at end of file diff --git a/Code/Chapter 10/StronglyTypedCollections/Car.vb b/Code/Chapter 10/StronglyTypedCollections/Car.vb new file mode 100644 index 0000000..b578655 --- /dev/null +++ b/Code/Chapter 10/StronglyTypedCollections/Car.vb @@ -0,0 +1,6 @@ +Option Explicit On +Option Strict On + +' This is just to test the custom Car collection. +Public Class Car +End Class diff --git a/Code/Chapter 10/StronglyTypedCollections/CarCollection.vb b/Code/Chapter 10/StronglyTypedCollections/CarCollection.vb new file mode 100644 index 0000000..aa0d76c --- /dev/null +++ b/Code/Chapter 10/StronglyTypedCollections/CarCollection.vb @@ -0,0 +1,41 @@ +Option Explicit On +Option Strict On + +Public Class CarCollection + Implements IEnumerable + Private arCars As New ArrayList() + + Public Function GetCar(ByVal pos As Integer) As Car + Return CType(arCars(pos), Car) + End Function + + Public Sub AddCar(ByVal c As Car) + arCars.Add(c) + End Sub + + Public Sub ClearCars() + arCars.Clear() + End Sub + + Public ReadOnly Property Count() As Integer + Get + Return arCars.Count + End Get + End Property + + Public Function GetEnumerator() As IEnumerator _ + Implements IEnumerable.GetEnumerator + Return arCars.GetEnumerator() + End Function + + ' The 'indexer' of this custom collection. + Default Public Property Item(ByVal c As Integer) As Car + Get + Return CType(arCars(c), Car) + End Get + Set(ByVal value As Car) + arCars.Insert(c, value) + End Set + End Property + +End Class diff --git a/Code/Chapter 10/StronglyTypedCollections/IntegerCollection.vb b/Code/Chapter 10/StronglyTypedCollections/IntegerCollection.vb new file mode 100644 index 0000000..577d564 --- /dev/null +++ b/Code/Chapter 10/StronglyTypedCollections/IntegerCollection.vb @@ -0,0 +1,41 @@ +Option Explicit On +Option Strict On + +Public Class IntegerCollection + Implements IEnumerable + + Private arInts As New ArrayList() + + Public Function GetInt(ByVal pos As Integer) As Integer + Return CType(arInts(pos), Integer) + End Function + + Public Sub AddInt(ByVal i As Integer) + arInts.Add(i) + End Sub + + Public Sub ClearInts() + arInts.Clear() + End Sub + + Public ReadOnly Property Count() As Integer + Get + Return arInts.Count + End Get + End Property + + Public Function GetEnumerator() As IEnumerator _ + Implements IEnumerable.GetEnumerator + Return arInts.GetEnumerator() + End Function + + ' The 'indexer' of this custom collection. + Default Public Property Item(ByVal c As Integer) As Integer + Get + Return CType(arInts(c), Integer) + End Get + Set(ByVal value As Integer) + arInts.Insert(c, value) + End Set + End Property +End Class diff --git a/Code/Chapter 10/StronglyTypedCollections/My Project/Application.Designer.vb b/Code/Chapter 10/StronglyTypedCollections/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 10/StronglyTypedCollections/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 10/StronglyTypedCollections/My Project/Application.myapp b/Code/Chapter 10/StronglyTypedCollections/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 10/StronglyTypedCollections/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 10/StronglyTypedCollections/My Project/AssemblyInfo.vb b/Code/Chapter 10/StronglyTypedCollections/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..c5b6855 --- /dev/null +++ b/Code/Chapter 10/StronglyTypedCollections/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/Code/Chapter 10/StronglyTypedCollections/My Project/Resources.Designer.vb b/Code/Chapter 10/StronglyTypedCollections/My Project/Resources.Designer.vb new file mode 100644 index 0000000..c1d6ea4 --- /dev/null +++ b/Code/Chapter 10/StronglyTypedCollections/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("StronglyTypedCollections.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/Code/Chapter 10/StronglyTypedCollections/My Project/Resources.resx b/Code/Chapter 10/StronglyTypedCollections/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 10/StronglyTypedCollections/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/Code/Chapter 10/StronglyTypedCollections/My Project/Settings.Designer.vb b/Code/Chapter 10/StronglyTypedCollections/My Project/Settings.Designer.vb new file mode 100644 index 0000000..211a3a9 --- /dev/null +++ b/Code/Chapter 10/StronglyTypedCollections/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.StronglyTypedCollections.My.MySettings + Get + Return Global.StronglyTypedCollections.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 10/StronglyTypedCollections/My Project/Settings.settings b/Code/Chapter 10/StronglyTypedCollections/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 10/StronglyTypedCollections/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 10/StronglyTypedCollections/PeopleCollection.vb b/Code/Chapter 10/StronglyTypedCollections/PeopleCollection.vb new file mode 100644 index 0000000..37766f8 --- /dev/null +++ b/Code/Chapter 10/StronglyTypedCollections/PeopleCollection.vb @@ -0,0 +1,41 @@ +Option Explicit On +Option Strict On + +Public Class PeopleCollection + Implements IEnumerable + Private arPeople As New ArrayList() + + Public Function GetPerson(ByVal pos As Integer) As Person + Return CType(arPeople(pos), Person) + End Function + + Public Sub AddPerson(ByVal p As Person) + arPeople.Add(p) + End Sub + + Public Sub ClearPeople() + arPeople.Clear() + End Sub + + Public ReadOnly Property Count() As Integer + Get + Return arPeople.Count + End Get + End Property + + Public Function GetEnumerator() As IEnumerator _ + Implements IEnumerable.GetEnumerator + Return arPeople.GetEnumerator() + End Function + + ' The 'indexer' of this custom collection. + Default Public Property Item(ByVal p As Integer) As Person + Get + Return CType(arPeople(p), Person) + End Get + Set(ByVal value As Person) + arPeople.Insert(p, value) + End Set + End Property + +End Class diff --git a/Code/Chapter 10/StronglyTypedCollections/Person.vb b/Code/Chapter 10/StronglyTypedCollections/Person.vb new file mode 100644 index 0000000..f66684f --- /dev/null +++ b/Code/Chapter 10/StronglyTypedCollections/Person.vb @@ -0,0 +1,22 @@ +Option Explicit On +Option Strict On + +Public Class Person + ' Made public for simplicity. + Public currAge As Integer + Public fName As String + Public lName As String + + Public Sub New() + End Sub + Public Sub New(ByVal firstName As String, ByVal lastName As String, _ + ByVal age As Integer) + currAge = age + fName = firstName + lName = lastName + End Sub + + Public Overrides Function ToString() As String + Return String.Format("{0}, {1} is {2} years old.", lName, fName, currAge) + End Function +End Class diff --git a/Code/Chapter 10/StronglyTypedCollections/Program.vb b/Code/Chapter 10/StronglyTypedCollections/Program.vb new file mode 100644 index 0000000..b03dc30 --- /dev/null +++ b/Code/Chapter 10/StronglyTypedCollections/Program.vb @@ -0,0 +1,43 @@ +Option Explicit On +Option Strict On + +Module Program + Sub Main() + Console.WriteLine("***** Strongly Typed Collections *****") + Console.WriteLine() + + Dim myPeople As New PeopleCollection() + myPeople.AddPerson(New Person("Homer", "Simpson", 40)) + myPeople.AddPerson(New Person("Marge", "Simpson", 38)) + myPeople.AddPerson(New Person("Lisa", "Simpson", 9)) + myPeople.AddPerson(New Person("Bart", "Simpson", 7)) + myPeople.AddPerson(New Person("Maggie", "Simpson", 2)) + + ' This would be a compile-time error! + ' Uncomment line below to test. + ' myPeople.AddPerson(New Car) + + For Each p As Person In myPeople + Console.WriteLine(p) + Next + + ' Use the generic List type to hold only people. + Dim morePeople As New List(Of Person) + morePeople.Add(New Person()) + + ' Use the generic List type to hold only cars. + Dim moreCars As New List(Of Car) + moreCars.Add(New Car()) + + ' Compile-time error! + ' Uncomment line below to test. + ' moreCars.Add(New Person()) + + ' Get / Set new Person object using type indexer. + myPeople(5) = New Person("Waylon", "Smithers", 47) + Console.WriteLine("Person #5 is {0}", myPeople(5)) + + Console.ReadLine() + + End Sub +End Module diff --git a/Code/Chapter 10/StronglyTypedCollections/StronglyTypedCollections.sln b/Code/Chapter 10/StronglyTypedCollections/StronglyTypedCollections.sln new file mode 100644 index 0000000..771f98a --- /dev/null +++ b/Code/Chapter 10/StronglyTypedCollections/StronglyTypedCollections.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "StronglyTypedCollections", "StronglyTypedCollections.vbproj", "{961B843C-AC0E-4F47-9BB2-5C8A274D08BA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {961B843C-AC0E-4F47-9BB2-5C8A274D08BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {961B843C-AC0E-4F47-9BB2-5C8A274D08BA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {961B843C-AC0E-4F47-9BB2-5C8A274D08BA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {961B843C-AC0E-4F47-9BB2-5C8A274D08BA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 10/StronglyTypedCollections/StronglyTypedCollections.suo b/Code/Chapter 10/StronglyTypedCollections/StronglyTypedCollections.suo new file mode 100644 index 0000000..993be17 Binary files /dev/null and b/Code/Chapter 10/StronglyTypedCollections/StronglyTypedCollections.suo differ diff --git a/Code/Chapter 10/StronglyTypedCollections/StronglyTypedCollections.vbproj b/Code/Chapter 10/StronglyTypedCollections/StronglyTypedCollections.vbproj new file mode 100644 index 0000000..566ef7e --- /dev/null +++ b/Code/Chapter 10/StronglyTypedCollections/StronglyTypedCollections.vbproj @@ -0,0 +1,139 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {961B843C-AC0E-4F47-9BB2-5C8A274D08BA} + Exe + StronglyTypedCollections.Program + StronglyTypedCollections + StronglyTypedCollections + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + StronglyTypedCollections.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + StronglyTypedCollections.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 10/StronglyTypedCollections/StronglyTypedCollections.vbproj.user b/Code/Chapter 10/StronglyTypedCollections/StronglyTypedCollections.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 10/StronglyTypedCollections/StronglyTypedCollections.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 11/CarDelegate/Car.vb b/Code/Chapter 11/CarDelegate/Car.vb new file mode 100644 index 0000000..09f70bc --- /dev/null +++ b/Code/Chapter 11/CarDelegate/Car.vb @@ -0,0 +1,79 @@ +Option Explicit On +Option Strict On + +Public Class Car + ' Our delegate type. + Public Delegate Sub CarDelegateHandler(ByVal msg As String) + + ' Because delegates are simply classes, we can create + ' member variables. + Private almostDeadList As CarDelegateHandler + Private explodedList As CarDelegateHandler + +#Region "Registration / unregistration methods" + ' Now with type-safe multicasting! + Public Sub OnAboutToBlow(ByVal clientMethod As CarDelegateHandler) + almostDeadList = CType(System.Delegate.Combine(almostDeadList, _ + clientMethod), CarDelegateHandler) + End Sub + Public Sub OnExploded(ByVal clientMethod As CarDelegateHandler) + explodedList = CType(System.Delegate.Combine(explodedList, _ + clientMethod), CarDelegateHandler) + End Sub + + ' To remove a target from the list. + Public Sub RemoveAboutToBlow(ByVal clientMethod As CarDelegateHandler) + almostDeadList = CType(System.Delegate.Remove(almostDeadList, _ + clientMethod), CarDelegateHandler) + End Sub + + Public Sub RemoveExploded(ByVal clientMethod As CarDelegateHandler) + explodedList = CType(System.Delegate.Remove(explodedList, _ + clientMethod), CarDelegateHandler) + End Sub +#End Region + + ' Constant for maximum speed. + Public Const maxSpeed As Integer = 100 + + 'Internal state data. + Private currSpeed As Integer + Private petName As String + + 'Is the car still operational? + Private carIsDead As Boolean + + 'A car has a radio. + Private theMusicBox As Radio = New Radio + + ' Constructors. + Public Sub New() + End Sub + Public Sub New(ByVal name As String, ByVal currSp As Integer) + currSpeed = currSp + petName = name + End Sub + + Public Sub CrankTunes(ByVal state As Boolean) + theMusicBox.TurnOn(state) + End Sub + + ' See if Car has overheated. + Public Sub Accelerate(ByVal delta As Integer) + If carIsDead Then + If explodedList IsNot Nothing Then + explodedList("Sorry, this car is dead...") + End If + Else + currSpeed += delta + If 10 = maxSpeed - currSpeed AndAlso almostDeadList IsNot Nothing Then + almostDeadList("Careful buddy! Gonna blow!") + End If + If currSpeed >= maxSpeed Then + carIsDead = True + Else + Console.WriteLine("->CurrSpeed = {0} ", currSpeed) + End If + End If + End Sub +End Class \ No newline at end of file diff --git a/Code/Chapter 11/CarDelegate/CarDelegate.sln b/Code/Chapter 11/CarDelegate/CarDelegate.sln new file mode 100644 index 0000000..9f04a8c --- /dev/null +++ b/Code/Chapter 11/CarDelegate/CarDelegate.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CarDelegate", "CarDelegate.vbproj", "{82805F75-D837-4E19-8DF4-36045950D9FB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {82805F75-D837-4E19-8DF4-36045950D9FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {82805F75-D837-4E19-8DF4-36045950D9FB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {82805F75-D837-4E19-8DF4-36045950D9FB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {82805F75-D837-4E19-8DF4-36045950D9FB}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 11/CarDelegate/CarDelegate.suo b/Code/Chapter 11/CarDelegate/CarDelegate.suo new file mode 100644 index 0000000..6604b55 Binary files /dev/null and b/Code/Chapter 11/CarDelegate/CarDelegate.suo differ diff --git a/Code/Chapter 11/CarDelegate/CarDelegate.vbproj b/Code/Chapter 11/CarDelegate/CarDelegate.vbproj new file mode 100644 index 0000000..660aa0e --- /dev/null +++ b/Code/Chapter 11/CarDelegate/CarDelegate.vbproj @@ -0,0 +1,99 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {82805F75-D837-4E19-8DF4-36045950D9FB} + Exe + CarDelegate.Program + CarDelegate + CarDelegate + Console + + + 2.0 + + + + + true + full + true + true + bin\Debug\ + CarDelegate.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + CarDelegate.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/Code/Chapter 11/CarDelegate/My Project/Application.Designer.vb b/Code/Chapter 11/CarDelegate/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 11/CarDelegate/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 11/CarDelegate/My Project/Application.myapp b/Code/Chapter 11/CarDelegate/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 11/CarDelegate/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 11/CarDelegate/My Project/AssemblyInfo.vb b/Code/Chapter 11/CarDelegate/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..8ceb0e2 --- /dev/null +++ b/Code/Chapter 11/CarDelegate/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/Code/Chapter 11/CarDelegate/My Project/Resources.Designer.vb b/Code/Chapter 11/CarDelegate/My Project/Resources.Designer.vb new file mode 100644 index 0000000..81a5ea4 --- /dev/null +++ b/Code/Chapter 11/CarDelegate/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("CarDelegate.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/Code/Chapter 11/CarDelegate/My Project/Resources.resx b/Code/Chapter 11/CarDelegate/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 11/CarDelegate/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/Code/Chapter 11/CarDelegate/My Project/Settings.Designer.vb b/Code/Chapter 11/CarDelegate/My Project/Settings.Designer.vb new file mode 100644 index 0000000..cebabcd --- /dev/null +++ b/Code/Chapter 11/CarDelegate/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CarDelegate.My.MySettings + Get + Return Global.CarDelegate.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 11/CarDelegate/My Project/Settings.settings b/Code/Chapter 11/CarDelegate/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 11/CarDelegate/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 11/CarDelegate/Program.vb b/Code/Chapter 11/CarDelegate/Program.vb new file mode 100644 index 0000000..64cf276 --- /dev/null +++ b/Code/Chapter 11/CarDelegate/Program.vb @@ -0,0 +1,40 @@ +Option Explicit On +Option Strict On + +Module Program + Sub Main() + Console.WriteLine("***** Delegates as event enablers *****") + Dim c1 As New Car("SlugBug", 10) + + ' Register multiple event handlers! + c1.OnAboutToBlow(AddressOf CarAboutToBlow) + c1.OnAboutToBlow(AddressOf CarIsAlmostDoomed) + c1.OnExploded(AddressOf CarExploded) + + Console.WriteLine("***** Speeding up *****") + For i As Integer = 0 To 5 + c1.Accelerate(20) + Next + + ' Remove CarExploded from list. + c1.RemoveExploded(AddressOf CarExploded) + + ' This will not fire the Exploded event. + For i As Integer = 0 To 5 + c1.Accelerate(20) + Next + Console.ReadLine() + End Sub + + Public Sub CarAboutToBlow(ByVal msg As String) + Console.WriteLine(msg) + End Sub + + Public Sub CarIsAlmostDoomed(ByVal msg As String) + Console.WriteLine("Critical Message from Car: {0} ", msg) + End Sub + + Public Sub CarExploded(ByVal msg As String) + Console.WriteLine(msg) + End Sub +End Module diff --git a/Code/Chapter 11/CarDelegate/Radio.vb b/Code/Chapter 11/CarDelegate/Radio.vb new file mode 100644 index 0000000..4423278 --- /dev/null +++ b/Code/Chapter 11/CarDelegate/Radio.vb @@ -0,0 +1,12 @@ +Option Explicit On +Option Strict On + +Public Class Radio + Public Sub TurnOn(ByVal state As Boolean) + If state = True Then + Console.WriteLine("Jamming...") + Else + Console.WriteLine("Quiet time...") + End If + End Sub +End Class \ No newline at end of file diff --git a/Code/Chapter 11/CarDelegate/UpgradeLog.XML b/Code/Chapter 11/CarDelegate/UpgradeLog.XML new file mode 100644 index 0000000..f59a70a --- /dev/null +++ b/Code/Chapter 11/CarDelegate/UpgradeLog.XML @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 11/CarEvent/Car.vb b/Code/Chapter 11/CarEvent/Car.vb new file mode 100644 index 0000000..f51d8e5 --- /dev/null +++ b/Code/Chapter 11/CarEvent/Car.vb @@ -0,0 +1,51 @@ +Option Explicit On +Option Strict On + +Public Class Car + ' Constant for maximum speed. + Public Const maxSpeed As Integer = 100 + + 'Internal state data. + Private currSpeed As Integer + Private petName As String + + 'Is the car still operational? + Private carIsDead As Boolean + + 'A car has a radio. + Private theMusicBox As Radio = New Radio + + ' This car can send these events. + Public Event Exploded(ByVal msg As String) + Public Event AboutToBlow(ByVal msg As String) + + ' Constructors. + Public Sub New() + End Sub + Public Sub New(ByVal name As String, ByVal currSp As Integer) + currSpeed = currSp + petName = name + End Sub + + Public Sub CrankTunes(ByVal state As Boolean) + theMusicBox.TurnOn(state) + End Sub + + Public Sub Accelerate(ByVal delta As Integer) + If carIsDead Then + ' If the car is doomed, sent out the Exploded notification. + RaiseEvent Exploded("Sorry, this car is dead...") + Else + currSpeed += delta + ' Are we almost doomed? If so, send out AboutToBlow notification. + If 10 = maxSpeed - currSpeed Then + RaiseEvent AboutToBlow("Careful buddy! Gonna blow!") + End If + If currSpeed >= maxSpeed Then + carIsDead = True + Else + Console.WriteLine("->CurrSpeed = {0} ", currSpeed) + End If + End If + End Sub +End Class diff --git a/Code/Chapter 11/CarEvent/CarEvent.sln b/Code/Chapter 11/CarEvent/CarEvent.sln new file mode 100644 index 0000000..3a578bc --- /dev/null +++ b/Code/Chapter 11/CarEvent/CarEvent.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CarEvent", "CarEvent.vbproj", "{CE38E111-9BB0-42C3-8E5C-6EC4C8FC23C3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CE38E111-9BB0-42C3-8E5C-6EC4C8FC23C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CE38E111-9BB0-42C3-8E5C-6EC4C8FC23C3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CE38E111-9BB0-42C3-8E5C-6EC4C8FC23C3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CE38E111-9BB0-42C3-8E5C-6EC4C8FC23C3}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 11/CarEvent/CarEvent.suo b/Code/Chapter 11/CarEvent/CarEvent.suo new file mode 100644 index 0000000..2bf83f5 Binary files /dev/null and b/Code/Chapter 11/CarEvent/CarEvent.suo differ diff --git a/Code/Chapter 11/CarEvent/CarEvent.vbproj b/Code/Chapter 11/CarEvent/CarEvent.vbproj new file mode 100644 index 0000000..67d4484 --- /dev/null +++ b/Code/Chapter 11/CarEvent/CarEvent.vbproj @@ -0,0 +1,99 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {CE38E111-9BB0-42C3-8E5C-6EC4C8FC23C3} + Exe + CarEvent.Program + CarEvent + CarEvent + Console + + + 2.0 + + + + + true + full + true + true + bin\Debug\ + CarEvent.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + CarEvent.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/Code/Chapter 11/CarEvent/CarEvent.vbproj.user b/Code/Chapter 11/CarEvent/CarEvent.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 11/CarEvent/CarEvent.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 11/CarEvent/My Project/Application.Designer.vb b/Code/Chapter 11/CarEvent/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 11/CarEvent/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 11/CarEvent/My Project/Application.myapp b/Code/Chapter 11/CarEvent/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 11/CarEvent/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 11/CarEvent/My Project/AssemblyInfo.vb b/Code/Chapter 11/CarEvent/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..863c72c --- /dev/null +++ b/Code/Chapter 11/CarEvent/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/Code/Chapter 11/CarEvent/My Project/Resources.Designer.vb b/Code/Chapter 11/CarEvent/My Project/Resources.Designer.vb new file mode 100644 index 0000000..3ef5bf5 --- /dev/null +++ b/Code/Chapter 11/CarEvent/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("CarEvent.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/Code/Chapter 11/CarEvent/My Project/Resources.resx b/Code/Chapter 11/CarEvent/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 11/CarEvent/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/Code/Chapter 11/CarEvent/My Project/Settings.Designer.vb b/Code/Chapter 11/CarEvent/My Project/Settings.Designer.vb new file mode 100644 index 0000000..09021ba --- /dev/null +++ b/Code/Chapter 11/CarEvent/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CarEvent.My.MySettings + Get + Return Global.CarEvent.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 11/CarEvent/My Project/Settings.settings b/Code/Chapter 11/CarEvent/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 11/CarEvent/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 11/CarEvent/Program.vb b/Code/Chapter 11/CarEvent/Program.vb new file mode 100644 index 0000000..b91fd62 --- /dev/null +++ b/Code/Chapter 11/CarEvent/Program.vb @@ -0,0 +1,25 @@ +Option Explicit On +Option Strict On + +Module Program + ' Declare variables 'WithEvents' to + ' receive the outbound events. + Private WithEvents c As New Car("NightRider", 50) + + Sub Main() + Console.WriteLine("***** Fun with Events *****") + Console.WriteLine() + + Dim i As Integer + For i = 0 To 5 + c.Accelerate(10) + Next + Console.ReadLine() + End Sub + + ' Event Handlers. + Public Sub MyExplodedHandler(ByVal s As String) _ + Handles c.Exploded, c.AboutToBlow + Console.WriteLine(s) + End Sub +End Module \ No newline at end of file diff --git a/Code/Chapter 11/CarEvent/Radio.vb b/Code/Chapter 11/CarEvent/Radio.vb new file mode 100644 index 0000000..4423278 --- /dev/null +++ b/Code/Chapter 11/CarEvent/Radio.vb @@ -0,0 +1,12 @@ +Option Explicit On +Option Strict On + +Public Class Radio + Public Sub TurnOn(ByVal state As Boolean) + If state = True Then + Console.WriteLine("Jamming...") + Else + Console.WriteLine("Quiet time...") + End If + End Sub +End Class \ No newline at end of file diff --git a/Code/Chapter 11/CustomEvent/Car.vb b/Code/Chapter 11/CustomEvent/Car.vb new file mode 100644 index 0000000..ee701b8 --- /dev/null +++ b/Code/Chapter 11/CustomEvent/Car.vb @@ -0,0 +1,32 @@ +Option Explicit On +Option Strict On + +Public Class Car + ' This ArrayList will hold onto the delegates + ' sent from the caller. + Private arConnections As New ArrayList() + + ' This event has been customized! + Public Custom Event EngineStart As System.EventHandler + AddHandler(ByVal value As EventHandler) + Console.WriteLine("Added connection") + arConnections.Add(value) + End AddHandler + + RemoveHandler(ByVal value As System.EventHandler) + Console.WriteLine("Removed connection") + arConnections.Remove(value) + End RemoveHandler + + RaiseEvent(ByVal sender As Object, ByVal e As System.EventArgs) + For Each h As EventHandler In arConnections + Console.WriteLine("Raising event") + h(sender, e) + Next + End RaiseEvent + End Event + + Public Sub Start() + RaiseEvent EngineStart(Me, New EventArgs()) + End Sub +End Class diff --git a/Code/Chapter 11/CustomEvent/CarEventArgs.vb b/Code/Chapter 11/CustomEvent/CarEventArgs.vb new file mode 100644 index 0000000..41f2c49 --- /dev/null +++ b/Code/Chapter 11/CustomEvent/CarEventArgs.vb @@ -0,0 +1,11 @@ +Option Explicit On +Option Strict On + +Public Class CarEventArgs + Inherits EventArgs + + Public ReadOnly msgData As String + Public Sub New(ByVal msg As String) + msgData = msg + End Sub +End Class diff --git a/Code/Chapter 11/CustomEvent/CustomEvent.sln b/Code/Chapter 11/CustomEvent/CustomEvent.sln new file mode 100644 index 0000000..bd26e0b --- /dev/null +++ b/Code/Chapter 11/CustomEvent/CustomEvent.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CustomEvent", "CustomEvent.vbproj", "{6FC77026-E19B-46A4-9C67-3D3D66163389}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6FC77026-E19B-46A4-9C67-3D3D66163389}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6FC77026-E19B-46A4-9C67-3D3D66163389}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6FC77026-E19B-46A4-9C67-3D3D66163389}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6FC77026-E19B-46A4-9C67-3D3D66163389}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 11/CustomEvent/CustomEvent.suo b/Code/Chapter 11/CustomEvent/CustomEvent.suo new file mode 100644 index 0000000..a1de2b5 Binary files /dev/null and b/Code/Chapter 11/CustomEvent/CustomEvent.suo differ diff --git a/Code/Chapter 11/CustomEvent/CustomEvent.vbproj b/Code/Chapter 11/CustomEvent/CustomEvent.vbproj new file mode 100644 index 0000000..684da50 --- /dev/null +++ b/Code/Chapter 11/CustomEvent/CustomEvent.vbproj @@ -0,0 +1,99 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {6FC77026-E19B-46A4-9C67-3D3D66163389} + Exe + CustomEvent.Program + CustomEvent + CustomEvent + Console + + + 2.0 + + + + + true + full + true + true + bin\Debug\ + CustomEvent.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + CustomEvent.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/Code/Chapter 11/CustomEvent/CustomEvent.vbproj.user b/Code/Chapter 11/CustomEvent/CustomEvent.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 11/CustomEvent/CustomEvent.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 11/CustomEvent/My Project/Application.Designer.vb b/Code/Chapter 11/CustomEvent/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 11/CustomEvent/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 11/CustomEvent/My Project/Application.myapp b/Code/Chapter 11/CustomEvent/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 11/CustomEvent/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 11/CustomEvent/My Project/AssemblyInfo.vb b/Code/Chapter 11/CustomEvent/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..321d47d --- /dev/null +++ b/Code/Chapter 11/CustomEvent/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/Code/Chapter 11/CustomEvent/My Project/Resources.Designer.vb b/Code/Chapter 11/CustomEvent/My Project/Resources.Designer.vb new file mode 100644 index 0000000..2aa02a8 --- /dev/null +++ b/Code/Chapter 11/CustomEvent/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("CustomEvent.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/Code/Chapter 11/CustomEvent/My Project/Resources.resx b/Code/Chapter 11/CustomEvent/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 11/CustomEvent/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/Code/Chapter 11/CustomEvent/My Project/Settings.Designer.vb b/Code/Chapter 11/CustomEvent/My Project/Settings.Designer.vb new file mode 100644 index 0000000..c299bb2 --- /dev/null +++ b/Code/Chapter 11/CustomEvent/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CustomEvent.My.MySettings + Get + Return Global.CustomEvent.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 11/CustomEvent/My Project/Settings.settings b/Code/Chapter 11/CustomEvent/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 11/CustomEvent/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 11/CustomEvent/Program.vb b/Code/Chapter 11/CustomEvent/Program.vb new file mode 100644 index 0000000..21ec4ac --- /dev/null +++ b/Code/Chapter 11/CustomEvent/Program.vb @@ -0,0 +1,28 @@ +Option Explicit On +Option Strict On + +Module Program + Sub Main() + Console.WriteLine("***** Fun with Custom Events *****") + Console.WriteLine() + + Dim c As New Car() + + ' Dynamically hook into event. + AddHandler c.EngineStart, AddressOf EngineStartHandler + c.Start() + + ' Just to trigger our custom logic. + RemoveHandler c.EngineStart, AddressOf EngineStartHandler + + ' Just to test we are no longer sending event. + c.Start() + Console.ReadLine() + End Sub + + ' Our handler must match this signature given that + ' EngineStart has been prototyped using the System.EventHandler delegate. + Public Sub EngineStartHandler(ByVal sender As Object, ByVal e As EventArgs) + Console.WriteLine("Car has started") + End Sub +End Module \ No newline at end of file diff --git a/Code/Chapter 11/CustomEventWithCustomDelegate/Car.vb b/Code/Chapter 11/CustomEventWithCustomDelegate/Car.vb new file mode 100644 index 0000000..d3fd51a --- /dev/null +++ b/Code/Chapter 11/CustomEventWithCustomDelegate/Car.vb @@ -0,0 +1,35 @@ +Option Explicit On +Option Strict On + +Public Class Car + ' The custom delegate. + Public Delegate Sub CarDelegate(ByVal sender As Object, ByVal args As CarEventArgs) + + ' This ArrayList will hold onto the delegates + ' sent from the caller. + Private arConnections As New ArrayList() + + ' This event has been customized! + Public Custom Event EngineStart As CarDelegate + AddHandler(ByVal value As CarDelegate) + Console.WriteLine("Added connection") + arConnections.Add(value) + End AddHandler + + RemoveHandler(ByVal value As CarDelegate) + Console.WriteLine("Removed connection") + arConnections.Remove(value) + End RemoveHandler + + RaiseEvent(ByVal sender As Object, ByVal e As CarEventArgs) + For Each h As CarDelegate In arConnections + Console.WriteLine("Raising event") + h.Invoke(sender, e) + Next + End RaiseEvent + End Event + + Public Sub Start() + RaiseEvent EngineStart(Me, New CarEventArgs("Enjoy the ride")) + End Sub +End Class diff --git a/Code/Chapter 11/CustomEventWithCustomDelegate/CarEventArgs.vb b/Code/Chapter 11/CustomEventWithCustomDelegate/CarEventArgs.vb new file mode 100644 index 0000000..41f2c49 --- /dev/null +++ b/Code/Chapter 11/CustomEventWithCustomDelegate/CarEventArgs.vb @@ -0,0 +1,11 @@ +Option Explicit On +Option Strict On + +Public Class CarEventArgs + Inherits EventArgs + + Public ReadOnly msgData As String + Public Sub New(ByVal msg As String) + msgData = msg + End Sub +End Class diff --git a/Code/Chapter 11/CustomEventWithCustomDelegate/CustomEventWithCustomDelegate.sln b/Code/Chapter 11/CustomEventWithCustomDelegate/CustomEventWithCustomDelegate.sln new file mode 100644 index 0000000..3944fa1 --- /dev/null +++ b/Code/Chapter 11/CustomEventWithCustomDelegate/CustomEventWithCustomDelegate.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CustomEventWithCustomDelegate", "CustomEventWithCustomDelegate.vbproj", "{9154A997-3359-4893-9F01-8CE491F1F03C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9154A997-3359-4893-9F01-8CE491F1F03C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9154A997-3359-4893-9F01-8CE491F1F03C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9154A997-3359-4893-9F01-8CE491F1F03C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9154A997-3359-4893-9F01-8CE491F1F03C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 11/CustomEventWithCustomDelegate/CustomEventWithCustomDelegate.suo b/Code/Chapter 11/CustomEventWithCustomDelegate/CustomEventWithCustomDelegate.suo new file mode 100644 index 0000000..78be5ca Binary files /dev/null and b/Code/Chapter 11/CustomEventWithCustomDelegate/CustomEventWithCustomDelegate.suo differ diff --git a/Code/Chapter 11/CustomEventWithCustomDelegate/CustomEventWithCustomDelegate.vbproj b/Code/Chapter 11/CustomEventWithCustomDelegate/CustomEventWithCustomDelegate.vbproj new file mode 100644 index 0000000..e29e3c5 --- /dev/null +++ b/Code/Chapter 11/CustomEventWithCustomDelegate/CustomEventWithCustomDelegate.vbproj @@ -0,0 +1,99 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {9154A997-3359-4893-9F01-8CE491F1F03C} + Exe + CustomEventWithCustomDelegate.Program + CustomEventWithCustomDelegate + CustomEventWithCustomDelegate + Console + + + 2.0 + + + + + true + full + true + true + bin\Debug\ + CustomEventWithCustomDelegate.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + CustomEventWithCustomDelegate.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/Code/Chapter 11/CustomEventWithCustomDelegate/CustomEventWithCustomDelegate.vbproj.user b/Code/Chapter 11/CustomEventWithCustomDelegate/CustomEventWithCustomDelegate.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 11/CustomEventWithCustomDelegate/CustomEventWithCustomDelegate.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 11/CustomEventWithCustomDelegate/My Project/Application.Designer.vb b/Code/Chapter 11/CustomEventWithCustomDelegate/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 11/CustomEventWithCustomDelegate/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 11/CustomEventWithCustomDelegate/My Project/Application.myapp b/Code/Chapter 11/CustomEventWithCustomDelegate/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 11/CustomEventWithCustomDelegate/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 11/CustomEventWithCustomDelegate/My Project/AssemblyInfo.vb b/Code/Chapter 11/CustomEventWithCustomDelegate/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..31a9e2d --- /dev/null +++ b/Code/Chapter 11/CustomEventWithCustomDelegate/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/Code/Chapter 11/CustomEventWithCustomDelegate/My Project/Resources.Designer.vb b/Code/Chapter 11/CustomEventWithCustomDelegate/My Project/Resources.Designer.vb new file mode 100644 index 0000000..238492a --- /dev/null +++ b/Code/Chapter 11/CustomEventWithCustomDelegate/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("CustomEventWithCustomDelegate.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/Code/Chapter 11/CustomEventWithCustomDelegate/My Project/Resources.resx b/Code/Chapter 11/CustomEventWithCustomDelegate/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 11/CustomEventWithCustomDelegate/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/Code/Chapter 11/CustomEventWithCustomDelegate/My Project/Settings.Designer.vb b/Code/Chapter 11/CustomEventWithCustomDelegate/My Project/Settings.Designer.vb new file mode 100644 index 0000000..4cd93a9 --- /dev/null +++ b/Code/Chapter 11/CustomEventWithCustomDelegate/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CustomEventWithCustomDelegate.My.MySettings + Get + Return Global.CustomEventWithCustomDelegate.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 11/CustomEventWithCustomDelegate/My Project/Settings.settings b/Code/Chapter 11/CustomEventWithCustomDelegate/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 11/CustomEventWithCustomDelegate/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 11/CustomEventWithCustomDelegate/Program.vb b/Code/Chapter 11/CustomEventWithCustomDelegate/Program.vb new file mode 100644 index 0000000..b7a75d6 --- /dev/null +++ b/Code/Chapter 11/CustomEventWithCustomDelegate/Program.vb @@ -0,0 +1,24 @@ +Option Explicit On +Option Strict On + +Module Program + Sub Main() + Console.WriteLine("***** Fun with Custom Events *****") + Dim c As New Car() + + ' Dynamically hook into event. + AddHandler c.EngineStart, AddressOf EngineStartHandler + c.Start() + + ' Just to trigger our custom logic. + RemoveHandler c.EngineStart, AddressOf EngineStartHandler + + ' Just to test we are no longer sending event. + c.Start() + Console.ReadLine() + End Sub + + Public Sub EngineStartHandler(ByVal sender As Object, ByVal e As CarEventArgs) + Console.WriteLine("Message from {0}: {1}", sender, e.msgData) + End Sub +End Module \ No newline at end of file diff --git a/Code/Chapter 11/DynamicCarEvents/Car.vb b/Code/Chapter 11/DynamicCarEvents/Car.vb new file mode 100644 index 0000000..f51d8e5 --- /dev/null +++ b/Code/Chapter 11/DynamicCarEvents/Car.vb @@ -0,0 +1,51 @@ +Option Explicit On +Option Strict On + +Public Class Car + ' Constant for maximum speed. + Public Const maxSpeed As Integer = 100 + + 'Internal state data. + Private currSpeed As Integer + Private petName As String + + 'Is the car still operational? + Private carIsDead As Boolean + + 'A car has a radio. + Private theMusicBox As Radio = New Radio + + ' This car can send these events. + Public Event Exploded(ByVal msg As String) + Public Event AboutToBlow(ByVal msg As String) + + ' Constructors. + Public Sub New() + End Sub + Public Sub New(ByVal name As String, ByVal currSp As Integer) + currSpeed = currSp + petName = name + End Sub + + Public Sub CrankTunes(ByVal state As Boolean) + theMusicBox.TurnOn(state) + End Sub + + Public Sub Accelerate(ByVal delta As Integer) + If carIsDead Then + ' If the car is doomed, sent out the Exploded notification. + RaiseEvent Exploded("Sorry, this car is dead...") + Else + currSpeed += delta + ' Are we almost doomed? If so, send out AboutToBlow notification. + If 10 = maxSpeed - currSpeed Then + RaiseEvent AboutToBlow("Careful buddy! Gonna blow!") + End If + If currSpeed >= maxSpeed Then + carIsDead = True + Else + Console.WriteLine("->CurrSpeed = {0} ", currSpeed) + End If + End If + End Sub +End Class diff --git a/Code/Chapter 11/DynamicCarEvents/DynamicCarEvents.sln b/Code/Chapter 11/DynamicCarEvents/DynamicCarEvents.sln new file mode 100644 index 0000000..95d88ad --- /dev/null +++ b/Code/Chapter 11/DynamicCarEvents/DynamicCarEvents.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DynamicCarEvents", "DynamicCarEvents.vbproj", "{155754F2-73EA-4EB3-BEB6-6D6B8A4C6060}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {155754F2-73EA-4EB3-BEB6-6D6B8A4C6060}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {155754F2-73EA-4EB3-BEB6-6D6B8A4C6060}.Debug|Any CPU.Build.0 = Debug|Any CPU + {155754F2-73EA-4EB3-BEB6-6D6B8A4C6060}.Release|Any CPU.ActiveCfg = Release|Any CPU + {155754F2-73EA-4EB3-BEB6-6D6B8A4C6060}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 11/DynamicCarEvents/DynamicCarEvents.suo b/Code/Chapter 11/DynamicCarEvents/DynamicCarEvents.suo new file mode 100644 index 0000000..aa943a2 Binary files /dev/null and b/Code/Chapter 11/DynamicCarEvents/DynamicCarEvents.suo differ diff --git a/Code/Chapter 11/DynamicCarEvents/DynamicCarEvents.vbproj b/Code/Chapter 11/DynamicCarEvents/DynamicCarEvents.vbproj new file mode 100644 index 0000000..348ea0f --- /dev/null +++ b/Code/Chapter 11/DynamicCarEvents/DynamicCarEvents.vbproj @@ -0,0 +1,98 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {155754F2-73EA-4EB3-BEB6-6D6B8A4C6060} + Exe + DynamicCarEvents.Program + DynamicCarEvents + DynamicCarEvents + Console + + + 2.0 + + + + + true + full + true + true + bin\Debug\ + DynamicCarEvents.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + DynamicCarEvents.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + + VbMyResourcesResXFileCodeGenerator + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + \ No newline at end of file diff --git a/Code/Chapter 11/DynamicCarEvents/DynamicCarEvents.vbproj.user b/Code/Chapter 11/DynamicCarEvents/DynamicCarEvents.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 11/DynamicCarEvents/DynamicCarEvents.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 11/DynamicCarEvents/My Project/Application.Designer.vb b/Code/Chapter 11/DynamicCarEvents/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 11/DynamicCarEvents/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 11/DynamicCarEvents/My Project/Application.myapp b/Code/Chapter 11/DynamicCarEvents/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 11/DynamicCarEvents/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 11/DynamicCarEvents/My Project/AssemblyInfo.vb b/Code/Chapter 11/DynamicCarEvents/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..cc9649e --- /dev/null +++ b/Code/Chapter 11/DynamicCarEvents/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/Code/Chapter 11/DynamicCarEvents/My Project/Resources.Designer.vb b/Code/Chapter 11/DynamicCarEvents/My Project/Resources.Designer.vb new file mode 100644 index 0000000..02d4cfd --- /dev/null +++ b/Code/Chapter 11/DynamicCarEvents/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.26 +' +' 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("DynamicCarEvents.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/Code/Chapter 11/DynamicCarEvents/My Project/Resources.resx b/Code/Chapter 11/DynamicCarEvents/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 11/DynamicCarEvents/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/Code/Chapter 11/DynamicCarEvents/My Project/Settings.Designer.vb b/Code/Chapter 11/DynamicCarEvents/My Project/Settings.Designer.vb new file mode 100644 index 0000000..b03127b --- /dev/null +++ b/Code/Chapter 11/DynamicCarEvents/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.DynamicCarEvents.My.MySettings + Get + Return Global.DynamicCarEvents.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 11/DynamicCarEvents/My Project/Settings.settings b/Code/Chapter 11/DynamicCarEvents/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 11/DynamicCarEvents/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 11/DynamicCarEvents/Program.vb b/Code/Chapter 11/DynamicCarEvents/Program.vb new file mode 100644 index 0000000..d0a213d --- /dev/null +++ b/Code/Chapter 11/DynamicCarEvents/Program.vb @@ -0,0 +1,25 @@ +Option Explicit On +Option Strict On + +Module Program + Sub Main() + Console.WriteLine("***** Fun with AddHandler/RemoveHandler *****") + ' Note lack of WithEvents keyword. + Dim c As New Car("NightRider", 50) + + ' Dynamically hook into event using AddHandler. + AddHandler c.Exploded, AddressOf CarEventHandler + AddHandler c.AboutToBlow, AddressOf CarEventHandler + + For i As Integer = 0 To 5 + c.Accelerate(10) + Next + Console.ReadLine() + End Sub + + ' Event Handler for both events + '(note lack of Handles keyword). + Public Sub CarEventHandler(ByVal s As String) + Console.WriteLine(s) + End Sub +End Module diff --git a/Code/Chapter 11/DynamicCarEvents/Radio.vb b/Code/Chapter 11/DynamicCarEvents/Radio.vb new file mode 100644 index 0000000..4423278 --- /dev/null +++ b/Code/Chapter 11/DynamicCarEvents/Radio.vb @@ -0,0 +1,12 @@ +Option Explicit On +Option Strict On + +Public Class Radio + Public Sub TurnOn(ByVal state As Boolean) + If state = True Then + Console.WriteLine("Jamming...") + Else + Console.WriteLine("Quiet time...") + End If + End Sub +End Class \ No newline at end of file diff --git a/Code/Chapter 11/LambdaExpressionsMultipleParams/DelegateNoArgs.vb b/Code/Chapter 11/LambdaExpressionsMultipleParams/DelegateNoArgs.vb new file mode 100644 index 0000000..2e0a2ac --- /dev/null +++ b/Code/Chapter 11/LambdaExpressionsMultipleParams/DelegateNoArgs.vb @@ -0,0 +1,18 @@ +' VB +Option Strict On + +Public Delegate Function GetTime() As String + +Module Test + Sub LambdaNoArgs() + Console.WriteLine("***** Lambdas with No Params! *****" + vbLf) + + ' Register w/ delegate as a lambda expression. + Dim t As New GetTime(Function() DateTime.Now.ToString()) + + ' This will execute the lambda expression. + Console.WriteLine(t) + + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 11/LambdaExpressionsMultipleParams/LambdaExpressionsMultipleParams.sln b/Code/Chapter 11/LambdaExpressionsMultipleParams/LambdaExpressionsMultipleParams.sln new file mode 100644 index 0000000..d6b1300 --- /dev/null +++ b/Code/Chapter 11/LambdaExpressionsMultipleParams/LambdaExpressionsMultipleParams.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "LambdaExpressionsMultipleParams", "LambdaExpressionsMultipleParams.vbproj", "{DB047EE7-322B-450B-9B0D-986F3B923320}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DB047EE7-322B-450B-9B0D-986F3B923320}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DB047EE7-322B-450B-9B0D-986F3B923320}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DB047EE7-322B-450B-9B0D-986F3B923320}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DB047EE7-322B-450B-9B0D-986F3B923320}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 11/LambdaExpressionsMultipleParams/LambdaExpressionsMultipleParams.suo b/Code/Chapter 11/LambdaExpressionsMultipleParams/LambdaExpressionsMultipleParams.suo new file mode 100644 index 0000000..679138a Binary files /dev/null and b/Code/Chapter 11/LambdaExpressionsMultipleParams/LambdaExpressionsMultipleParams.suo differ diff --git a/Code/Chapter 11/LambdaExpressionsMultipleParams/LambdaExpressionsMultipleParams.vbproj b/Code/Chapter 11/LambdaExpressionsMultipleParams/LambdaExpressionsMultipleParams.vbproj new file mode 100644 index 0000000..3894e74 --- /dev/null +++ b/Code/Chapter 11/LambdaExpressionsMultipleParams/LambdaExpressionsMultipleParams.vbproj @@ -0,0 +1,110 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {DB047EE7-322B-450B-9B0D-986F3B923320} + Exe + LambdaExpressionsMultipleParams.Program + LambdaExpressionsMultipleParams + LambdaExpressionsMultipleParams + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + LambdaExpressionsMultipleParams.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + LambdaExpressionsMultipleParams.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + + 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/Code/Chapter 11/LambdaExpressionsMultipleParams/My Project/Application.Designer.vb b/Code/Chapter 11/LambdaExpressionsMultipleParams/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 11/LambdaExpressionsMultipleParams/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 11/LambdaExpressionsMultipleParams/My Project/Application.myapp b/Code/Chapter 11/LambdaExpressionsMultipleParams/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 11/LambdaExpressionsMultipleParams/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 11/LambdaExpressionsMultipleParams/My Project/AssemblyInfo.vb b/Code/Chapter 11/LambdaExpressionsMultipleParams/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..80220f9 --- /dev/null +++ b/Code/Chapter 11/LambdaExpressionsMultipleParams/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/Code/Chapter 11/LambdaExpressionsMultipleParams/My Project/Resources.Designer.vb b/Code/Chapter 11/LambdaExpressionsMultipleParams/My Project/Resources.Designer.vb new file mode 100644 index 0000000..4afc99a --- /dev/null +++ b/Code/Chapter 11/LambdaExpressionsMultipleParams/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("LambdaExpressionsMultipleParams.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/Code/Chapter 11/LambdaExpressionsMultipleParams/My Project/Resources.resx b/Code/Chapter 11/LambdaExpressionsMultipleParams/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 11/LambdaExpressionsMultipleParams/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/Code/Chapter 11/LambdaExpressionsMultipleParams/My Project/Settings.Designer.vb b/Code/Chapter 11/LambdaExpressionsMultipleParams/My Project/Settings.Designer.vb new file mode 100644 index 0000000..fe15ae7 --- /dev/null +++ b/Code/Chapter 11/LambdaExpressionsMultipleParams/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.LambdaExpressionsMultipleParams.My.MySettings + Get + Return Global.LambdaExpressionsMultipleParams.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 11/LambdaExpressionsMultipleParams/My Project/Settings.settings b/Code/Chapter 11/LambdaExpressionsMultipleParams/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 11/LambdaExpressionsMultipleParams/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 11/LambdaExpressionsMultipleParams/Program.vb b/Code/Chapter 11/LambdaExpressionsMultipleParams/Program.vb new file mode 100644 index 0000000..2bf5d5c --- /dev/null +++ b/Code/Chapter 11/LambdaExpressionsMultipleParams/Program.vb @@ -0,0 +1,40 @@ +' VB +Option Strict On + +Public Delegate Function BinaryOp(ByVal x As Integer, ByVal y As Integer) As Integer + +#Region "Simple Math" +Public Class SimpleMath + Public Function Add(ByVal x As Integer, ByVal y As Integer) As Integer + Return x + y + End Function + Public Function Subtract(ByVal x As Integer, _ + ByVal y As Integer) As Integer + Return x - y + End Function +End Class +#End Region + +Module Program + Sub Main() + Console.WriteLine("***** Lambdas with Multiple Params! *****") + + ' Register w/ delegate as a lambda expression. + Dim b As New BinaryOp(Function(x, y) x + y) + + ' What method is b pointing to? + DisplayDelegateInfo(b) + + Console.WriteLine(b(10, 10)) + Console.ReadLine() + End Sub + + Sub DisplayDelegateInfo(ByVal delObj As System.Delegate) + For Each d As System.Delegate In delObj.GetInvocationList() + Console.WriteLine("Method Name: {0}", d.Method) + Console.WriteLine("Type Name: {0}", d.Target) + Next + End Sub +End Module + + diff --git a/Code/Chapter 11/PrimAndProperEvent/Car.vb b/Code/Chapter 11/PrimAndProperEvent/Car.vb new file mode 100644 index 0000000..c7585d7 --- /dev/null +++ b/Code/Chapter 11/PrimAndProperEvent/Car.vb @@ -0,0 +1,51 @@ +Option Explicit On +Option Strict On + +Public Class Car + ' Constant for maximum speed. + Public Const maxSpeed As Integer = 100 + + 'Internal state data. + Private currSpeed As Integer + Private petName As String + + 'Is the car still operational? + Private carIsDead As Boolean + + 'A car has a radio. + Private theMusicBox As Radio = New Radio + + ' This car can send these events. + Public Event Exploded(ByVal sender As Object, ByVal e As CarEventArgs) + Public Event AboutToBlow(ByVal sender As Object, ByVal e As CarEventArgs) + + ' Constructors. + Public Sub New() + End Sub + Public Sub New(ByVal name As String, ByVal currSp As Integer) + currSpeed = currSp + petName = name + End Sub + + Public Sub CrankTunes(ByVal state As Boolean) + theMusicBox.TurnOn(state) + End Sub + + Public Sub Accelerate(ByVal delta As Integer) + If carIsDead Then + ' If the car is doomed, sent out the Exploded notification. + RaiseEvent Exploded(Me, New CarEventArgs("This car is doomed...")) + Else + currSpeed += delta + ' Are we almost doomed? If so, send out AboutToBlow notification. + If 10 = maxSpeed - currSpeed Then + RaiseEvent AboutToBlow(Me, New CarEventArgs("Slow down!")) + End If + If currSpeed >= maxSpeed Then + carIsDead = True + Else + Console.WriteLine("->CurrSpeed = {0} ", currSpeed) + End If + End If + End Sub +End Class diff --git a/Code/Chapter 11/PrimAndProperEvent/CarEventArgs.vb b/Code/Chapter 11/PrimAndProperEvent/CarEventArgs.vb new file mode 100644 index 0000000..41f2c49 --- /dev/null +++ b/Code/Chapter 11/PrimAndProperEvent/CarEventArgs.vb @@ -0,0 +1,11 @@ +Option Explicit On +Option Strict On + +Public Class CarEventArgs + Inherits EventArgs + + Public ReadOnly msgData As String + Public Sub New(ByVal msg As String) + msgData = msg + End Sub +End Class diff --git a/Code/Chapter 11/PrimAndProperEvent/My Project/Application.Designer.vb b/Code/Chapter 11/PrimAndProperEvent/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 11/PrimAndProperEvent/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 11/PrimAndProperEvent/My Project/Application.myapp b/Code/Chapter 11/PrimAndProperEvent/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 11/PrimAndProperEvent/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 11/PrimAndProperEvent/My Project/AssemblyInfo.vb b/Code/Chapter 11/PrimAndProperEvent/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..36458b7 --- /dev/null +++ b/Code/Chapter 11/PrimAndProperEvent/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/Code/Chapter 11/PrimAndProperEvent/My Project/Resources.Designer.vb b/Code/Chapter 11/PrimAndProperEvent/My Project/Resources.Designer.vb new file mode 100644 index 0000000..625dc2f --- /dev/null +++ b/Code/Chapter 11/PrimAndProperEvent/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("PrimAndProperEvent.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/Code/Chapter 11/PrimAndProperEvent/My Project/Resources.resx b/Code/Chapter 11/PrimAndProperEvent/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 11/PrimAndProperEvent/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/Code/Chapter 11/PrimAndProperEvent/My Project/Settings.Designer.vb b/Code/Chapter 11/PrimAndProperEvent/My Project/Settings.Designer.vb new file mode 100644 index 0000000..31462a0 --- /dev/null +++ b/Code/Chapter 11/PrimAndProperEvent/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.PrimAndProperEvent.My.MySettings + Get + Return Global.PrimAndProperEvent.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 11/PrimAndProperEvent/My Project/Settings.settings b/Code/Chapter 11/PrimAndProperEvent/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 11/PrimAndProperEvent/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 11/PrimAndProperEvent/PrimAndProperEvent.sln b/Code/Chapter 11/PrimAndProperEvent/PrimAndProperEvent.sln new file mode 100644 index 0000000..7672cf8 --- /dev/null +++ b/Code/Chapter 11/PrimAndProperEvent/PrimAndProperEvent.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "PrimAndProperEvent", "PrimAndProperEvent.vbproj", "{CA29623D-C199-4347-B973-D675B8A92867}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CA29623D-C199-4347-B973-D675B8A92867}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CA29623D-C199-4347-B973-D675B8A92867}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CA29623D-C199-4347-B973-D675B8A92867}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CA29623D-C199-4347-B973-D675B8A92867}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 11/PrimAndProperEvent/PrimAndProperEvent.suo b/Code/Chapter 11/PrimAndProperEvent/PrimAndProperEvent.suo new file mode 100644 index 0000000..d4e4209 Binary files /dev/null and b/Code/Chapter 11/PrimAndProperEvent/PrimAndProperEvent.suo differ diff --git a/Code/Chapter 11/PrimAndProperEvent/PrimAndProperEvent.vbproj b/Code/Chapter 11/PrimAndProperEvent/PrimAndProperEvent.vbproj new file mode 100644 index 0000000..2edd03f --- /dev/null +++ b/Code/Chapter 11/PrimAndProperEvent/PrimAndProperEvent.vbproj @@ -0,0 +1,100 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {CA29623D-C199-4347-B973-D675B8A92867} + Exe + PrimAndProperEvent.Program + PrimAndProperEvent + PrimAndProperEvent + Console + + + 2.0 + + + + + true + full + true + true + bin\Debug\ + PrimAndProperEvent.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + PrimAndProperEvent.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/Code/Chapter 11/PrimAndProperEvent/PrimAndProperEvent.vbproj.user b/Code/Chapter 11/PrimAndProperEvent/PrimAndProperEvent.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 11/PrimAndProperEvent/PrimAndProperEvent.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 11/PrimAndProperEvent/Program.vb b/Code/Chapter 11/PrimAndProperEvent/Program.vb new file mode 100644 index 0000000..80605da --- /dev/null +++ b/Code/Chapter 11/PrimAndProperEvent/Program.vb @@ -0,0 +1,32 @@ +Option Explicit On +Option Strict On + +Module Program + Sub Main() + Console.WriteLine("***** Fun with Prim and Proper Events *****") + Dim c As New Car("NightRider", 50) + + ' Dynamically hook into event using AddressOf. + AddHandler c.Exploded, AddressOf ExplodedHandler + AddHandler c.AboutToBlow, AddressOf AboutToBlowHandler + + For i As Integer = 0 To 5 + c.Accelerate(10) + Next + Console.ReadLine() + End Sub + + ' Event Handler for both events + '(note lack of Handles keyword). + Public Sub AboutToBlowHandler(ByVal sender As Object, ByVal e As CarEventArgs) + Console.WriteLine("{0} says: {1}", sender, e.msgData) + End Sub + + Public Sub ExplodedHandler(ByVal sender As Object, ByVal e As CarEventArgs) + If TypeOf sender Is Car Then + Dim c As Car = CType(sender, Car) + c.CrankTunes(False) + End If + Console.WriteLine("Critical message from {0}: {1}", sender, e.msgData) + End Sub +End Module \ No newline at end of file diff --git a/Code/Chapter 11/PrimAndProperEvent/Radio.vb b/Code/Chapter 11/PrimAndProperEvent/Radio.vb new file mode 100644 index 0000000..4423278 --- /dev/null +++ b/Code/Chapter 11/PrimAndProperEvent/Radio.vb @@ -0,0 +1,12 @@ +Option Explicit On +Option Strict On + +Public Class Radio + Public Sub TurnOn(ByVal state As Boolean) + If state = True Then + Console.WriteLine("Jamming...") + Else + Console.WriteLine("Quiet time...") + End If + End Sub +End Class \ No newline at end of file diff --git a/Code/Chapter 11/SimpleDelegate/My Project/Application.Designer.vb b/Code/Chapter 11/SimpleDelegate/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 11/SimpleDelegate/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 11/SimpleDelegate/My Project/Application.myapp b/Code/Chapter 11/SimpleDelegate/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 11/SimpleDelegate/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 11/SimpleDelegate/My Project/AssemblyInfo.vb b/Code/Chapter 11/SimpleDelegate/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..90f0555 --- /dev/null +++ b/Code/Chapter 11/SimpleDelegate/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/Code/Chapter 11/SimpleDelegate/My Project/Resources.Designer.vb b/Code/Chapter 11/SimpleDelegate/My Project/Resources.Designer.vb new file mode 100644 index 0000000..79ad88d --- /dev/null +++ b/Code/Chapter 11/SimpleDelegate/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("SimpleDelegate.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/Code/Chapter 11/SimpleDelegate/My Project/Resources.resx b/Code/Chapter 11/SimpleDelegate/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 11/SimpleDelegate/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/Code/Chapter 11/SimpleDelegate/My Project/Settings.Designer.vb b/Code/Chapter 11/SimpleDelegate/My Project/Settings.Designer.vb new file mode 100644 index 0000000..92dd7e4 --- /dev/null +++ b/Code/Chapter 11/SimpleDelegate/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SimpleDelegate.My.MySettings + Get + Return Global.SimpleDelegate.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 11/SimpleDelegate/My Project/Settings.settings b/Code/Chapter 11/SimpleDelegate/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 11/SimpleDelegate/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 11/SimpleDelegate/Program.vb b/Code/Chapter 11/SimpleDelegate/Program.vb new file mode 100644 index 0000000..b378105 --- /dev/null +++ b/Code/Chapter 11/SimpleDelegate/Program.vb @@ -0,0 +1,49 @@ +Option Explicit On +Option Strict On + +' Our delegate type can point to any method +' taking two integers and returning an integer. +Public Delegate Function BinaryOp(ByVal x As Integer, ByVal y As Integer) As Integer + +#Region "SimpleMath type" +' This class defines the methods which will be 'pointed to' by the delegate. +Public Class SimpleMath + Public Function Add(ByVal x As Integer, ByVal y As Integer) As Integer + Return x + y + End Function + Public Function Subtract(ByVal x As Integer, ByVal y As Integer) As Integer + Return x - y + End Function + Public Function SquareNumber(ByVal a As Integer) As Integer + Return a * a + End Function +End Class +#End Region + +Module Program + Sub Main() + Console.WriteLine("***** Simple Delegate Example *****" & vbLf) + + Dim myMath As New SimpleMath() + + ' Make a delegate object and add a method to the invocation + ' list using the AddressOf keyword. + Dim b As BinaryOp = New BinaryOp(AddressOf myMath.Add) + + ' Invoke the method 'pointed to' + Console.WriteLine("10 + 10 is {0} ", b.Invoke(10, 10)) + DisplayDelegateInfo(b) + + ' This is a compiler error! + ' Dim b2 As BinaryOp = New BinaryOp(AddressOf myMath.SquareNumber) + + Console.ReadLine() + End Sub + + Sub DisplayDelegateInfo(ByVal delObj As System.Delegate) + For Each d As System.Delegate In delObj.GetInvocationList() + Console.WriteLine("Method Name: {0} ", d.Method) + Console.WriteLine("Type Name: {0} ", d.Target) + Next + End Sub +End Module diff --git a/Code/Chapter 11/SimpleDelegate/SimpleDelegate.sln b/Code/Chapter 11/SimpleDelegate/SimpleDelegate.sln new file mode 100644 index 0000000..ecc5e57 --- /dev/null +++ b/Code/Chapter 11/SimpleDelegate/SimpleDelegate.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SimpleDelegate", "SimpleDelegate.vbproj", "{D2A09CCA-789A-4F2D-95A7-A823A64E6BD3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D2A09CCA-789A-4F2D-95A7-A823A64E6BD3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D2A09CCA-789A-4F2D-95A7-A823A64E6BD3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D2A09CCA-789A-4F2D-95A7-A823A64E6BD3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D2A09CCA-789A-4F2D-95A7-A823A64E6BD3}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 11/SimpleDelegate/SimpleDelegate.suo b/Code/Chapter 11/SimpleDelegate/SimpleDelegate.suo new file mode 100644 index 0000000..54f786e Binary files /dev/null and b/Code/Chapter 11/SimpleDelegate/SimpleDelegate.suo differ diff --git a/Code/Chapter 11/SimpleDelegate/SimpleDelegate.vbproj b/Code/Chapter 11/SimpleDelegate/SimpleDelegate.vbproj new file mode 100644 index 0000000..770c585 --- /dev/null +++ b/Code/Chapter 11/SimpleDelegate/SimpleDelegate.vbproj @@ -0,0 +1,97 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {D2A09CCA-789A-4F2D-95A7-A823A64E6BD3} + Exe + SimpleDelegate.Program + SimpleDelegate + SimpleDelegate + Console + + + 2.0 + + + + + true + full + true + true + bin\Debug\ + SimpleDelegate.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SimpleDelegate.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/Code/Chapter 11/SimpleDelegate/SimpleDelegate.vbproj.user b/Code/Chapter 11/SimpleDelegate/SimpleDelegate.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 11/SimpleDelegate/SimpleDelegate.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 11/SimpleLambdaExpressions/My Project/Application.Designer.vb b/Code/Chapter 11/SimpleLambdaExpressions/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 11/SimpleLambdaExpressions/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 11/SimpleLambdaExpressions/My Project/Application.myapp b/Code/Chapter 11/SimpleLambdaExpressions/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 11/SimpleLambdaExpressions/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 11/SimpleLambdaExpressions/My Project/AssemblyInfo.vb b/Code/Chapter 11/SimpleLambdaExpressions/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..e378f3d --- /dev/null +++ b/Code/Chapter 11/SimpleLambdaExpressions/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/Code/Chapter 11/SimpleLambdaExpressions/My Project/Resources.Designer.vb b/Code/Chapter 11/SimpleLambdaExpressions/My Project/Resources.Designer.vb new file mode 100644 index 0000000..472ed05 --- /dev/null +++ b/Code/Chapter 11/SimpleLambdaExpressions/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("SimpleLambdaExpressions.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/Code/Chapter 11/SimpleLambdaExpressions/My Project/Resources.resx b/Code/Chapter 11/SimpleLambdaExpressions/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 11/SimpleLambdaExpressions/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/Code/Chapter 11/SimpleLambdaExpressions/My Project/Settings.Designer.vb b/Code/Chapter 11/SimpleLambdaExpressions/My Project/Settings.Designer.vb new file mode 100644 index 0000000..332b987 --- /dev/null +++ b/Code/Chapter 11/SimpleLambdaExpressions/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SimpleLambdaExpressions.My.MySettings + Get + Return Global.SimpleLambdaExpressions.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 11/SimpleLambdaExpressions/My Project/Settings.settings b/Code/Chapter 11/SimpleLambdaExpressions/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 11/SimpleLambdaExpressions/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 11/SimpleLambdaExpressions/Program.vb b/Code/Chapter 11/SimpleLambdaExpressions/Program.vb new file mode 100644 index 0000000..e522821 --- /dev/null +++ b/Code/Chapter 11/SimpleLambdaExpressions/Program.vb @@ -0,0 +1,52 @@ +Option Strict On + +Module Program + Sub Main() + Console.WriteLine("***** Fun with Lambdas *****") + TraditionalDelegateSyntax() + LambdaExpressionSyntax() + Console.ReadLine() + End Sub + +#Region "Traditional delegate syntax" + Sub TraditionalDelegateSyntax() + Dim list As New List(Of Integer)() + list.AddRange(New Integer() {20, 1, 4, 8, 9, 44}) + + ' Create a Predicate(Of T) object for use by the List(Of T).FindAll() method. + Dim callback As New Predicate(Of Integer)(AddressOf IsEvenNumber) + + ' Call FindAll() passing the delegate object. + Dim evenNumbers As List(Of Integer) = list.FindAll(callback) + + ' Print out the result set. + Console.WriteLine("Here are the even numbers:") + For Each evenNumber As Integer In evenNumbers + Console.WriteLine(evenNumber) + Next + End Sub + + ' Target for the Predicate(Of T) delegate. + Function IsEvenNumber(ByVal i As Integer) As Boolean + ' Is it an even number? + Return (i Mod 2) = 0 + End Function +#End Region + +#Region "Lambda expression syntax" + Sub LambdaExpressionSyntax() + Dim list As New List(Of Integer)() + list.AddRange(New Integer() {20, 1, 4, 8, 9, 44}) + + ' Call FindAll() using a VB lambda. + Dim evenNumbers As List(Of Integer) = list.FindAll(Function(i As Integer) (i Mod 2) = 0) + + ' Print out the result set. + Console.WriteLine("Here are the even numbers:") + For Each evenNumber As Integer In evenNumbers + Console.WriteLine(evenNumber) + Next + End Sub +#End Region + +End Module diff --git a/Code/Chapter 11/SimpleLambdaExpressions/SimpleLambdaExpressions.sln b/Code/Chapter 11/SimpleLambdaExpressions/SimpleLambdaExpressions.sln new file mode 100644 index 0000000..0013175 --- /dev/null +++ b/Code/Chapter 11/SimpleLambdaExpressions/SimpleLambdaExpressions.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SimpleLambdaExpressions", "SimpleLambdaExpressions.vbproj", "{8FDD0491-247A-41D7-A899-55B0B7518A4A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8FDD0491-247A-41D7-A899-55B0B7518A4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8FDD0491-247A-41D7-A899-55B0B7518A4A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8FDD0491-247A-41D7-A899-55B0B7518A4A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8FDD0491-247A-41D7-A899-55B0B7518A4A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 11/SimpleLambdaExpressions/SimpleLambdaExpressions.suo b/Code/Chapter 11/SimpleLambdaExpressions/SimpleLambdaExpressions.suo new file mode 100644 index 0000000..c8fd8c2 Binary files /dev/null and b/Code/Chapter 11/SimpleLambdaExpressions/SimpleLambdaExpressions.suo differ diff --git a/Code/Chapter 11/SimpleLambdaExpressions/SimpleLambdaExpressions.vbproj b/Code/Chapter 11/SimpleLambdaExpressions/SimpleLambdaExpressions.vbproj new file mode 100644 index 0000000..fc430a7 --- /dev/null +++ b/Code/Chapter 11/SimpleLambdaExpressions/SimpleLambdaExpressions.vbproj @@ -0,0 +1,109 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {8FDD0491-247A-41D7-A899-55B0B7518A4A} + Exe + SimpleLambdaExpressions.Program + SimpleLambdaExpressions + SimpleLambdaExpressions + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + SimpleLambdaExpressions.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SimpleLambdaExpressions.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 12/Casting/Casting.sln b/Code/Chapter 12/Casting/Casting.sln new file mode 100644 index 0000000..478ea57 --- /dev/null +++ b/Code/Chapter 12/Casting/Casting.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Casting", "Casting.vbproj", "{D7CBEBE0-668C-4DEA-9ACC-83F31E2B41E8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D7CBEBE0-668C-4DEA-9ACC-83F31E2B41E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D7CBEBE0-668C-4DEA-9ACC-83F31E2B41E8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D7CBEBE0-668C-4DEA-9ACC-83F31E2B41E8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D7CBEBE0-668C-4DEA-9ACC-83F31E2B41E8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 12/Casting/Casting.suo b/Code/Chapter 12/Casting/Casting.suo new file mode 100644 index 0000000..58a049b Binary files /dev/null and b/Code/Chapter 12/Casting/Casting.suo differ diff --git a/Code/Chapter 12/Casting/Casting.vbproj b/Code/Chapter 12/Casting/Casting.vbproj new file mode 100644 index 0000000..8562a03 --- /dev/null +++ b/Code/Chapter 12/Casting/Casting.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {D7CBEBE0-668C-4DEA-9ACC-83F31E2B41E8} + Exe + Casting.Program + Casting + Casting + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + Casting.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + Casting.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 12/Casting/Casting.vbproj.user b/Code/Chapter 12/Casting/Casting.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 12/Casting/Casting.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 12/Casting/My Project/Application.Designer.vb b/Code/Chapter 12/Casting/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 12/Casting/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 12/Casting/My Project/Application.myapp b/Code/Chapter 12/Casting/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 12/Casting/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 12/Casting/My Project/AssemblyInfo.vb b/Code/Chapter 12/Casting/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..b1d4355 --- /dev/null +++ b/Code/Chapter 12/Casting/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/Code/Chapter 12/Casting/My Project/Resources.Designer.vb b/Code/Chapter 12/Casting/My Project/Resources.Designer.vb new file mode 100644 index 0000000..08d0526 --- /dev/null +++ b/Code/Chapter 12/Casting/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("Casting.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/Code/Chapter 12/Casting/My Project/Resources.resx b/Code/Chapter 12/Casting/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 12/Casting/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/Code/Chapter 12/Casting/My Project/Settings.Designer.vb b/Code/Chapter 12/Casting/My Project/Settings.Designer.vb new file mode 100644 index 0000000..84bfc10 --- /dev/null +++ b/Code/Chapter 12/Casting/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.Casting.My.MySettings + Get + Return Global.Casting.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 12/Casting/My Project/Settings.settings b/Code/Chapter 12/Casting/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 12/Casting/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 12/Casting/Program.vb b/Code/Chapter 12/Casting/Program.vb new file mode 100644 index 0000000..0ec930a --- /dev/null +++ b/Code/Chapter 12/Casting/Program.vb @@ -0,0 +1,63 @@ +Option Explicit On +Option Strict On + +#Region "Helper types for testing" +Interface ITurboBoost + Sub TurboCharge(ByVal onOff As Boolean) +End Interface + +Class Car +End Class + +Class SportsCar + Inherits Car + Implements ITurboBoost + Public Sub TurboCharge(ByVal onOff As Boolean) _ + Implements ITurboBoost.TurboCharge + End Sub +End Class +#End Region + +Module Program + Sub Main() + Console.WriteLine("***** Fun with CType / DirectCast / TryCast ******" & vbLf) + + Dim myCar As New Car + Dim iTB As ITurboBoost + + ' CType()throws + ' exceptions if the types are not compatible. + Try + iTB = CType(myCar, ITurboBoost) + Catch ex As InvalidCastException + Console.WriteLine(ex.Message) + Console.WriteLine() + End Try + + + ' CType() can also be used to narrow or widen + ' between primitive types. + Dim i As Integer = 200 + Dim b As Byte = CType(i, Byte) + + ' Like CType(), DirectCast() throws + ' exceptions if the types are not compatible. + Dim myViper As New SportsCar + Try + iTB = DirectCast(myViper, ITurboBoost) + Catch ex As Exception + Console.WriteLine(ex.Message) + Console.WriteLine() + End Try + + ' TryCast() returns Nothing if the types are not + ' compatible. + Dim c As Car = TryCast(myViper, Car) + If c Is Nothing Then + Console.WriteLine("Sorry, types are not compatable...") + Else + Console.WriteLine(c.ToString()) + End If + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 12/CustomConversions/CustomConversions.sln b/Code/Chapter 12/CustomConversions/CustomConversions.sln new file mode 100644 index 0000000..a93bdf6 --- /dev/null +++ b/Code/Chapter 12/CustomConversions/CustomConversions.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CustomConversions", "CustomConversions.vbproj", "{CFD8B745-3CEE-48C5-BE3D-93EB8930728E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CFD8B745-3CEE-48C5-BE3D-93EB8930728E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CFD8B745-3CEE-48C5-BE3D-93EB8930728E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CFD8B745-3CEE-48C5-BE3D-93EB8930728E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CFD8B745-3CEE-48C5-BE3D-93EB8930728E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 12/CustomConversions/CustomConversions.suo b/Code/Chapter 12/CustomConversions/CustomConversions.suo new file mode 100644 index 0000000..be95ccf Binary files /dev/null and b/Code/Chapter 12/CustomConversions/CustomConversions.suo differ diff --git a/Code/Chapter 12/CustomConversions/CustomConversions.vbproj b/Code/Chapter 12/CustomConversions/CustomConversions.vbproj new file mode 100644 index 0000000..f713cb1 --- /dev/null +++ b/Code/Chapter 12/CustomConversions/CustomConversions.vbproj @@ -0,0 +1,137 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {CFD8B745-3CEE-48C5-BE3D-93EB8930728E} + Exe + CustomConversions.Program + CustomConversions + CustomConversions + Console + + + 2.0 + + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + v3.5 + + + true + full + true + true + bin\Debug\ + CustomConversions.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + pdbonly + false + true + true + bin\Release\ + CustomConversions.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 12/CustomConversions/CustomConversions.vbproj.user b/Code/Chapter 12/CustomConversions/CustomConversions.vbproj.user new file mode 100644 index 0000000..71ff977 --- /dev/null +++ b/Code/Chapter 12/CustomConversions/CustomConversions.vbproj.user @@ -0,0 +1,16 @@ + + + http://localhost/CustomConversions/ + + + + + + + + + en-US + true + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 12/CustomConversions/My Project/Application.Designer.vb b/Code/Chapter 12/CustomConversions/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 12/CustomConversions/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 12/CustomConversions/My Project/Application.myapp b/Code/Chapter 12/CustomConversions/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 12/CustomConversions/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 12/CustomConversions/My Project/AssemblyInfo.vb b/Code/Chapter 12/CustomConversions/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..68f75d5 --- /dev/null +++ b/Code/Chapter 12/CustomConversions/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/Code/Chapter 12/CustomConversions/My Project/Resources.Designer.vb b/Code/Chapter 12/CustomConversions/My Project/Resources.Designer.vb new file mode 100644 index 0000000..8720fa0 --- /dev/null +++ b/Code/Chapter 12/CustomConversions/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("CustomConversions.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/Code/Chapter 12/CustomConversions/My Project/Resources.resx b/Code/Chapter 12/CustomConversions/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 12/CustomConversions/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/Code/Chapter 12/CustomConversions/My Project/Settings.Designer.vb b/Code/Chapter 12/CustomConversions/My Project/Settings.Designer.vb new file mode 100644 index 0000000..e40f0e6 --- /dev/null +++ b/Code/Chapter 12/CustomConversions/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CustomConversions.My.MySettings + Get + Return Global.CustomConversions.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 12/CustomConversions/My Project/Settings.settings b/Code/Chapter 12/CustomConversions/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 12/CustomConversions/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 12/CustomConversions/MyTypes.vb b/Code/Chapter 12/CustomConversions/MyTypes.vb new file mode 100644 index 0000000..0ff49ae --- /dev/null +++ b/Code/Chapter 12/CustomConversions/MyTypes.vb @@ -0,0 +1,62 @@ +Option Explicit On +Option Strict On + +#Region "The Rectangle" +Public Structure Rectangle + ' Public for ease of use; + ' however, feel free to encapsulate with properties. + Public Width As Integer, Height As Integer + Public Sub Draw() + Console.WriteLine("Drawing a rect.") + End Sub + Public Overloads Overrides Function ToString() As String + Return String.Format("[Width = {0}; Height = {1}]", Width, Height) + End Function + + Public Shared Widening Operator CType(ByVal s As Square) As Rectangle + Dim r As Rectangle + r.Height = s.Length + + ' Assume the length of the new Rectangle with + ' (Length x 2) + r.Width = s.Length * 2 + Return r + End Operator +End Structure +#End Region + +#Region "The Square" +Public Structure Square + Public Length As Integer + Public Sub Draw() + Console.WriteLine("Drawing a square.") + End Sub + Public Overloads Overrides Function ToString() As String + Return String.Format("[Length = {0}]", Length) + End Function + + ' Rectangles can be explicitly converted + ' into Squares. + Public Shared Narrowing Operator CType(ByVal r As Rectangle) As Square + Dim s As Square + s.Length = r.Width + Return s + End Operator + + ' Can call as: + ' Dim sq2 As Square = CType(90, Square) + ' or as: + ' Dim sq2 As Square = 90 + Public Shared Widening Operator CType(ByVal sideLength As Integer) As Square + Dim newSq As Square + newSq.Length = sideLength + Return newSq + End Operator + + ' Must call as: + ' Dim side As Integer = CType(mySquare, Square) + Public Shared Narrowing Operator CType(ByVal s As Square) As Integer + Return s.Length + End Operator +End Structure +#End Region diff --git a/Code/Chapter 12/CustomConversions/Program.vb b/Code/Chapter 12/CustomConversions/Program.vb new file mode 100644 index 0000000..c0bdb03 --- /dev/null +++ b/Code/Chapter 12/CustomConversions/Program.vb @@ -0,0 +1,40 @@ +Option Explicit On +Option Strict On + +Module Program + Sub Main() + Console.WriteLine("***** Fun with Custom Conversions *****") + Console.WriteLine() + + ' Create a 5 * 10 Rectangle. + Dim rect As Rectangle + rect.Width = 10 + rect.Height = 5 + Console.WriteLine("rect = {0} ", rect) + + DrawSquare(CType(rect, Square)) + + ' Convert Rectangle to a 10 * 10 Square. + Dim sq As Square = CType(rect, Square) + Console.WriteLine("sq = {0} ", sq) + + ' Implicit cast OK! + Dim s3 As Square + s3.Length = 83 + Dim rect2 As Rectangle = s3 + Console.WriteLine("rect2 = {0}", rect2) + DrawSquare(s3) + + ' Explicit cast syntax still OK! + Dim s4 As Square + s4.Length = 3 + Dim rect3 As Rectangle = CType(s4, Rectangle) + Console.WriteLine("rect3 = {0}", rect3) + Console.ReadLine() + End Sub + + ' This method requires a Square type. + Sub DrawSquare(ByVal sq As Square) + sq.Draw() + End Sub +End Module diff --git a/Code/Chapter 12/OverloadedOps/My Project/Application.Designer.vb b/Code/Chapter 12/OverloadedOps/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 12/OverloadedOps/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 12/OverloadedOps/My Project/Application.myapp b/Code/Chapter 12/OverloadedOps/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 12/OverloadedOps/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 12/OverloadedOps/My Project/AssemblyInfo.vb b/Code/Chapter 12/OverloadedOps/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..a03ccc6 --- /dev/null +++ b/Code/Chapter 12/OverloadedOps/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/Code/Chapter 12/OverloadedOps/My Project/Resources.Designer.vb b/Code/Chapter 12/OverloadedOps/My Project/Resources.Designer.vb new file mode 100644 index 0000000..4d7e8ff --- /dev/null +++ b/Code/Chapter 12/OverloadedOps/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("OverloadedOps.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/Code/Chapter 12/OverloadedOps/My Project/Resources.resx b/Code/Chapter 12/OverloadedOps/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 12/OverloadedOps/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/Code/Chapter 12/OverloadedOps/My Project/Settings.Designer.vb b/Code/Chapter 12/OverloadedOps/My Project/Settings.Designer.vb new file mode 100644 index 0000000..31f47da --- /dev/null +++ b/Code/Chapter 12/OverloadedOps/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.OverloadedOps.My.MySettings + Get + Return Global.OverloadedOps.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 12/OverloadedOps/My Project/Settings.settings b/Code/Chapter 12/OverloadedOps/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 12/OverloadedOps/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 12/OverloadedOps/MyPoint.vb b/Code/Chapter 12/OverloadedOps/MyPoint.vb new file mode 100644 index 0000000..6658632 --- /dev/null +++ b/Code/Chapter 12/OverloadedOps/MyPoint.vb @@ -0,0 +1,96 @@ +Public Structure MyPoint + Implements IComparable + Private x As Integer, y As Integer + + Public Sub New(ByVal xPos As Integer, ByVal yPos As Integer) + x = xPos + y = yPos + End Sub + + Public Overrides Function ToString() As String + Return String.Format("[{0}, {1}]", Me.x, Me.y) + End Function + +#Region "Add/Subtract methods" + ' Adding two MyPoint objects to yeild a new (larger) MyPoint. + Public Shared Function Add(ByVal p1 As MyPoint, ByVal p2 As MyPoint) As MyPoint + Return New MyPoint(p1.x + p2.x, p1.y + p2.y) + End Function + + ' Subtracting two MyPoint objects to yeild a new (smaller) MyPoint. + Public Shared Function Subtract(ByVal p1 As MyPoint, ByVal p2 As MyPoint) As MyPoint + Return New MyPoint(p1.x - p2.x, p1.y - p2.y) + End Function +#End Region + +#Region "Overloaded + and - Operators" + ' Overloaded operator +. + Public Shared Operator +(ByVal p1 As MyPoint, ByVal p2 As MyPoint) As MyPoint + Return New MyPoint(p1.x + p2.x, p1.y + p2.y) + End Operator + + ' Overloaded operator -. + Public Shared Operator -(ByVal p1 As MyPoint, ByVal p2 As MyPoint) As MyPoint + Return New MyPoint(p1.x - p2.x, p1.y - p2.y) + End Operator +#End Region + +#Region "Overridden methods of System.Object" + Public Overrides Function Equals(ByVal o As Object) As Boolean + If TypeOf o Is MyPoint Then + If Me.ToString() = o.ToString() Then + Return True + End If + End If + Return False + End Function + + Public Overrides Function GetHashCode() As Integer + Return Me.ToString().GetHashCode() + End Function +#End Region + +#Region "overload the = and <> operators" + Public Shared Operator =(ByVal p1 As MyPoint, ByVal p2 As MyPoint) As Boolean + Return p1.Equals(p2) + End Operator + Public Shared Operator <>(ByVal p1 As MyPoint, ByVal p2 As MyPoint) As Boolean + Return Not p1.Equals(p2) + End Operator +#End Region + +#Region "IComparable implementation" + Public Function CompareTo(ByVal obj As Object) As Integer _ + Implements IComparable.CompareTo + If TypeOf obj Is MyPoint Then + Dim p As MyPoint = CType(obj, MyPoint) + If Me.x > p.x AndAlso Me.y > p.y Then + Return 1 + End If + If Me.x < p.x AndAlso Me.y < p.y Then + Return -1 + Else + Return 0 + End If + Else + Throw New ArgumentException() + End If + End Function +#End Region + +#Region "The overloaded comparison ops" + Public Shared Operator <(ByVal p1 As MyPoint, ByVal p2 As MyPoint) As Boolean + Return (p1.CompareTo(p2) < 0) + End Operator + Public Shared Operator >(ByVal p1 As MyPoint, ByVal p2 As MyPoint) As Boolean + Return (p1.CompareTo(p2) > 0) + End Operator + Public Shared Operator <=(ByVal p1 As MyPoint, ByVal p2 As MyPoint) As Boolean + Return (p1.CompareTo(p2) <= 0) + End Operator + Public Shared Operator >=(ByVal p1 As MyPoint, ByVal p2 As MyPoint) As Boolean + Return (p1.CompareTo(p2) >= 0) + End Operator +#End Region + +End Structure diff --git a/Code/Chapter 12/OverloadedOps/OverloadedOps.sln b/Code/Chapter 12/OverloadedOps/OverloadedOps.sln new file mode 100644 index 0000000..11f63dc --- /dev/null +++ b/Code/Chapter 12/OverloadedOps/OverloadedOps.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "OverloadedOps", "OverloadedOps.vbproj", "{CCBBE78B-BC9A-43EB-95B7-DD0031AE2F19}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CCBBE78B-BC9A-43EB-95B7-DD0031AE2F19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CCBBE78B-BC9A-43EB-95B7-DD0031AE2F19}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CCBBE78B-BC9A-43EB-95B7-DD0031AE2F19}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CCBBE78B-BC9A-43EB-95B7-DD0031AE2F19}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 12/OverloadedOps/OverloadedOps.suo b/Code/Chapter 12/OverloadedOps/OverloadedOps.suo new file mode 100644 index 0000000..be9b508 Binary files /dev/null and b/Code/Chapter 12/OverloadedOps/OverloadedOps.suo differ diff --git a/Code/Chapter 12/OverloadedOps/OverloadedOps.vbproj b/Code/Chapter 12/OverloadedOps/OverloadedOps.vbproj new file mode 100644 index 0000000..2d4a62e --- /dev/null +++ b/Code/Chapter 12/OverloadedOps/OverloadedOps.vbproj @@ -0,0 +1,110 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {CCBBE78B-BC9A-43EB-95B7-DD0031AE2F19} + Exe + OverloadedOps.Program + OverloadedOps + OverloadedOps + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + OverloadedOps.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + OverloadedOps.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + + 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/Code/Chapter 12/OverloadedOps/Program.vb b/Code/Chapter 12/OverloadedOps/Program.vb new file mode 100644 index 0000000..97fe7f5 --- /dev/null +++ b/Code/Chapter 12/OverloadedOps/Program.vb @@ -0,0 +1,54 @@ +Module Program + + Sub Main() + Console.WriteLine("***** Fun with Operator Overloading *****" & vbLf) + 'AddSubtractMyPointsWithMethodCalls() + 'AddSubtractMyPointsWithOperators() + 'TestMyPointsForEquality() + TestMyPointsForGreaterLessThan() + Console.ReadLine() + End Sub + + Sub AddSubtractMyPointsWithMethodCalls() + Dim p As New MyPoint(10, 10) + Dim p2 As New MyPoint(20, 30) + + ' Add two MyPoints. + Dim newPoint As MyPoint = MyPoint.Add(p, p2) + Console.WriteLine("p + p2 = {0}", newPoint) + + ' Subtract two MyPoints. + Console.WriteLine("p - p2 = {0}", MyPoint.Subtract(p, p2)) + End Sub + + Sub AddSubtractMyPointsWithOperators() + Dim p As New MyPoint(10, 10) + Dim p2 As New MyPoint(20, 30) + + ' Really calls: MyPoint.Operator+(p, p2) + Dim newPoint As MyPoint = p + p2 + Console.WriteLine("p + p2 = {0}", newPoint) + + ' Really calls: MyPoint.Operator-(p, p2) + Console.WriteLine("p - p2 = {0}", p - p2) + End Sub + + ' Make use of the overloaded equality operators. + Sub TestMyPointsForEquality() + Dim ptOne As New MyPoint(10, 2) + Dim ptTwo As New MyPoint(10, 44) + + Console.WriteLine("ptOne = ptTwo : {0}", ptOne = ptTwo) ' False! + Console.WriteLine("ptOne <> ptTwo : {0}", ptOne <> ptTwo) ' True! + End Sub + + Sub TestMyPointsForGreaterLessThan() + Dim ptOne As New MyPoint(5, 2) + Dim ptTwo As New MyPoint(5, 44) + + Console.WriteLine("ptOne > ptTwo : {0}", ptOne > ptTwo) ' False! + Console.WriteLine("ptOne < ptTwo : {0}", ptOne < ptTwo) ' False! + Console.WriteLine("ptOne >= ptTwo : {0}", ptOne >= ptTwo) ' True! + Console.WriteLine("ptOne <= ptTwo : {0}", ptOne <= ptTwo) ' True! + End Sub +End Module diff --git a/Code/Chapter 12/RefTypeValTypeParams/My Project/Application.Designer.vb b/Code/Chapter 12/RefTypeValTypeParams/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 12/RefTypeValTypeParams/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 12/RefTypeValTypeParams/My Project/Application.myapp b/Code/Chapter 12/RefTypeValTypeParams/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 12/RefTypeValTypeParams/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 12/RefTypeValTypeParams/My Project/AssemblyInfo.vb b/Code/Chapter 12/RefTypeValTypeParams/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..3b5f34a --- /dev/null +++ b/Code/Chapter 12/RefTypeValTypeParams/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/Code/Chapter 12/RefTypeValTypeParams/My Project/Resources.Designer.vb b/Code/Chapter 12/RefTypeValTypeParams/My Project/Resources.Designer.vb new file mode 100644 index 0000000..269f43f --- /dev/null +++ b/Code/Chapter 12/RefTypeValTypeParams/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("RefTypeValTypeParams.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/Code/Chapter 12/RefTypeValTypeParams/My Project/Resources.resx b/Code/Chapter 12/RefTypeValTypeParams/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 12/RefTypeValTypeParams/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/Code/Chapter 12/RefTypeValTypeParams/My Project/Settings.Designer.vb b/Code/Chapter 12/RefTypeValTypeParams/My Project/Settings.Designer.vb new file mode 100644 index 0000000..5c91f26 --- /dev/null +++ b/Code/Chapter 12/RefTypeValTypeParams/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.RefTypeValTypeParams.My.MySettings + Get + Return Global.RefTypeValTypeParams.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 12/RefTypeValTypeParams/My Project/Settings.settings b/Code/Chapter 12/RefTypeValTypeParams/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 12/RefTypeValTypeParams/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 12/RefTypeValTypeParams/Person.vb b/Code/Chapter 12/RefTypeValTypeParams/Person.vb new file mode 100644 index 0000000..5de6e3f --- /dev/null +++ b/Code/Chapter 12/RefTypeValTypeParams/Person.vb @@ -0,0 +1,15 @@ +Class Person + Public fullName As String + Public age As Integer + + Public Sub New(ByVal n As String, ByVal a As Integer) + fullName = n + age = a + End Sub + Public Sub New() + End Sub + + Public Overrides Function ToString() As String + Return String.Format("Name: {0}, Age: {1}", fullName, age) + End Function +End Class diff --git a/Code/Chapter 12/RefTypeValTypeParams/Program.vb b/Code/Chapter 12/RefTypeValTypeParams/Program.vb new file mode 100644 index 0000000..e1d94b2 --- /dev/null +++ b/Code/Chapter 12/RefTypeValTypeParams/Program.vb @@ -0,0 +1,42 @@ +Module Program + + Sub Main() + '' Passing ref types by value. + 'Console.WriteLine("***** Passing Person object by reference *****" & vbLf) + 'Dim fred As Person = New Person("Fred", 12) + 'Console.WriteLine("Before by value call, Person is:") + 'Console.WriteLine(fred) + 'SendAPersonByValue(fred) + 'Console.WriteLine("After by value call, Person is:") + 'Console.WriteLine(fred) + 'Console.ReadLine() + + ' Passing ref types by ref. + Console.WriteLine("***** Passing Person object by reference *****") + Dim mel As New Person("Mel", 23) + Console.WriteLine("Before by ref call, Person is:") + Console.WriteLine(mel) + SendAPersonByReference(mel) + Console.WriteLine("After by ref call, Person is:") + Console.WriteLine(mel) + Console.ReadLine() + + End Sub + + Sub SendAPersonByValue(ByVal p As Person) + ' Change the age of 'p'? + p.age = 99 + + ' Will the caller see this reassignment? + p = New Person("Nikki", 999) + End Sub + + Sub SendAPersonByReference(ByRef p As Person) + ' Change some data of 'p'. + p.age = 555 + + ' 'p' is now pointing to a new object on the heap! + p = New Person("Nikki", 999) + End Sub + +End Module diff --git a/Code/Chapter 12/RefTypeValTypeParams/RefTypeValTypeParams.sln b/Code/Chapter 12/RefTypeValTypeParams/RefTypeValTypeParams.sln new file mode 100644 index 0000000..4e1355f --- /dev/null +++ b/Code/Chapter 12/RefTypeValTypeParams/RefTypeValTypeParams.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "RefTypeValTypeParams", "RefTypeValTypeParams.vbproj", "{ED4FB1D6-C352-47F5-8E7C-F90AA64B7045}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {ED4FB1D6-C352-47F5-8E7C-F90AA64B7045}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ED4FB1D6-C352-47F5-8E7C-F90AA64B7045}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ED4FB1D6-C352-47F5-8E7C-F90AA64B7045}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ED4FB1D6-C352-47F5-8E7C-F90AA64B7045}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 12/RefTypeValTypeParams/RefTypeValTypeParams.suo b/Code/Chapter 12/RefTypeValTypeParams/RefTypeValTypeParams.suo new file mode 100644 index 0000000..2c65323 Binary files /dev/null and b/Code/Chapter 12/RefTypeValTypeParams/RefTypeValTypeParams.suo differ diff --git a/Code/Chapter 12/RefTypeValTypeParams/RefTypeValTypeParams.vbproj b/Code/Chapter 12/RefTypeValTypeParams/RefTypeValTypeParams.vbproj new file mode 100644 index 0000000..b1538d6 --- /dev/null +++ b/Code/Chapter 12/RefTypeValTypeParams/RefTypeValTypeParams.vbproj @@ -0,0 +1,110 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {ED4FB1D6-C352-47F5-8E7C-F90AA64B7045} + Exe + RefTypeValTypeParams.Program + RefTypeValTypeParams + RefTypeValTypeParams + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + RefTypeValTypeParams.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + RefTypeValTypeParams.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + + 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/Code/Chapter 12/ValAndRef/My Project/Application.Designer.vb b/Code/Chapter 12/ValAndRef/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 12/ValAndRef/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 12/ValAndRef/My Project/Application.myapp b/Code/Chapter 12/ValAndRef/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 12/ValAndRef/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 12/ValAndRef/My Project/AssemblyInfo.vb b/Code/Chapter 12/ValAndRef/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..82ba0ed --- /dev/null +++ b/Code/Chapter 12/ValAndRef/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/Code/Chapter 12/ValAndRef/My Project/Resources.Designer.vb b/Code/Chapter 12/ValAndRef/My Project/Resources.Designer.vb new file mode 100644 index 0000000..4fa2bcc --- /dev/null +++ b/Code/Chapter 12/ValAndRef/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("ValAndRef.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/Code/Chapter 12/ValAndRef/My Project/Resources.resx b/Code/Chapter 12/ValAndRef/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 12/ValAndRef/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/Code/Chapter 12/ValAndRef/My Project/Settings.Designer.vb b/Code/Chapter 12/ValAndRef/My Project/Settings.Designer.vb new file mode 100644 index 0000000..b762856 --- /dev/null +++ b/Code/Chapter 12/ValAndRef/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.ValAndRef.My.MySettings + Get + Return Global.ValAndRef.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 12/ValAndRef/My Project/Settings.settings b/Code/Chapter 12/ValAndRef/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 12/ValAndRef/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 12/ValAndRef/MyPoint.vb b/Code/Chapter 12/ValAndRef/MyPoint.vb new file mode 100644 index 0000000..f1673d6 --- /dev/null +++ b/Code/Chapter 12/ValAndRef/MyPoint.vb @@ -0,0 +1,98 @@ +' Change to a Structure to see the change +' in program behavior. +Public Class MyPoint + Implements IComparable + Public x As Integer, y As Integer + + Public Sub New(ByVal xPos As Integer, ByVal yPos As Integer) + x = xPos + y = yPos + End Sub + + Public Overrides Function ToString() As String + Return String.Format("[{0}, {1}]", Me.x, Me.y) + End Function + +#Region "Add/Subtract methods" + ' Adding two MyPoint objects to yeild a new (larger) MyPoint. + Public Shared Function Add(ByVal p1 As MyPoint, ByVal p2 As MyPoint) As MyPoint + Return New MyPoint(p1.x + p2.x, p1.y + p2.y) + End Function + + ' Subtracting two MyPoint objects to yeild a new (smaller) MyPoint. + Public Shared Function Subtract(ByVal p1 As MyPoint, ByVal p2 As MyPoint) As MyPoint + Return New MyPoint(p1.x - p2.x, p1.y - p2.y) + End Function +#End Region + +#Region "Overloaded + and - Operators" + ' Overloaded operator +. + Public Shared Operator +(ByVal p1 As MyPoint, ByVal p2 As MyPoint) As MyPoint + Return New MyPoint(p1.x + p2.x, p1.y + p2.y) + End Operator + + ' Overloaded operator -. + Public Shared Operator -(ByVal p1 As MyPoint, ByVal p2 As MyPoint) As MyPoint + Return New MyPoint(p1.x - p2.x, p1.y - p2.y) + End Operator +#End Region + +#Region "Overridden methods of System.Object" + Public Overrides Function Equals(ByVal o As Object) As Boolean + If TypeOf o Is MyPoint Then + If Me.ToString() = o.ToString() Then + Return True + End If + End If + Return False + End Function + + Public Overrides Function GetHashCode() As Integer + Return Me.ToString().GetHashCode() + End Function +#End Region + +#Region "overload the = and <> operators" + Public Shared Operator =(ByVal p1 As MyPoint, ByVal p2 As MyPoint) As Boolean + Return p1.Equals(p2) + End Operator + Public Shared Operator <>(ByVal p1 As MyPoint, ByVal p2 As MyPoint) As Boolean + Return Not p1.Equals(p2) + End Operator +#End Region + +#Region "IComparable implementation" + Public Function CompareTo(ByVal obj As Object) As Integer _ + Implements IComparable.CompareTo + If TypeOf obj Is MyPoint Then + Dim p As MyPoint = CType(obj, MyPoint) + If Me.x > p.x AndAlso Me.y > p.y Then + Return 1 + End If + If Me.x < p.x AndAlso Me.y < p.y Then + Return -1 + Else + Return 0 + End If + Else + Throw New ArgumentException() + End If + End Function +#End Region + +#Region "The overloaded comparison ops" + Public Shared Operator <(ByVal p1 As MyPoint, ByVal p2 As MyPoint) As Boolean + Return (p1.CompareTo(p2) < 0) + End Operator + Public Shared Operator >(ByVal p1 As MyPoint, ByVal p2 As MyPoint) As Boolean + Return (p1.CompareTo(p2) > 0) + End Operator + Public Shared Operator <=(ByVal p1 As MyPoint, ByVal p2 As MyPoint) As Boolean + Return (p1.CompareTo(p2) <= 0) + End Operator + Public Shared Operator >=(ByVal p1 As MyPoint, ByVal p2 As MyPoint) As Boolean + Return (p1.CompareTo(p2) >= 0) + End Operator +#End Region + +End Class diff --git a/Code/Chapter 12/ValAndRef/Program.vb b/Code/Chapter 12/ValAndRef/Program.vb new file mode 100644 index 0000000..9f993f9 --- /dev/null +++ b/Code/Chapter 12/ValAndRef/Program.vb @@ -0,0 +1,37 @@ +Option Strict On +Option Explicit On + +Module Program + + Sub Main() + ValueTypesRefTypesAndAssignment() + End Sub + + Sub ValueTypesRefTypesAndAssignment() + Console.WriteLine("***** Value Types and the Assignment Operator *****") + Console.WriteLine("-> Creating p1") + Dim p1 As New MyPoint(100, 100) + + Console.WriteLine("-> Assigning p2 to p1") + Dim p2 As MyPoint = p1 + + ' Here is p1. + Console.WriteLine("p1.x = {0}", p1.x) + Console.WriteLine("p1.y = {0}", p1.y) + + ' Here is p2. + Console.WriteLine("p2.x = {0}", p2.x) + Console.WriteLine("p2.y = {0}", p2.y) + + ' Change p2.x. This will NOT change p1.x. + Console.WriteLine("-> Changing p2.x to 900") + p2.x = 900 + + ' Print again. + Console.WriteLine("-> Here are the X values again...") + Console.WriteLine("p1.x = {0}", p1.x) + Console.WriteLine("p2.x = {0}", p2.x) + Console.ReadLine() + End Sub + +End Module diff --git a/Code/Chapter 12/ValAndRef/ValAndRef.sln b/Code/Chapter 12/ValAndRef/ValAndRef.sln new file mode 100644 index 0000000..60fa90b --- /dev/null +++ b/Code/Chapter 12/ValAndRef/ValAndRef.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ValAndRef", "ValAndRef.vbproj", "{9DEAD564-C533-4D01-A697-539F74CEAD5B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9DEAD564-C533-4D01-A697-539F74CEAD5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9DEAD564-C533-4D01-A697-539F74CEAD5B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9DEAD564-C533-4D01-A697-539F74CEAD5B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9DEAD564-C533-4D01-A697-539F74CEAD5B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 12/ValAndRef/ValAndRef.suo b/Code/Chapter 12/ValAndRef/ValAndRef.suo new file mode 100644 index 0000000..7d5eaaa Binary files /dev/null and b/Code/Chapter 12/ValAndRef/ValAndRef.suo differ diff --git a/Code/Chapter 12/ValAndRef/ValAndRef.vbproj b/Code/Chapter 12/ValAndRef/ValAndRef.vbproj new file mode 100644 index 0000000..25c664d --- /dev/null +++ b/Code/Chapter 12/ValAndRef/ValAndRef.vbproj @@ -0,0 +1,110 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {9DEAD564-C533-4D01-A697-539F74CEAD5B} + Exe + ValAndRef.Program + ValAndRef + ValAndRef + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + ValAndRef.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + ValAndRef.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 12/ValTypeContainingRefType/My Project/Application.Designer.vb b/Code/Chapter 12/ValTypeContainingRefType/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 12/ValTypeContainingRefType/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 12/ValTypeContainingRefType/My Project/Application.myapp b/Code/Chapter 12/ValTypeContainingRefType/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 12/ValTypeContainingRefType/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 12/ValTypeContainingRefType/My Project/AssemblyInfo.vb b/Code/Chapter 12/ValTypeContainingRefType/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..ce0bb92 --- /dev/null +++ b/Code/Chapter 12/ValTypeContainingRefType/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/Code/Chapter 12/ValTypeContainingRefType/My Project/Resources.Designer.vb b/Code/Chapter 12/ValTypeContainingRefType/My Project/Resources.Designer.vb new file mode 100644 index 0000000..f3c7000 --- /dev/null +++ b/Code/Chapter 12/ValTypeContainingRefType/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("ValTypeContainingRefType.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/Code/Chapter 12/ValTypeContainingRefType/My Project/Resources.resx b/Code/Chapter 12/ValTypeContainingRefType/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 12/ValTypeContainingRefType/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/Code/Chapter 12/ValTypeContainingRefType/My Project/Settings.Designer.vb b/Code/Chapter 12/ValTypeContainingRefType/My Project/Settings.Designer.vb new file mode 100644 index 0000000..ec75ff3 --- /dev/null +++ b/Code/Chapter 12/ValTypeContainingRefType/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.ValTypeContainingRefType.My.MySettings + Get + Return Global.ValTypeContainingRefType.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 12/ValTypeContainingRefType/My Project/Settings.settings b/Code/Chapter 12/ValTypeContainingRefType/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 12/ValTypeContainingRefType/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 12/ValTypeContainingRefType/MyRectangle.vb b/Code/Chapter 12/ValTypeContainingRefType/MyRectangle.vb new file mode 100644 index 0000000..2aa6cba --- /dev/null +++ b/Code/Chapter 12/ValTypeContainingRefType/MyRectangle.vb @@ -0,0 +1,12 @@ +Structure MyRectangle + ' The MyRectangle structure contains a reference type member. + Public rectInfo As ShapeInfo + + Public top, left, bottom, right As Integer + + Public Sub New(ByVal info As String) + rectInfo = New ShapeInfo(info) + top = 10 : left = 10 + bottom = 10 : right = 100 + End Sub +End Structure diff --git a/Code/Chapter 12/ValTypeContainingRefType/Program.vb b/Code/Chapter 12/ValTypeContainingRefType/Program.vb new file mode 100644 index 0000000..db71485 --- /dev/null +++ b/Code/Chapter 12/ValTypeContainingRefType/Program.vb @@ -0,0 +1,29 @@ +Module Program + + Sub Main() + Console.WriteLine("***** Value type containing reference type *****" & vbLf) + + ' Create the first MyRectangle. + Console.WriteLine("-> Creating r1") + Dim r1 As New MyRectangle("This is my first rect") + + ' Now assign a new MyRectangle to r1. + Console.WriteLine("-> Assigning r2 to r1") + Dim r2 As MyRectangle + r2 = r1 + + ' Change values of r2. + Console.WriteLine("-> Changing all values of r2") + r2.rectInfo.infoString = "This is new info!" + r2.bottom = 4444 + + ' Print values + Console.WriteLine("-> Values after change:") + Console.WriteLine("-> r1.rectInfo.infoString: {0}", r1.rectInfo.infoString) + Console.WriteLine("-> r2.rectInfo.infoString: {0}", r2.rectInfo.infoString) + Console.WriteLine("-> r1.bottom: {0}", r1.bottom) + Console.WriteLine("-> r2.bottom: {0}", r2.bottom) + Console.ReadLine() + End Sub + +End Module diff --git a/Code/Chapter 12/ValTypeContainingRefType/ShapeInfo.vb b/Code/Chapter 12/ValTypeContainingRefType/ShapeInfo.vb new file mode 100644 index 0000000..078b396 --- /dev/null +++ b/Code/Chapter 12/ValTypeContainingRefType/ShapeInfo.vb @@ -0,0 +1,6 @@ +Class ShapeInfo + Public infoString As String + Public Sub New(ByVal info As String) + infoString = info + End Sub +End Class diff --git a/Code/Chapter 12/ValTypeContainingRefType/ValTypeContainingRefType.sln b/Code/Chapter 12/ValTypeContainingRefType/ValTypeContainingRefType.sln new file mode 100644 index 0000000..de0f021 --- /dev/null +++ b/Code/Chapter 12/ValTypeContainingRefType/ValTypeContainingRefType.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ValTypeContainingRefType", "ValTypeContainingRefType.vbproj", "{DDE17907-B771-4436-9E69-A387D1D3F020}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DDE17907-B771-4436-9E69-A387D1D3F020}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DDE17907-B771-4436-9E69-A387D1D3F020}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DDE17907-B771-4436-9E69-A387D1D3F020}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DDE17907-B771-4436-9E69-A387D1D3F020}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 12/ValTypeContainingRefType/ValTypeContainingRefType.suo b/Code/Chapter 12/ValTypeContainingRefType/ValTypeContainingRefType.suo new file mode 100644 index 0000000..86fb136 Binary files /dev/null and b/Code/Chapter 12/ValTypeContainingRefType/ValTypeContainingRefType.suo differ diff --git a/Code/Chapter 12/ValTypeContainingRefType/ValTypeContainingRefType.vbproj b/Code/Chapter 12/ValTypeContainingRefType/ValTypeContainingRefType.vbproj new file mode 100644 index 0000000..c9707bd --- /dev/null +++ b/Code/Chapter 12/ValTypeContainingRefType/ValTypeContainingRefType.vbproj @@ -0,0 +1,111 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {DDE17907-B771-4436-9E69-A387D1D3F020} + Exe + ValTypeContainingRefType.Program + ValTypeContainingRefType + ValTypeContainingRefType + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + ValTypeContainingRefType.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + ValTypeContainingRefType.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + + 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/Code/Chapter 13/AnonymousTypes/AnonymousTypes.sln b/Code/Chapter 13/AnonymousTypes/AnonymousTypes.sln new file mode 100644 index 0000000..318b24b --- /dev/null +++ b/Code/Chapter 13/AnonymousTypes/AnonymousTypes.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AnonymousTypes", "AnonymousTypes.vbproj", "{D9F485F5-5057-4F69-B862-21DA064D5457}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D9F485F5-5057-4F69-B862-21DA064D5457}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D9F485F5-5057-4F69-B862-21DA064D5457}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D9F485F5-5057-4F69-B862-21DA064D5457}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D9F485F5-5057-4F69-B862-21DA064D5457}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 13/AnonymousTypes/AnonymousTypes.suo b/Code/Chapter 13/AnonymousTypes/AnonymousTypes.suo new file mode 100644 index 0000000..a9f9be5 Binary files /dev/null and b/Code/Chapter 13/AnonymousTypes/AnonymousTypes.suo differ diff --git a/Code/Chapter 13/AnonymousTypes/AnonymousTypes.vbproj b/Code/Chapter 13/AnonymousTypes/AnonymousTypes.vbproj new file mode 100644 index 0000000..6093996 --- /dev/null +++ b/Code/Chapter 13/AnonymousTypes/AnonymousTypes.vbproj @@ -0,0 +1,115 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {D9F485F5-5057-4F69-B862-21DA064D5457} + Exe + AnonymousTypes.Program + AnonymousTypes + AnonymousTypes + 512 + Console + v3.5 + On + Binary + On + On + + + true + full + true + true + bin\Debug\ + AnonymousTypes.xml + + + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + true + + + pdbonly + false + true + true + bin\Release\ + AnonymousTypes.xml + + + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + true + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 13/AnonymousTypes/My Project/Application.Designer.vb b/Code/Chapter 13/AnonymousTypes/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 13/AnonymousTypes/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 13/AnonymousTypes/My Project/Application.myapp b/Code/Chapter 13/AnonymousTypes/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 13/AnonymousTypes/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 13/AnonymousTypes/My Project/AssemblyInfo.vb b/Code/Chapter 13/AnonymousTypes/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..e9213f2 --- /dev/null +++ b/Code/Chapter 13/AnonymousTypes/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/Code/Chapter 13/AnonymousTypes/My Project/Resources.Designer.vb b/Code/Chapter 13/AnonymousTypes/My Project/Resources.Designer.vb new file mode 100644 index 0000000..8fa8e29 --- /dev/null +++ b/Code/Chapter 13/AnonymousTypes/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("AnonymousTypes.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/Code/Chapter 13/AnonymousTypes/My Project/Resources.resx b/Code/Chapter 13/AnonymousTypes/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 13/AnonymousTypes/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/Code/Chapter 13/AnonymousTypes/My Project/Settings.Designer.vb b/Code/Chapter 13/AnonymousTypes/My Project/Settings.Designer.vb new file mode 100644 index 0000000..b096ec8 --- /dev/null +++ b/Code/Chapter 13/AnonymousTypes/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.AnonymousTypes.My.MySettings + Get + Return Global.AnonymousTypes.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 13/AnonymousTypes/My Project/Settings.settings b/Code/Chapter 13/AnonymousTypes/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 13/AnonymousTypes/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 13/AnonymousTypes/Program.vb b/Code/Chapter 13/AnonymousTypes/Program.vb new file mode 100644 index 0000000..f92e5fc --- /dev/null +++ b/Code/Chapter 13/AnonymousTypes/Program.vb @@ -0,0 +1,76 @@ +Module Program + + Sub Main() + Console.WriteLine("***** Fun with Anonymous Types *****") + + ' Make an anonymous type representing a car. + Dim myCar = New With {.Color = "Bright Pink", .Make = "Saab", .CurrentSpeed = 55} + myCar.Color = "Black" + + ' Now show the color and make. + Console.WriteLine("My car is a {0} {1}.", myCar.Color, myCar.Make) + + ' Reflect over what the compiler generated. + ReflectOverAnonymousType(myCar) + Console.WriteLine() + CompositeAnonymousType() + Console.WriteLine() + EqualityTest() + Console.ReadLine() + End Sub + + Sub ReflectOverAnonymousType(ByVal obj As Object) + Console.WriteLine("obj is an instance of: {0}", obj.GetType().Name) + Console.WriteLine("Base class of {0} is {1}", _ + obj.GetType().Name, _ + obj.GetType().BaseType) + Console.WriteLine("obj.ToString() = {0}", obj.ToString()) + Console.WriteLine("obj.GetHashCode() = {0}", obj.GetHashCode()) + Console.WriteLine() + End Sub + +#Region "Test for equality" + Sub EqualityTest() + + ' Make 2 anonymous classes with identical name/value pairs. + Dim firstCar = New With {.Color = "Bright Pink", .Make = "Saab", .CurrentSpeed = 55} + Dim secondCar = New With {.Color = "Bright Pink", .Make = "Saab", .CurrentSpeed = 55} + + ' Are they considered equal when using Equals()? + If (firstCar.Equals(secondCar)) Then + Console.WriteLine("Same anonymous object!") + Else + Console.WriteLine("Not the same anonymous object!") + End If + + ' Error!! No overloaded = operator for anonymous types! + 'If (firstCar = secondCar) Then + 'Console.WriteLine("Same anonymous object!") + 'Else + 'Console.WriteLine("Not the same anonymous object!") + 'End If + + ' Are these objects the same underlying type? + If (firstCar.GetType().Name = secondCar.GetType().Name) Then + Console.WriteLine("We are both the same type!") + Else + Console.WriteLine("We are different types!") + End If + + ' Show all the details. + Console.WriteLine() + ReflectOverAnonymousType(firstCar) + ReflectOverAnonymousType(secondCar) + End Sub +#End Region + + Sub CompositeAnonymousType() + ' Make an anonymous type that is composed of another. + Dim purchaseItem = New With { _ + .TimeBought = DateTime.Now, _ + .ItemBought = New With {.Color = "Red", .Make = "Saab", .CurrentSpeed = 55}, _ + .Price = 34.0} + + ReflectOverAnonymousType(purchaseItem) + End Sub +End Module diff --git a/Code/Chapter 13/ExtensionMethods/ExtensionMethods.sln b/Code/Chapter 13/ExtensionMethods/ExtensionMethods.sln new file mode 100644 index 0000000..92340b1 --- /dev/null +++ b/Code/Chapter 13/ExtensionMethods/ExtensionMethods.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ExtensionMethods", "ExtensionMethods.vbproj", "{2A346F42-B014-4D33-8D13-821149275245}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2A346F42-B014-4D33-8D13-821149275245}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2A346F42-B014-4D33-8D13-821149275245}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2A346F42-B014-4D33-8D13-821149275245}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2A346F42-B014-4D33-8D13-821149275245}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 13/ExtensionMethods/ExtensionMethods.suo b/Code/Chapter 13/ExtensionMethods/ExtensionMethods.suo new file mode 100644 index 0000000..3f02252 Binary files /dev/null and b/Code/Chapter 13/ExtensionMethods/ExtensionMethods.suo differ diff --git a/Code/Chapter 13/ExtensionMethods/ExtensionMethods.vbproj b/Code/Chapter 13/ExtensionMethods/ExtensionMethods.vbproj new file mode 100644 index 0000000..7184b18 --- /dev/null +++ b/Code/Chapter 13/ExtensionMethods/ExtensionMethods.vbproj @@ -0,0 +1,117 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {2A346F42-B014-4D33-8D13-821149275245} + Exe + ExtensionMethods.Project + ExtensionMethods + ExtensionMethods + 512 + Console + v3.5 + On + Binary + On + On + + + true + full + true + true + bin\Debug\ + ExtensionMethods.xml + + + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + true + + + pdbonly + false + true + true + bin\Release\ + ExtensionMethods.xml + + + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + true + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + + + 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/Code/Chapter 13/ExtensionMethods/My Project/Application.Designer.vb b/Code/Chapter 13/ExtensionMethods/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 13/ExtensionMethods/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 13/ExtensionMethods/My Project/Application.myapp b/Code/Chapter 13/ExtensionMethods/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 13/ExtensionMethods/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 13/ExtensionMethods/My Project/AssemblyInfo.vb b/Code/Chapter 13/ExtensionMethods/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..6ebfe20 --- /dev/null +++ b/Code/Chapter 13/ExtensionMethods/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/Code/Chapter 13/ExtensionMethods/My Project/Resources.Designer.vb b/Code/Chapter 13/ExtensionMethods/My Project/Resources.Designer.vb new file mode 100644 index 0000000..03a6025 --- /dev/null +++ b/Code/Chapter 13/ExtensionMethods/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("ExtensionMethods.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/Code/Chapter 13/ExtensionMethods/My Project/Resources.resx b/Code/Chapter 13/ExtensionMethods/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 13/ExtensionMethods/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/Code/Chapter 13/ExtensionMethods/My Project/Settings.Designer.vb b/Code/Chapter 13/ExtensionMethods/My Project/Settings.Designer.vb new file mode 100644 index 0000000..c08477b --- /dev/null +++ b/Code/Chapter 13/ExtensionMethods/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.ExtensionMethods.My.MySettings + Get + Return Global.ExtensionMethods.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 13/ExtensionMethods/My Project/Settings.settings b/Code/Chapter 13/ExtensionMethods/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 13/ExtensionMethods/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 13/ExtensionMethods/MyExtensions.vb b/Code/Chapter 13/ExtensionMethods/MyExtensions.vb new file mode 100644 index 0000000..4c50c8e --- /dev/null +++ b/Code/Chapter 13/ExtensionMethods/MyExtensions.vb @@ -0,0 +1,59 @@ +Imports System.Reflection +Imports System.Runtime.CompilerServices + +Namespace MyExtensionMethods + +#Region "MyExtensions module" + Module MyExtensions + + '' This method allows any object to display the assembly + '' it is defined in. + ' _ + 'Public Sub DisplayDefiningAssembly(ByVal obj As Object) + ' Console.WriteLine("{0} lives here: {1}", obj.GetType().Name, _ + ' obj.GetType().Assembly) + ' Console.WriteLine() + 'End Sub + + ' This version takes a booelan argument when calling the method. + _ + Public Sub DisplayDefiningAssembly(ByVal obj As Object, Optional ByVal showDetails As Boolean = False) + Console.WriteLine("Defining Assembly: {0}", obj.GetType().Assembly) + + If showDetails Then + Console.WriteLine("Name of type: {0}", obj.GetType().Name) + Console.WriteLine("Parent of type: {0}", obj.GetType().BaseType) + Console.WriteLine("Is generic?: {0}", obj.GetType().IsGenericType) + End If + End Sub + + + ' This method allows any integer to reverse its digits. + ' For example, 56 would return 65. + _ + Public Function ReverseDigits(ByVal i As Integer) As Integer + ' Translate int into a string, and then + ' get all the characters. + Dim digits() As Char = i.ToString().ToCharArray() + + ' Now reverse items in the array. + Array.Reverse(digits) + + ' Put back into string. + Dim newDigits As String = New String(digits) + + ' Finally, return the modified string back as an int. + Return Integer.Parse(newDigits) + End Function + End Module +#End Region + + Module CarExtensions + _ + Public Function SlowDown(ByVal c As Car) As Integer + c.Speed -= 1 + Return c.Speed + End Function + End Module + +End Namespace diff --git a/Code/Chapter 13/ExtensionMethods/NamespaceTestClass.vb b/Code/Chapter 13/ExtensionMethods/NamespaceTestClass.vb new file mode 100644 index 0000000..aae6202 --- /dev/null +++ b/Code/Chapter 13/ExtensionMethods/NamespaceTestClass.vb @@ -0,0 +1,18 @@ +' Here is our only imports directive. +Imports System + +' Comment this out to receive a coding error. +Imports ExtensionMethods.MyExtensionMethods + +Namespace MyNewApp + + Class JustATest + Sub SomeMethod() + ' Error! Need to import MyExtensionMethods + ' namespace to extend integer with ReverseDigits()! + Dim i As Integer = 0 + i.ReverseDigits() + End Sub + End Class + +End Namespace diff --git a/Code/Chapter 13/ExtensionMethods/Project.vb b/Code/Chapter 13/ExtensionMethods/Project.vb new file mode 100644 index 0000000..e7e2fc2 --- /dev/null +++ b/Code/Chapter 13/ExtensionMethods/Project.vb @@ -0,0 +1,44 @@ +Imports ExtensionMethods.MyExtensionMethods + +Public Class Car + Public Speed As Integer + Public Function SpeedUp() As Integer + Speed += 1 + Return Speed + End Function +End Class + +Module Project + Sub Main() + Console.WriteLine("***** Fun with Extension Methods *****" + vbLf) + + ' The Integer has assumed a new identity! + Dim myInt As Integer = 12345678 + MyExtensions.DisplayDefiningAssembly(myInt) + + ' So has the DataSet! + Dim d = New System.Data.DataSet() + MyExtensions.DisplayDefiningAssembly(d) + + ' And the SoundPlayer (with details). + Dim sp As New System.Media.SoundPlayer() + MyExtensions.DisplayDefiningAssembly(d, True) + + ' Use new integer functionality. + Console.WriteLine("Value of myInt: {0}", myInt) + Console.WriteLine("Reversed digits of myInt: {0}", _ + MyExtensions.ReverseDigits(myInt)) + + Console.WriteLine() + UseCar() + Console.ReadLine() + End Sub + + Sub UseCar() + Dim c As New Car() + c.Speed = 10 + Console.WriteLine("Speed: {0}", c.SpeedUp()) + Console.WriteLine("Speed: {0}", c.SlowDown()) + End Sub + +End Module diff --git a/Code/Chapter 13/ImplicitDataTypes/ImplicitDataTypes.sln b/Code/Chapter 13/ImplicitDataTypes/ImplicitDataTypes.sln new file mode 100644 index 0000000..282b08e --- /dev/null +++ b/Code/Chapter 13/ImplicitDataTypes/ImplicitDataTypes.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ImplicitDataTypes", "ImplicitDataTypes.vbproj", "{D0E8D0A2-C133-4969-9BEF-7ECA2A016FB2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D0E8D0A2-C133-4969-9BEF-7ECA2A016FB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D0E8D0A2-C133-4969-9BEF-7ECA2A016FB2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D0E8D0A2-C133-4969-9BEF-7ECA2A016FB2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D0E8D0A2-C133-4969-9BEF-7ECA2A016FB2}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 13/ImplicitDataTypes/ImplicitDataTypes.suo b/Code/Chapter 13/ImplicitDataTypes/ImplicitDataTypes.suo new file mode 100644 index 0000000..f7cccd9 Binary files /dev/null and b/Code/Chapter 13/ImplicitDataTypes/ImplicitDataTypes.suo differ diff --git a/Code/Chapter 13/ImplicitDataTypes/ImplicitDataTypes.vbproj b/Code/Chapter 13/ImplicitDataTypes/ImplicitDataTypes.vbproj new file mode 100644 index 0000000..a653fb0 --- /dev/null +++ b/Code/Chapter 13/ImplicitDataTypes/ImplicitDataTypes.vbproj @@ -0,0 +1,117 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {D0E8D0A2-C133-4969-9BEF-7ECA2A016FB2} + Exe + ImplicitDataTypes.Program + ImplicitDataTypes + ImplicitDataTypes + 512 + Console + v3.5 + On + Binary + On + On + + + true + full + true + true + bin\Debug\ + ImplicitDataTypes.xml + + + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + true + 1 + + + pdbonly + false + true + true + bin\Release\ + ImplicitDataTypes.xml + + + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + true + 1 + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + 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/Code/Chapter 13/ImplicitDataTypes/My Project/Application.Designer.vb b/Code/Chapter 13/ImplicitDataTypes/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 13/ImplicitDataTypes/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 13/ImplicitDataTypes/My Project/Application.myapp b/Code/Chapter 13/ImplicitDataTypes/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 13/ImplicitDataTypes/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 13/ImplicitDataTypes/My Project/AssemblyInfo.vb b/Code/Chapter 13/ImplicitDataTypes/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..af98be8 --- /dev/null +++ b/Code/Chapter 13/ImplicitDataTypes/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/Code/Chapter 13/ImplicitDataTypes/My Project/Resources.Designer.vb b/Code/Chapter 13/ImplicitDataTypes/My Project/Resources.Designer.vb new file mode 100644 index 0000000..505b895 --- /dev/null +++ b/Code/Chapter 13/ImplicitDataTypes/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("ImplicitDataTypes.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/Code/Chapter 13/ImplicitDataTypes/My Project/Resources.resx b/Code/Chapter 13/ImplicitDataTypes/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 13/ImplicitDataTypes/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/Code/Chapter 13/ImplicitDataTypes/My Project/Settings.Designer.vb b/Code/Chapter 13/ImplicitDataTypes/My Project/Settings.Designer.vb new file mode 100644 index 0000000..c7367a6 --- /dev/null +++ b/Code/Chapter 13/ImplicitDataTypes/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.ImplicitDataTypes.My.MySettings + Get + Return Global.ImplicitDataTypes.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 13/ImplicitDataTypes/My Project/Settings.settings b/Code/Chapter 13/ImplicitDataTypes/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 13/ImplicitDataTypes/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 13/ImplicitDataTypes/Program.vb b/Code/Chapter 13/ImplicitDataTypes/Program.vb new file mode 100644 index 0000000..c205788 --- /dev/null +++ b/Code/Chapter 13/ImplicitDataTypes/Program.vb @@ -0,0 +1,96 @@ +' Do not allow VB 6.0 style late binding. +Option Strict On + +' Remember this is the default. +Option Infer On + +#Region "Simple car types for testing purposes." +Public Class Car +End Class +Public Class SportsCar + Inherits Car +End Class +Public Class MiniVan + Inherits Car +End Class +#End Region + +Module Program + + Sub Main() + Console.WriteLine("***** Fun with Impliict Typing *****") + Console.WriteLine() + + ImplicitTyping() + Console.WriteLine() + + ImplicitTypingInForEach() + Console.WriteLine() + + QueryOverInts() + Console.ReadLine() + End Sub + +#Region "Explicit typing example" + Public Sub ExplicitTyping() + ' Local variables are declared as so: + ' Dim variableName As dataType = initialValue + Dim myInt As Integer = 0 + Dim myBool As Boolean = True + Dim myString As String = "Time, marches on..." + End Sub +#End Region + +#Region "Implicit typing examples" + Public Sub ImplicitTyping() + ' Implicitly typed local variables. + Dim myInt = 0 + Dim myBool = True + Dim myString = "Time, marches on..." + + ' Print out the underlying type. + Console.WriteLine("myInt is a: {0}", myInt.GetType().Name) + Console.WriteLine("myBool is a: {0}", myBool.GetType().Name) + Console.WriteLine("myString is a: {0}", myString.GetType().Name) + + ' Assume we have classes of type SportsCar + ' and MiniVan somewhere in the project. + Dim evenNumbers = New Integer() {2, 4, 6, 8} + + Dim myMinivans = New List(Of MiniVan)() + Dim myCar = New SportsCar() + + Console.WriteLine("evenNumbers is a: {0}", evenNumbers.GetType().Name) + Console.WriteLine("myMinivans is a: {0}", myMinivans.GetType().Name) + Console.WriteLine("myCar is a: {0}", myCar.GetType().Name) + End Sub + + Public Sub ImplicitTypingInForEach() + ' Use implicit typing in a standard for each loop. + Dim evenNumbers() = New Integer() {2, 4, 6, 8} + + ' Here, explicitly define the iterator type. + For Each item As Integer In evenNumbers + Console.WriteLine("Item value: {0}", item) + Next + End Sub +#End Region + +#Region "Simple LINQ query w/ implicit typing" + Sub QueryOverInts() + Dim numbers() As Integer = {10, 20, 30, 40, 1, 2, 3, 8} + Dim subset = From i In numbers Where i < 10 Select i + + Console.Write("Values in subset: ") + For Each i In subset + Console.Write("{0} ", i) + Next + Console.WriteLine() + + ' Humm...what type is subset? + Console.WriteLine("subset is a: {0}", subset.GetType().Name) + Console.WriteLine("Namespace of subset is: {0}", subset.GetType().Namespace) + End Sub +#End Region + +End Module diff --git a/Code/Chapter 13/InterfaceExtensions/InterfaceExtensions.sln b/Code/Chapter 13/InterfaceExtensions/InterfaceExtensions.sln new file mode 100644 index 0000000..b58ba8a --- /dev/null +++ b/Code/Chapter 13/InterfaceExtensions/InterfaceExtensions.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "InterfaceExtensions", "InterfaceExtensions.vbproj", "{40BECDB5-6693-4E5B-A54A-455E51C3457E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {40BECDB5-6693-4E5B-A54A-455E51C3457E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {40BECDB5-6693-4E5B-A54A-455E51C3457E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {40BECDB5-6693-4E5B-A54A-455E51C3457E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {40BECDB5-6693-4E5B-A54A-455E51C3457E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 13/InterfaceExtensions/InterfaceExtensions.suo b/Code/Chapter 13/InterfaceExtensions/InterfaceExtensions.suo new file mode 100644 index 0000000..8e563ee Binary files /dev/null and b/Code/Chapter 13/InterfaceExtensions/InterfaceExtensions.suo differ diff --git a/Code/Chapter 13/InterfaceExtensions/InterfaceExtensions.vbproj b/Code/Chapter 13/InterfaceExtensions/InterfaceExtensions.vbproj new file mode 100644 index 0000000..8894d53 --- /dev/null +++ b/Code/Chapter 13/InterfaceExtensions/InterfaceExtensions.vbproj @@ -0,0 +1,115 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {40BECDB5-6693-4E5B-A54A-455E51C3457E} + Exe + InterfaceExtensions.Program + InterfaceExtensions + InterfaceExtensions + 512 + Console + v3.5 + On + Binary + On + On + + + true + full + true + true + bin\Debug\ + InterfaceExtensions.xml + + + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + true + + + pdbonly + false + true + true + bin\Release\ + InterfaceExtensions.xml + + + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + true + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 13/InterfaceExtensions/My Project/Application.Designer.vb b/Code/Chapter 13/InterfaceExtensions/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 13/InterfaceExtensions/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 13/InterfaceExtensions/My Project/Application.myapp b/Code/Chapter 13/InterfaceExtensions/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 13/InterfaceExtensions/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 13/InterfaceExtensions/My Project/AssemblyInfo.vb b/Code/Chapter 13/InterfaceExtensions/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..4f7812e --- /dev/null +++ b/Code/Chapter 13/InterfaceExtensions/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/Code/Chapter 13/InterfaceExtensions/My Project/Resources.Designer.vb b/Code/Chapter 13/InterfaceExtensions/My Project/Resources.Designer.vb new file mode 100644 index 0000000..1d835f5 --- /dev/null +++ b/Code/Chapter 13/InterfaceExtensions/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("InterfaceExtensions.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/Code/Chapter 13/InterfaceExtensions/My Project/Resources.resx b/Code/Chapter 13/InterfaceExtensions/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 13/InterfaceExtensions/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/Code/Chapter 13/InterfaceExtensions/My Project/Settings.Designer.vb b/Code/Chapter 13/InterfaceExtensions/My Project/Settings.Designer.vb new file mode 100644 index 0000000..80ea348 --- /dev/null +++ b/Code/Chapter 13/InterfaceExtensions/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.InterfaceExtensions.My.MySettings + Get + Return Global.InterfaceExtensions.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 13/InterfaceExtensions/My Project/Settings.settings b/Code/Chapter 13/InterfaceExtensions/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 13/InterfaceExtensions/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 13/InterfaceExtensions/Program.vb b/Code/Chapter 13/InterfaceExtensions/Program.vb new file mode 100644 index 0000000..c10229e --- /dev/null +++ b/Code/Chapter 13/InterfaceExtensions/Program.vb @@ -0,0 +1,37 @@ +Imports System.Runtime.CompilerServices + +Module Program + Sub Main() + Console.WriteLine("***** Extending an interface *****") + + ' Call IBasicMath members from MyCalc object. + Dim c As New MyCalc() + Console.WriteLine("1 + 2 = {0}", c.Add(1, 2)) + Console.WriteLine("1 - 2 = {0}", c.Subtract(1, 2)) + Console.ReadLine() + End Sub +End Module + +' Define a normal CLR interface in VB. +Interface IBasicMath + Function Add(ByVal x As Integer, ByVal y As Integer) As Integer +End Interface + +' Implementation of IBasicMath. +Class MyCalc + Implements IBasicMath + Public Function Add(ByVal x As Integer, _ + ByVal y As Integer) As Integer Implements IBasicMath.Add + Return x + y + End Function +End Class + +Module MathExtensions + ' Extend IBasicMath with this method and this + ' implementation. + _ + Public Function Subtract(ByVal itf As IBasicMath, _ + ByVal x As Integer, ByVal y As Integer) As Integer + Return x - y + End Function +End Module diff --git a/Code/Chapter 13/MyExtensionsLibrary/My Project/Application.Designer.vb b/Code/Chapter 13/MyExtensionsLibrary/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 13/MyExtensionsLibrary/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 13/MyExtensionsLibrary/My Project/Application.myapp b/Code/Chapter 13/MyExtensionsLibrary/My Project/Application.myapp new file mode 100644 index 0000000..758895d --- /dev/null +++ b/Code/Chapter 13/MyExtensionsLibrary/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/Code/Chapter 13/MyExtensionsLibrary/My Project/AssemblyInfo.vb b/Code/Chapter 13/MyExtensionsLibrary/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..432e02d --- /dev/null +++ b/Code/Chapter 13/MyExtensionsLibrary/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/Code/Chapter 13/MyExtensionsLibrary/My Project/Resources.Designer.vb b/Code/Chapter 13/MyExtensionsLibrary/My Project/Resources.Designer.vb new file mode 100644 index 0000000..9a80715 --- /dev/null +++ b/Code/Chapter 13/MyExtensionsLibrary/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("MyExtensionsLibrary.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/Code/Chapter 13/MyExtensionsLibrary/My Project/Resources.resx b/Code/Chapter 13/MyExtensionsLibrary/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 13/MyExtensionsLibrary/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/Code/Chapter 13/MyExtensionsLibrary/My Project/Settings.Designer.vb b/Code/Chapter 13/MyExtensionsLibrary/My Project/Settings.Designer.vb new file mode 100644 index 0000000..46a04a0 --- /dev/null +++ b/Code/Chapter 13/MyExtensionsLibrary/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.MyExtensionsLibrary.My.MySettings + Get + Return Global.MyExtensionsLibrary.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 13/MyExtensionsLibrary/My Project/Settings.settings b/Code/Chapter 13/MyExtensionsLibrary/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 13/MyExtensionsLibrary/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 13/MyExtensionsLibrary/MyExtensions.vb b/Code/Chapter 13/MyExtensionsLibrary/MyExtensions.vb new file mode 100644 index 0000000..bc193ba --- /dev/null +++ b/Code/Chapter 13/MyExtensionsLibrary/MyExtensions.vb @@ -0,0 +1,45 @@ +Imports System.Runtime.CompilerServices + +#Region "MyExtensions module" +Public Module MyExtensions + + '' This method allows any object to display the assembly + '' it is defined in. + ' _ + 'Public Sub DisplayDefiningAssembly(ByVal obj As Object) + ' Console.WriteLine("{0} lives here: {1}", obj.GetType().Name, _ + ' obj.GetType().Assembly) + ' Console.WriteLine() + 'End Sub + + ' This version takes a booelan argument when calling the method. + _ + Public Sub DisplayDefiningAssembly(ByVal obj As Object, Optional ByVal showDetails As Boolean = False) + Console.WriteLine("Defining Assembly: {0}", obj.GetType().Assembly) + + If showDetails Then + Console.WriteLine("Name of type: {0}", obj.GetType().Name) + Console.WriteLine("Parent of type: {0}", obj.GetType().BaseType) + Console.WriteLine("Is generic?: {0}", obj.GetType().IsGenericType) + End If + End Sub + + ' This method allows any integer to reverse its digits. + ' For example, 56 would return 65. + _ + Public Function ReverseDigits(ByVal i As Integer) As Integer + ' Translate int into a string, and then + ' get all the characters. + Dim digits() As Char = i.ToString().ToCharArray() + + ' Now reverse items in the array. + Array.Reverse(digits) + + ' Put back into string. + Dim newDigits As String = New String(digits) + + ' Finally, return the modified string back as an int. + Return Integer.Parse(newDigits) + End Function +End Module +#End Region diff --git a/Code/Chapter 13/MyExtensionsLibrary/MyExtensionsLibrary.sln b/Code/Chapter 13/MyExtensionsLibrary/MyExtensionsLibrary.sln new file mode 100644 index 0000000..af028ce --- /dev/null +++ b/Code/Chapter 13/MyExtensionsLibrary/MyExtensionsLibrary.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MyExtensionsLibrary", "MyExtensionsLibrary.vbproj", "{02A84287-CCD2-44B5-B9DD-A6E38067B4BA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {02A84287-CCD2-44B5-B9DD-A6E38067B4BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {02A84287-CCD2-44B5-B9DD-A6E38067B4BA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {02A84287-CCD2-44B5-B9DD-A6E38067B4BA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {02A84287-CCD2-44B5-B9DD-A6E38067B4BA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 13/MyExtensionsLibrary/MyExtensionsLibrary.suo b/Code/Chapter 13/MyExtensionsLibrary/MyExtensionsLibrary.suo new file mode 100644 index 0000000..c98ae12 Binary files /dev/null and b/Code/Chapter 13/MyExtensionsLibrary/MyExtensionsLibrary.suo differ diff --git a/Code/Chapter 13/MyExtensionsLibrary/MyExtensionsLibrary.vbproj b/Code/Chapter 13/MyExtensionsLibrary/MyExtensionsLibrary.vbproj new file mode 100644 index 0000000..a120f6a --- /dev/null +++ b/Code/Chapter 13/MyExtensionsLibrary/MyExtensionsLibrary.vbproj @@ -0,0 +1,113 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {02A84287-CCD2-44B5-B9DD-A6E38067B4BA} + Library + MyExtensionsLibrary + MyExtensionsLibrary + 512 + Windows + v3.5 + On + Binary + On + On + + + true + full + true + true + bin\Debug\ + MyExtensionsLibrary.xml + + + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + + + pdbonly + false + true + true + bin\Release\ + MyExtensionsLibrary.xml + + + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 13/MyExtensionsLibraryClient/My Project/Application.Designer.vb b/Code/Chapter 13/MyExtensionsLibraryClient/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 13/MyExtensionsLibraryClient/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 13/MyExtensionsLibraryClient/My Project/Application.myapp b/Code/Chapter 13/MyExtensionsLibraryClient/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 13/MyExtensionsLibraryClient/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 13/MyExtensionsLibraryClient/My Project/AssemblyInfo.vb b/Code/Chapter 13/MyExtensionsLibraryClient/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..d18638e --- /dev/null +++ b/Code/Chapter 13/MyExtensionsLibraryClient/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/Code/Chapter 13/MyExtensionsLibraryClient/My Project/Resources.Designer.vb b/Code/Chapter 13/MyExtensionsLibraryClient/My Project/Resources.Designer.vb new file mode 100644 index 0000000..2260a72 --- /dev/null +++ b/Code/Chapter 13/MyExtensionsLibraryClient/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("MyExtensionsLibraryClient.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/Code/Chapter 13/MyExtensionsLibraryClient/My Project/Resources.resx b/Code/Chapter 13/MyExtensionsLibraryClient/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 13/MyExtensionsLibraryClient/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/Code/Chapter 13/MyExtensionsLibraryClient/My Project/Settings.Designer.vb b/Code/Chapter 13/MyExtensionsLibraryClient/My Project/Settings.Designer.vb new file mode 100644 index 0000000..9179488 --- /dev/null +++ b/Code/Chapter 13/MyExtensionsLibraryClient/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.MyExtensionsLibraryClient.My.MySettings + Get + Return Global.MyExtensionsLibraryClient.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 13/MyExtensionsLibraryClient/My Project/Settings.settings b/Code/Chapter 13/MyExtensionsLibraryClient/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 13/MyExtensionsLibraryClient/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 13/MyExtensionsLibraryClient/MyExtensionsLibraryClient.sln b/Code/Chapter 13/MyExtensionsLibraryClient/MyExtensionsLibraryClient.sln new file mode 100644 index 0000000..45aa807 --- /dev/null +++ b/Code/Chapter 13/MyExtensionsLibraryClient/MyExtensionsLibraryClient.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MyExtensionsLibraryClient", "MyExtensionsLibraryClient.vbproj", "{092FD18B-9084-4D44-A2A5-E1CD103597DF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {092FD18B-9084-4D44-A2A5-E1CD103597DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {092FD18B-9084-4D44-A2A5-E1CD103597DF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {092FD18B-9084-4D44-A2A5-E1CD103597DF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {092FD18B-9084-4D44-A2A5-E1CD103597DF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 13/MyExtensionsLibraryClient/MyExtensionsLibraryClient.suo b/Code/Chapter 13/MyExtensionsLibraryClient/MyExtensionsLibraryClient.suo new file mode 100644 index 0000000..0cdf878 Binary files /dev/null and b/Code/Chapter 13/MyExtensionsLibraryClient/MyExtensionsLibraryClient.suo differ diff --git a/Code/Chapter 13/MyExtensionsLibraryClient/MyExtensionsLibraryClient.vbproj b/Code/Chapter 13/MyExtensionsLibraryClient/MyExtensionsLibraryClient.vbproj new file mode 100644 index 0000000..a490e86 --- /dev/null +++ b/Code/Chapter 13/MyExtensionsLibraryClient/MyExtensionsLibraryClient.vbproj @@ -0,0 +1,119 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {092FD18B-9084-4D44-A2A5-E1CD103597DF} + Exe + MyExtensionsLibraryClient.Program + MyExtensionsLibraryClient + MyExtensionsLibraryClient + 512 + Console + v3.5 + On + Binary + On + On + + + true + full + true + true + bin\Debug\ + MyExtensionsLibraryClient.xml + + + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + true + + + pdbonly + false + true + true + bin\Release\ + MyExtensionsLibraryClient.xml + + + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + true + + + + False + ..\MyExtensionsLibrary\bin\Debug\MyExtensionsLibrary.dll + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 13/MyExtensionsLibraryClient/MyExtensionsLibraryClient.vbproj.user b/Code/Chapter 13/MyExtensionsLibraryClient/MyExtensionsLibraryClient.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 13/MyExtensionsLibraryClient/MyExtensionsLibraryClient.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 13/MyExtensionsLibraryClient/Program.vb b/Code/Chapter 13/MyExtensionsLibraryClient/Program.vb new file mode 100644 index 0000000..0591f7b --- /dev/null +++ b/Code/Chapter 13/MyExtensionsLibraryClient/Program.vb @@ -0,0 +1,17 @@ +Imports MyExtensionsLibrary + +Module Program + + Sub Main() + Console.WriteLine("***** Using Library with Extensions *****") + ' This time, these extension methods + ' have been defined within an external + ' .NET class library. + Dim myInt As Integer = 987 + myInt.DisplayDefiningAssembly() + Console.WriteLine("{0} is reversed to {1}", _ + myInt, myInt.ReverseDigits()) + Console.ReadLine() + End Sub + +End Module diff --git a/Code/Chapter 13/ObjectInitializers/My Project/Application.Designer.vb b/Code/Chapter 13/ObjectInitializers/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 13/ObjectInitializers/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 13/ObjectInitializers/My Project/Application.myapp b/Code/Chapter 13/ObjectInitializers/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 13/ObjectInitializers/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 13/ObjectInitializers/My Project/AssemblyInfo.vb b/Code/Chapter 13/ObjectInitializers/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..d992cd3 --- /dev/null +++ b/Code/Chapter 13/ObjectInitializers/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/Code/Chapter 13/ObjectInitializers/My Project/Resources.Designer.vb b/Code/Chapter 13/ObjectInitializers/My Project/Resources.Designer.vb new file mode 100644 index 0000000..240f3f4 --- /dev/null +++ b/Code/Chapter 13/ObjectInitializers/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("ObjectInitializers.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/Code/Chapter 13/ObjectInitializers/My Project/Resources.resx b/Code/Chapter 13/ObjectInitializers/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 13/ObjectInitializers/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/Code/Chapter 13/ObjectInitializers/My Project/Settings.Designer.vb b/Code/Chapter 13/ObjectInitializers/My Project/Settings.Designer.vb new file mode 100644 index 0000000..537b407 --- /dev/null +++ b/Code/Chapter 13/ObjectInitializers/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.ObjectInitializers.My.MySettings + Get + Return Global.ObjectInitializers.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 13/ObjectInitializers/My Project/Settings.settings b/Code/Chapter 13/ObjectInitializers/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 13/ObjectInitializers/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 13/ObjectInitializers/ObjectInitializers.sln b/Code/Chapter 13/ObjectInitializers/ObjectInitializers.sln new file mode 100644 index 0000000..5e30fcb --- /dev/null +++ b/Code/Chapter 13/ObjectInitializers/ObjectInitializers.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ObjectInitializers", "ObjectInitializers.vbproj", "{97579564-C908-4396-B117-D9B5B2E1CDE1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {97579564-C908-4396-B117-D9B5B2E1CDE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {97579564-C908-4396-B117-D9B5B2E1CDE1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {97579564-C908-4396-B117-D9B5B2E1CDE1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {97579564-C908-4396-B117-D9B5B2E1CDE1}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 13/ObjectInitializers/ObjectInitializers.suo b/Code/Chapter 13/ObjectInitializers/ObjectInitializers.suo new file mode 100644 index 0000000..2282214 Binary files /dev/null and b/Code/Chapter 13/ObjectInitializers/ObjectInitializers.suo differ diff --git a/Code/Chapter 13/ObjectInitializers/ObjectInitializers.vbproj b/Code/Chapter 13/ObjectInitializers/ObjectInitializers.vbproj new file mode 100644 index 0000000..cd90550 --- /dev/null +++ b/Code/Chapter 13/ObjectInitializers/ObjectInitializers.vbproj @@ -0,0 +1,117 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {97579564-C908-4396-B117-D9B5B2E1CDE1} + Exe + ObjectInitializers.Program + ObjectInitializers + ObjectInitializers + 512 + Console + v3.5 + On + Binary + On + On + + + true + full + true + true + bin\Debug\ + ObjectInitializers.xml + + + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + true + + + pdbonly + false + true + true + bin\Release\ + ObjectInitializers.xml + + + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + true + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + + 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/Code/Chapter 13/ObjectInitializers/Point.vb b/Code/Chapter 13/ObjectInitializers/Point.vb new file mode 100644 index 0000000..201135c --- /dev/null +++ b/Code/Chapter 13/ObjectInitializers/Point.vb @@ -0,0 +1,45 @@ +Public Enum PointColor + LightBlue + BloodRed + Gold +End Enum + +Public Class Point + Public xPos, yPos As Integer + Private c As PointColor + + Public Sub New(ByVal color As PointColor) + xPos = 0 + yPos = 0 + c = color + End Sub + Public Sub New() + End Sub + + Public Sub New(ByVal x As Integer, ByVal y As Integer) + xPos = x + yPos = y + c = PointColor.Gold + End Sub + + Public Property X() As Integer + Get + Return xPos + End Get + Set(ByVal value As Integer) + xPos = value + End Set + End Property + Public Property Y() As Integer + Get + Return yPos + End Get + Set(ByVal value As Integer) + yPos = value + End Set + End Property + + Public Overrides Function ToString() As String + Return String.Format("[{0}, {1}, {2}]", xPos, yPos, c) + End Function +End Class diff --git a/Code/Chapter 13/ObjectInitializers/Program.vb b/Code/Chapter 13/ObjectInitializers/Program.vb new file mode 100644 index 0000000..9d7b602 --- /dev/null +++ b/Code/Chapter 13/ObjectInitializers/Program.vb @@ -0,0 +1,41 @@ +Module Program + + Sub Main() + Console.WriteLine("***** Fun with Object Init Syntax *****") + ' Make a Point by setting each property manually... + Dim firstPoint As New Point() + firstPoint.X = 10 + firstPoint.Y = 10 + Console.WriteLine(firstPoint.ToString()) + + ' ...or make a Point via a custom constructor... + Dim anotherPoint As New Point(20, 20) + Console.WriteLine(anotherPoint.ToString()) + + ' ...or make a Point types using the new object init syntax. + Dim finalPoint As New Point() With {.X = 30, .Y = 30} + Console.WriteLine(finalPoint.ToString()) + + Dim p As New Point With {.xPos = 2, .yPos = 3, .X = 900} + Console.WriteLine(p.ToString()) + + ' Calling a custom constructor. + Dim pt As New Point(10, 16) With {.X = 100, .Y = 100} + Console.WriteLine(pt.ToString()) + + ' Calling a more interesting custom constructor with init syntax. + Dim goldPoint As New Point(PointColor.Gold) With {.X = 90, .Y = 20} + Console.WriteLine("Value of Point is: {0}", goldPoint) + + + ' Create and initialize a Rectangle. + Dim myRect As New Rectangle() With _ + { _ + .TopLeft = New Point() With {.X = 10, .Y = 10}, _ + .BottomRight = New Point() With {.X = 200, .Y = 200} _ + } + Console.WriteLine(myRect) + Console.ReadLine() + End Sub + +End Module diff --git a/Code/Chapter 13/ObjectInitializers/Rectangle.vb b/Code/Chapter 13/ObjectInitializers/Rectangle.vb new file mode 100644 index 0000000..0fdeac6 --- /dev/null +++ b/Code/Chapter 13/ObjectInitializers/Rectangle.vb @@ -0,0 +1,26 @@ +Public Class Rectangle + Private m_topLeft As New Point() + Private m_bottomRight As New Point() + + Public Property TopLeft() As Point + Get + Return m_topLeft + End Get + Set(ByVal value As Point) + m_topLeft = value + End Set + End Property + Public Property BottomRight() As Point + Get + Return m_bottomRight + End Get + Set(ByVal value As Point) + m_bottomRight = value + End Set + End Property + + Public Overrides Function ToString() As String + Return String.Format("[TopLeft: {0}, {1}, BottomRight: {2}, {3}]", _ + m_topLeft.X, m_topLeft.Y, m_bottomRight.X, m_bottomRight.Y) + End Function +End Class diff --git a/Code/Chapter 14/FunWithLinqExpressions/FunWithLinqExpressions.sln b/Code/Chapter 14/FunWithLinqExpressions/FunWithLinqExpressions.sln new file mode 100644 index 0000000..5b45e3c --- /dev/null +++ b/Code/Chapter 14/FunWithLinqExpressions/FunWithLinqExpressions.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "FunWithLinqExpressions", "FunWithLinqExpressions.vbproj", "{158B95C7-4186-4C5C-A301-596B68FF5801}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {158B95C7-4186-4C5C-A301-596B68FF5801}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {158B95C7-4186-4C5C-A301-596B68FF5801}.Debug|Any CPU.Build.0 = Debug|Any CPU + {158B95C7-4186-4C5C-A301-596B68FF5801}.Release|Any CPU.ActiveCfg = Release|Any CPU + {158B95C7-4186-4C5C-A301-596B68FF5801}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 14/FunWithLinqExpressions/FunWithLinqExpressions.suo b/Code/Chapter 14/FunWithLinqExpressions/FunWithLinqExpressions.suo new file mode 100644 index 0000000..9ad2834 Binary files /dev/null and b/Code/Chapter 14/FunWithLinqExpressions/FunWithLinqExpressions.suo differ diff --git a/Code/Chapter 14/FunWithLinqExpressions/FunWithLinqExpressions.vbproj b/Code/Chapter 14/FunWithLinqExpressions/FunWithLinqExpressions.vbproj new file mode 100644 index 0000000..6ba5b86 --- /dev/null +++ b/Code/Chapter 14/FunWithLinqExpressions/FunWithLinqExpressions.vbproj @@ -0,0 +1,115 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {158B95C7-4186-4C5C-A301-596B68FF5801} + Exe + FunWithLinqExpressions.Program + FunWithLinqExpressions + FunWithLinqExpressions + 512 + Console + v3.5 + On + Binary + On + On + + + true + full + true + true + bin\Debug\ + FunWithLinqExpressions.xml + + + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + true + + + pdbonly + false + true + true + bin\Release\ + FunWithLinqExpressions.xml + + + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + true + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 14/FunWithLinqExpressions/My Project/Application.Designer.vb b/Code/Chapter 14/FunWithLinqExpressions/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 14/FunWithLinqExpressions/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 14/FunWithLinqExpressions/My Project/Application.myapp b/Code/Chapter 14/FunWithLinqExpressions/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 14/FunWithLinqExpressions/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 14/FunWithLinqExpressions/My Project/AssemblyInfo.vb b/Code/Chapter 14/FunWithLinqExpressions/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..507b1b0 --- /dev/null +++ b/Code/Chapter 14/FunWithLinqExpressions/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/Code/Chapter 14/FunWithLinqExpressions/My Project/Resources.Designer.vb b/Code/Chapter 14/FunWithLinqExpressions/My Project/Resources.Designer.vb new file mode 100644 index 0000000..9f30219 --- /dev/null +++ b/Code/Chapter 14/FunWithLinqExpressions/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("FunWithLinqExpressions.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/Code/Chapter 14/FunWithLinqExpressions/My Project/Resources.resx b/Code/Chapter 14/FunWithLinqExpressions/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 14/FunWithLinqExpressions/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/Code/Chapter 14/FunWithLinqExpressions/My Project/Settings.Designer.vb b/Code/Chapter 14/FunWithLinqExpressions/My Project/Settings.Designer.vb new file mode 100644 index 0000000..6159ca6 --- /dev/null +++ b/Code/Chapter 14/FunWithLinqExpressions/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.FunWithLinqExpressions.My.MySettings + Get + Return Global.FunWithLinqExpressions.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 14/FunWithLinqExpressions/My Project/Settings.settings b/Code/Chapter 14/FunWithLinqExpressions/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 14/FunWithLinqExpressions/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 14/FunWithLinqExpressions/Program.vb b/Code/Chapter 14/FunWithLinqExpressions/Program.vb new file mode 100644 index 0000000..d0ac894 --- /dev/null +++ b/Code/Chapter 14/FunWithLinqExpressions/Program.vb @@ -0,0 +1,179 @@ + +#Region "Car class for testing purposes" +Public Class Car + Public PetName As String = String.Empty + Public Color As String = String.Empty + Public Speed As Integer + Public Make As String = String.Empty + + Public Overloads Overrides Function ToString() As String + Return String.Format("Make={0}, Color={1}, Speed={2}, PetName={3}", Make, Color, Speed, PetName) + End Function +End Class +#End Region + +Module Program + + Sub Main() + Console.WriteLine("***** Fun with Query Expressions *****") + + ' This array will be the basis of our testing... + Dim myCars As Car() = {New Car With _ + {.PetName = "Henry", .Color = "Silver", _ + .Speed = 100, .Make = "BMW"}, _ + New Car With {.PetName = "Daisy", .Color = "Tan", .Speed = 90, .Make = "BMW"}, _ + New Car With {.PetName = "Mary", .Color = "Black", .Speed = 55, .Make = "VW"}, _ + New Car With {.PetName = "Clunker", _ + .Color = "Rust", .Speed = 5, .Make = "Yugo"}, _ + New Car With {.PetName = "Hank", .Color = "Tan", .Speed = 0, .Make = "Ford"}, _ + New Car With {.PetName = "Sven", .Color = "White", .Speed = 90, .Make = "Ford"}, _ + New Car With {.PetName = "Mary", .Color = "Black", .Speed = 55, .Make = "VW"}, _ + New Car With {.PetName = "Zippy", .Color = "Yellow", .Speed = 55, .Make = "VW"}, _ + New Car With {.PetName = "Melvin", .Color = "White", _ + .Speed = 43, .Make = "Ford"}} + + ' Comment / uncomment to test. + 'BasicSelections(myCars) + 'GetSubsets(myCars) + 'GetProjection(myCars) + 'ReversedSelection(myCars) + 'OrderedResults(myCars) + GetDiff() + + Console.ReadLine() + End Sub + + +#Region "Select everything" + Sub BasicSelections(ByVal myCars As Car()) + + ' Get all cars. Similar to Select * in SQL. + Console.WriteLine(vbLf + "All Cars:") + Dim allCars = From c In myCars Select c + For Each c In allCars + Console.WriteLine("Car: {0}", c) + Next + Console.WriteLine() + + ' Get only the pet names. + Console.WriteLine(vbLf + "All Pet Names:") + Dim allNames = From c In myCars Select c.PetName + For Each n In allNames + Console.WriteLine("Pet Name: {0}", n) + Next + Console.WriteLine() + + ' Now get only distinct makes. + Console.WriteLine(vbLf + "All Distinct Makes:") + Dim makes = From c In myCars Select c.Make Distinct + For Each m In makes + Console.WriteLine("Make: {0}", m) + Next + Console.WriteLine() + + End Sub +#End Region + +#Region "Get subsets" + Sub GetSubsets(ByVal myCars As Car()) + ' Now get only the BMWs. + Console.WriteLine("Only BMWs:") + Dim onlyBMWs = From c In myCars Where c.Make = "BMW" Select c + + For Each n In onlyBMWs + Console.WriteLine("Name: {0}", n) + Next + + ' Get BMWs going at least 100 mph. + Dim onlyFastBMWs = From c In myCars _ + Where c.Make = "BMW" And c.Speed >= 100 _ + Select c + + For Each c As Car In onlyFastBMWs + Console.WriteLine("{0} is going {1} MPH", c.PetName, c.Speed) + Next + End Sub +#End Region + +#Region "Get count" + Sub GetCount() + Dim currentVideoGames() As String = {"Morrowind", "BioShock", _ + "Half Life 2: Episode 1", "The Darkness", _ + "Daxter", "System Shock 2"} + + ' Get count from the query. + Dim numb As Integer = (From g In currentVideoGames _ + Where g.Length > 6 _ + Order By g _ + Select g).Count() + + ' numb is the value 5. + Console.WriteLine("{0} items honor the LINQ query.", numb) + End Sub +#End Region + +#Region "Get projection" + Sub GetProjection(ByVal myCars As Car()) + ' Now get structured data which only accounts for the + ' Make and Color of each item. + Console.WriteLine(vbLf + "Makes and Color:") + + Dim makesColors = From c In myCars Select New With {c.Make, c.Color} + + For Each n In makesColors + Console.WriteLine("Name: {0}", n) + Next + End Sub +#End Region + +#Region "Reverse selections" + Sub ReversedSelection(ByVal myCars As Car()) + ' Get everything in reverse. + Console.WriteLine("All cars in reverse:") + Dim subset = (From c In myCars Select c).Reverse() + For Each c As Car In subset + Console.WriteLine("{0} is going {1} MPH", c.PetName, c.Speed) + Next + End Sub +#End Region + +#Region "Ordering results" + Sub OrderedResults(ByVal myCars As Car()) + ' Order all the cars by PetName. + Dim subset = From c In myCars Order By c.PetName Select c + + Console.WriteLine("Ordered by PetName:") + For Each c As Car In subset + Console.WriteLine("Car {0}", c) + Next + + ' Now find the cars that are going less than 55 mph, + ' and order by descending PetName + subset = From c In myCars _ + Where c.Speed > 55 Order By c.PetName Descending Select c + Console.WriteLine(vbLf + "Cars going faster than 55, ordered by PetName:") + For Each c As Car In subset + Console.WriteLine("Car {0}", c) + Next + End Sub +#End Region + +#Region "Get differences" + Sub GetDiff() + ' Two lists of strings. + Dim myCars As String() = {"Yugo", "Aztec", "BMW"} + Dim yourCars As String() = {"BMW", "Saab", "Aztec"} + + ' Find the differences. + Dim carDiff = (From c In myCars Select c) _ + .Except(From c2 In yourCars Select c2) + + Console.WriteLine(vbLf + "Here is what you don't have, but I do:") + For Each s As String In carDiff + ' Prints Yugo. + Console.WriteLine(s) + Next + End Sub +#End Region + +End Module diff --git a/Code/Chapter 14/LinqOverArray/LinqOverArray.sln b/Code/Chapter 14/LinqOverArray/LinqOverArray.sln new file mode 100644 index 0000000..8108b04 --- /dev/null +++ b/Code/Chapter 14/LinqOverArray/LinqOverArray.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "LinqOverArray", "LinqOverArray.vbproj", "{E7B51EFA-66CF-43D4-85CF-95301EF2C2A9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E7B51EFA-66CF-43D4-85CF-95301EF2C2A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E7B51EFA-66CF-43D4-85CF-95301EF2C2A9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E7B51EFA-66CF-43D4-85CF-95301EF2C2A9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E7B51EFA-66CF-43D4-85CF-95301EF2C2A9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 14/LinqOverArray/LinqOverArray.suo b/Code/Chapter 14/LinqOverArray/LinqOverArray.suo new file mode 100644 index 0000000..a91dc81 Binary files /dev/null and b/Code/Chapter 14/LinqOverArray/LinqOverArray.suo differ diff --git a/Code/Chapter 14/LinqOverArray/LinqOverArray.vbproj b/Code/Chapter 14/LinqOverArray/LinqOverArray.vbproj new file mode 100644 index 0000000..32b5f19 --- /dev/null +++ b/Code/Chapter 14/LinqOverArray/LinqOverArray.vbproj @@ -0,0 +1,109 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {E7B51EFA-66CF-43D4-85CF-95301EF2C2A9} + Exe + LinqOverArray.Program + LinqOverArray + LinqOverArray + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + LinqOverArray.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + LinqOverArray.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 14/LinqOverArray/My Project/Application.Designer.vb b/Code/Chapter 14/LinqOverArray/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 14/LinqOverArray/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 14/LinqOverArray/My Project/Application.myapp b/Code/Chapter 14/LinqOverArray/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 14/LinqOverArray/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 14/LinqOverArray/My Project/AssemblyInfo.vb b/Code/Chapter 14/LinqOverArray/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..3262b7e --- /dev/null +++ b/Code/Chapter 14/LinqOverArray/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/Code/Chapter 14/LinqOverArray/My Project/Resources.Designer.vb b/Code/Chapter 14/LinqOverArray/My Project/Resources.Designer.vb new file mode 100644 index 0000000..0e4d7a7 --- /dev/null +++ b/Code/Chapter 14/LinqOverArray/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("LinqOverArray.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/Code/Chapter 14/LinqOverArray/My Project/Resources.resx b/Code/Chapter 14/LinqOverArray/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 14/LinqOverArray/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/Code/Chapter 14/LinqOverArray/My Project/Settings.Designer.vb b/Code/Chapter 14/LinqOverArray/My Project/Settings.Designer.vb new file mode 100644 index 0000000..a4287e3 --- /dev/null +++ b/Code/Chapter 14/LinqOverArray/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.LinqOverArray.My.MySettings + Get + Return Global.LinqOverArray.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 14/LinqOverArray/My Project/Settings.settings b/Code/Chapter 14/LinqOverArray/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 14/LinqOverArray/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 14/LinqOverArray/Program.vb b/Code/Chapter 14/LinqOverArray/Program.vb new file mode 100644 index 0000000..44df0f2 --- /dev/null +++ b/Code/Chapter 14/LinqOverArray/Program.vb @@ -0,0 +1,79 @@ +Option Explicit On +Option Strict On + +Module Program + + Sub Main() + Console.WriteLine("***** Fun with LINQ *****") + 'QueryOverStrings() + Console.WriteLine() + QueryOverInts() + Console.ReadLine() + End Sub + +#Region "Simple query over strings and integers" + Sub QueryOverStrings() + ' Assume we have an array of strings. + ' that have more than 6 letters. + Dim currentVideoGames As String() = {"Morrowind", "BioShock", _ + "Half Life 2: Episode 1", "The Darkness", _ + "Daxter", "System Shock 2"} + + Dim subset As IEnumerable(Of String) = From game In currentVideoGames _ + Where game.Length > 6 Order By game Select game + ReflectOverQueryResults(subset) + + ' Print out the results. + For Each s As String In subset + Console.WriteLine("Item: {0}", s) + Next + Console.WriteLine() + End Sub + + Sub QueryOverInts() + Dim numbers() As Integer = {10, 20, 30, 40, 1, 2, 3, 8} + + ' Only print items less than 10. + ' (note use of implicit typing) + Dim subset = From i In numbers Where i < 10 Select i + + ' LINQ statment evaluated here! + For Each i In subset + Console.WriteLine("{0} < 10", i) + Next + + ' Change some data in the array. + numbers(0) = 4 + Console.WriteLine() + + ' Evaluate again. + For Each i In subset + Console.WriteLine("{0} < 10", i) + Next + ReflectOverQueryResults(subset) + End Sub + +#End Region + +#Region "Immediate execution" + Sub ImmediateExecution() + Dim numbers() As Integer = {10, 20, 30, 40, 1, 2, 3, 8} + + ' Get data RIGHT NOW as Integer(). + Dim subsetAsIntArray() As Integer = _ + (From i In numbers Where i < 10 Select i).ToArray() + + ' Get data RIGHT NOW as List(Of Integer). + Dim subsetAsListOfInts As List(Of Integer) = _ + (From i In numbers Where i < 10 Select i).ToList() + End Sub +#End Region + + Sub ReflectOverQueryResults(ByVal resultSet As Object) + Console.WriteLine("***** Info about your query *****") + Console.WriteLine("resultSet is of type: {0}", resultSet.GetType().Name) + Console.WriteLine("resultSet location: {0}", resultSet.GetType().Assembly) + Console.WriteLine() + End Sub + +End Module diff --git a/Code/Chapter 14/LinqOverArrayList/Car.vb b/Code/Chapter 14/LinqOverArrayList/Car.vb new file mode 100644 index 0000000..610f10a --- /dev/null +++ b/Code/Chapter 14/LinqOverArrayList/Car.vb @@ -0,0 +1,6 @@ +Public Class Car + Public PetName As String = String.Empty + Public Color As String = String.Empty + Public Speed As Integer + Public Make As String = String.Empty +End Class diff --git a/Code/Chapter 14/LinqOverArrayList/LinqOverArrayList.sln b/Code/Chapter 14/LinqOverArrayList/LinqOverArrayList.sln new file mode 100644 index 0000000..0dd293a --- /dev/null +++ b/Code/Chapter 14/LinqOverArrayList/LinqOverArrayList.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "LinqOverArrayList", "LinqOverArrayList.vbproj", "{F9E03354-E667-40C4-8869-8AD9084DB16A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F9E03354-E667-40C4-8869-8AD9084DB16A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F9E03354-E667-40C4-8869-8AD9084DB16A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F9E03354-E667-40C4-8869-8AD9084DB16A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F9E03354-E667-40C4-8869-8AD9084DB16A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 14/LinqOverArrayList/LinqOverArrayList.suo b/Code/Chapter 14/LinqOverArrayList/LinqOverArrayList.suo new file mode 100644 index 0000000..4f7955b Binary files /dev/null and b/Code/Chapter 14/LinqOverArrayList/LinqOverArrayList.suo differ diff --git a/Code/Chapter 14/LinqOverArrayList/LinqOverArrayList.vbproj b/Code/Chapter 14/LinqOverArrayList/LinqOverArrayList.vbproj new file mode 100644 index 0000000..843d0ab --- /dev/null +++ b/Code/Chapter 14/LinqOverArrayList/LinqOverArrayList.vbproj @@ -0,0 +1,114 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {F9E03354-E667-40C4-8869-8AD9084DB16A} + Exe + LinqOverArrayList.Program + LinqOverArrayList + LinqOverArrayList + 512 + Console + v3.5 + On + Binary + On + On + + + true + full + true + true + bin\Debug\ + LinqOverArrayList.xml + + + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + + + pdbonly + false + true + true + bin\Release\ + LinqOverArrayList.xml + + + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + + 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/Code/Chapter 14/LinqOverArrayList/My Project/Application.Designer.vb b/Code/Chapter 14/LinqOverArrayList/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 14/LinqOverArrayList/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 14/LinqOverArrayList/My Project/Application.myapp b/Code/Chapter 14/LinqOverArrayList/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 14/LinqOverArrayList/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 14/LinqOverArrayList/My Project/AssemblyInfo.vb b/Code/Chapter 14/LinqOverArrayList/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..0c80e61 --- /dev/null +++ b/Code/Chapter 14/LinqOverArrayList/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/Code/Chapter 14/LinqOverArrayList/My Project/Resources.Designer.vb b/Code/Chapter 14/LinqOverArrayList/My Project/Resources.Designer.vb new file mode 100644 index 0000000..f4d9bb7 --- /dev/null +++ b/Code/Chapter 14/LinqOverArrayList/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("LinqOverArrayList.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/Code/Chapter 14/LinqOverArrayList/My Project/Resources.resx b/Code/Chapter 14/LinqOverArrayList/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 14/LinqOverArrayList/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/Code/Chapter 14/LinqOverArrayList/My Project/Settings.Designer.vb b/Code/Chapter 14/LinqOverArrayList/My Project/Settings.Designer.vb new file mode 100644 index 0000000..bf77ad8 --- /dev/null +++ b/Code/Chapter 14/LinqOverArrayList/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.LinqOverArrayList.My.MySettings + Get + Return Global.LinqOverArrayList.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 14/LinqOverArrayList/My Project/Settings.settings b/Code/Chapter 14/LinqOverArrayList/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 14/LinqOverArrayList/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 14/LinqOverArrayList/Program.vb b/Code/Chapter 14/LinqOverArrayList/Program.vb new file mode 100644 index 0000000..895911f --- /dev/null +++ b/Code/Chapter 14/LinqOverArrayList/Program.vb @@ -0,0 +1,44 @@ +Option Strict On + +Module Program + Sub Main() + Console.WriteLine("***** LINQ over ArrayList *****") + + Dim myCars As New ArrayList() + myCars.Add(New Car With {.PetName = "Henry", .Color = "Silver", _ + .Speed = 100, .Make = "BMW"}) + myCars.Add(New Car With {.PetName = "Daisy", .Color = "Tan", _ + .Speed = 90, .Make = "BMW"}) + myCars.Add(New Car With {.PetName = "Mary", .Color = "Black", _ + .Speed = 55, .Make = "VW"}) + myCars.Add(New Car With {.PetName = "Clunker", .Color = "Rust", _ + .Speed = 5, .Make = "Yugo"}) + myCars.Add(New Car With {.PetName = "Melvin", .Color = "White", _ + .Speed = 43, .Make = "Ford"}) + + ' Transform ArrayList into an IEnumerable-compatible type. + ' Could also use implicit typing here. + Dim myCarsEnum As IEnumerable(Of Car) = myCars.OfType(Of Car)() + + ' Create a query expression. + Dim fastCars = From c In myCarsEnum Where c.Speed > 55 Select c + + For Each car In fastCars + Console.WriteLine("{0} is going too fast!", car.PetName) + Next + + ExtractNumericalData() + End Sub + + Sub ExtractNumericalData() + ' Extract the ints from the ArrayList. + Dim myStuff As New ArrayList() + myStuff.AddRange(New Object() {10, 400, 8, False, New Car(), "string data"}) + Dim myInts As IEnumerable(Of Integer) = myStuff.OfType(Of Integer)() + + ' Prints out 10, 400, and 8. + For Each i As Integer In myInts + Console.WriteLine("Int value: {0}", i) + Next + End Sub +End Module diff --git a/Code/Chapter 14/LinqOverCustomObjects/Car.vb b/Code/Chapter 14/LinqOverCustomObjects/Car.vb new file mode 100644 index 0000000..610f10a --- /dev/null +++ b/Code/Chapter 14/LinqOverCustomObjects/Car.vb @@ -0,0 +1,6 @@ +Public Class Car + Public PetName As String = String.Empty + Public Color As String = String.Empty + Public Speed As Integer + Public Make As String = String.Empty +End Class diff --git a/Code/Chapter 14/LinqOverCustomObjects/LinqOverCustomObjects.sln b/Code/Chapter 14/LinqOverCustomObjects/LinqOverCustomObjects.sln new file mode 100644 index 0000000..dbaf08d --- /dev/null +++ b/Code/Chapter 14/LinqOverCustomObjects/LinqOverCustomObjects.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "LinqOverCustomObjects", "LinqOverCustomObjects.vbproj", "{47B8A7A5-0D48-4909-908E-D38895D575B4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {47B8A7A5-0D48-4909-908E-D38895D575B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {47B8A7A5-0D48-4909-908E-D38895D575B4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {47B8A7A5-0D48-4909-908E-D38895D575B4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {47B8A7A5-0D48-4909-908E-D38895D575B4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 14/LinqOverCustomObjects/LinqOverCustomObjects.suo b/Code/Chapter 14/LinqOverCustomObjects/LinqOverCustomObjects.suo new file mode 100644 index 0000000..5147cff Binary files /dev/null and b/Code/Chapter 14/LinqOverCustomObjects/LinqOverCustomObjects.suo differ diff --git a/Code/Chapter 14/LinqOverCustomObjects/LinqOverCustomObjects.vbproj b/Code/Chapter 14/LinqOverCustomObjects/LinqOverCustomObjects.vbproj new file mode 100644 index 0000000..4acea1c --- /dev/null +++ b/Code/Chapter 14/LinqOverCustomObjects/LinqOverCustomObjects.vbproj @@ -0,0 +1,110 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {47B8A7A5-0D48-4909-908E-D38895D575B4} + Exe + LinqOverCustomObjects.Program + LinqOverCustomObjects + LinqOverCustomObjects + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + LinqOverCustomObjects.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + LinqOverCustomObjects.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + + 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/Code/Chapter 14/LinqOverCustomObjects/My Project/Application.Designer.vb b/Code/Chapter 14/LinqOverCustomObjects/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 14/LinqOverCustomObjects/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 14/LinqOverCustomObjects/My Project/Application.myapp b/Code/Chapter 14/LinqOverCustomObjects/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 14/LinqOverCustomObjects/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 14/LinqOverCustomObjects/My Project/AssemblyInfo.vb b/Code/Chapter 14/LinqOverCustomObjects/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..40c14f6 --- /dev/null +++ b/Code/Chapter 14/LinqOverCustomObjects/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/Code/Chapter 14/LinqOverCustomObjects/My Project/Resources.Designer.vb b/Code/Chapter 14/LinqOverCustomObjects/My Project/Resources.Designer.vb new file mode 100644 index 0000000..0cbfc7b --- /dev/null +++ b/Code/Chapter 14/LinqOverCustomObjects/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("LinqOverCustomObjects.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/Code/Chapter 14/LinqOverCustomObjects/My Project/Resources.resx b/Code/Chapter 14/LinqOverCustomObjects/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 14/LinqOverCustomObjects/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/Code/Chapter 14/LinqOverCustomObjects/My Project/Settings.Designer.vb b/Code/Chapter 14/LinqOverCustomObjects/My Project/Settings.Designer.vb new file mode 100644 index 0000000..712e8be --- /dev/null +++ b/Code/Chapter 14/LinqOverCustomObjects/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.LinqOverCustomObjects.My.MySettings + Get + Return Global.LinqOverCustomObjects.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 14/LinqOverCustomObjects/My Project/Settings.settings b/Code/Chapter 14/LinqOverCustomObjects/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 14/LinqOverCustomObjects/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 14/LinqOverCustomObjects/Program.vb b/Code/Chapter 14/LinqOverCustomObjects/Program.vb new file mode 100644 index 0000000..793a4c3 --- /dev/null +++ b/Code/Chapter 14/LinqOverCustomObjects/Program.vb @@ -0,0 +1,44 @@ +Module Program + + Sub Main() + Console.WriteLine("***** More fun with LINQ Expressions *****") + + ' Make a List of Car objects. + Dim myCars As New List(Of Car)() + myCars.Add(New Car With {.PetName = "Henry", .Color = "Silver", _ + .Speed = 100, .Make = "BMW"}) + myCars.Add(New Car With {.PetName = "Daisy", .Color = "Tan", _ + .Speed = 90, .Make = "BMW"}) + myCars.Add(New Car With {.PetName = "Mary", .Color = "Black", _ + .Speed = 55, .Make = "VW"}) + myCars.Add(New Car With {.PetName = "Clunker", .Color = "Rust", _ + .Speed = 5, .Make = "Yugo"}) + myCars.Add(New Car With {.PetName = "Melvin", .Color = "White", _ + .Speed = 43, .Make = "Ford"}) + + GetFastCars(myCars) + Console.WriteLine() + + GetFastBMWs(myCars) + End Sub + + Sub GetFastCars(ByVal myCars As List(Of Car)) + ' Create a query expression. + Dim fastCars = From c In myCars Where c.Speed > 55 Select c + + For Each car In fastCars + Console.WriteLine("{0} is going too fast!", car.PetName) + Next + + End Sub + + Sub GetFastBMWs(ByVal myCars As List(Of Car)) + ' Create a query expression. + Dim fastCars = From c In myCars Where _ + c.Speed > 90 And c.Make = "BMW" Select c + For Each car In fastCars + Console.WriteLine("{0} is going too fast!", car.PetName) + Next + End Sub + +End Module diff --git a/Code/Chapter 14/LinqRetValues/LinqRetValues.sln b/Code/Chapter 14/LinqRetValues/LinqRetValues.sln new file mode 100644 index 0000000..f43f227 --- /dev/null +++ b/Code/Chapter 14/LinqRetValues/LinqRetValues.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "LinqRetValues", "LinqRetValues.vbproj", "{AFCF0443-659B-4B27-A597-D2E31243DC53}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AFCF0443-659B-4B27-A597-D2E31243DC53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AFCF0443-659B-4B27-A597-D2E31243DC53}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AFCF0443-659B-4B27-A597-D2E31243DC53}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AFCF0443-659B-4B27-A597-D2E31243DC53}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 14/LinqRetValues/LinqRetValues.suo b/Code/Chapter 14/LinqRetValues/LinqRetValues.suo new file mode 100644 index 0000000..6b96fc9 Binary files /dev/null and b/Code/Chapter 14/LinqRetValues/LinqRetValues.suo differ diff --git a/Code/Chapter 14/LinqRetValues/LinqRetValues.vbproj b/Code/Chapter 14/LinqRetValues/LinqRetValues.vbproj new file mode 100644 index 0000000..f1fb3cb --- /dev/null +++ b/Code/Chapter 14/LinqRetValues/LinqRetValues.vbproj @@ -0,0 +1,115 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {AFCF0443-659B-4B27-A597-D2E31243DC53} + Exe + LinqRetValues.Program + LinqRetValues + LinqRetValues + 512 + Console + v3.5 + On + Binary + On + On + + + true + full + true + true + bin\Debug\ + LinqRetValues.xml + + + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + true + + + pdbonly + false + true + true + bin\Release\ + LinqRetValues.xml + + + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + true + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 14/LinqRetValues/My Project/Application.Designer.vb b/Code/Chapter 14/LinqRetValues/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 14/LinqRetValues/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 14/LinqRetValues/My Project/Application.myapp b/Code/Chapter 14/LinqRetValues/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 14/LinqRetValues/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 14/LinqRetValues/My Project/AssemblyInfo.vb b/Code/Chapter 14/LinqRetValues/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..1e12d41 --- /dev/null +++ b/Code/Chapter 14/LinqRetValues/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/Code/Chapter 14/LinqRetValues/My Project/Resources.Designer.vb b/Code/Chapter 14/LinqRetValues/My Project/Resources.Designer.vb new file mode 100644 index 0000000..2b53089 --- /dev/null +++ b/Code/Chapter 14/LinqRetValues/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("LinqRetValues.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/Code/Chapter 14/LinqRetValues/My Project/Resources.resx b/Code/Chapter 14/LinqRetValues/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 14/LinqRetValues/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/Code/Chapter 14/LinqRetValues/My Project/Settings.Designer.vb b/Code/Chapter 14/LinqRetValues/My Project/Settings.Designer.vb new file mode 100644 index 0000000..312d514 --- /dev/null +++ b/Code/Chapter 14/LinqRetValues/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.LinqRetValues.My.MySettings + Get + Return Global.LinqRetValues.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 14/LinqRetValues/My Project/Settings.settings b/Code/Chapter 14/LinqRetValues/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 14/LinqRetValues/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 14/LinqRetValues/Program.vb b/Code/Chapter 14/LinqRetValues/Program.vb new file mode 100644 index 0000000..612368d --- /dev/null +++ b/Code/Chapter 14/LinqRetValues/Program.vb @@ -0,0 +1,60 @@ +#Region "Car class for testing" +Public Class Car + Public PetName As String = String.Empty + Public Color As String = String.Empty + Public Speed As Integer + Public Make As String = String.Empty + + Public Overloads Overrides Function ToString() As String + Return String.Format("Make={0}, Color={1}, Speed={2}, PetName={3}", _ + Make, Color, Speed, PetName) + End Function +End Class +#End Region + +Module Program + + Sub Main() + Console.WriteLine("***** LINQ Transformations *****" + vbLf) + Dim subset As IEnumerable(Of String) = GetStringSubset() + For Each item As String In subset + Console.WriteLine(item) + Next + + Dim objs As Array = GetProjectedSubset() + For Each o As Object In objs + Console.WriteLine(o) ' Calls ToString() on each anonymous object. + Next + + Console.ReadLine() + End Sub + + Function GetStringSubset() As IEnumerable(Of String) + Dim currentVideoGames() As String = {"Morrowind", "BioShock", _ + "Half Life 2: Episode 1", "The Darkness", _ + "Daxter", "System Shock 2"} + + ' Note subset is an IEnumerable(OfString) compatable object. + Dim subset As IEnumerable(Of String) = _ + From g In currentVideoGames Where g.Length > 6 Order By g Select g + Return subset + End Function + + ' Return value is now an Array. + Public Function GetProjectedSubset() As Array + ' This array will be the basis of our testing... + Dim myCars As Car() = {New Car With _ + {.PetName = "Henry", .Color = "Silver", _ + .Speed = 100, .Make = "BMW"}, _ + New Car With {.PetName = "Daisy", .Color = "Tan", .Speed = 90, .Make = "BMW"}, _ + New Car With {.PetName = "Zippy", .Color = "Yellow", .Speed = 55, .Make = "VW"}} + + Dim makesColors = From c In myCars Select New With {c.Make, c.Color} + + ' Map set of anonymous objects to an Array object. + ' Here were are relying on type inference of the generic + ' type parameter, as we don't know the type of type! + Return makesColors.ToArray() + End Function + +End Module diff --git a/Code/Chapter 14/LinqUsingEnumerable/LinqUsingEnumerable.sln b/Code/Chapter 14/LinqUsingEnumerable/LinqUsingEnumerable.sln new file mode 100644 index 0000000..3b4945c --- /dev/null +++ b/Code/Chapter 14/LinqUsingEnumerable/LinqUsingEnumerable.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "LinqUsingEnumerable", "LinqUsingEnumerable.vbproj", "{47A99220-B2FC-4C96-B60C-26156B6F0F9A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {47A99220-B2FC-4C96-B60C-26156B6F0F9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {47A99220-B2FC-4C96-B60C-26156B6F0F9A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {47A99220-B2FC-4C96-B60C-26156B6F0F9A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {47A99220-B2FC-4C96-B60C-26156B6F0F9A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 14/LinqUsingEnumerable/LinqUsingEnumerable.suo b/Code/Chapter 14/LinqUsingEnumerable/LinqUsingEnumerable.suo new file mode 100644 index 0000000..6b6f939 Binary files /dev/null and b/Code/Chapter 14/LinqUsingEnumerable/LinqUsingEnumerable.suo differ diff --git a/Code/Chapter 14/LinqUsingEnumerable/LinqUsingEnumerable.vbproj b/Code/Chapter 14/LinqUsingEnumerable/LinqUsingEnumerable.vbproj new file mode 100644 index 0000000..3e0bd83 --- /dev/null +++ b/Code/Chapter 14/LinqUsingEnumerable/LinqUsingEnumerable.vbproj @@ -0,0 +1,110 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {47A99220-B2FC-4C96-B60C-26156B6F0F9A} + Exe + LinqUsingEnumerable.Program + LinqUsingEnumerable + LinqUsingEnumerable + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + LinqUsingEnumerable.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + LinqUsingEnumerable.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 14/LinqUsingEnumerable/My Project/Application.Designer.vb b/Code/Chapter 14/LinqUsingEnumerable/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 14/LinqUsingEnumerable/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 14/LinqUsingEnumerable/My Project/Application.myapp b/Code/Chapter 14/LinqUsingEnumerable/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 14/LinqUsingEnumerable/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 14/LinqUsingEnumerable/My Project/AssemblyInfo.vb b/Code/Chapter 14/LinqUsingEnumerable/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..17fe2be --- /dev/null +++ b/Code/Chapter 14/LinqUsingEnumerable/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/Code/Chapter 14/LinqUsingEnumerable/My Project/Resources.Designer.vb b/Code/Chapter 14/LinqUsingEnumerable/My Project/Resources.Designer.vb new file mode 100644 index 0000000..1d5cc60 --- /dev/null +++ b/Code/Chapter 14/LinqUsingEnumerable/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("LinqUsingEnumerable.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/Code/Chapter 14/LinqUsingEnumerable/My Project/Resources.resx b/Code/Chapter 14/LinqUsingEnumerable/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 14/LinqUsingEnumerable/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/Code/Chapter 14/LinqUsingEnumerable/My Project/Settings.Designer.vb b/Code/Chapter 14/LinqUsingEnumerable/My Project/Settings.Designer.vb new file mode 100644 index 0000000..47b9461 --- /dev/null +++ b/Code/Chapter 14/LinqUsingEnumerable/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.LinqUsingEnumerable.My.MySettings + Get + Return Global.LinqUsingEnumerable.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 14/LinqUsingEnumerable/My Project/Settings.settings b/Code/Chapter 14/LinqUsingEnumerable/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 14/LinqUsingEnumerable/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 14/LinqUsingEnumerable/Program.vb b/Code/Chapter 14/LinqUsingEnumerable/Program.vb new file mode 100644 index 0000000..925ab87 --- /dev/null +++ b/Code/Chapter 14/LinqUsingEnumerable/Program.vb @@ -0,0 +1,58 @@ +Module Program + + ' Comment / uncomment to see results. + Sub Main() + Console.WriteLine("***** Fun with LINQ *****") + QueryStringArrayWithOperators() + QueryStringsWithEnumerableAndLambdas() + VeryComplexQueryExpression.QueryStringsWithRawDelegates() + + Console.ReadLine() + End Sub + +#Region "LINQ query with operators" + Sub QueryStringArrayWithOperators() + Console.WriteLine("***** Using LINQ Query Operators *****") + + Dim currentVideoGames As String() = {"Morrowind", "BioShock", _ + "Half Life 2: Episode 1", "The Darkness", _ + "Daxter", "System Shock 2"} + + ' Build a LINQ query with VB LINQ operators. + Dim subset = From g In currentVideoGames _ + Where g.Length > 6 Order By g Select g + + For Each s As String In subset + Console.WriteLine("Item: {0}", s) + Next + Console.WriteLine() + End Sub +#End Region + +#Region "LINQ query with Enumerable / Lambdas" + Sub QueryStringsWithEnumerableAndLambdas() + + Console.WriteLine("***** Using Enumerable / Lambda Expressions *****") + + Dim currentVideoGames() As String = {"Morrowind", "BioShock", _ + "Half Life 2: Episode 1", "The Darkness", _ + "Daxter", "System Shock 2"} + + ' Build a query expression using extension methods + ' granted to the Array via the Enumerable type. + 'Dim subset = currentVideoGames.Where(Function(game) game.Length > 6). _ + 'OrderBy(Function(game) game).Select(Function(game) game) + + Dim subset = Enumerable.Where(currentVideoGames, Function(game) game.Length > 6). _ + OrderBy(Function(game) game).Select(Function(game) game) + + ' Print out the results. + For Each game In subset + Console.WriteLine("Item: {0}", game) + Next + Console.WriteLine() + End Sub + +#End Region + +End Module diff --git a/Code/Chapter 14/LinqUsingEnumerable/VeryComplexQuery.vb b/Code/Chapter 14/LinqUsingEnumerable/VeryComplexQuery.vb new file mode 100644 index 0000000..b2beee7 --- /dev/null +++ b/Code/Chapter 14/LinqUsingEnumerable/VeryComplexQuery.vb @@ -0,0 +1,30 @@ +Class VeryComplexQueryExpression + Public Shared Sub QueryStringsWithRawDelegates() + Console.WriteLine("***** Using Raw Delegates *****") + + Dim currentVideoGames As String() = {"Morrowind", "BioShock", _ + "Half Life 2: Episode 1", "The Darkness", _ + "Daxter", "System Shock 2"} + + ' Build the necessary Func<> delegates using anonymous methods. + Dim searchFilter As New Func(Of String, Boolean)(AddressOf Filter) + Dim itemToProcess As New Func(Of String, String)(AddressOf ProcessItem) + + ' Pass the delegates into the methods of Enumerable. + Dim subset = currentVideoGames.Where(searchFilter).OrderBy(itemToProcess).Select(itemToProcess) + + ' Print out the results. + For Each game In subset + Console.WriteLine("Item: {0}", game) + Next + Console.WriteLine() + End Sub + + ' Delegate targets. + Public Shared Function Filter(ByVal str As String) As Boolean + Return str.Length > 6 + End Function + Public Shared Function ProcessItem(ByVal str As String) As String + Return str + End Function +End Class diff --git a/Code/Chapter 15/AppConfigReaderApp/AppConfigReaderApp.sln b/Code/Chapter 15/AppConfigReaderApp/AppConfigReaderApp.sln new file mode 100644 index 0000000..8663614 --- /dev/null +++ b/Code/Chapter 15/AppConfigReaderApp/AppConfigReaderApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AppConfigReaderApp", "AppConfigReaderApp.vbproj", "{5F0F8BAA-372D-42B8-8201-D9FC7C1CAA1A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5F0F8BAA-372D-42B8-8201-D9FC7C1CAA1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5F0F8BAA-372D-42B8-8201-D9FC7C1CAA1A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5F0F8BAA-372D-42B8-8201-D9FC7C1CAA1A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5F0F8BAA-372D-42B8-8201-D9FC7C1CAA1A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 15/AppConfigReaderApp/AppConfigReaderApp.suo b/Code/Chapter 15/AppConfigReaderApp/AppConfigReaderApp.suo new file mode 100644 index 0000000..a9790bc Binary files /dev/null and b/Code/Chapter 15/AppConfigReaderApp/AppConfigReaderApp.suo differ diff --git a/Code/Chapter 15/AppConfigReaderApp/AppConfigReaderApp.vbproj b/Code/Chapter 15/AppConfigReaderApp/AppConfigReaderApp.vbproj new file mode 100644 index 0000000..7a4fa5c --- /dev/null +++ b/Code/Chapter 15/AppConfigReaderApp/AppConfigReaderApp.vbproj @@ -0,0 +1,98 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {5F0F8BAA-372D-42B8-8201-D9FC7C1CAA1A} + Exe + AppConfigReaderApp.Program + AppConfigReaderApp + AppConfigReaderApp + Console + + + 2.0 + + + + + true + full + true + true + bin\Debug\ + AppConfigReaderApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + AppConfigReaderApp.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/Code/Chapter 15/AppConfigReaderApp/AppConfigReaderApp.vbproj.user b/Code/Chapter 15/AppConfigReaderApp/AppConfigReaderApp.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 15/AppConfigReaderApp/AppConfigReaderApp.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 15/AppConfigReaderApp/My Project/Application.Designer.vb b/Code/Chapter 15/AppConfigReaderApp/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 15/AppConfigReaderApp/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 15/AppConfigReaderApp/My Project/Application.myapp b/Code/Chapter 15/AppConfigReaderApp/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 15/AppConfigReaderApp/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 15/AppConfigReaderApp/My Project/AssemblyInfo.vb b/Code/Chapter 15/AppConfigReaderApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..d8ae170 --- /dev/null +++ b/Code/Chapter 15/AppConfigReaderApp/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/Code/Chapter 15/AppConfigReaderApp/My Project/Resources.Designer.vb b/Code/Chapter 15/AppConfigReaderApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..abf2ae7 --- /dev/null +++ b/Code/Chapter 15/AppConfigReaderApp/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("AppConfigReaderApp.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/Code/Chapter 15/AppConfigReaderApp/My Project/Resources.resx b/Code/Chapter 15/AppConfigReaderApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 15/AppConfigReaderApp/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/Code/Chapter 15/AppConfigReaderApp/My Project/Settings.Designer.vb b/Code/Chapter 15/AppConfigReaderApp/My Project/Settings.Designer.vb new file mode 100644 index 0000000..0550c64 --- /dev/null +++ b/Code/Chapter 15/AppConfigReaderApp/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.AppConfigReaderApp.My.MySettings + Get + Return Global.AppConfigReaderApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 15/AppConfigReaderApp/My Project/Settings.settings b/Code/Chapter 15/AppConfigReaderApp/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 15/AppConfigReaderApp/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 15/AppConfigReaderApp/Program.vb b/Code/Chapter 15/AppConfigReaderApp/Program.vb new file mode 100644 index 0000000..427c0b6 --- /dev/null +++ b/Code/Chapter 15/AppConfigReaderApp/Program.vb @@ -0,0 +1,18 @@ +Option Explicit On +Option Strict On + +Imports System.Configuration + +Module Program + Sub Main() + Dim ar As New AppSettingsReader() + Console.WriteLine(ar.GetValue("appConStr", GetType(String))) + Dim numbOfTimes As Integer = CType(ar.GetValue("timesToSayHello", _ + GetType(Integer)), Integer) + + For i As Integer = 0 To numbOfTimes + Console.WriteLine("Yo!") + Next + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 15/AppConfigReaderApp/app.config b/Code/Chapter 15/AppConfigReaderApp/app.config new file mode 100644 index 0000000..1412ee5 --- /dev/null +++ b/Code/Chapter 15/AppConfigReaderApp/app.config @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/Code/Chapter 15/CSharpCarClient/CSharpCarClient.csproj b/Code/Chapter 15/CSharpCarClient/CSharpCarClient.csproj new file mode 100644 index 0000000..0a98dfa --- /dev/null +++ b/Code/Chapter 15/CSharpCarClient/CSharpCarClient.csproj @@ -0,0 +1,93 @@ + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {CB5C8E4D-2CA5-4D81-B508-03A715EB41F7} + Exe + Properties + CSharpCarClient + CSharpCarClient + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\CarLibrary\bin\Debug\CarLibrary.dll + + + + 3.5 + + + + + + + + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 15/CSharpCarClient/CSharpCarClient.csproj.user b/Code/Chapter 15/CSharpCarClient/CSharpCarClient.csproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 15/CSharpCarClient/CSharpCarClient.csproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 15/CSharpCarClient/CSharpCarClient.sln b/Code/Chapter 15/CSharpCarClient/CSharpCarClient.sln new file mode 100644 index 0000000..d9a8fc7 --- /dev/null +++ b/Code/Chapter 15/CSharpCarClient/CSharpCarClient.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpCarClient", "CSharpCarClient.csproj", "{CB5C8E4D-2CA5-4D81-B508-03A715EB41F7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CB5C8E4D-2CA5-4D81-B508-03A715EB41F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CB5C8E4D-2CA5-4D81-B508-03A715EB41F7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CB5C8E4D-2CA5-4D81-B508-03A715EB41F7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CB5C8E4D-2CA5-4D81-B508-03A715EB41F7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 15/CSharpCarClient/CSharpCarClient.suo b/Code/Chapter 15/CSharpCarClient/CSharpCarClient.suo new file mode 100644 index 0000000..606ed1b Binary files /dev/null and b/Code/Chapter 15/CSharpCarClient/CSharpCarClient.suo differ diff --git a/Code/Chapter 15/CSharpCarClient/PerformanceCar.cs b/Code/Chapter 15/CSharpCarClient/PerformanceCar.cs new file mode 100644 index 0000000..3eaaea6 --- /dev/null +++ b/Code/Chapter 15/CSharpCarClient/PerformanceCar.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; +using CarLibrary; + +namespace CSharpCarClient +{ + public class PerformanceCar : SportsCar + { + // This C# type is deriving from the VB 2005 SportsCar. + public override void TurboBoost() + { + Console.WriteLine("Zero to 60 in a cool 4.8 seconds..."); + } + } +} diff --git a/Code/Chapter 15/CSharpCarClient/Program.cs b/Code/Chapter 15/CSharpCarClient/Program.cs new file mode 100644 index 0000000..5bdcb0d --- /dev/null +++ b/Code/Chapter 15/CSharpCarClient/Program.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Text; +using CarLibrary; + +namespace CSharpCarClient +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("***** Fun with C# *****"); + + // Make a sports car. + SportsCar viper = new SportsCar("Viper", 240, 40); + viper.TurboBoost(); + + // Make a mini van. + MiniVan mv = new MiniVan(); + mv.TurboBoost(); + + // Make a performance car. + PerformanceCar dreamCar = new PerformanceCar(); + // Inherited property. + dreamCar.PetName = "Hank"; + dreamCar.TurboBoost(); + Console.ReadLine(); + } + } +} diff --git a/Code/Chapter 15/CSharpCarClient/Properties/AssemblyInfo.cs b/Code/Chapter 15/CSharpCarClient/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ce012b9 --- /dev/null +++ b/Code/Chapter 15/CSharpCarClient/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("CSharpCarClient")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CSharpCarClient")] +[assembly: AssemblyCopyright("Copyright © 2005")] +[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("63a00b4b-bc35-4865-ad30-8e790538454c")] + +// 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/Code/Chapter 15/CarLibrary/Car.vb b/Code/Chapter 15/CarLibrary/Car.vb new file mode 100644 index 0000000..fd2a3f4 --- /dev/null +++ b/Code/Chapter 15/CarLibrary/Car.vb @@ -0,0 +1,77 @@ +Option Explicit On +Option Strict On + +Imports System.Windows.Forms + +' Represents the state of the engine. +Public Enum EngineState + engineAlive + engineDead +End Enum + +' Holds source of music. +Public Enum MusicMedia + musicCd + musicTape + musicRadio + musicMp3 +End Enum + +#Region "Car base class" +' The abstract base class in the hierarchy. +Public MustInherit Class Car + Protected name As String + Protected speed As Short + Protected max_speed As Short + Protected egnState As EngineState = EngineState.engineAlive + + Public MustOverride Sub TurboBoost() + Public Sub TurnOnRadio(ByVal musicOn As Boolean, ByVal mm As MusicMedia) + If musicOn Then + MessageBox.Show(String.Format("Jamming {0} ", mm)) + Else + MessageBox.Show("Quiet time...") + End If + End Sub + Public Sub New() + MessageBox.Show("Car 2.0.0.0") + End Sub + + Public Sub New(ByVal carName As String, ByVal max As Short, ByVal curr As Short) + MessageBox.Show("Car 2.0.0.0") + name = carName + max_speed = max + speed = curr + End Sub + + Public Property PetName() As String + Get + Return name + End Get + Set(ByVal value As String) + name = value + End Set + End Property + + Public Property CurrSpeed() As Short + Get + Return speed + End Get + Set(ByVal value As Short) + speed = value + End Set + End Property + + Public ReadOnly Property MaxSpeed() As Short + Get + Return max_speed + End Get + End Property + + Public ReadOnly Property EngineState() As EngineState + Get + Return egnState + End Get + End Property +End Class +#End Region diff --git a/Code/Chapter 15/CarLibrary/CarLibrary.sln b/Code/Chapter 15/CarLibrary/CarLibrary.sln new file mode 100644 index 0000000..0a29138 --- /dev/null +++ b/Code/Chapter 15/CarLibrary/CarLibrary.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CarLibrary", "CarLibrary.vbproj", "{F4997D6A-53FC-4763-B8B6-DBFE6CB15AD8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F4997D6A-53FC-4763-B8B6-DBFE6CB15AD8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F4997D6A-53FC-4763-B8B6-DBFE6CB15AD8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F4997D6A-53FC-4763-B8B6-DBFE6CB15AD8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F4997D6A-53FC-4763-B8B6-DBFE6CB15AD8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 15/CarLibrary/CarLibrary.suo b/Code/Chapter 15/CarLibrary/CarLibrary.suo new file mode 100644 index 0000000..f734125 Binary files /dev/null and b/Code/Chapter 15/CarLibrary/CarLibrary.suo differ diff --git a/Code/Chapter 15/CarLibrary/CarLibrary.vbproj b/Code/Chapter 15/CarLibrary/CarLibrary.vbproj new file mode 100644 index 0000000..b0f782b --- /dev/null +++ b/Code/Chapter 15/CarLibrary/CarLibrary.vbproj @@ -0,0 +1,137 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {F4997D6A-53FC-4763-B8B6-DBFE6CB15AD8} + Library + CarLibrary + CarLibrary + Windows + true + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + MyTestKeyPair.snk + + + true + full + true + true + bin\Debug\ + CarLibrary.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + CarLibrary.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + 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 + + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 15/CarLibrary/CarLibrary.vbproj.user b/Code/Chapter 15/CarLibrary/CarLibrary.vbproj.user new file mode 100644 index 0000000..1659b79 --- /dev/null +++ b/Code/Chapter 15/CarLibrary/CarLibrary.vbproj.user @@ -0,0 +1,17 @@ + + + ShowAllFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 15/CarLibrary/DerivedCars.vb b/Code/Chapter 15/CarLibrary/DerivedCars.vb new file mode 100644 index 0000000..293d9c2 --- /dev/null +++ b/Code/Chapter 15/CarLibrary/DerivedCars.vb @@ -0,0 +1,40 @@ +Option Explicit On +Option Strict On + +Imports System.Windows.Forms + +#Region "SportsCar" +Public Class SportsCar + Inherits Car + + Public Sub New() + End Sub + + Public Sub New(ByVal carName As String, ByVal max As Short, ByVal curr As Short) + MyBase.New(carName, max, curr) + End Sub + + Public Overrides Sub TurboBoost() + MessageBox.Show("Ramming speed!", "Faster is better...") + End Sub +End Class +#End Region + +#Region "MiniVan" +Public Class MiniVan + Inherits Car + + Public Sub New() + End Sub + + Public Sub New(ByVal carName As String, ByVal max As Short, ByVal curr As Short) + MyBase.New(carName, max, curr) + End Sub + + ' Minivans have poor turbo capabilities! + Public Overrides Sub TurboBoost() + egnState = EngineState.engineDead + MessageBox.Show("Time to call AAA", "Your car is dead") + End Sub +End Class +#End Region diff --git a/Code/Chapter 15/CarLibrary/My Project/Application.Designer.vb b/Code/Chapter 15/CarLibrary/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 15/CarLibrary/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 15/CarLibrary/My Project/Application.myapp b/Code/Chapter 15/CarLibrary/My Project/Application.myapp new file mode 100644 index 0000000..758895d --- /dev/null +++ b/Code/Chapter 15/CarLibrary/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/Code/Chapter 15/CarLibrary/My Project/AssemblyInfo.vb b/Code/Chapter 15/CarLibrary/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..b4c6536 --- /dev/null +++ b/Code/Chapter 15/CarLibrary/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: +' + + + +' \ No newline at end of file diff --git a/Code/Chapter 15/CarLibrary/My Project/Resources.Designer.vb b/Code/Chapter 15/CarLibrary/My Project/Resources.Designer.vb new file mode 100644 index 0000000..7df1826 --- /dev/null +++ b/Code/Chapter 15/CarLibrary/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("CarLibrary.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/Code/Chapter 15/CarLibrary/My Project/Resources.resx b/Code/Chapter 15/CarLibrary/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 15/CarLibrary/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/Code/Chapter 15/CarLibrary/My Project/Settings.Designer.vb b/Code/Chapter 15/CarLibrary/My Project/Settings.Designer.vb new file mode 100644 index 0000000..e650364 --- /dev/null +++ b/Code/Chapter 15/CarLibrary/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CarLibrary.My.MySettings + Get + Return Global.CarLibrary.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 15/CarLibrary/My Project/Settings.settings b/Code/Chapter 15/CarLibrary/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 15/CarLibrary/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 15/CarLibrary/MyTestKeyPair.snk b/Code/Chapter 15/CarLibrary/MyTestKeyPair.snk new file mode 100644 index 0000000..858ea69 Binary files /dev/null and b/Code/Chapter 15/CarLibrary/MyTestKeyPair.snk differ diff --git a/Code/Chapter 15/CarLibrary/Version 1.0.0.0/CarLibrary.dll b/Code/Chapter 15/CarLibrary/Version 1.0.0.0/CarLibrary.dll new file mode 100644 index 0000000..02336cf Binary files /dev/null and b/Code/Chapter 15/CarLibrary/Version 1.0.0.0/CarLibrary.dll differ diff --git a/Code/Chapter 15/CodeBaseClient/CodeBaseClient.sln b/Code/Chapter 15/CodeBaseClient/CodeBaseClient.sln new file mode 100644 index 0000000..3a6114c --- /dev/null +++ b/Code/Chapter 15/CodeBaseClient/CodeBaseClient.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CodeBaseClient", "CodeBaseClient.vbproj", "{C2C73A88-BFE2-4326-8E04-C1BD13028BF9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C2C73A88-BFE2-4326-8E04-C1BD13028BF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C2C73A88-BFE2-4326-8E04-C1BD13028BF9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C2C73A88-BFE2-4326-8E04-C1BD13028BF9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C2C73A88-BFE2-4326-8E04-C1BD13028BF9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 15/CodeBaseClient/CodeBaseClient.suo b/Code/Chapter 15/CodeBaseClient/CodeBaseClient.suo new file mode 100644 index 0000000..4b847df Binary files /dev/null and b/Code/Chapter 15/CodeBaseClient/CodeBaseClient.suo differ diff --git a/Code/Chapter 15/CodeBaseClient/CodeBaseClient.vbproj b/Code/Chapter 15/CodeBaseClient/CodeBaseClient.vbproj new file mode 100644 index 0000000..c8c9871 --- /dev/null +++ b/Code/Chapter 15/CodeBaseClient/CodeBaseClient.vbproj @@ -0,0 +1,139 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {C2C73A88-BFE2-4326-8E04-C1BD13028BF9} + Exe + CodeBaseClient.Program + CodeBaseClient + CodeBaseClient + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + CodeBaseClient.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + CodeBaseClient.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + False + ..\CarLibrary\bin\Debug\CarLibrary.dll + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 15/CodeBaseClient/CodeBaseClient.vbproj.user b/Code/Chapter 15/CodeBaseClient/CodeBaseClient.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 15/CodeBaseClient/CodeBaseClient.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 15/CodeBaseClient/My Project/Application.Designer.vb b/Code/Chapter 15/CodeBaseClient/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 15/CodeBaseClient/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 15/CodeBaseClient/My Project/Application.myapp b/Code/Chapter 15/CodeBaseClient/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 15/CodeBaseClient/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 15/CodeBaseClient/My Project/AssemblyInfo.vb b/Code/Chapter 15/CodeBaseClient/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..5fbacba --- /dev/null +++ b/Code/Chapter 15/CodeBaseClient/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/Code/Chapter 15/CodeBaseClient/My Project/Resources.Designer.vb b/Code/Chapter 15/CodeBaseClient/My Project/Resources.Designer.vb new file mode 100644 index 0000000..339adbe --- /dev/null +++ b/Code/Chapter 15/CodeBaseClient/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("CodeBaseClient.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/Code/Chapter 15/CodeBaseClient/My Project/Resources.resx b/Code/Chapter 15/CodeBaseClient/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 15/CodeBaseClient/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/Code/Chapter 15/CodeBaseClient/My Project/Settings.Designer.vb b/Code/Chapter 15/CodeBaseClient/My Project/Settings.Designer.vb new file mode 100644 index 0000000..c633fe8 --- /dev/null +++ b/Code/Chapter 15/CodeBaseClient/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CodeBaseClient.My.MySettings + Get + Return Global.CodeBaseClient.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 15/CodeBaseClient/My Project/Settings.settings b/Code/Chapter 15/CodeBaseClient/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 15/CodeBaseClient/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 15/CodeBaseClient/Program.vb b/Code/Chapter 15/CodeBaseClient/Program.vb new file mode 100644 index 0000000..ff9d43a --- /dev/null +++ b/Code/Chapter 15/CodeBaseClient/Program.vb @@ -0,0 +1,13 @@ +Option Explicit On +Option Strict On + +Imports CarLibrary + +Module Program + Sub Main() + Console.WriteLine("***** Fun with CodeBases *****") + Dim c As New SportsCar() + Console.WriteLine("Sports car has been allocated.") + Console.ReadLine() + End Sub +End Module \ No newline at end of file diff --git a/Code/Chapter 15/CodeBaseClient/app.config b/Code/Chapter 15/CodeBaseClient/app.config new file mode 100644 index 0000000..c1e185e --- /dev/null +++ b/Code/Chapter 15/CodeBaseClient/app.config @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 15/MultifileAssembly/Client.vb b/Code/Chapter 15/MultifileAssembly/Client.vb new file mode 100644 index 0000000..cc3fe1f --- /dev/null +++ b/Code/Chapter 15/MultifileAssembly/Client.vb @@ -0,0 +1,13 @@ +Imports AirVehicles + +Module Module1 + Sub Main() + Dim h As New AirVehicles.Helicopter() + h.TakeOff() + + ' This will load the *.netmodule on demand. + Dim u As New UFO() + u.AbductHuman() + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 15/MultifileAssembly/helicopter.vb b/Code/Chapter 15/MultifileAssembly/helicopter.vb new file mode 100644 index 0000000..8cfa3ef --- /dev/null +++ b/Code/Chapter 15/MultifileAssembly/helicopter.vb @@ -0,0 +1,11 @@ +' This type will be in the +' primary module of the multifile +' assembly, therefore this assembly +' will contain the assembly manifest. +Namespace AirVehicles + Public Class Helicopter + Public Sub TakeOff() + Console.WriteLine("Helicopter taking off!") + End Sub + End Class +End Namespace diff --git a/Code/Chapter 15/MultifileAssembly/ufo.vb b/Code/Chapter 15/MultifileAssembly/ufo.vb new file mode 100644 index 0000000..c08d94d --- /dev/null +++ b/Code/Chapter 15/MultifileAssembly/ufo.vb @@ -0,0 +1,11 @@ +' This type will be placed +' within a *.netmodule binary, +' and it thus part of a multifile +' Assembly. +Namespace AirVehicles + Public Class Ufo + Public Sub AbductHuman() + Console.WriteLine("Resistance is futile") + End Sub + End Class +End Namespace diff --git a/Code/Chapter 15/MyCodeLibrary/Class1.vb b/Code/Chapter 15/MyCodeLibrary/Class1.vb new file mode 100644 index 0000000..028a462 --- /dev/null +++ b/Code/Chapter 15/MyCodeLibrary/Class1.vb @@ -0,0 +1,26 @@ +Option Explicit On +Option Strict On + +' This type is in the root namespace, +' which is (by default) the same name +' as the initial project. +Public Class SomeClass +End Class + +' This namespace is nested within the +' root. Therefore the fully qualified +' name of this class is MyCodeLibrary.MyTypes.SomeClass +Namespace MyTypes + Public Class SomeClass + End Class + + ' It is possible to nest namespaces within other + ' namespaces to gain a greater level of structure. + ' Thus, the fully qualified name of this enum is: + ' MyCodeLibrary.MyTypes.MyEnums.TestEnum + Namespace MyEnums + Public Enum TestEnum + TestValue + End Enum + End Namespace +End Namespace diff --git a/Code/Chapter 15/MyCodeLibrary/Class2.vb b/Code/Chapter 15/MyCodeLibrary/Class2.vb new file mode 100644 index 0000000..72bbb15 --- /dev/null +++ b/Code/Chapter 15/MyCodeLibrary/Class2.vb @@ -0,0 +1,20 @@ +Option Explicit On +Option Strict On + +Imports MyCodeLibrary.MyTypes.MyEnums + +' A type alias! +Imports TypeIWant = MyCodeLibrary.MyTypes.SomeClass + +Public Class Class2 + Public Sub MySub() + Dim e As TestEnum + + ' 's' is now of type MyCodeLibrary.MyTypes.SomeClass + Dim s As New TypeIWant + + ' Use the object test bench to invoke this member + ' to verify. + MsgBox(s.GetType().FullName) + End Sub +End Class diff --git a/Code/Chapter 15/MyCodeLibrary/My Project/Application.Designer.vb b/Code/Chapter 15/MyCodeLibrary/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 15/MyCodeLibrary/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 15/MyCodeLibrary/My Project/Application.myapp b/Code/Chapter 15/MyCodeLibrary/My Project/Application.myapp new file mode 100644 index 0000000..758895d --- /dev/null +++ b/Code/Chapter 15/MyCodeLibrary/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/Code/Chapter 15/MyCodeLibrary/My Project/AssemblyInfo.vb b/Code/Chapter 15/MyCodeLibrary/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..7824322 --- /dev/null +++ b/Code/Chapter 15/MyCodeLibrary/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/Code/Chapter 15/MyCodeLibrary/My Project/Resources.Designer.vb b/Code/Chapter 15/MyCodeLibrary/My Project/Resources.Designer.vb new file mode 100644 index 0000000..2fff729 --- /dev/null +++ b/Code/Chapter 15/MyCodeLibrary/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("MyCodeLibrary.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/Code/Chapter 15/MyCodeLibrary/My Project/Resources.resx b/Code/Chapter 15/MyCodeLibrary/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 15/MyCodeLibrary/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/Code/Chapter 15/MyCodeLibrary/My Project/Settings.Designer.vb b/Code/Chapter 15/MyCodeLibrary/My Project/Settings.Designer.vb new file mode 100644 index 0000000..1ff0413 --- /dev/null +++ b/Code/Chapter 15/MyCodeLibrary/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.MyCodeLibrary.My.MySettings + Get + Return Global.MyCodeLibrary.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 15/MyCodeLibrary/My Project/Settings.settings b/Code/Chapter 15/MyCodeLibrary/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 15/MyCodeLibrary/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 15/MyCodeLibrary/MyCodeLibrary.sln b/Code/Chapter 15/MyCodeLibrary/MyCodeLibrary.sln new file mode 100644 index 0000000..82c98cb --- /dev/null +++ b/Code/Chapter 15/MyCodeLibrary/MyCodeLibrary.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MyCodeLibrary", "MyCodeLibrary.vbproj", "{EC1245F3-AB3E-491D-9995-A60C29E95CA4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EC1245F3-AB3E-491D-9995-A60C29E95CA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EC1245F3-AB3E-491D-9995-A60C29E95CA4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EC1245F3-AB3E-491D-9995-A60C29E95CA4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EC1245F3-AB3E-491D-9995-A60C29E95CA4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 15/MyCodeLibrary/MyCodeLibrary.suo b/Code/Chapter 15/MyCodeLibrary/MyCodeLibrary.suo new file mode 100644 index 0000000..a03bf43 Binary files /dev/null and b/Code/Chapter 15/MyCodeLibrary/MyCodeLibrary.suo differ diff --git a/Code/Chapter 15/MyCodeLibrary/MyCodeLibrary.vbproj b/Code/Chapter 15/MyCodeLibrary/MyCodeLibrary.vbproj new file mode 100644 index 0000000..ac10e3e --- /dev/null +++ b/Code/Chapter 15/MyCodeLibrary/MyCodeLibrary.vbproj @@ -0,0 +1,133 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {EC1245F3-AB3E-491D-9995-A60C29E95CA4} + Library + MyCodeLibrary + MyCodeLibrary + Windows + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + MyCodeLibrary.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + MyCodeLibrary.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 15/MyCodeLibrary/MyCodeLibrary.vbproj.user b/Code/Chapter 15/MyCodeLibrary/MyCodeLibrary.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 15/MyCodeLibrary/MyCodeLibrary.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 15/SharedCarLibClient/My Project/Application.Designer.vb b/Code/Chapter 15/SharedCarLibClient/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 15/SharedCarLibClient/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 15/SharedCarLibClient/My Project/Application.myapp b/Code/Chapter 15/SharedCarLibClient/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 15/SharedCarLibClient/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 15/SharedCarLibClient/My Project/AssemblyInfo.vb b/Code/Chapter 15/SharedCarLibClient/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..2569007 --- /dev/null +++ b/Code/Chapter 15/SharedCarLibClient/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/Code/Chapter 15/SharedCarLibClient/My Project/Resources.Designer.vb b/Code/Chapter 15/SharedCarLibClient/My Project/Resources.Designer.vb new file mode 100644 index 0000000..3fa0364 --- /dev/null +++ b/Code/Chapter 15/SharedCarLibClient/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("SharedCarLibClient.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/Code/Chapter 15/SharedCarLibClient/My Project/Resources.resx b/Code/Chapter 15/SharedCarLibClient/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 15/SharedCarLibClient/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/Code/Chapter 15/SharedCarLibClient/My Project/Settings.Designer.vb b/Code/Chapter 15/SharedCarLibClient/My Project/Settings.Designer.vb new file mode 100644 index 0000000..6785ed3 --- /dev/null +++ b/Code/Chapter 15/SharedCarLibClient/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SharedCarLibClient.My.MySettings + Get + Return Global.SharedCarLibClient.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 15/SharedCarLibClient/My Project/Settings.settings b/Code/Chapter 15/SharedCarLibClient/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 15/SharedCarLibClient/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 15/SharedCarLibClient/Program.vb b/Code/Chapter 15/SharedCarLibClient/Program.vb new file mode 100644 index 0000000..432695d --- /dev/null +++ b/Code/Chapter 15/SharedCarLibClient/Program.vb @@ -0,0 +1,13 @@ +Option Explicit On +Option Strict On + +Imports CarLibrary + +Module Program + Sub Main() + Console.WriteLine("***** Fun with Shared Assemblies *****") + Dim mycar As New SportsCar() + mycar.TurboBoost() + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 15/SharedCarLibClient/SharedCarLibClient.sln b/Code/Chapter 15/SharedCarLibClient/SharedCarLibClient.sln new file mode 100644 index 0000000..bdb4176 --- /dev/null +++ b/Code/Chapter 15/SharedCarLibClient/SharedCarLibClient.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SharedCarLibClient", "SharedCarLibClient.vbproj", "{34359BD7-A953-468F-95CA-3885502040D7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {34359BD7-A953-468F-95CA-3885502040D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {34359BD7-A953-468F-95CA-3885502040D7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {34359BD7-A953-468F-95CA-3885502040D7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {34359BD7-A953-468F-95CA-3885502040D7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 15/SharedCarLibClient/SharedCarLibClient.suo b/Code/Chapter 15/SharedCarLibClient/SharedCarLibClient.suo new file mode 100644 index 0000000..5acbc5a Binary files /dev/null and b/Code/Chapter 15/SharedCarLibClient/SharedCarLibClient.suo differ diff --git a/Code/Chapter 15/SharedCarLibClient/SharedCarLibClient.vbproj b/Code/Chapter 15/SharedCarLibClient/SharedCarLibClient.vbproj new file mode 100644 index 0000000..2a90ce4 --- /dev/null +++ b/Code/Chapter 15/SharedCarLibClient/SharedCarLibClient.vbproj @@ -0,0 +1,139 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {34359BD7-A953-468F-95CA-3885502040D7} + Exe + SharedCarLibClient.Program + SharedCarLibClient + SharedCarLibClient + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + SharedCarLibClient.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SharedCarLibClient.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + ..\CarLibrary\Version 1.0.0.0\CarLibrary.dll + False + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 15/SharedCarLibClient/SharedCarLibClient.vbproj.user b/Code/Chapter 15/SharedCarLibClient/SharedCarLibClient.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 15/SharedCarLibClient/SharedCarLibClient.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 15/SharedCarLibClient/app.config b/Code/Chapter 15/SharedCarLibClient/app.config new file mode 100644 index 0000000..0a09f5b --- /dev/null +++ b/Code/Chapter 15/SharedCarLibClient/app.config @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Code/Chapter 15/Vb2008CarClient/My Project/Application.Designer.vb b/Code/Chapter 15/Vb2008CarClient/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 15/Vb2008CarClient/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 15/Vb2008CarClient/My Project/Application.myapp b/Code/Chapter 15/Vb2008CarClient/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 15/Vb2008CarClient/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 15/Vb2008CarClient/My Project/AssemblyInfo.vb b/Code/Chapter 15/Vb2008CarClient/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..64a03f1 --- /dev/null +++ b/Code/Chapter 15/Vb2008CarClient/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/Code/Chapter 15/Vb2008CarClient/My Project/Resources.Designer.vb b/Code/Chapter 15/Vb2008CarClient/My Project/Resources.Designer.vb new file mode 100644 index 0000000..9944d2e --- /dev/null +++ b/Code/Chapter 15/Vb2008CarClient/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("Vb2008CarClient.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/Code/Chapter 15/Vb2008CarClient/My Project/Resources.resx b/Code/Chapter 15/Vb2008CarClient/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 15/Vb2008CarClient/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/Code/Chapter 15/Vb2008CarClient/My Project/Settings.Designer.vb b/Code/Chapter 15/Vb2008CarClient/My Project/Settings.Designer.vb new file mode 100644 index 0000000..da8efb0 --- /dev/null +++ b/Code/Chapter 15/Vb2008CarClient/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.Vb2008CarClient.My.MySettings + Get + Return Global.Vb2008CarClient.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 15/Vb2008CarClient/My Project/Settings.settings b/Code/Chapter 15/Vb2008CarClient/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 15/Vb2008CarClient/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 15/Vb2008CarClient/Program.vb b/Code/Chapter 15/Vb2008CarClient/Program.vb new file mode 100644 index 0000000..09044cb --- /dev/null +++ b/Code/Chapter 15/Vb2008CarClient/Program.vb @@ -0,0 +1,17 @@ +Option Explicit On +Option Strict On + +' Import the CarLibrary namespace +' defined in the CarLibrary.dll assembly. +Imports CarLibrary + +Module Program + Sub Main() + Console.WriteLine("***** Visual Basic 2008 Client *****") + Dim myMiniVan As New MiniVan() + myMiniVan.TurboBoost() + + Dim mySportsCar As New SportsCar() + mySportsCar.TurboBoost() + End Sub +End Module diff --git a/Code/Chapter 15/Vb2008CarClient/Vb2008CarClient.sln b/Code/Chapter 15/Vb2008CarClient/Vb2008CarClient.sln new file mode 100644 index 0000000..cb98bee --- /dev/null +++ b/Code/Chapter 15/Vb2008CarClient/Vb2008CarClient.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Vb2008CarClient", "Vb2008CarClient.vbproj", "{8A1C896A-82AB-4011-9590-412B080E8AC0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8A1C896A-82AB-4011-9590-412B080E8AC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8A1C896A-82AB-4011-9590-412B080E8AC0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8A1C896A-82AB-4011-9590-412B080E8AC0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8A1C896A-82AB-4011-9590-412B080E8AC0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 15/Vb2008CarClient/Vb2008CarClient.suo b/Code/Chapter 15/Vb2008CarClient/Vb2008CarClient.suo new file mode 100644 index 0000000..ecd2365 Binary files /dev/null and b/Code/Chapter 15/Vb2008CarClient/Vb2008CarClient.suo differ diff --git a/Code/Chapter 15/Vb2008CarClient/Vb2008CarClient.vbproj b/Code/Chapter 15/Vb2008CarClient/Vb2008CarClient.vbproj new file mode 100644 index 0000000..2920fcb --- /dev/null +++ b/Code/Chapter 15/Vb2008CarClient/Vb2008CarClient.vbproj @@ -0,0 +1,138 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {8A1C896A-82AB-4011-9590-412B080E8AC0} + Exe + Vb2008CarClient.Program + Vb2008CarClient + Vb2008CarClient + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + Vb2008CarClient.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + Vb2008CarClient.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + False + ..\CarLibrary\bin\Debug\CarLibrary.dll + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 15/Vb2008CarClient/Vb2008CarClient.vbproj.user b/Code/Chapter 15/Vb2008CarClient/Vb2008CarClient.vbproj.user new file mode 100644 index 0000000..1659b79 --- /dev/null +++ b/Code/Chapter 15/Vb2008CarClient/Vb2008CarClient.vbproj.user @@ -0,0 +1,17 @@ + + + ShowAllFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 16/AttributedCarLibrary/AttributedCarLibrary.sln b/Code/Chapter 16/AttributedCarLibrary/AttributedCarLibrary.sln new file mode 100644 index 0000000..dbf1adc --- /dev/null +++ b/Code/Chapter 16/AttributedCarLibrary/AttributedCarLibrary.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AttributedCarLibrary", "AttributedCarLibrary.vbproj", "{4B3406BF-CB6A-4620-AC1A-CADC0F9324AE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4B3406BF-CB6A-4620-AC1A-CADC0F9324AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4B3406BF-CB6A-4620-AC1A-CADC0F9324AE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4B3406BF-CB6A-4620-AC1A-CADC0F9324AE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4B3406BF-CB6A-4620-AC1A-CADC0F9324AE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 16/AttributedCarLibrary/AttributedCarLibrary.suo b/Code/Chapter 16/AttributedCarLibrary/AttributedCarLibrary.suo new file mode 100644 index 0000000..75da030 Binary files /dev/null and b/Code/Chapter 16/AttributedCarLibrary/AttributedCarLibrary.suo differ diff --git a/Code/Chapter 16/AttributedCarLibrary/AttributedCarLibrary.vbproj b/Code/Chapter 16/AttributedCarLibrary/AttributedCarLibrary.vbproj new file mode 100644 index 0000000..c919f3c --- /dev/null +++ b/Code/Chapter 16/AttributedCarLibrary/AttributedCarLibrary.vbproj @@ -0,0 +1,135 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {4B3406BF-CB6A-4620-AC1A-CADC0F9324AE} + Library + + + AttributedCarLibrary + AttributedCarLibrary + Windows + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + AttributedCarLibrary.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + AttributedCarLibrary.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 16/AttributedCarLibrary/AttributedCarLibrary.vbproj.user b/Code/Chapter 16/AttributedCarLibrary/AttributedCarLibrary.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 16/AttributedCarLibrary/AttributedCarLibrary.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 16/AttributedCarLibrary/My Project/Application.Designer.vb b/Code/Chapter 16/AttributedCarLibrary/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 16/AttributedCarLibrary/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 16/AttributedCarLibrary/My Project/Application.myapp b/Code/Chapter 16/AttributedCarLibrary/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 16/AttributedCarLibrary/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 16/AttributedCarLibrary/My Project/AssemblyInfo.vb b/Code/Chapter 16/AttributedCarLibrary/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..455f7c8 --- /dev/null +++ b/Code/Chapter 16/AttributedCarLibrary/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/Code/Chapter 16/AttributedCarLibrary/My Project/Resources.Designer.vb b/Code/Chapter 16/AttributedCarLibrary/My Project/Resources.Designer.vb new file mode 100644 index 0000000..044a24e --- /dev/null +++ b/Code/Chapter 16/AttributedCarLibrary/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("AttributedCarLibrary.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/Code/Chapter 16/AttributedCarLibrary/My Project/Resources.resx b/Code/Chapter 16/AttributedCarLibrary/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 16/AttributedCarLibrary/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/Code/Chapter 16/AttributedCarLibrary/My Project/Settings.Designer.vb b/Code/Chapter 16/AttributedCarLibrary/My Project/Settings.Designer.vb new file mode 100644 index 0000000..97c4941 --- /dev/null +++ b/Code/Chapter 16/AttributedCarLibrary/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.AttributedCarLibrary.My.MySettings + Get + Return Global.AttributedCarLibrary.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 16/AttributedCarLibrary/My Project/Settings.settings b/Code/Chapter 16/AttributedCarLibrary/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 16/AttributedCarLibrary/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 16/AttributedCarLibrary/MyTypes.vb b/Code/Chapter 16/AttributedCarLibrary/MyTypes.vb new file mode 100644 index 0000000..abb8804 --- /dev/null +++ b/Code/Chapter 16/AttributedCarLibrary/MyTypes.vb @@ -0,0 +1,55 @@ +Option Explicit On +Option Strict On + +' Enforce CLS compliance for all public types in this assembly. + + +#Region "Our custom attribute" + _ +Public NotInheritable Class VehicleDescriptionAttribute + Inherits System.Attribute + Private msgData As String + + Public Sub New(ByVal description As String) + msgData = description + End Sub + + Public Sub New() + End Sub + + Public Property Description() As String + Get + Return msgData + End Get + Set(ByVal value As String) + msgData = value + End Set + End Property +End Class +#End Region + + _ +Public Class Motorcycle + ' However this field will not be persisted. + _ + Private weightOfCurrentPassengers As Single + + ' These fields are still serializable. + Private hasRadioSystem As Boolean + Private hasHeadSet As Boolean + Private hasSissyBar As Boolean +End Class + + _ + _ +Public Class HorseAndBuggy +End Class + + _ +Public Class Winnebago + ' This will generate a warning, as UInt64 is not + ' CLS compilant, and we have specified the attribute! + ' Public notCompliant As UInt64 +End Class \ No newline at end of file diff --git a/Code/Chapter 16/Extendable App Example/CSharpSnapIn/AssemblyInfo.cs b/Code/Chapter 16/Extendable App Example/CSharpSnapIn/AssemblyInfo.cs new file mode 100644 index 0000000..9f89a32 --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/CSharpSnapIn/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// 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("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// 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 Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/Code/Chapter 16/Extendable App Example/CSharpSnapIn/CSharpSnapIn.cs b/Code/Chapter 16/Extendable App Example/CSharpSnapIn/CSharpSnapIn.cs new file mode 100644 index 0000000..57a2e07 --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/CSharpSnapIn/CSharpSnapIn.cs @@ -0,0 +1,16 @@ +using System; +using CommonSnappableTypes; +using System.Windows.Forms; + +namespace CSharpSnapIn +{ + [CompanyInfo(Name = "Intertech Training", + Url = "www.intertechtraining.com")] + public class CSharpSnapInModule : IAppFunctionality + { + void IAppFunctionality.DoIt() + { + MessageBox.Show("You have just used the C# snap in!"); + } + } +} diff --git a/Code/Chapter 16/Extendable App Example/CSharpSnapIn/CSharpSnapIn.csproj b/Code/Chapter 16/Extendable App Example/CSharpSnapIn/CSharpSnapIn.csproj new file mode 100644 index 0000000..55d1529 --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/CSharpSnapIn/CSharpSnapIn.csproj @@ -0,0 +1,143 @@ + + + Local + 9.0.21022 + 2.0 + {40969DAE-5043-465B-8554-47C67FECA5E8} + Debug + AnyCPU + + + + + CSharpSnapIn + + + JScript + Grid + IE50 + false + Library + CSharpSnapIn + OnBuildSuccess + + + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + bin\Debug\ + false + 285212672 + false + + + DEBUG;TRACE + + + true + 4096 + false + + + false + false + false + false + 4 + + + bin\Release\ + false + 285212672 + false + + + TRACE + + + false + 4096 + false + + + true + false + false + false + 4 + + + + CommonSnappableTypes + ..\CommonSnappableTypes\bin\Debug\CommonSnappableTypes.dll + + + System + + + 3.5 + + + System.Data + + + System.Windows.Forms + + + System.XML + + + + + Code + + + Code + + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 16/Extendable App Example/CSharpSnapIn/CSharpSnapIn.csproj.user b/Code/Chapter 16/Extendable App Example/CSharpSnapIn/CSharpSnapIn.csproj.user new file mode 100644 index 0000000..045cd5a --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/CSharpSnapIn/CSharpSnapIn.csproj.user @@ -0,0 +1,69 @@ + + + 7.10.3077 + Debug + AnyCPU + C:\Documents and Settings\Andrew Troelsen\Desktop\MyBooks\C# Book Second Edition\Code\Chapter 11\CommonSnappableTypes\bin\Debug\;C:\Books\C# Book Second Edition\Code\Done\SOLID and DONE\Chapter 11\CommonSnappableTypes\bin\Debug\;C:\Books\C# Book Second Edition\Code\Done\Chapter 11\CommonSnappableTypes\bin\Debug\ + + + + + 0 + ProjectFiles + 0 + + + + + + + + + + + en-US + false + + + false + false + false + false + false + + + Project + + + + + + + + + + + true + + + false + false + false + false + false + + + Project + + + + + + + + + + + true + + \ No newline at end of file diff --git a/Code/Chapter 16/Extendable App Example/CSharpSnapIn/CSharpSnapIn.sln b/Code/Chapter 16/Extendable App Example/CSharpSnapIn/CSharpSnapIn.sln new file mode 100644 index 0000000..73dcdfd --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/CSharpSnapIn/CSharpSnapIn.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpSnapIn", "CSharpSnapIn.csproj", "{40969DAE-5043-465B-8554-47C67FECA5E8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {40969DAE-5043-465B-8554-47C67FECA5E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {40969DAE-5043-465B-8554-47C67FECA5E8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {40969DAE-5043-465B-8554-47C67FECA5E8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {40969DAE-5043-465B-8554-47C67FECA5E8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 16/Extendable App Example/CSharpSnapIn/CSharpSnapIn.suo b/Code/Chapter 16/Extendable App Example/CSharpSnapIn/CSharpSnapIn.suo new file mode 100644 index 0000000..4887759 Binary files /dev/null and b/Code/Chapter 16/Extendable App Example/CSharpSnapIn/CSharpSnapIn.suo differ diff --git a/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/CommonSnappableTypes.sln b/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/CommonSnappableTypes.sln new file mode 100644 index 0000000..8a06643 --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/CommonSnappableTypes.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CommonSnappableTypes", "CommonSnappableTypes.vbproj", "{4A364B7C-B298-4438-B3FF-ACB7CDF5340C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4A364B7C-B298-4438-B3FF-ACB7CDF5340C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4A364B7C-B298-4438-B3FF-ACB7CDF5340C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4A364B7C-B298-4438-B3FF-ACB7CDF5340C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4A364B7C-B298-4438-B3FF-ACB7CDF5340C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/CommonSnappableTypes.suo b/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/CommonSnappableTypes.suo new file mode 100644 index 0000000..80336cd Binary files /dev/null and b/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/CommonSnappableTypes.suo differ diff --git a/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/CommonSnappableTypes.vbproj b/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/CommonSnappableTypes.vbproj new file mode 100644 index 0000000..69443fc --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/CommonSnappableTypes.vbproj @@ -0,0 +1,132 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {4A364B7C-B298-4438-B3FF-ACB7CDF5340C} + Library + CommonSnappableTypes + CommonSnappableTypes + Windows + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + CommonSnappableTypes.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + CommonSnappableTypes.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/CommonSnappableTypes.vbproj.user b/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/CommonSnappableTypes.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/CommonSnappableTypes.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/My Project/Application.Designer.vb b/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/My Project/Application.myapp b/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/My Project/Application.myapp new file mode 100644 index 0000000..758895d --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/My Project/AssemblyInfo.vb b/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..b13d873 --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/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/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/My Project/Resources.Designer.vb b/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/My Project/Resources.Designer.vb new file mode 100644 index 0000000..e7f4d2f --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("CommonSnappableTypes.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/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/My Project/Resources.resx b/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/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/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/My Project/Settings.Designer.vb b/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/My Project/Settings.Designer.vb new file mode 100644 index 0000000..0309b08 --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CommonSnappableTypes.My.MySettings + Get + Return Global.CommonSnappableTypes.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/My Project/Settings.settings b/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/MyTypes.vb b/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/MyTypes.vb new file mode 100644 index 0000000..647d061 --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/CommonSnappableTypes/MyTypes.vb @@ -0,0 +1,34 @@ +Option Explicit On +Option Strict On + +Public Interface IAppFunctionality + Sub DoIt() +End Interface + + _ +Public NotInheritable Class CompanyInfoAttribute + Inherits System.Attribute + Private companyName As String + Private companyUrl As String + + Public Sub New() + End Sub + + Public Property Name() As String + Get + Return companyName + End Get + Set(ByVal value As String) + companyName = value + End Set + End Property + + Public Property Url() As String + Get + Return companyUrl + End Get + Set(ByVal value As String) + companyUrl = value + End Set + End Property +End Class \ No newline at end of file diff --git a/Code/Chapter 16/Extendable App Example/MyExtendableApp/MainForm.Designer.vb b/Code/Chapter 16/Extendable App Example/MyExtendableApp/MainForm.Designer.vb new file mode 100644 index 0000000..3bc2920 --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/MyExtendableApp/MainForm.Designer.vb @@ -0,0 +1,92 @@ + _ +Partial Class MainForm + 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.MenuStrip1 = New System.Windows.Forms.MenuStrip + Me.ToolsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.SnapInModuleToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.label1 = New System.Windows.Forms.Label + Me.lstLoadedSnapIns = New System.Windows.Forms.ListBox + Me.MenuStrip1.SuspendLayout() + Me.SuspendLayout() + ' + 'MenuStrip1 + ' + Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolsToolStripMenuItem}) + Me.MenuStrip1.Location = New System.Drawing.Point(0, 0) + Me.MenuStrip1.Name = "MenuStrip1" + Me.MenuStrip1.Size = New System.Drawing.Size(383, 24) + Me.MenuStrip1.TabIndex = 0 + Me.MenuStrip1.Text = "MenuStrip1" + ' + 'ToolsToolStripMenuItem + ' + Me.ToolsToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.SnapInModuleToolStripMenuItem}) + Me.ToolsToolStripMenuItem.Name = "ToolsToolStripMenuItem" + Me.ToolsToolStripMenuItem.Size = New System.Drawing.Size(44, 20) + Me.ToolsToolStripMenuItem.Text = "Tools" + ' + 'SnapInModuleToolStripMenuItem + ' + Me.SnapInModuleToolStripMenuItem.Name = "SnapInModuleToolStripMenuItem" + Me.SnapInModuleToolStripMenuItem.Size = New System.Drawing.Size(159, 22) + Me.SnapInModuleToolStripMenuItem.Text = "Snap In Module" + ' + 'label1 + ' + Me.label1.AutoSize = True + Me.label1.Location = New System.Drawing.Point(12, 83) + Me.label1.Name = "label1" + Me.label1.Size = New System.Drawing.Size(146, 13) + Me.label1.TabIndex = 7 + Me.label1.Text = "Here are the loaded Snap Ins" + ' + 'lstLoadedSnapIns + ' + Me.lstLoadedSnapIns.FormattingEnabled = True + Me.lstLoadedSnapIns.Location = New System.Drawing.Point(12, 104) + Me.lstLoadedSnapIns.Name = "lstLoadedSnapIns" + Me.lstLoadedSnapIns.Size = New System.Drawing.Size(335, 56) + Me.lstLoadedSnapIns.TabIndex = 6 + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(383, 182) + Me.Controls.Add(Me.label1) + Me.Controls.Add(Me.lstLoadedSnapIns) + Me.Controls.Add(Me.MenuStrip1) + Me.MainMenuStrip = Me.MenuStrip1 + Me.Name = "MainForm" + Me.Text = "My Extendable App!" + Me.MenuStrip1.ResumeLayout(False) + Me.MenuStrip1.PerformLayout() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents MenuStrip1 As System.Windows.Forms.MenuStrip + Friend WithEvents ToolsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Friend WithEvents SnapInModuleToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Private WithEvents label1 As System.Windows.Forms.Label + Private WithEvents lstLoadedSnapIns As System.Windows.Forms.ListBox + +End Class diff --git a/Code/Chapter 16/Extendable App Example/MyExtendableApp/MainForm.resx b/Code/Chapter 16/Extendable App Example/MyExtendableApp/MainForm.resx new file mode 100644 index 0000000..812f765 --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/MyExtendableApp/MainForm.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/Code/Chapter 16/Extendable App Example/MyExtendableApp/MainForm.vb b/Code/Chapter 16/Extendable App Example/MyExtendableApp/MainForm.vb new file mode 100644 index 0000000..70f0861 --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/MyExtendableApp/MainForm.vb @@ -0,0 +1,74 @@ +Option Explicit On + +Imports System.Windows.Forms +Imports CommonSnappableTypes +Imports System.Reflection + +Public Class MainForm + Sub New() + ' This call is required by the Windows Form Designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call. + CenterToScreen() + End Sub + + Private Sub SnapInModuleToolStripMenuItem_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles SnapInModuleToolStripMenuItem.Click + ' Allow user to select an assembly to load. + Dim dlg As OpenFileDialog = New OpenFileDialog() + + If dlg.ShowDialog = Windows.Forms.DialogResult.OK Then + If dlg.FileName.Contains("CommonSnappableTypes") Then + MessageBox.Show("CommonSnappableTypes has no snap-ins!") + ElseIf LoadExternalModule(dlg.FileName) = False Then + MessageBox.Show("Nothing implements IAppFunctionality!") + End If + End If + End Sub + + Private Function LoadExternalModule(ByVal path As String) As Boolean + Dim foundSnapIn As Boolean = False + Dim itfAppFx As IAppFunctionality + Dim theSnapInAsm As Assembly = Nothing + + ' Try to dynamically load the selected assembly. + Try + theSnapInAsm = Assembly.LoadFrom(path) + Catch ex As Exception + MessageBox.Show(ex.Message) + Return foundSnapIn + End Try + + ' Get all IAppFunctionality compatible classes in assembly, + ' using a LINQ query and implicitly typed data. + Dim classTypes = From t In theSnapInAsm.GetTypes() Where _ + t.IsClass And (t.GetInterface("IAppFunctionality") _ + IsNot Nothing) Select t + + For Each c As Object In classTypes + foundSnapIn = True + + ' Use late binding to create the type. + Dim o As Object = theSnapInAsm.CreateInstance(c.FullName) + + ' Call DoIt() off the interface. + itfAppFx = CType(o, IAppFunctionality) + itfAppFx.DoIt() + lstLoadedSnapIns.Items.Add(c.FullName) + + ' Show company info. + DisplayCompanyData(c) + Next + Return foundSnapIn + End Function + + Private Sub DisplayCompanyData(ByVal t As Type) + ' Get data. + Dim customAtts As Object() = t.GetCustomAttributes(False) + For Each c As CompanyInfoAttribute In customAtts + ' Show data. + MessageBox.Show(c.Url, String.Format("More info about {0} can be found at", c.Name)) + Next + End Sub +End Class diff --git a/Code/Chapter 16/Extendable App Example/MyExtendableApp/My Project/Application.Designer.vb b/Code/Chapter 16/Extendable App Example/MyExtendableApp/My Project/Application.Designer.vb new file mode 100644 index 0000000..88d3d0c --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/MyExtendableApp/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.26 +' +' 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.MyExtendableApp.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 16/Extendable App Example/MyExtendableApp/My Project/Application.myapp b/Code/Chapter 16/Extendable App Example/MyExtendableApp/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/MyExtendableApp/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 16/Extendable App Example/MyExtendableApp/My Project/AssemblyInfo.vb b/Code/Chapter 16/Extendable App Example/MyExtendableApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..451a23a --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/MyExtendableApp/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/Code/Chapter 16/Extendable App Example/MyExtendableApp/My Project/Resources.Designer.vb b/Code/Chapter 16/Extendable App Example/MyExtendableApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..4803293 --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/MyExtendableApp/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("MyExtendableApp.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/Code/Chapter 16/Extendable App Example/MyExtendableApp/My Project/Resources.resx b/Code/Chapter 16/Extendable App Example/MyExtendableApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/MyExtendableApp/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/Code/Chapter 16/Extendable App Example/MyExtendableApp/My Project/Settings.Designer.vb b/Code/Chapter 16/Extendable App Example/MyExtendableApp/My Project/Settings.Designer.vb new file mode 100644 index 0000000..8bbe81d --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/MyExtendableApp/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.MyExtendableApp.My.MySettings + Get + Return Global.MyExtendableApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 16/Extendable App Example/MyExtendableApp/My Project/Settings.settings b/Code/Chapter 16/Extendable App Example/MyExtendableApp/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/MyExtendableApp/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 16/Extendable App Example/MyExtendableApp/MyExtendableApp.sln b/Code/Chapter 16/Extendable App Example/MyExtendableApp/MyExtendableApp.sln new file mode 100644 index 0000000..7b44181 --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/MyExtendableApp/MyExtendableApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MyExtendableApp", "MyExtendableApp.vbproj", "{75596EED-261F-4F8F-9605-B3BF6FB02C58}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {75596EED-261F-4F8F-9605-B3BF6FB02C58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {75596EED-261F-4F8F-9605-B3BF6FB02C58}.Debug|Any CPU.Build.0 = Debug|Any CPU + {75596EED-261F-4F8F-9605-B3BF6FB02C58}.Release|Any CPU.ActiveCfg = Release|Any CPU + {75596EED-261F-4F8F-9605-B3BF6FB02C58}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 16/Extendable App Example/MyExtendableApp/MyExtendableApp.suo b/Code/Chapter 16/Extendable App Example/MyExtendableApp/MyExtendableApp.suo new file mode 100644 index 0000000..0f965cd Binary files /dev/null and b/Code/Chapter 16/Extendable App Example/MyExtendableApp/MyExtendableApp.suo differ diff --git a/Code/Chapter 16/Extendable App Example/MyExtendableApp/MyExtendableApp.vbproj b/Code/Chapter 16/Extendable App Example/MyExtendableApp/MyExtendableApp.vbproj new file mode 100644 index 0000000..d72a6f4 --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/MyExtendableApp/MyExtendableApp.vbproj @@ -0,0 +1,151 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {75596EED-261F-4F8F-9605-B3BF6FB02C58} + WinExe + MyExtendableApp.My.MyApplication + MyExtendableApp + MyExtendableApp + WindowsForms + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + MyExtendableApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + MyExtendableApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + False + ..\CommonSnappableTypes\bin\Debug\CommonSnappableTypes.dll + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + MainForm.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 16/Extendable App Example/MyExtendableApp/MyExtendableApp.vbproj.user b/Code/Chapter 16/Extendable App Example/MyExtendableApp/MyExtendableApp.vbproj.user new file mode 100644 index 0000000..55af084 --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/MyExtendableApp/MyExtendableApp.vbproj.user @@ -0,0 +1,16 @@ + + + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 16/Extendable App Example/VbNetSnapIn/AssemblyInfo.vb b/Code/Chapter 16/Extendable App Example/VbNetSnapIn/AssemblyInfo.vb new file mode 100644 index 0000000..f6e1914 --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/VbNetSnapIn/AssemblyInfo.vb @@ -0,0 +1,32 @@ +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/Code/Chapter 16/Extendable App Example/VbNetSnapIn/VbNetSnapIn.sln b/Code/Chapter 16/Extendable App Example/VbNetSnapIn/VbNetSnapIn.sln new file mode 100644 index 0000000..79cb347 --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/VbNetSnapIn/VbNetSnapIn.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VbNetSnapIn", "VbNetSnapIn.vbproj", "{50ECB5AF-245D-4267-A00D-4B03D14D8242}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {50ECB5AF-245D-4267-A00D-4B03D14D8242}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {50ECB5AF-245D-4267-A00D-4B03D14D8242}.Debug|Any CPU.Build.0 = Debug|Any CPU + {50ECB5AF-245D-4267-A00D-4B03D14D8242}.Release|Any CPU.ActiveCfg = Release|Any CPU + {50ECB5AF-245D-4267-A00D-4B03D14D8242}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 16/Extendable App Example/VbNetSnapIn/VbNetSnapIn.suo b/Code/Chapter 16/Extendable App Example/VbNetSnapIn/VbNetSnapIn.suo new file mode 100644 index 0000000..d21946e Binary files /dev/null and b/Code/Chapter 16/Extendable App Example/VbNetSnapIn/VbNetSnapIn.suo differ diff --git a/Code/Chapter 16/Extendable App Example/VbNetSnapIn/VbNetSnapIn.vb b/Code/Chapter 16/Extendable App Example/VbNetSnapIn/VbNetSnapIn.vb new file mode 100644 index 0000000..1868a50 --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/VbNetSnapIn/VbNetSnapIn.vb @@ -0,0 +1,14 @@ +Option Explicit On +Option Strict On + +Imports System.Windows.Forms +Imports CommonSnappableTypes + + _ +Public Class VbNetSnapInModule + Implements IAppFunctionality + + Public Sub DoIt() Implements CommonSnappableTypes.IAppFunctionality.DoIt + MessageBox.Show("You have just used the VB 2008 snap in!") + End Sub +End Class diff --git a/Code/Chapter 16/Extendable App Example/VbNetSnapIn/VbNetSnapIn.vbproj b/Code/Chapter 16/Extendable App Example/VbNetSnapIn/VbNetSnapIn.vbproj new file mode 100644 index 0000000..e246ae5 --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/VbNetSnapIn/VbNetSnapIn.vbproj @@ -0,0 +1,149 @@ + + + Local + 9.0.21022 + 2.0 + {50ECB5AF-245D-4267-A00D-4B03D14D8242} + Debug + AnyCPU + + + + + VbNetSnapIn + + + None + JScript + Grid + IE50 + false + Library + Binary + On + Off + VbNetSnapIn + + + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + bin\ + 285212672 + + + + + true + true + true + false + false + false + false + 1 + 42016,42017,42018,42019,42032 + + + bin\ + 285212672 + + + + + false + true + false + true + false + false + false + 1 + 42016,42017,42018,42019,42032 + + + + CommonSnappableTypes + ..\CommonSnappableTypes\bin\Debug\CommonSnappableTypes.dll + + + System + + + 3.5 + + + System.Data + + + System.Windows.Forms + + + System.XML + + + + + + + + + + + + + Code + + + Code + + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 16/Extendable App Example/VbNetSnapIn/VbNetSnapIn.vbproj.user b/Code/Chapter 16/Extendable App Example/VbNetSnapIn/VbNetSnapIn.vbproj.user new file mode 100644 index 0000000..4d26db8 --- /dev/null +++ b/Code/Chapter 16/Extendable App Example/VbNetSnapIn/VbNetSnapIn.vbproj.user @@ -0,0 +1,71 @@ + + + 7.10.3077 + Debug + AnyCPU + C:\Documents and Settings\Andrew Troelsen\Desktop\MyBooks\C# Book Second Edition\Code\Chapter 11\CommonSnappableTypes\bin\Debug\;C:\Books\C# Book Second Edition\Code\Done\SOLID and DONE\Chapter 11\CommonSnappableTypes\bin\Debug\;C:\Books\C# Book Second Edition\Code\Done\Chapter 11\CommonSnappableTypes\bin\Debug\ + + + + + 0 + ProjectFiles + 0 + + + + + + + + + + + en-US + false + + + false + false + false + false + false + + + Project + + + + + + + + + + + true + 42016,42017,42018,42019,42032 + + + false + false + false + false + false + + + Project + + + + + + + + + + + true + 42016,42017,42018,42019,42032 + + \ No newline at end of file diff --git a/Code/Chapter 16/ExternalAssemblyReflector/ExternalAssemblyReflector.sln b/Code/Chapter 16/ExternalAssemblyReflector/ExternalAssemblyReflector.sln new file mode 100644 index 0000000..b1e14f2 --- /dev/null +++ b/Code/Chapter 16/ExternalAssemblyReflector/ExternalAssemblyReflector.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ExternalAssemblyReflector", "ExternalAssemblyReflector.vbproj", "{8F0FF091-8DCC-4EC8-8AA1-6B312EC11BD3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8F0FF091-8DCC-4EC8-8AA1-6B312EC11BD3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8F0FF091-8DCC-4EC8-8AA1-6B312EC11BD3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8F0FF091-8DCC-4EC8-8AA1-6B312EC11BD3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8F0FF091-8DCC-4EC8-8AA1-6B312EC11BD3}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 16/ExternalAssemblyReflector/ExternalAssemblyReflector.suo b/Code/Chapter 16/ExternalAssemblyReflector/ExternalAssemblyReflector.suo new file mode 100644 index 0000000..3f17171 Binary files /dev/null and b/Code/Chapter 16/ExternalAssemblyReflector/ExternalAssemblyReflector.suo differ diff --git a/Code/Chapter 16/ExternalAssemblyReflector/ExternalAssemblyReflector.vbproj b/Code/Chapter 16/ExternalAssemblyReflector/ExternalAssemblyReflector.vbproj new file mode 100644 index 0000000..e0dec1c --- /dev/null +++ b/Code/Chapter 16/ExternalAssemblyReflector/ExternalAssemblyReflector.vbproj @@ -0,0 +1,121 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {8F0FF091-8DCC-4EC8-8AA1-6B312EC11BD3} + Exe + ExternalAssemblyReflector.Program + ExternalAssemblyReflector + ExternalAssemblyReflector + Console + + + 2.0 + + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + v3.5 + + + true + full + true + true + bin\Debug\ + ExternalAssemblyReflector.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + ExternalAssemblyReflector.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + Settings.settings + True + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 16/ExternalAssemblyReflector/ExternalAssemblyReflector.vbproj.user b/Code/Chapter 16/ExternalAssemblyReflector/ExternalAssemblyReflector.vbproj.user new file mode 100644 index 0000000..1659b79 --- /dev/null +++ b/Code/Chapter 16/ExternalAssemblyReflector/ExternalAssemblyReflector.vbproj.user @@ -0,0 +1,17 @@ + + + ShowAllFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 16/ExternalAssemblyReflector/My Project/Application.Designer.vb b/Code/Chapter 16/ExternalAssemblyReflector/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 16/ExternalAssemblyReflector/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 16/ExternalAssemblyReflector/My Project/Application.myapp b/Code/Chapter 16/ExternalAssemblyReflector/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 16/ExternalAssemblyReflector/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 16/ExternalAssemblyReflector/My Project/AssemblyInfo.vb b/Code/Chapter 16/ExternalAssemblyReflector/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..bfa2576 --- /dev/null +++ b/Code/Chapter 16/ExternalAssemblyReflector/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/Code/Chapter 16/ExternalAssemblyReflector/My Project/Settings.Designer.vb b/Code/Chapter 16/ExternalAssemblyReflector/My Project/Settings.Designer.vb new file mode 100644 index 0000000..53660f2 --- /dev/null +++ b/Code/Chapter 16/ExternalAssemblyReflector/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.ExternalAssemblyReflector.My.MySettings + Get + Return Global.ExternalAssemblyReflector.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 16/ExternalAssemblyReflector/My Project/Settings.settings b/Code/Chapter 16/ExternalAssemblyReflector/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 16/ExternalAssemblyReflector/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 16/ExternalAssemblyReflector/Program.vb b/Code/Chapter 16/ExternalAssemblyReflector/Program.vb new file mode 100644 index 0000000..9146ac2 --- /dev/null +++ b/Code/Chapter 16/ExternalAssemblyReflector/Program.vb @@ -0,0 +1,43 @@ +Option Explicit On +Option Strict On + +Imports System.Reflection + +Module Program + Sub Main() + Console.WriteLine("***** External Assembly Viewer *****") + Dim asmName As String = String.Empty + Dim asm As Assembly = Nothing + Do + Console.WriteLine() + Console.WriteLine("Enter an assembly to evaluate") + Console.Write("or enter Q to quit: ") + + ' Get name of assembly. + asmName = Console.ReadLine() + + ' Does user want to quit? + If asmName.ToUpper = "Q" Then + Exit Do + End If + + Try ' Try to load assembly. + asm = Assembly.Load(asmName) + DisplayTypesInAsm(asm) + Catch + Console.WriteLine("Sorry, can't find assembly named {0}.", asmName) + End Try + Loop + End Sub + + Sub DisplayTypesInAsm(ByVal asm As Assembly) + Console.WriteLine() + Console.WriteLine("***** Types in Assembly *****") + Console.WriteLine("->{0}", asm.FullName) + Dim types As Type() = asm.GetTypes() + For Each t As Type In types + Console.WriteLine("Type: {0}", t) + Next + Console.WriteLine() + End Sub +End Module diff --git a/Code/Chapter 16/LateBinding/LateBinding.sln b/Code/Chapter 16/LateBinding/LateBinding.sln new file mode 100644 index 0000000..fe9d436 --- /dev/null +++ b/Code/Chapter 16/LateBinding/LateBinding.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "LateBinding", "LateBinding.vbproj", "{939DD842-C38C-471D-A392-3ADA952916C1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {939DD842-C38C-471D-A392-3ADA952916C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {939DD842-C38C-471D-A392-3ADA952916C1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {939DD842-C38C-471D-A392-3ADA952916C1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {939DD842-C38C-471D-A392-3ADA952916C1}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 16/LateBinding/LateBinding.suo b/Code/Chapter 16/LateBinding/LateBinding.suo new file mode 100644 index 0000000..561a3dd Binary files /dev/null and b/Code/Chapter 16/LateBinding/LateBinding.suo differ diff --git a/Code/Chapter 16/LateBinding/LateBinding.vbproj b/Code/Chapter 16/LateBinding/LateBinding.vbproj new file mode 100644 index 0000000..7f6cc73 --- /dev/null +++ b/Code/Chapter 16/LateBinding/LateBinding.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {939DD842-C38C-471D-A392-3ADA952916C1} + Exe + LateBinding.Program + LateBinding + LateBinding + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + LateBinding.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + LateBinding.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 16/LateBinding/LateBinding.vbproj.user b/Code/Chapter 16/LateBinding/LateBinding.vbproj.user new file mode 100644 index 0000000..55af084 --- /dev/null +++ b/Code/Chapter 16/LateBinding/LateBinding.vbproj.user @@ -0,0 +1,16 @@ + + + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 16/LateBinding/My Project/Application.Designer.vb b/Code/Chapter 16/LateBinding/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 16/LateBinding/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 16/LateBinding/My Project/Application.myapp b/Code/Chapter 16/LateBinding/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 16/LateBinding/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 16/LateBinding/My Project/AssemblyInfo.vb b/Code/Chapter 16/LateBinding/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..9152f30 --- /dev/null +++ b/Code/Chapter 16/LateBinding/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/Code/Chapter 16/LateBinding/My Project/Resources.Designer.vb b/Code/Chapter 16/LateBinding/My Project/Resources.Designer.vb new file mode 100644 index 0000000..cd79d5d --- /dev/null +++ b/Code/Chapter 16/LateBinding/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("LateBinding.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/Code/Chapter 16/LateBinding/My Project/Resources.resx b/Code/Chapter 16/LateBinding/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 16/LateBinding/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/Code/Chapter 16/LateBinding/My Project/Settings.Designer.vb b/Code/Chapter 16/LateBinding/My Project/Settings.Designer.vb new file mode 100644 index 0000000..3915942 --- /dev/null +++ b/Code/Chapter 16/LateBinding/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.LateBinding.My.MySettings + Get + Return Global.LateBinding.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 16/LateBinding/My Project/Settings.settings b/Code/Chapter 16/LateBinding/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 16/LateBinding/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 16/LateBinding/Program.vb b/Code/Chapter 16/LateBinding/Program.vb new file mode 100644 index 0000000..622d77f --- /dev/null +++ b/Code/Chapter 16/LateBinding/Program.vb @@ -0,0 +1,72 @@ +Option Explicit On + +' If you disable Option Strict, you are able to +' Simplify your late biniding, as shown in the +' commented out EasyMain() method below. +Option Strict On + +Imports System.Reflection +Imports System.IO + +Module Program + +#Region "This logic will when Option Strict is On or Off" + Sub Main() + Console.WriteLine("***** Fun with Late Binding *****") + + ' Try to load a local copy of CarLibrary. + Dim a As Assembly = Nothing + Try + a = Assembly.Load("CarLibrary") + Catch e As FileNotFoundException + Console.WriteLine(e.Message) + Return + End Try + + ' If we found it, get type information about + ' the minivan and create an instance. + Dim miniVan As Type = a.GetType("CarLibrary.MiniVan") + Dim obj As Object = Activator.CreateInstance(miniVan) + + ' Get info for TurboBoost. + Dim mi As MethodInfo = miniVan.GetMethod("TurboBoost") + + ' Invoke method ('Nothing' for no parameters). + mi.Invoke(obj, Nothing) + + '' Bind late to a method taking params. + '' If you updated MiniVan with a TellChildToBeQuiet() method + '' (see Ch. 14) you can test with the following. + 'Dim args(1) As Object + 'args(0) = "Fred" + 'args(1) = 4 + 'mi = miniVan.GetMethod("TellChildToBeQuiet") + 'mi.Invoke(obj, args) + + Console.ReadLine() + End Sub +#End Region + +#Region "This logic will ONLY work if Option Strict is Off" + 'Sub EasyMain() + ' Console.WriteLine("You must disable Option Strict for this to work!") + + ' ' Try to load a local copy of CarLibrary. + ' Dim a As Assembly = Nothing + ' Try + ' a = Assembly.Load("CarLibrary") + ' Catch e As FileNotFoundException + ' Console.WriteLine(e.Message) + ' Return + ' End Try + + ' ' If we found it, get type information about + ' ' the minivan and create an instance. + ' Dim miniVan As Type = a.GetType("CarLibrary.MiniVan") + ' Dim obj As Object = Activator.CreateInstance(miniVan) + ' obj.TurboBoost() + ' obj.TellChildToBeQuiet("Fred", 4) + 'End Sub +#End Region + +End Module diff --git a/Code/Chapter 16/MyTypeViewer/My Project/Application.Designer.vb b/Code/Chapter 16/MyTypeViewer/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 16/MyTypeViewer/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 16/MyTypeViewer/My Project/Application.myapp b/Code/Chapter 16/MyTypeViewer/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 16/MyTypeViewer/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 16/MyTypeViewer/My Project/AssemblyInfo.vb b/Code/Chapter 16/MyTypeViewer/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..37718e8 --- /dev/null +++ b/Code/Chapter 16/MyTypeViewer/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/Code/Chapter 16/MyTypeViewer/My Project/Resources.Designer.vb b/Code/Chapter 16/MyTypeViewer/My Project/Resources.Designer.vb new file mode 100644 index 0000000..f7fbe0e --- /dev/null +++ b/Code/Chapter 16/MyTypeViewer/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("MyTypeViewer.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/Code/Chapter 16/MyTypeViewer/My Project/Resources.resx b/Code/Chapter 16/MyTypeViewer/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 16/MyTypeViewer/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/Code/Chapter 16/MyTypeViewer/My Project/Settings.Designer.vb b/Code/Chapter 16/MyTypeViewer/My Project/Settings.Designer.vb new file mode 100644 index 0000000..045707d --- /dev/null +++ b/Code/Chapter 16/MyTypeViewer/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.MyTypeViewer.My.MySettings + Get + Return Global.MyTypeViewer.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 16/MyTypeViewer/My Project/Settings.settings b/Code/Chapter 16/MyTypeViewer/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 16/MyTypeViewer/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 16/MyTypeViewer/MyTypeViewer.sln b/Code/Chapter 16/MyTypeViewer/MyTypeViewer.sln new file mode 100644 index 0000000..379d18d --- /dev/null +++ b/Code/Chapter 16/MyTypeViewer/MyTypeViewer.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MyTypeViewer", "MyTypeViewer.vbproj", "{04CD22D3-4134-4D9D-A245-0EA1ED9B4480}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {04CD22D3-4134-4D9D-A245-0EA1ED9B4480}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {04CD22D3-4134-4D9D-A245-0EA1ED9B4480}.Debug|Any CPU.Build.0 = Debug|Any CPU + {04CD22D3-4134-4D9D-A245-0EA1ED9B4480}.Release|Any CPU.ActiveCfg = Release|Any CPU + {04CD22D3-4134-4D9D-A245-0EA1ED9B4480}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 16/MyTypeViewer/MyTypeViewer.suo b/Code/Chapter 16/MyTypeViewer/MyTypeViewer.suo new file mode 100644 index 0000000..de22bfc Binary files /dev/null and b/Code/Chapter 16/MyTypeViewer/MyTypeViewer.suo differ diff --git a/Code/Chapter 16/MyTypeViewer/MyTypeViewer.vbproj b/Code/Chapter 16/MyTypeViewer/MyTypeViewer.vbproj new file mode 100644 index 0000000..2578977 --- /dev/null +++ b/Code/Chapter 16/MyTypeViewer/MyTypeViewer.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {04CD22D3-4134-4D9D-A245-0EA1ED9B4480} + Exe + MyTypeViewer.Program + MyTypeViewer + MyTypeViewer + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + MyTypeViewer.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + MyTypeViewer.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 16/MyTypeViewer/MyTypeViewer.vbproj.user b/Code/Chapter 16/MyTypeViewer/MyTypeViewer.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 16/MyTypeViewer/MyTypeViewer.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 16/MyTypeViewer/Program.vb b/Code/Chapter 16/MyTypeViewer/Program.vb new file mode 100644 index 0000000..15a61f9 --- /dev/null +++ b/Code/Chapter 16/MyTypeViewer/Program.vb @@ -0,0 +1,98 @@ +Option Explicit On +Option Strict On + +Imports System.Reflection + +Module Program + Sub Main() + Console.WriteLine("***** Welcome to MyTypeViewer *****") + Dim typeName As String = String.Empty + + Do + Console.WriteLine() + Console.WriteLine("Enter a type name to evaluate") + Console.Write("or enter Q to quit: ") + + ' Get name of type. + typeName = Console.ReadLine() + + ' Does user want to quit? + If typeName.ToUpper() = "Q" Then + Exit Do + End If + + ' Try to display type + Try + Dim t As Type = Type.GetType(typeName) + Console.WriteLine() + ListVariousStats(t) + ListFields(t) + ListProps(t) + ListMethods(t) + ListInterfaces(t) + Catch + Console.WriteLine("Sorry, can't find {0}.", typeName) + End Try + Loop + End Sub + +#Region "Helper methods" + ' Display method names of type. + Public Sub ListMethods(ByVal t As Type) + Console.WriteLine("***** Methods *****") + Dim mi As MethodInfo() = t.GetMethods() + For Each m As MethodInfo In mi + Dim retVal As String = m.ReturnType.FullName() + Dim paramInfo As String = "( " + For Each pi As ParameterInfo In m.GetParameters() + paramInfo &= String.Format("{0} {1} ", pi.ParameterType, pi.Name) + Next + paramInfo &= ")" + Console.WriteLine("->{0} {1} {2}", retVal, m.Name, paramInfo) + Next + Console.WriteLine() + End Sub + + ' Display field names of type. + Public Sub ListFields(ByVal t As Type) + Console.WriteLine("***** Fields *****") + Dim fi As FieldInfo() = t.GetFields() + For Each field As FieldInfo In fi + Console.WriteLine("->{0} ", field.Name) + Next + Console.WriteLine() + End Sub + + ' Display property names of type. + Public Sub ListProps(ByVal t As Type) + Console.WriteLine("***** Properties *****") + Dim pi As PropertyInfo() = t.GetProperties() + For Each prop As PropertyInfo In pi + Console.WriteLine("->{0} ", prop.Name) + Next + Console.WriteLine() + End Sub + + ' Display implemented interfaces. + Public Sub ListInterfaces(ByVal t As Type) + Console.WriteLine("***** Interfaces *****") + Dim ifaces As Type() = t.GetInterfaces() + For Each i As Type In ifaces + Console.WriteLine("->{0} ", i.Name) + Next + Console.WriteLine() + End Sub + + ' Just for good measure. + Public Sub ListVariousStats(ByVal t As Type) + Console.WriteLine("***** Various Statistics *****") + Console.WriteLine("Base class is: {0} ", t.BaseType) + Console.WriteLine("Is type abstract? {0} ", t.IsAbstract) + Console.WriteLine("Is type sealed? {0} ", t.IsSealed) + Console.WriteLine("Is type generic? {0} ", t.IsGenericTypeDefinition) + Console.WriteLine("Is type a class type? {0} ", t.IsClass) + Console.WriteLine() + End Sub +#End Region + +End Module diff --git a/Code/Chapter 16/SharedAssemblyReflector/My Project/Application.Designer.vb b/Code/Chapter 16/SharedAssemblyReflector/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 16/SharedAssemblyReflector/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 16/SharedAssemblyReflector/My Project/Application.myapp b/Code/Chapter 16/SharedAssemblyReflector/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 16/SharedAssemblyReflector/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 16/SharedAssemblyReflector/My Project/AssemblyInfo.vb b/Code/Chapter 16/SharedAssemblyReflector/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..2f80dd1 --- /dev/null +++ b/Code/Chapter 16/SharedAssemblyReflector/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/Code/Chapter 16/SharedAssemblyReflector/My Project/Settings.Designer.vb b/Code/Chapter 16/SharedAssemblyReflector/My Project/Settings.Designer.vb new file mode 100644 index 0000000..29d4f45 --- /dev/null +++ b/Code/Chapter 16/SharedAssemblyReflector/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SharedAssemblyReflector.My.MySettings + Get + Return Global.SharedAssemblyReflector.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 16/SharedAssemblyReflector/My Project/Settings.settings b/Code/Chapter 16/SharedAssemblyReflector/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 16/SharedAssemblyReflector/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 16/SharedAssemblyReflector/Program.vb b/Code/Chapter 16/SharedAssemblyReflector/Program.vb new file mode 100644 index 0000000..e6161ce --- /dev/null +++ b/Code/Chapter 16/SharedAssemblyReflector/Program.vb @@ -0,0 +1,34 @@ +Option Explicit On +Option Strict On + +Imports System.Reflection + +Module Program + Sub Main() + Console.WriteLine("***** The Shared Asm Reflector App *****") + Console.WriteLine() + Dim displayName As String = Nothing + displayName = "System.Windows.Forms, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, Culture=neutral" + Dim asm As Assembly = Assembly.Load(displayName) + DisplayInfo(asm) + Console.ReadLine() + End Sub + + Sub DisplayInfo(ByVal a As Assembly) + Console.WriteLine("***** Info about Assembly *****") + Console.WriteLine("Loaded from GAC? {0} ", a.GlobalAssemblyCache()) + Console.WriteLine("Asm Name: {0} ", a.GetName().Name) + Console.WriteLine("Asm Version: {0} ", a.GetName().Version) + Console.WriteLine("Asm Culture: {0} ", a.GetName().CultureInfo.DisplayName) + Dim types As Type() = a.GetTypes() + + ' Just print out the first 20 types. + For i As Integer = 0 To 19 + Try + Console.WriteLine("Type: {0}", types(i)) + Catch ex As Exception + Console.WriteLine(ex.Message) + End Try + Next + End Sub +End Module diff --git a/Code/Chapter 16/SharedAssemblyReflector/SharedAssemblyReflector.sln b/Code/Chapter 16/SharedAssemblyReflector/SharedAssemblyReflector.sln new file mode 100644 index 0000000..2ed8fc8 --- /dev/null +++ b/Code/Chapter 16/SharedAssemblyReflector/SharedAssemblyReflector.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SharedAssemblyReflector", "SharedAssemblyReflector.vbproj", "{D5CB3179-8DD5-4A2A-A5B6-D5B33BF28199}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D5CB3179-8DD5-4A2A-A5B6-D5B33BF28199}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D5CB3179-8DD5-4A2A-A5B6-D5B33BF28199}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D5CB3179-8DD5-4A2A-A5B6-D5B33BF28199}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D5CB3179-8DD5-4A2A-A5B6-D5B33BF28199}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 16/SharedAssemblyReflector/SharedAssemblyReflector.suo b/Code/Chapter 16/SharedAssemblyReflector/SharedAssemblyReflector.suo new file mode 100644 index 0000000..5abc3c8 Binary files /dev/null and b/Code/Chapter 16/SharedAssemblyReflector/SharedAssemblyReflector.suo differ diff --git a/Code/Chapter 16/SharedAssemblyReflector/SharedAssemblyReflector.vbproj b/Code/Chapter 16/SharedAssemblyReflector/SharedAssemblyReflector.vbproj new file mode 100644 index 0000000..767b5a1 --- /dev/null +++ b/Code/Chapter 16/SharedAssemblyReflector/SharedAssemblyReflector.vbproj @@ -0,0 +1,121 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {D5CB3179-8DD5-4A2A-A5B6-D5B33BF28199} + Exe + SharedAssemblyReflector.Program + SharedAssemblyReflector + SharedAssemblyReflector + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + SharedAssemblyReflector.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SharedAssemblyReflector.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + Settings.settings + True + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 16/SharedAssemblyReflector/SharedAssemblyReflector.vbproj.user b/Code/Chapter 16/SharedAssemblyReflector/SharedAssemblyReflector.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 16/SharedAssemblyReflector/SharedAssemblyReflector.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 16/VehicleDescriptionReader/My Project/Application.Designer.vb b/Code/Chapter 16/VehicleDescriptionReader/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 16/VehicleDescriptionReader/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 16/VehicleDescriptionReader/My Project/Application.myapp b/Code/Chapter 16/VehicleDescriptionReader/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 16/VehicleDescriptionReader/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 16/VehicleDescriptionReader/My Project/AssemblyInfo.vb b/Code/Chapter 16/VehicleDescriptionReader/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..261c0ff --- /dev/null +++ b/Code/Chapter 16/VehicleDescriptionReader/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/Code/Chapter 16/VehicleDescriptionReader/My Project/Resources.Designer.vb b/Code/Chapter 16/VehicleDescriptionReader/My Project/Resources.Designer.vb new file mode 100644 index 0000000..1db8b4e --- /dev/null +++ b/Code/Chapter 16/VehicleDescriptionReader/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("VehicleDescriptionReader.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/Code/Chapter 16/VehicleDescriptionReader/My Project/Resources.resx b/Code/Chapter 16/VehicleDescriptionReader/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 16/VehicleDescriptionReader/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/Code/Chapter 16/VehicleDescriptionReader/My Project/Settings.Designer.vb b/Code/Chapter 16/VehicleDescriptionReader/My Project/Settings.Designer.vb new file mode 100644 index 0000000..f7a676e --- /dev/null +++ b/Code/Chapter 16/VehicleDescriptionReader/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.VehicleDescriptionReader.My.MySettings + Get + Return Global.VehicleDescriptionReader.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 16/VehicleDescriptionReader/My Project/Settings.settings b/Code/Chapter 16/VehicleDescriptionReader/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 16/VehicleDescriptionReader/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 16/VehicleDescriptionReader/Program.vb b/Code/Chapter 16/VehicleDescriptionReader/Program.vb new file mode 100644 index 0000000..31697b0 --- /dev/null +++ b/Code/Chapter 16/VehicleDescriptionReader/Program.vb @@ -0,0 +1,23 @@ +Option Explicit On +Option Strict On + +Imports AttributedCarLibrary + +' Reflecting on custom attributes using early binding. +Module Program + Sub Main() + ' Get a Type representing the Winnebago. + Dim t As Type = GetType(Winnebago) + + ' Get all attributes on the Winnebago. + Dim customAtts As Object() = t.GetCustomAttributes(False) + + ' Print the description. + Console.WriteLine("***** Value of VehicleDescriptionAttribute *****") + For Each v As VehicleDescriptionAttribute In customAtts + Console.WriteLine() + Console.WriteLine("->{0}", v.Description) + Next + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 16/VehicleDescriptionReader/VehicleDescriptionReader.sln b/Code/Chapter 16/VehicleDescriptionReader/VehicleDescriptionReader.sln new file mode 100644 index 0000000..0742676 --- /dev/null +++ b/Code/Chapter 16/VehicleDescriptionReader/VehicleDescriptionReader.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VehicleDescriptionReader", "VehicleDescriptionReader.vbproj", "{5217D13D-B4AE-4C73-8566-D132C60009C5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5217D13D-B4AE-4C73-8566-D132C60009C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5217D13D-B4AE-4C73-8566-D132C60009C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5217D13D-B4AE-4C73-8566-D132C60009C5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5217D13D-B4AE-4C73-8566-D132C60009C5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 16/VehicleDescriptionReader/VehicleDescriptionReader.suo b/Code/Chapter 16/VehicleDescriptionReader/VehicleDescriptionReader.suo new file mode 100644 index 0000000..ba21a20 Binary files /dev/null and b/Code/Chapter 16/VehicleDescriptionReader/VehicleDescriptionReader.suo differ diff --git a/Code/Chapter 16/VehicleDescriptionReader/VehicleDescriptionReader.vbproj b/Code/Chapter 16/VehicleDescriptionReader/VehicleDescriptionReader.vbproj new file mode 100644 index 0000000..8818e88 --- /dev/null +++ b/Code/Chapter 16/VehicleDescriptionReader/VehicleDescriptionReader.vbproj @@ -0,0 +1,138 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {5217D13D-B4AE-4C73-8566-D132C60009C5} + Exe + VehicleDescriptionReader.Program + VehicleDescriptionReader + VehicleDescriptionReader + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + VehicleDescriptionReader.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + VehicleDescriptionReader.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + False + ..\AttributedCarLibrary\bin\Debug\AttributedCarLibrary.dll + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 16/VehicleDescriptionReader/VehicleDescriptionReader.vbproj.user b/Code/Chapter 16/VehicleDescriptionReader/VehicleDescriptionReader.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 16/VehicleDescriptionReader/VehicleDescriptionReader.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 16/VehicleDescriptionReaderLB/My Project/Application.Designer.vb b/Code/Chapter 16/VehicleDescriptionReaderLB/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 16/VehicleDescriptionReaderLB/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 16/VehicleDescriptionReaderLB/My Project/Application.myapp b/Code/Chapter 16/VehicleDescriptionReaderLB/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 16/VehicleDescriptionReaderLB/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 16/VehicleDescriptionReaderLB/My Project/AssemblyInfo.vb b/Code/Chapter 16/VehicleDescriptionReaderLB/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..f283cdf --- /dev/null +++ b/Code/Chapter 16/VehicleDescriptionReaderLB/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/Code/Chapter 16/VehicleDescriptionReaderLB/My Project/Resources.Designer.vb b/Code/Chapter 16/VehicleDescriptionReaderLB/My Project/Resources.Designer.vb new file mode 100644 index 0000000..fed0ac1 --- /dev/null +++ b/Code/Chapter 16/VehicleDescriptionReaderLB/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("VehicleDescriptionReaderLB.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/Code/Chapter 16/VehicleDescriptionReaderLB/My Project/Resources.resx b/Code/Chapter 16/VehicleDescriptionReaderLB/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 16/VehicleDescriptionReaderLB/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/Code/Chapter 16/VehicleDescriptionReaderLB/My Project/Settings.Designer.vb b/Code/Chapter 16/VehicleDescriptionReaderLB/My Project/Settings.Designer.vb new file mode 100644 index 0000000..4940945 --- /dev/null +++ b/Code/Chapter 16/VehicleDescriptionReaderLB/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.VehicleDescriptionReaderLB.My.MySettings + Get + Return Global.VehicleDescriptionReaderLB.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 16/VehicleDescriptionReaderLB/My Project/Settings.settings b/Code/Chapter 16/VehicleDescriptionReaderLB/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 16/VehicleDescriptionReaderLB/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 16/VehicleDescriptionReaderLB/Project.vb b/Code/Chapter 16/VehicleDescriptionReaderLB/Project.vb new file mode 100644 index 0000000..028da6f --- /dev/null +++ b/Code/Chapter 16/VehicleDescriptionReaderLB/Project.vb @@ -0,0 +1,34 @@ +Option Explicit On +Option Strict On + +Imports System.Reflection + +Module Project + + Sub Main() + Console.WriteLine("***** Descriptions of Your Vehicles *****") + Console.WriteLine() + + ' the local copy of AttributedCarLibrary. + Dim asm As Assembly = Assembly.Load("AttributedCarLibrary") + + ' Get type info of VehicleDescriptionAttribute. + Dim vehicleDesc As Type = asm.GetType("AttributedCarLibrary.VehicleDescriptionAttribute") + + ' Get type info of the Description property. + Dim propDesc As PropertyInfo = vehicleDesc.GetProperty("Description") + + ' Get all types in the assembly. + Dim types As Type() = asm.GetTypes() + + ' Iterate over each attribute. + For Each t As Type In types + Dim objs As Object() = t.GetCustomAttributes(vehicleDesc, False) + For Each o As Object In objs + Console.WriteLine("-> {0} : {1}", t.Name, propDesc.GetValue(o, Nothing)) + Next + Next + Console.ReadLine() + End Sub + +End Module diff --git a/Code/Chapter 16/VehicleDescriptionReaderLB/VehicleDescriptionReaderLB.sln b/Code/Chapter 16/VehicleDescriptionReaderLB/VehicleDescriptionReaderLB.sln new file mode 100644 index 0000000..5d7dbb2 --- /dev/null +++ b/Code/Chapter 16/VehicleDescriptionReaderLB/VehicleDescriptionReaderLB.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VehicleDescriptionReaderLB", "VehicleDescriptionReaderLB.vbproj", "{CC9CA480-8A47-446E-81B9-3F458A1F1B41}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CC9CA480-8A47-446E-81B9-3F458A1F1B41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CC9CA480-8A47-446E-81B9-3F458A1F1B41}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CC9CA480-8A47-446E-81B9-3F458A1F1B41}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CC9CA480-8A47-446E-81B9-3F458A1F1B41}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 16/VehicleDescriptionReaderLB/VehicleDescriptionReaderLB.suo b/Code/Chapter 16/VehicleDescriptionReaderLB/VehicleDescriptionReaderLB.suo new file mode 100644 index 0000000..be1c7e6 Binary files /dev/null and b/Code/Chapter 16/VehicleDescriptionReaderLB/VehicleDescriptionReaderLB.suo differ diff --git a/Code/Chapter 16/VehicleDescriptionReaderLB/VehicleDescriptionReaderLB.vbproj b/Code/Chapter 16/VehicleDescriptionReaderLB/VehicleDescriptionReaderLB.vbproj new file mode 100644 index 0000000..34156ed --- /dev/null +++ b/Code/Chapter 16/VehicleDescriptionReaderLB/VehicleDescriptionReaderLB.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {CC9CA480-8A47-446E-81B9-3F458A1F1B41} + Exe + VehicleDescriptionReaderLB.Project + VehicleDescriptionReaderLB + VehicleDescriptionReaderLB + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + VehicleDescriptionReaderLB.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + VehicleDescriptionReaderLB.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 16/VehicleDescriptionReaderLB/VehicleDescriptionReaderLB.vbproj.user b/Code/Chapter 16/VehicleDescriptionReaderLB/VehicleDescriptionReaderLB.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 16/VehicleDescriptionReaderLB/VehicleDescriptionReaderLB.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 17/AppDomainManipulator/AppDomainManipulator.sln b/Code/Chapter 17/AppDomainManipulator/AppDomainManipulator.sln new file mode 100644 index 0000000..c318290 --- /dev/null +++ b/Code/Chapter 17/AppDomainManipulator/AppDomainManipulator.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AppDomainManipulator", "AppDomainManipulator.vbproj", "{523EFF58-9062-44EA-8731-D79C3EA3675C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {523EFF58-9062-44EA-8731-D79C3EA3675C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {523EFF58-9062-44EA-8731-D79C3EA3675C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {523EFF58-9062-44EA-8731-D79C3EA3675C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {523EFF58-9062-44EA-8731-D79C3EA3675C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 17/AppDomainManipulator/AppDomainManipulator.suo b/Code/Chapter 17/AppDomainManipulator/AppDomainManipulator.suo new file mode 100644 index 0000000..1377109 Binary files /dev/null and b/Code/Chapter 17/AppDomainManipulator/AppDomainManipulator.suo differ diff --git a/Code/Chapter 17/AppDomainManipulator/AppDomainManipulator.vbproj b/Code/Chapter 17/AppDomainManipulator/AppDomainManipulator.vbproj new file mode 100644 index 0000000..853ec17 --- /dev/null +++ b/Code/Chapter 17/AppDomainManipulator/AppDomainManipulator.vbproj @@ -0,0 +1,139 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {523EFF58-9062-44EA-8731-D79C3EA3675C} + Exe + AppDomainManipulator.Program + AppDomainManipulator + AppDomainManipulator + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + AppDomainManipulator.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + AppDomainManipulator.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + False + ..\..\..\..\C# and the .NET Platform 4th ed\Code\Chapter 15\CarLibrary\bin\Debug\CarLibrary.dll + + + + 3.5 + + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 17/AppDomainManipulator/AppDomainManipulator.vbproj.user b/Code/Chapter 17/AppDomainManipulator/AppDomainManipulator.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 17/AppDomainManipulator/AppDomainManipulator.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 17/AppDomainManipulator/My Project/Application.Designer.vb b/Code/Chapter 17/AppDomainManipulator/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 17/AppDomainManipulator/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 17/AppDomainManipulator/My Project/Application.myapp b/Code/Chapter 17/AppDomainManipulator/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 17/AppDomainManipulator/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 17/AppDomainManipulator/My Project/AssemblyInfo.vb b/Code/Chapter 17/AppDomainManipulator/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..290db8a --- /dev/null +++ b/Code/Chapter 17/AppDomainManipulator/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/Code/Chapter 17/AppDomainManipulator/My Project/Resources.Designer.vb b/Code/Chapter 17/AppDomainManipulator/My Project/Resources.Designer.vb new file mode 100644 index 0000000..69b02f3 --- /dev/null +++ b/Code/Chapter 17/AppDomainManipulator/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("AppDomainManipulator.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/Code/Chapter 17/AppDomainManipulator/My Project/Resources.resx b/Code/Chapter 17/AppDomainManipulator/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 17/AppDomainManipulator/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/Code/Chapter 17/AppDomainManipulator/My Project/Settings.Designer.vb b/Code/Chapter 17/AppDomainManipulator/My Project/Settings.Designer.vb new file mode 100644 index 0000000..34a08fc --- /dev/null +++ b/Code/Chapter 17/AppDomainManipulator/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.AppDomainManipulator.My.MySettings + Get + Return Global.AppDomainManipulator.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 17/AppDomainManipulator/My Project/Settings.settings b/Code/Chapter 17/AppDomainManipulator/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 17/AppDomainManipulator/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 17/AppDomainManipulator/Program.vb b/Code/Chapter 17/AppDomainManipulator/Program.vb new file mode 100644 index 0000000..276dffe --- /dev/null +++ b/Code/Chapter 17/AppDomainManipulator/Program.vb @@ -0,0 +1,57 @@ +Imports System.Reflection +Imports System.Windows.Forms + +Module Program + + Sub Main() + Console.WriteLine("***** The Amazing AppDomain app *****" & vbLf) + + ' Get info for current AppDomain. + Dim defaultAD As AppDomain = AppDomain.CurrentDomain() + MessageBox.Show("Hello") + PrintAllAssembliesInAppDomain(defaultAD) + Console.WriteLine() + + ' Programmatically make a new app domain. + Dim anotherAD As AppDomain = AppDomain.CreateDomain("SecondAppDomain") + ' Load CarLibrary.dll into this new appdomain. + anotherAD.Load("CarLibrary") + PrintAllAssembliesInAppDomain(anotherAD) + + ' Hook into DomainUnload event. + AddHandler anotherAD.DomainUnload, AddressOf anotherAD_DomainUnload + + ' Now unload anotherAD. + AppDomain.Unload(anotherAD) + + ' Hook into ProcessExit. + AddHandler defaultAD.ProcessExit, AddressOf defaultAD_ProcessExit + Console.ReadLine() + End Sub + +#Region "Handler for unloading app domains" + Public Sub anotherAD_DomainUnload(ByVal sender As Object, ByVal e As EventArgs) + Console.WriteLine("***** Unloaded anotherAD! *****") + End Sub + + Private Sub defaultAD_ProcessExit(ByVal sender As Object, ByVal e As EventArgs) + Console.WriteLine("***** Unloaded defaultAD! *****") + End Sub +#End Region + +#Region "PrintAllAssembliesInAppDomain" + Public Sub PrintAllAssembliesInAppDomain(ByVal ad As AppDomain) + Dim loadedAssemblies As Assembly() = ad.GetAssemblies() + Console.WriteLine("***** Here are the assemblies loaded in {0} *****", _ + ad.FriendlyName) + + ' Remember! We need to import System.Reflection to use + ' the Assembly type. + For Each a As Assembly In loadedAssemblies + Console.WriteLine("-> Name: {0}", a.GetName.Name) + Console.WriteLine("-> Version: {0}", a.GetName.Version) + Next + End Sub +#End Region + +End Module diff --git a/Code/Chapter 17/ContextManipulator/ContextManipulator.sln b/Code/Chapter 17/ContextManipulator/ContextManipulator.sln new file mode 100644 index 0000000..ce7ded0 --- /dev/null +++ b/Code/Chapter 17/ContextManipulator/ContextManipulator.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ContextManipulator", "ContextManipulator.vbproj", "{A8269A84-8FC8-4225-BDDE-2B21B14F93AA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A8269A84-8FC8-4225-BDDE-2B21B14F93AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A8269A84-8FC8-4225-BDDE-2B21B14F93AA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A8269A84-8FC8-4225-BDDE-2B21B14F93AA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A8269A84-8FC8-4225-BDDE-2B21B14F93AA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 17/ContextManipulator/ContextManipulator.suo b/Code/Chapter 17/ContextManipulator/ContextManipulator.suo new file mode 100644 index 0000000..8b3771f Binary files /dev/null and b/Code/Chapter 17/ContextManipulator/ContextManipulator.suo differ diff --git a/Code/Chapter 17/ContextManipulator/ContextManipulator.vbproj b/Code/Chapter 17/ContextManipulator/ContextManipulator.vbproj new file mode 100644 index 0000000..e998d7c --- /dev/null +++ b/Code/Chapter 17/ContextManipulator/ContextManipulator.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {A8269A84-8FC8-4225-BDDE-2B21B14F93AA} + Exe + ContextManipulator.Program + ContextManipulator + ContextManipulator + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + ContextManipulator.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + ContextManipulator.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 17/ContextManipulator/ContextManipulator.vbproj.user b/Code/Chapter 17/ContextManipulator/ContextManipulator.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 17/ContextManipulator/ContextManipulator.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 17/ContextManipulator/My Project/Application.Designer.vb b/Code/Chapter 17/ContextManipulator/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 17/ContextManipulator/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 17/ContextManipulator/My Project/Application.myapp b/Code/Chapter 17/ContextManipulator/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 17/ContextManipulator/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 17/ContextManipulator/My Project/AssemblyInfo.vb b/Code/Chapter 17/ContextManipulator/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..6930c95 --- /dev/null +++ b/Code/Chapter 17/ContextManipulator/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/Code/Chapter 17/ContextManipulator/My Project/Resources.Designer.vb b/Code/Chapter 17/ContextManipulator/My Project/Resources.Designer.vb new file mode 100644 index 0000000..9e3b389 --- /dev/null +++ b/Code/Chapter 17/ContextManipulator/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("ContextManipulator.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/Code/Chapter 17/ContextManipulator/My Project/Resources.resx b/Code/Chapter 17/ContextManipulator/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 17/ContextManipulator/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/Code/Chapter 17/ContextManipulator/My Project/Settings.Designer.vb b/Code/Chapter 17/ContextManipulator/My Project/Settings.Designer.vb new file mode 100644 index 0000000..5569ce3 --- /dev/null +++ b/Code/Chapter 17/ContextManipulator/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.ContextManipulator.My.MySettings + Get + Return Global.ContextManipulator.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 17/ContextManipulator/My Project/Settings.settings b/Code/Chapter 17/ContextManipulator/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 17/ContextManipulator/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 17/ContextManipulator/Program.vb b/Code/Chapter 17/ContextManipulator/Program.vb new file mode 100644 index 0000000..ac64183 --- /dev/null +++ b/Code/Chapter 17/ContextManipulator/Program.vb @@ -0,0 +1,53 @@ +Imports System.Runtime.Remoting.Contexts ' For Context type. +Imports System.Threading ' For Thread type. + +#Region "Car types for context testing" +' SportsCar has no special contextual +' needs and will be loaded into the +' default context of the app domain. +Public Class SportsCar + Public Sub New() + ' Get context information and print out context ID. + Dim ctx As Context = Thread.CurrentContext() + Console.WriteLine("{0} object in context {1}", Me.ToString(), ctx.ContextID) + For Each prop As IContextProperty In ctx.ContextProperties + Console.WriteLine("-> Ctx Prop: {0}", prop.Name) + Next + End Sub +End Class + +' SportsCarTS demands to be loaded in +' a synchronization context. + _ +Public Class SportsCarTS + Inherits ContextBoundObject + + Public Sub New() + ' Get context information and print out context ID. + Dim ctx As Context = Thread.CurrentContext() + Console.WriteLine("{0} object in context {1}", Me.ToString(), ctx.ContextID) + For Each prop As IContextProperty In ctx.ContextProperties + Console.WriteLine("-> Ctx Prop: {0}", prop.Name) + Next + End Sub +End Class +#End Region + +Module Program + + Sub Main() + Console.WriteLine("***** The Amazing Context Application *****") + Console.WriteLine() + + ' Objects will display contextual info upon creation. + Dim sport As New SportsCar() + Console.WriteLine() + + Dim sport2 As New SportsCar() + Console.WriteLine() + + Dim synchroSport As New SportsCarTS() + Console.ReadLine() + End Sub + +End Module diff --git a/Code/Chapter 17/ProcessManipulator/My Project/Application.Designer.vb b/Code/Chapter 17/ProcessManipulator/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 17/ProcessManipulator/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 17/ProcessManipulator/My Project/Application.myapp b/Code/Chapter 17/ProcessManipulator/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 17/ProcessManipulator/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 17/ProcessManipulator/My Project/AssemblyInfo.vb b/Code/Chapter 17/ProcessManipulator/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..2c73e33 --- /dev/null +++ b/Code/Chapter 17/ProcessManipulator/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/Code/Chapter 17/ProcessManipulator/My Project/Resources.Designer.vb b/Code/Chapter 17/ProcessManipulator/My Project/Resources.Designer.vb new file mode 100644 index 0000000..39b615d --- /dev/null +++ b/Code/Chapter 17/ProcessManipulator/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("ProcessManipulator.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/Code/Chapter 17/ProcessManipulator/My Project/Resources.resx b/Code/Chapter 17/ProcessManipulator/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 17/ProcessManipulator/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/Code/Chapter 17/ProcessManipulator/My Project/Settings.Designer.vb b/Code/Chapter 17/ProcessManipulator/My Project/Settings.Designer.vb new file mode 100644 index 0000000..9947007 --- /dev/null +++ b/Code/Chapter 17/ProcessManipulator/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.ProcessManipulator.My.MySettings + Get + Return Global.ProcessManipulator.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 17/ProcessManipulator/My Project/Settings.settings b/Code/Chapter 17/ProcessManipulator/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 17/ProcessManipulator/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 17/ProcessManipulator/ProcessManipulator.sln b/Code/Chapter 17/ProcessManipulator/ProcessManipulator.sln new file mode 100644 index 0000000..8a86e34 --- /dev/null +++ b/Code/Chapter 17/ProcessManipulator/ProcessManipulator.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ProcessManipulator", "ProcessManipulator.vbproj", "{6B2A5C30-A621-4BDF-B78E-8D7461E2B70D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6B2A5C30-A621-4BDF-B78E-8D7461E2B70D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6B2A5C30-A621-4BDF-B78E-8D7461E2B70D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6B2A5C30-A621-4BDF-B78E-8D7461E2B70D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6B2A5C30-A621-4BDF-B78E-8D7461E2B70D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 17/ProcessManipulator/ProcessManipulator.suo b/Code/Chapter 17/ProcessManipulator/ProcessManipulator.suo new file mode 100644 index 0000000..2e59d94 Binary files /dev/null and b/Code/Chapter 17/ProcessManipulator/ProcessManipulator.suo differ diff --git a/Code/Chapter 17/ProcessManipulator/ProcessManipulator.vbproj b/Code/Chapter 17/ProcessManipulator/ProcessManipulator.vbproj new file mode 100644 index 0000000..e13aa88 --- /dev/null +++ b/Code/Chapter 17/ProcessManipulator/ProcessManipulator.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {6B2A5C30-A621-4BDF-B78E-8D7461E2B70D} + Exe + ProcessManipulator.Program + ProcessManipulator + ProcessManipulator + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + ProcessManipulator.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + ProcessManipulator.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 17/ProcessManipulator/ProcessManipulator.vbproj.user b/Code/Chapter 17/ProcessManipulator/ProcessManipulator.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 17/ProcessManipulator/ProcessManipulator.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 17/ProcessManipulator/Program.vb b/Code/Chapter 17/ProcessManipulator/Program.vb new file mode 100644 index 0000000..48fdbf7 --- /dev/null +++ b/Code/Chapter 17/ProcessManipulator/Program.vb @@ -0,0 +1,114 @@ +Imports System.Diagnostics + +Module Program + + Sub Main() + Console.WriteLine("***** Fun with Processes *****" & vbLf) + ListAllRunningProcesses() + + ' Prompt user for a PID and print out the set of active threads. + Console.WriteLine("***** Enter PID of process to investigate *****") + Console.Write("PID: ") + Dim pID As String = Console.ReadLine() + Try + Dim theProcID As Integer = Integer.Parse(pID) + EnumThreadsForPid(theProcID) + EnumModsForPid(theProcID) + Catch ex As Exception + Console.WriteLine(ex.Message) + End Try + + ' Launch IE. + StartAndKillProcess() + Console.ReadLine() + End Sub + + +#Region "ListAllRunningProcesses" + Public Sub ListAllRunningProcesses() + ' Get all the processes on the local machine. + Dim runningProcs As Process() = Process.GetProcesses(".") + + ' Print out PID and name of each process. + For Each p As Process In runningProcs + Dim info As String = String.Format("-> PID: {0}" & _ + Chr(9) & "Name: {1}", p.Id, p.ProcessName) + Console.WriteLine(info) + Next + Console.WriteLine("************************************") + Console.WriteLine() + End Sub +#End Region + +#Region "EnumThreadsForPid" + Public Sub EnumThreadsForPid(ByVal pID As Integer) + Dim theProc As Process + Try + theProc = Process.GetProcessById(pID) + Catch + Console.WriteLine("-> Sorry...bad PID!") + Console.WriteLine("************************************") + Console.WriteLine() + Return + End Try + Console.WriteLine("Here are the threads used by: {0}", theProc.ProcessName) + + ' List out stats for each thread in the specified process. + Dim theThreads As ProcessThreadCollection = theProc.Threads + For Each pt As ProcessThread In theThreads + Dim info As String = String.Format("-> Thread ID: {0}" _ + & Chr(9) & "Start Time {1}" & _ + Chr(9) & "Priority {2}", _ + pt.Id, pt.StartTime.ToShortTimeString(), pt.PriorityLevel) + Console.WriteLine(info) + Next + Console.WriteLine("************************************") + Console.WriteLine() + End Sub +#End Region + +#Region "EnumModsForPid" + Public Sub EnumModsForPid(ByVal pID As Integer) + Dim theProc As Process + Try + theProc = Process.GetProcessById(pID) + Catch + Console.WriteLine("-> Sorry...bad PID!") + Console.WriteLine("************************************") + Console.WriteLine() + Return + End Try + Console.WriteLine("Here are the loaded modules for: {0}", theProc.ProcessName) + Try + Dim theMods As ProcessModuleCollection = theProc.Modules + For Each pm As ProcessModule In theMods + Dim info As String = String.Format("-> Mod Name: {0}", pm.ModuleName) + Console.WriteLine(info) + Next + Console.WriteLine("************************************") + Console.WriteLine() + Catch + Console.WriteLine("No mods!") + End Try + End Sub +#End Region + +#Region "StartAndKillProcess" + Public Sub StartAndKillProcess() + ' Launch Internet Explorer. + Console.Write("--> Hit a key to launch IE") + Console.ReadLine() + Dim ieProc As Process = Process.Start("IExplore.exe", _ + "www.intertech.com") + Console.Write("--> Hit a key to kill {0}...", ieProc.ProcessName) + Console.ReadLine() + + ' Kill the iexplorer.exe process. + Try + ieProc.Kill() + Catch ' In case the user already killed it... + End Try + End Sub +#End Region + +End Module diff --git a/Code/Chapter 18/AddWithThreads/AddWithThreads.sln b/Code/Chapter 18/AddWithThreads/AddWithThreads.sln new file mode 100644 index 0000000..9fd9a82 --- /dev/null +++ b/Code/Chapter 18/AddWithThreads/AddWithThreads.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AddWithThreads", "AddWithThreads.vbproj", "{D1D92285-9417-4CC0-9633-2D4076226635}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D1D92285-9417-4CC0-9633-2D4076226635}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D1D92285-9417-4CC0-9633-2D4076226635}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D1D92285-9417-4CC0-9633-2D4076226635}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D1D92285-9417-4CC0-9633-2D4076226635}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 18/AddWithThreads/AddWithThreads.suo b/Code/Chapter 18/AddWithThreads/AddWithThreads.suo new file mode 100644 index 0000000..0a32d1c Binary files /dev/null and b/Code/Chapter 18/AddWithThreads/AddWithThreads.suo differ diff --git a/Code/Chapter 18/AddWithThreads/AddWithThreads.vbproj b/Code/Chapter 18/AddWithThreads/AddWithThreads.vbproj new file mode 100644 index 0000000..6fedf9e --- /dev/null +++ b/Code/Chapter 18/AddWithThreads/AddWithThreads.vbproj @@ -0,0 +1,114 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {D1D92285-9417-4CC0-9633-2D4076226635} + Exe + AddWithThreads.Program + AddWithThreads + AddWithThreads + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + AddWithThreads.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + AddWithThreads.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + True + True + Resources.resx + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 18/AddWithThreads/AddWithThreads.vbproj.user b/Code/Chapter 18/AddWithThreads/AddWithThreads.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 18/AddWithThreads/AddWithThreads.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 18/AddWithThreads/My Project/AssemblyInfo.vb b/Code/Chapter 18/AddWithThreads/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..16adffc --- /dev/null +++ b/Code/Chapter 18/AddWithThreads/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/Code/Chapter 18/AddWithThreads/My Project/Resources.Designer.vb b/Code/Chapter 18/AddWithThreads/My Project/Resources.Designer.vb new file mode 100644 index 0000000..7b5f3e2 --- /dev/null +++ b/Code/Chapter 18/AddWithThreads/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("AddWithThreads.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/Code/Chapter 18/AddWithThreads/My Project/Resources.resx b/Code/Chapter 18/AddWithThreads/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 18/AddWithThreads/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/Code/Chapter 18/AddWithThreads/Program.vb b/Code/Chapter 18/AddWithThreads/Program.vb new file mode 100644 index 0000000..17dc322 --- /dev/null +++ b/Code/Chapter 18/AddWithThreads/Program.vb @@ -0,0 +1,36 @@ +Option Explicit On +Option Strict On + +Imports System.Threading + +#Region "AddParams helper class" +Class AddParams + Public a As Integer + Public b As Integer + Public Sub New(ByVal numb1 As Integer, ByVal numb2 As Integer) + a = numb1 + b = numb2 + End Sub +End Class +#End Region + +Module Program + Sub Main(ByVal args As String()) + Console.WriteLine("***** Adding with Thread objects *****") + Console.WriteLine() + + Console.WriteLine("ID of thread in Main(): {0}", Thread.CurrentThread.ManagedThreadId) + Dim ap As AddParams = New AddParams(10, 10) + Dim t As Thread = New Thread(AddressOf Add) + t.Start(ap) + Console.ReadLine() + End Sub + + Public Sub Add(ByVal data As Object) + If TypeOf data Is AddParams Then + Console.WriteLine("ID of thread in Add(): {0}", Thread.CurrentThread.ManagedThreadId) + Dim ap As AddParams = CType(data, AddParams) + Console.WriteLine("{0} + {1} is {2}", ap.a, ap.b, ap.a + ap.b) + End If + End Sub +End Module diff --git a/Code/Chapter 18/AsyncCallbackDelegate/AsyncCallbackDelegate.sln b/Code/Chapter 18/AsyncCallbackDelegate/AsyncCallbackDelegate.sln new file mode 100644 index 0000000..79d10d1 --- /dev/null +++ b/Code/Chapter 18/AsyncCallbackDelegate/AsyncCallbackDelegate.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AsyncCallbackDelegate", "AsyncCallbackDelegate.vbproj", "{B0358504-04B2-4CA5-93B6-B43E22323E85}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0358504-04B2-4CA5-93B6-B43E22323E85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0358504-04B2-4CA5-93B6-B43E22323E85}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0358504-04B2-4CA5-93B6-B43E22323E85}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0358504-04B2-4CA5-93B6-B43E22323E85}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 18/AsyncCallbackDelegate/AsyncCallbackDelegate.suo b/Code/Chapter 18/AsyncCallbackDelegate/AsyncCallbackDelegate.suo new file mode 100644 index 0000000..994b249 Binary files /dev/null and b/Code/Chapter 18/AsyncCallbackDelegate/AsyncCallbackDelegate.suo differ diff --git a/Code/Chapter 18/AsyncCallbackDelegate/AsyncCallbackDelegate.vbproj b/Code/Chapter 18/AsyncCallbackDelegate/AsyncCallbackDelegate.vbproj new file mode 100644 index 0000000..af5f3c3 --- /dev/null +++ b/Code/Chapter 18/AsyncCallbackDelegate/AsyncCallbackDelegate.vbproj @@ -0,0 +1,101 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {B0358504-04B2-4CA5-93B6-B43E22323E85} + Exe + AsyncCallbackDelegate.Program + AsyncCallbackDelegate + AsyncCallbackDelegate + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + AsyncCallbackDelegate.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + AsyncCallbackDelegate.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 18/AsyncCallbackDelegate/AsyncCallbackDelegate.vbproj.user b/Code/Chapter 18/AsyncCallbackDelegate/AsyncCallbackDelegate.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 18/AsyncCallbackDelegate/AsyncCallbackDelegate.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 18/AsyncCallbackDelegate/My Project/AssemblyInfo.vb b/Code/Chapter 18/AsyncCallbackDelegate/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..09d0116 --- /dev/null +++ b/Code/Chapter 18/AsyncCallbackDelegate/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/Code/Chapter 18/AsyncCallbackDelegate/Program.vb b/Code/Chapter 18/AsyncCallbackDelegate/Program.vb new file mode 100644 index 0000000..e653e9c --- /dev/null +++ b/Code/Chapter 18/AsyncCallbackDelegate/Program.vb @@ -0,0 +1,54 @@ +Option Explicit On +Option Strict On + +Imports System.Threading +Imports System.Runtime.Remoting.Messaging + +' Our delegate. +Public Delegate Function BinaryOp(ByVal x As Integer, _ +ByVal y As Integer) As Integer + +Module Program + Sub Main() + Console.WriteLine("***** AsyncCallbackDelegate Example *****") + Console.WriteLine() + + Console.WriteLine("Main() invoked on thread {0}.", _ + Thread.CurrentThread.ManagedThreadId) + Dim b As BinaryOp = New BinaryOp(AddressOf Add) + + Dim itfAR As IAsyncResult = _ + b.BeginInvoke(10, 10, New AsyncCallback(AddressOf AddComplete), _ + "Main() thanks you for adding these numbers.") + + ' Other work performed here... + + Console.ReadLine() + End Sub + +#Region "Target for AsynchCallback delegate" + ' Don't forget to add a 'imports' directive for + ' System.Runtime.Remoting.Messaging! + Sub AddComplete(ByVal itfAR As IAsyncResult) + Console.WriteLine("AddComplete() invoked on thread {0}.", _ + Thread.CurrentThread.GetHashCode) + Console.WriteLine("Your addition is complete") + + ' Now get the result. + Dim ar As AsyncResult = CType(itfAR, AsyncResult) + Dim b As BinaryOp = CType(ar.AsyncDelegate, BinaryOp) + Console.WriteLine("10 + 10 is {0}.", b.EndInvoke(itfAR)) + + ' Retrieve the informational object and cast it to string + Dim msg As String = CType(itfAR.AsyncState, String) + Console.WriteLine(msg) + End Sub +#End Region + + Function Add(ByVal x As Integer, ByVal y As Integer) As Integer + Console.WriteLine("Add() invoked on thread {0}.", _ + Thread.CurrentThread.ManagedThreadId) + Thread.Sleep(5000) + Return x + y + End Function +End Module diff --git a/Code/Chapter 18/AsyncDelegate/AsyncDelegate.sln b/Code/Chapter 18/AsyncDelegate/AsyncDelegate.sln new file mode 100644 index 0000000..523250f --- /dev/null +++ b/Code/Chapter 18/AsyncDelegate/AsyncDelegate.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AsyncDelegate", "AsyncDelegate.vbproj", "{79BFF25E-C540-4E0D-B915-8F0ABD5CC7B0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {79BFF25E-C540-4E0D-B915-8F0ABD5CC7B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {79BFF25E-C540-4E0D-B915-8F0ABD5CC7B0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {79BFF25E-C540-4E0D-B915-8F0ABD5CC7B0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {79BFF25E-C540-4E0D-B915-8F0ABD5CC7B0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 18/AsyncDelegate/AsyncDelegate.suo b/Code/Chapter 18/AsyncDelegate/AsyncDelegate.suo new file mode 100644 index 0000000..ac95175 Binary files /dev/null and b/Code/Chapter 18/AsyncDelegate/AsyncDelegate.suo differ diff --git a/Code/Chapter 18/AsyncDelegate/AsyncDelegate.vbproj b/Code/Chapter 18/AsyncDelegate/AsyncDelegate.vbproj new file mode 100644 index 0000000..46a3b74 --- /dev/null +++ b/Code/Chapter 18/AsyncDelegate/AsyncDelegate.vbproj @@ -0,0 +1,111 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {79BFF25E-C540-4E0D-B915-8F0ABD5CC7B0} + Exe + AsyncDelegate.Program + AsyncDelegate + AsyncDelegate + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + AsyncDelegate.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + AsyncDelegate.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 18/AsyncDelegate/AsyncDelegate.vbproj.user b/Code/Chapter 18/AsyncDelegate/AsyncDelegate.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 18/AsyncDelegate/AsyncDelegate.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 18/AsyncDelegate/My Project/Application.Designer.vb b/Code/Chapter 18/AsyncDelegate/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 18/AsyncDelegate/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 18/AsyncDelegate/My Project/Application.myapp b/Code/Chapter 18/AsyncDelegate/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 18/AsyncDelegate/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 18/AsyncDelegate/My Project/AssemblyInfo.vb b/Code/Chapter 18/AsyncDelegate/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..4b4fb78 --- /dev/null +++ b/Code/Chapter 18/AsyncDelegate/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/Code/Chapter 18/AsyncDelegate/Program.vb b/Code/Chapter 18/AsyncDelegate/Program.vb new file mode 100644 index 0000000..df65be3 --- /dev/null +++ b/Code/Chapter 18/AsyncDelegate/Program.vb @@ -0,0 +1,45 @@ +Option Explicit On +Option Strict On + +Imports System.Threading + +' Our custom delegate. +Public Delegate Function BinaryOp(ByVal x As Integer, _ +ByVal y As Integer) As Integer + +Module Program + Sub Main() + Console.WriteLine("***** Async Delegate Invocation *****") + Console.WriteLine() + + ' Print out the ID of the executing thread. + Console.WriteLine("Main() invoked on thread {0}.", _ + Thread.CurrentThread.ManagedThreadId) + + ' Invoke Add() on a secondary thread. + Dim b As BinaryOp = New BinaryOp(AddressOf Add) + Dim itfAR As IAsyncResult = b.BeginInvoke(10, 10, Nothing, Nothing) + + While Not itfAR.AsyncWaitHandle.WaitOne(2000, True) + ' Do other work on primary thread... + Console.WriteLine("Doing more work in Main()!") + Thread.Sleep(1000) + End While + + ' Obtain the result of the Add() + ' method when ready. + Dim answer As Integer = b.EndInvoke(itfAR) + Console.WriteLine("10 + 10 is {0} .", answer) + Console.ReadLine() + End Sub + + Function Add(ByVal x As Integer, ByVal y As Integer) As Integer + ' Print out the ID of the executing thread. + Console.WriteLine("Add() invoked on thread {0}.", _ + Thread.CurrentThread.ManagedThreadId) + + ' Pause to simulate a lengthy operation. + Thread.Sleep(5000) + Return x + y + End Function +End Module diff --git a/Code/Chapter 18/BackgroundThread/BackgroundThread.sln b/Code/Chapter 18/BackgroundThread/BackgroundThread.sln new file mode 100644 index 0000000..d615153 --- /dev/null +++ b/Code/Chapter 18/BackgroundThread/BackgroundThread.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "BackgroundThread", "BackgroundThread.vbproj", "{D74DB6EB-B064-4D2D-95C0-5534505AEBFD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D74DB6EB-B064-4D2D-95C0-5534505AEBFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D74DB6EB-B064-4D2D-95C0-5534505AEBFD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D74DB6EB-B064-4D2D-95C0-5534505AEBFD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D74DB6EB-B064-4D2D-95C0-5534505AEBFD}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 18/BackgroundThread/BackgroundThread.suo b/Code/Chapter 18/BackgroundThread/BackgroundThread.suo new file mode 100644 index 0000000..41b036a Binary files /dev/null and b/Code/Chapter 18/BackgroundThread/BackgroundThread.suo differ diff --git a/Code/Chapter 18/BackgroundThread/BackgroundThread.vbproj b/Code/Chapter 18/BackgroundThread/BackgroundThread.vbproj new file mode 100644 index 0000000..926c22d --- /dev/null +++ b/Code/Chapter 18/BackgroundThread/BackgroundThread.vbproj @@ -0,0 +1,114 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {D74DB6EB-B064-4D2D-95C0-5534505AEBFD} + Exe + BackgroundThread.Program + BackgroundThread + BackgroundThread + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + BackgroundThread.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + BackgroundThread.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + True + True + Resources.resx + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 18/BackgroundThread/BackgroundThread.vbproj.user b/Code/Chapter 18/BackgroundThread/BackgroundThread.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 18/BackgroundThread/BackgroundThread.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 18/BackgroundThread/My Project/AssemblyInfo.vb b/Code/Chapter 18/BackgroundThread/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..abdbb15 --- /dev/null +++ b/Code/Chapter 18/BackgroundThread/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/Code/Chapter 18/BackgroundThread/My Project/Resources.Designer.vb b/Code/Chapter 18/BackgroundThread/My Project/Resources.Designer.vb new file mode 100644 index 0000000..9b9fd44 --- /dev/null +++ b/Code/Chapter 18/BackgroundThread/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("BackgroundThread.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/Code/Chapter 18/BackgroundThread/My Project/Resources.resx b/Code/Chapter 18/BackgroundThread/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 18/BackgroundThread/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/Code/Chapter 18/BackgroundThread/Program.vb b/Code/Chapter 18/BackgroundThread/Program.vb new file mode 100644 index 0000000..b2cfcee --- /dev/null +++ b/Code/Chapter 18/BackgroundThread/Program.vb @@ -0,0 +1,38 @@ +Option Explicit On +Option Strict On + +Imports System.Threading + +#Region "Printer class" +Public Class Printer + Public Sub PrintNumbers() + ' Display Thread info. + Console.WriteLine("-> {0} is executing PrintNumbers()", _ + Thread.CurrentThread.Name) + + ' Print out numbers. + Console.Write("Your numbers: ") + For i As Integer = 0 To 10 + Console.Write(i & ", ") + Thread.Sleep(2000) + Next + Console.WriteLine() + End Sub +End Class +#End Region + +Module Program + Sub Main() + Console.WriteLine("***** Background Threads *****") + Console.WriteLine() + + Dim p As Printer = New Printer + Dim bgroundThread As Thread = New Thread(AddressOf p.PrintNumbers) + + ' Comment out the line below to force all threads to complete + ' before this app domain shuts down. + bgroundThread.IsBackground = True + + bgroundThread.Start() + End Sub +End Module diff --git a/Code/Chapter 18/MultiThreadedPrinting/MultiThreadedPrinting.sln b/Code/Chapter 18/MultiThreadedPrinting/MultiThreadedPrinting.sln new file mode 100644 index 0000000..29d91e8 --- /dev/null +++ b/Code/Chapter 18/MultiThreadedPrinting/MultiThreadedPrinting.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MultiThreadedPrinting", "MultiThreadedPrinting.vbproj", "{D251EC20-E917-4C8E-A031-A6C431C5158E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D251EC20-E917-4C8E-A031-A6C431C5158E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D251EC20-E917-4C8E-A031-A6C431C5158E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D251EC20-E917-4C8E-A031-A6C431C5158E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D251EC20-E917-4C8E-A031-A6C431C5158E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 18/MultiThreadedPrinting/MultiThreadedPrinting.suo b/Code/Chapter 18/MultiThreadedPrinting/MultiThreadedPrinting.suo new file mode 100644 index 0000000..843f8d9 Binary files /dev/null and b/Code/Chapter 18/MultiThreadedPrinting/MultiThreadedPrinting.suo differ diff --git a/Code/Chapter 18/MultiThreadedPrinting/MultiThreadedPrinting.vbproj b/Code/Chapter 18/MultiThreadedPrinting/MultiThreadedPrinting.vbproj new file mode 100644 index 0000000..5d7015b --- /dev/null +++ b/Code/Chapter 18/MultiThreadedPrinting/MultiThreadedPrinting.vbproj @@ -0,0 +1,114 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {D251EC20-E917-4C8E-A031-A6C431C5158E} + Exe + MultiThreadedPrinting.Program + MultiThreadedPrinting + MultiThreadedPrinting + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + MultiThreadedPrinting.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + MultiThreadedPrinting.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + True + True + Resources.resx + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 18/MultiThreadedPrinting/MultiThreadedPrinting.vbproj.user b/Code/Chapter 18/MultiThreadedPrinting/MultiThreadedPrinting.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 18/MultiThreadedPrinting/MultiThreadedPrinting.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 18/MultiThreadedPrinting/My Project/AssemblyInfo.vb b/Code/Chapter 18/MultiThreadedPrinting/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..7dc091e --- /dev/null +++ b/Code/Chapter 18/MultiThreadedPrinting/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/Code/Chapter 18/MultiThreadedPrinting/My Project/Resources.Designer.vb b/Code/Chapter 18/MultiThreadedPrinting/My Project/Resources.Designer.vb new file mode 100644 index 0000000..1f6f203 --- /dev/null +++ b/Code/Chapter 18/MultiThreadedPrinting/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("MultiThreadedPrinting.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/Code/Chapter 18/MultiThreadedPrinting/My Project/Resources.resx b/Code/Chapter 18/MultiThreadedPrinting/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 18/MultiThreadedPrinting/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/Code/Chapter 18/MultiThreadedPrinting/Program.vb b/Code/Chapter 18/MultiThreadedPrinting/Program.vb new file mode 100644 index 0000000..532bd80 --- /dev/null +++ b/Code/Chapter 18/MultiThreadedPrinting/Program.vb @@ -0,0 +1,48 @@ +Option Explicit On +Option Strict On + +Imports System.Threading + +#Region "Printer class" +Public Class Printer + ' Lock token. + Private threadLock As Object = New Object() + + Public Sub PrintNumbers() + SyncLock threadLock + Console.WriteLine("-> {0} is executing PrintNumbers()", _ + Thread.CurrentThread.Name) + Console.Write("Your numbers: ") + For i As Integer = 0 To 10 + Dim r As Random = New Random() + Thread.Sleep(100 * r.Next(5)) + Console.Write(i & ", ") + Next + Console.WriteLine() + End SyncLock + End Sub +End Class +#End Region + +Module Program + Sub Main() + Console.WriteLine("***** Synchronizing Threads *****") + Console.WriteLine() + + Dim p As Printer = New Printer() + + ' Make 11 threads that are all pointing to the same + ' method on the same object. + Dim threads(10) As Thread + For i As Integer = 0 To 10 + threads(i) = New Thread(AddressOf p.PrintNumbers) + threads(i).Name = String.Format("Worker thread #{0}", i) + Next + + ' Now start each one. + For Each t As Thread In threads + t.Start() + Next + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 18/SimpleMultiThreadApp/My Project/AssemblyInfo.vb b/Code/Chapter 18/SimpleMultiThreadApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..5dabf56 --- /dev/null +++ b/Code/Chapter 18/SimpleMultiThreadApp/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/Code/Chapter 18/SimpleMultiThreadApp/My Project/Resources.Designer.vb b/Code/Chapter 18/SimpleMultiThreadApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..ff5ab0c --- /dev/null +++ b/Code/Chapter 18/SimpleMultiThreadApp/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("SimpleMultiThreadApp.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/Code/Chapter 18/SimpleMultiThreadApp/My Project/Resources.resx b/Code/Chapter 18/SimpleMultiThreadApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 18/SimpleMultiThreadApp/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/Code/Chapter 18/SimpleMultiThreadApp/Program.vb b/Code/Chapter 18/SimpleMultiThreadApp/Program.vb new file mode 100644 index 0000000..a6da584 --- /dev/null +++ b/Code/Chapter 18/SimpleMultiThreadApp/Program.vb @@ -0,0 +1,58 @@ +Option Explicit On +Option Strict On + +Imports System.Threading +Imports System.Windows.Forms + +#Region "Printer class" +Public Class Printer + Public Sub PrintNumbers() + ' Display Thread info. + Console.WriteLine("-> {0} is executing PrintNumbers()", _ + Thread.CurrentThread.Name) + + ' Print out numbers. + Console.Write("Your numbers: ") + For i As Integer = 0 To 10 + Console.Write(i & ", ") + Thread.Sleep(2000) + Next + Console.WriteLine() + End Sub +End Class +#End Region + +Module Program + Sub Main() + Console.WriteLine("***** The Amazing Thread App *****") + Console.Write("Do you want [1] or [2] threads? ") + Dim threadCount As String = Console.ReadLine() + + ' Name the current thread. + Dim primaryThread As Thread = Thread.CurrentThread + primaryThread.Name = "Primary" + + ' Display Thread info. + Console.WriteLine("-> {0} is executing Main()", Thread.CurrentThread.Name) + + ' Make worker class. + Dim p As Printer = New Printer() + + ' How many threads does the user want? + Select Case threadCount + Case "2" + ' They want an extra thread. + Dim backgroundThread As Thread = New Thread(AddressOf p.PrintNumbers) + backgroundThread.Name = "Secondary" + backgroundThread.Start() + Case "1" + p.PrintNumbers() + Case Else + Console.WriteLine("I don't know what you want...you get 1 thread.") + p.PrintNumbers() + End Select + + MessageBox.Show("I'm busy!", "Work on main thread...") + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 18/SimpleMultiThreadApp/SimpleMultiThreadApp.sln b/Code/Chapter 18/SimpleMultiThreadApp/SimpleMultiThreadApp.sln new file mode 100644 index 0000000..5259865 --- /dev/null +++ b/Code/Chapter 18/SimpleMultiThreadApp/SimpleMultiThreadApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SimpleMultiThreadApp", "SimpleMultiThreadApp.vbproj", "{24F61515-ACF5-4073-A1B6-F3DD99816B37}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {24F61515-ACF5-4073-A1B6-F3DD99816B37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {24F61515-ACF5-4073-A1B6-F3DD99816B37}.Debug|Any CPU.Build.0 = Debug|Any CPU + {24F61515-ACF5-4073-A1B6-F3DD99816B37}.Release|Any CPU.ActiveCfg = Release|Any CPU + {24F61515-ACF5-4073-A1B6-F3DD99816B37}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 18/SimpleMultiThreadApp/SimpleMultiThreadApp.suo b/Code/Chapter 18/SimpleMultiThreadApp/SimpleMultiThreadApp.suo new file mode 100644 index 0000000..1a2e7cd Binary files /dev/null and b/Code/Chapter 18/SimpleMultiThreadApp/SimpleMultiThreadApp.suo differ diff --git a/Code/Chapter 18/SimpleMultiThreadApp/SimpleMultiThreadApp.vbproj b/Code/Chapter 18/SimpleMultiThreadApp/SimpleMultiThreadApp.vbproj new file mode 100644 index 0000000..5213c0c --- /dev/null +++ b/Code/Chapter 18/SimpleMultiThreadApp/SimpleMultiThreadApp.vbproj @@ -0,0 +1,115 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {24F61515-ACF5-4073-A1B6-F3DD99816B37} + Exe + SimpleMultiThreadApp.Program + SimpleMultiThreadApp + SimpleMultiThreadApp + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + SimpleMultiThreadApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SimpleMultiThreadApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + True + True + Resources.resx + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 18/SimpleMultiThreadApp/SimpleMultiThreadApp.vbproj.user b/Code/Chapter 18/SimpleMultiThreadApp/SimpleMultiThreadApp.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 18/SimpleMultiThreadApp/SimpleMultiThreadApp.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 18/SyncDelegate/My Project/AssemblyInfo.vb b/Code/Chapter 18/SyncDelegate/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..14e61dd --- /dev/null +++ b/Code/Chapter 18/SyncDelegate/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/Code/Chapter 18/SyncDelegate/Program.vb b/Code/Chapter 18/SyncDelegate/Program.vb new file mode 100644 index 0000000..fb61aef --- /dev/null +++ b/Code/Chapter 18/SyncDelegate/Program.vb @@ -0,0 +1,38 @@ +Option Explicit On +Option Strict On + +Imports System.Threading + +' Our custom delegate. +Public Delegate Function BinaryOp(ByVal x As Integer, ByVal y As Integer) As Integer + +Module Program + Sub Main() + Console.WriteLine("***** Synch Delegate Review *****") + Console.WriteLine() + + 'Print out the ID of the executing thread. + Console.WriteLine("Main() invoked on thread {0}.", _ + Thread.CurrentThread.ManagedThreadId) + + ' Invoke Add() in a synchronous manner. + Dim b As BinaryOp = AddressOf Add + Dim answer As Integer = b(10, 10) + + ' These lines will not execute until + ' the Add() method has completed. + Console.WriteLine("Doing more work in Main()!") + Console.WriteLine("10 + 10 is {0}.", answer) + Console.ReadLine() + End Sub + + Function Add(ByVal x As Integer, ByVal y As Integer) As Integer + ' Print out the ID of the executing thread. + Console.WriteLine("Add() invoked on thread {0}.", _ + Thread.CurrentThread.ManagedThreadId) + + ' Pause to simulate a lengthy operation. + Thread.Sleep(5000) + Return x + y + End Function +End Module diff --git a/Code/Chapter 18/SyncDelegate/SyncDelegate.sln b/Code/Chapter 18/SyncDelegate/SyncDelegate.sln new file mode 100644 index 0000000..78f7411 --- /dev/null +++ b/Code/Chapter 18/SyncDelegate/SyncDelegate.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SyncDelegate", "SyncDelegate.vbproj", "{08CBDF1A-090C-4206-B42D-56FDAFFC7FA1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {08CBDF1A-090C-4206-B42D-56FDAFFC7FA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {08CBDF1A-090C-4206-B42D-56FDAFFC7FA1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {08CBDF1A-090C-4206-B42D-56FDAFFC7FA1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {08CBDF1A-090C-4206-B42D-56FDAFFC7FA1}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 18/SyncDelegate/SyncDelegate.suo b/Code/Chapter 18/SyncDelegate/SyncDelegate.suo new file mode 100644 index 0000000..828219a Binary files /dev/null and b/Code/Chapter 18/SyncDelegate/SyncDelegate.suo differ diff --git a/Code/Chapter 18/SyncDelegate/SyncDelegate.vbproj b/Code/Chapter 18/SyncDelegate/SyncDelegate.vbproj new file mode 100644 index 0000000..ea0d8ea --- /dev/null +++ b/Code/Chapter 18/SyncDelegate/SyncDelegate.vbproj @@ -0,0 +1,101 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {08CBDF1A-090C-4206-B42D-56FDAFFC7FA1} + Exe + SyncDelegate.Program + SyncDelegate + SyncDelegate + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + SyncDelegate.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SyncDelegate.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 18/SyncDelegate/SyncDelegate.vbproj.user b/Code/Chapter 18/SyncDelegate/SyncDelegate.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 18/SyncDelegate/SyncDelegate.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 18/ThreadPoolApp/My Project/AssemblyInfo.vb b/Code/Chapter 18/ThreadPoolApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..8aa06ea --- /dev/null +++ b/Code/Chapter 18/ThreadPoolApp/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/Code/Chapter 18/ThreadPoolApp/My Project/Resources.Designer.vb b/Code/Chapter 18/ThreadPoolApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..efb6a8d --- /dev/null +++ b/Code/Chapter 18/ThreadPoolApp/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("ThreadPoolApp.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/Code/Chapter 18/ThreadPoolApp/My Project/Resources.resx b/Code/Chapter 18/ThreadPoolApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 18/ThreadPoolApp/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/Code/Chapter 18/ThreadPoolApp/Program.vb b/Code/Chapter 18/ThreadPoolApp/Program.vb new file mode 100644 index 0000000..31eb998 --- /dev/null +++ b/Code/Chapter 18/ThreadPoolApp/Program.vb @@ -0,0 +1,43 @@ +Option Explicit On +Option Strict On + +Imports System.Threading + +#Region "Printer class" +Public Class Printer + Public Sub PrintNumbers() + SyncLock Me + Console.WriteLine("-> {0} is executing PrintNumbers()", _ + Thread.CurrentThread.Name) + Console.Write("Your numbers: ") + For i As Integer = 0 To 10 + Dim r As Random = New Random() + Thread.Sleep(100 * r.Next(5)) + Console.Write(i & ", ") + Next + Console.WriteLine() + End SyncLock + End Sub +End Class +#End Region + +Module Program + Sub Main() + Console.WriteLine("Main thread started. ThreadID = {0}", _ + Thread.CurrentThread.GetHashCode) + Dim p As Printer = New Printer + Dim workItem As WaitCallback = AddressOf PrintTheNumbers + + ' Queue the method 10 times + For i As Integer = 0 To 9 + ThreadPool.QueueUserWorkItem(workItem, p) + Next + Console.WriteLine("All tasks queued") + Console.ReadLine() + End Sub + + Sub PrintTheNumbers(ByVal state As Object) + Dim task As Printer = CType(state, Printer) + task.PrintNumbers() + End Sub +End Module diff --git a/Code/Chapter 18/ThreadPoolApp/ThreadPoolApp.sln b/Code/Chapter 18/ThreadPoolApp/ThreadPoolApp.sln new file mode 100644 index 0000000..fccfbb1 --- /dev/null +++ b/Code/Chapter 18/ThreadPoolApp/ThreadPoolApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ThreadPoolApp", "ThreadPoolApp.vbproj", "{4E137050-C7DD-485C-90DE-87945D37728A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4E137050-C7DD-485C-90DE-87945D37728A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4E137050-C7DD-485C-90DE-87945D37728A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4E137050-C7DD-485C-90DE-87945D37728A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4E137050-C7DD-485C-90DE-87945D37728A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 18/ThreadPoolApp/ThreadPoolApp.suo b/Code/Chapter 18/ThreadPoolApp/ThreadPoolApp.suo new file mode 100644 index 0000000..9ec17d9 Binary files /dev/null and b/Code/Chapter 18/ThreadPoolApp/ThreadPoolApp.suo differ diff --git a/Code/Chapter 18/ThreadPoolApp/ThreadPoolApp.vbproj b/Code/Chapter 18/ThreadPoolApp/ThreadPoolApp.vbproj new file mode 100644 index 0000000..6385c35 --- /dev/null +++ b/Code/Chapter 18/ThreadPoolApp/ThreadPoolApp.vbproj @@ -0,0 +1,114 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {4E137050-C7DD-485C-90DE-87945D37728A} + Exe + ThreadPoolApp.Program + ThreadPoolApp + ThreadPoolApp + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + ThreadPoolApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + ThreadPoolApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + True + True + Resources.resx + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 18/ThreadPoolApp/ThreadPoolApp.vbproj.user b/Code/Chapter 18/ThreadPoolApp/ThreadPoolApp.vbproj.user new file mode 100644 index 0000000..1659b79 --- /dev/null +++ b/Code/Chapter 18/ThreadPoolApp/ThreadPoolApp.vbproj.user @@ -0,0 +1,17 @@ + + + ShowAllFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 18/ThreadStats/My Project/AssemblyInfo.vb b/Code/Chapter 18/ThreadStats/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..ce52da0 --- /dev/null +++ b/Code/Chapter 18/ThreadStats/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/Code/Chapter 18/ThreadStats/My Project/Resources.Designer.vb b/Code/Chapter 18/ThreadStats/My Project/Resources.Designer.vb new file mode 100644 index 0000000..a1bbe06 --- /dev/null +++ b/Code/Chapter 18/ThreadStats/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("ThreadStats.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/Code/Chapter 18/ThreadStats/My Project/Resources.resx b/Code/Chapter 18/ThreadStats/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 18/ThreadStats/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/Code/Chapter 18/ThreadStats/Program.vb b/Code/Chapter 18/ThreadStats/Program.vb new file mode 100644 index 0000000..cd107e2 --- /dev/null +++ b/Code/Chapter 18/ThreadStats/Program.vb @@ -0,0 +1,32 @@ +Option Explicit On +Option Strict On + +Imports System.Threading + +Module Program + Sub Main() + Console.WriteLine("***** Primary Thread stats *****") + Console.WriteLine() + + ' Obtain and name the current thread. + Dim primaryThread As Thread = Thread.CurrentThread + primaryThread.Name = "ThePrimaryThread" + + ' Show details of hosting AppDomain/Context. + Console.WriteLine("Name of current AppDomain: {0}", _ + Thread.GetDomain().FriendlyName) + Console.WriteLine("ID of current Context: {0}", _ + Thread.CurrentContext.ContextID) + + ' Print out some stats about this thread. + Console.WriteLine("Thread Name: {0}", _ + primaryThread.Name) + Console.WriteLine("Has thread started?: {0}", _ + primaryThread.IsAlive) + Console.WriteLine("Priority Level: {0}", _ + primaryThread.Priority) + Console.WriteLine("Thread State: {0}", _ + primaryThread.ThreadState) + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 18/ThreadStats/ThreadStats.sln b/Code/Chapter 18/ThreadStats/ThreadStats.sln new file mode 100644 index 0000000..75b79cb --- /dev/null +++ b/Code/Chapter 18/ThreadStats/ThreadStats.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ThreadStats", "ThreadStats.vbproj", "{93400CCC-AE69-44FD-8FA1-528B31158E54}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {93400CCC-AE69-44FD-8FA1-528B31158E54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {93400CCC-AE69-44FD-8FA1-528B31158E54}.Debug|Any CPU.Build.0 = Debug|Any CPU + {93400CCC-AE69-44FD-8FA1-528B31158E54}.Release|Any CPU.ActiveCfg = Release|Any CPU + {93400CCC-AE69-44FD-8FA1-528B31158E54}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 18/ThreadStats/ThreadStats.suo b/Code/Chapter 18/ThreadStats/ThreadStats.suo new file mode 100644 index 0000000..17f13b8 Binary files /dev/null and b/Code/Chapter 18/ThreadStats/ThreadStats.suo differ diff --git a/Code/Chapter 18/ThreadStats/ThreadStats.vbproj b/Code/Chapter 18/ThreadStats/ThreadStats.vbproj new file mode 100644 index 0000000..93abf7d --- /dev/null +++ b/Code/Chapter 18/ThreadStats/ThreadStats.vbproj @@ -0,0 +1,114 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {93400CCC-AE69-44FD-8FA1-528B31158E54} + Exe + ThreadStats.Program + ThreadStats + ThreadStats + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + ThreadStats.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + ThreadStats.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + True + True + Resources.resx + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 18/ThreadStats/ThreadStats.vbproj.user b/Code/Chapter 18/ThreadStats/ThreadStats.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 18/ThreadStats/ThreadStats.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 18/TimerApp/My Project/AssemblyInfo.vb b/Code/Chapter 18/TimerApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..66d9803 --- /dev/null +++ b/Code/Chapter 18/TimerApp/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/Code/Chapter 18/TimerApp/My Project/Resources.Designer.vb b/Code/Chapter 18/TimerApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..af9bb5c --- /dev/null +++ b/Code/Chapter 18/TimerApp/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("TimerApp.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/Code/Chapter 18/TimerApp/My Project/Resources.resx b/Code/Chapter 18/TimerApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 18/TimerApp/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/Code/Chapter 18/TimerApp/Program.vb b/Code/Chapter 18/TimerApp/Program.vb new file mode 100644 index 0000000..fdbb2db --- /dev/null +++ b/Code/Chapter 18/TimerApp/Program.vb @@ -0,0 +1,24 @@ +Option Explicit On +Option Strict On + +Imports System.Threading + +Module Program + Sub Main() + Console.WriteLine("***** Working with Timer type *****") + Console.WriteLine() + + ' Pass in the delegate instance, data to send the + ' method 'pointed to', time to wait before starting + ' and interval of time between calles. + Dim t As Timer = New Timer(AddressOf PrintTime, "Hi", 0, 1000) + + Console.WriteLine("Hit key to terminate...") + Console.ReadLine() + End Sub + + Sub PrintTime(ByVal state As Object) + Console.WriteLine("Time is: {0}, Param is: {1}", _ + DateTime.Now.ToLongTimeString, state.ToString()) + End Sub +End Module diff --git a/Code/Chapter 18/TimerApp/TimerApp.sln b/Code/Chapter 18/TimerApp/TimerApp.sln new file mode 100644 index 0000000..89ba6c6 --- /dev/null +++ b/Code/Chapter 18/TimerApp/TimerApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TimerApp", "TimerApp.vbproj", "{E9FA414C-3C25-44A0-80FA-36F39ADA1293}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E9FA414C-3C25-44A0-80FA-36F39ADA1293}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E9FA414C-3C25-44A0-80FA-36F39ADA1293}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E9FA414C-3C25-44A0-80FA-36F39ADA1293}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E9FA414C-3C25-44A0-80FA-36F39ADA1293}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 18/TimerApp/TimerApp.suo b/Code/Chapter 18/TimerApp/TimerApp.suo new file mode 100644 index 0000000..a78112e Binary files /dev/null and b/Code/Chapter 18/TimerApp/TimerApp.suo differ diff --git a/Code/Chapter 18/TimerApp/TimerApp.vbproj b/Code/Chapter 18/TimerApp/TimerApp.vbproj new file mode 100644 index 0000000..d8ab138 --- /dev/null +++ b/Code/Chapter 18/TimerApp/TimerApp.vbproj @@ -0,0 +1,114 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {E9FA414C-3C25-44A0-80FA-36F39ADA1293} + Exe + TimerApp.Program + TimerApp + TimerApp + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + TimerApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + TimerApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + True + True + Resources.resx + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 18/TimerApp/TimerApp.vbproj.user b/Code/Chapter 18/TimerApp/TimerApp.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 18/TimerApp/TimerApp.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 18/WinFormsBackgroundWorkerThread/MainForm.Designer.vb b/Code/Chapter 18/WinFormsBackgroundWorkerThread/MainForm.Designer.vb new file mode 100644 index 0000000..f6fecf1 --- /dev/null +++ b/Code/Chapter 18/WinFormsBackgroundWorkerThread/MainForm.Designer.vb @@ -0,0 +1,101 @@ + _ +Partial Class MainForm + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + 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.Label2 = New System.Windows.Forms.Label + Me.btnAdd = New System.Windows.Forms.Button + Me.txtNumbOne = New System.Windows.Forms.TextBox + Me.txtNumbTwo = New System.Windows.Forms.TextBox + Me.ProcessNumbersBackgroundWorker = New System.ComponentModel.BackgroundWorker + Me.SuspendLayout() + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(13, 13) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(66, 13) + Me.Label1.TabIndex = 0 + Me.Label1.Text = "First Number" + ' + 'Label2 + ' + Me.Label2.AutoSize = True + Me.Label2.Location = New System.Drawing.Point(13, 63) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(84, 13) + Me.Label2.TabIndex = 1 + Me.Label2.Text = "Second Number" + ' + 'btnAdd + ' + Me.btnAdd.Location = New System.Drawing.Point(197, 103) + Me.btnAdd.Name = "btnAdd" + Me.btnAdd.Size = New System.Drawing.Size(75, 23) + Me.btnAdd.TabIndex = 2 + Me.btnAdd.Text = "Add" + Me.btnAdd.UseVisualStyleBackColor = True + ' + 'txtNumbOne + ' + Me.txtNumbOne.Location = New System.Drawing.Point(132, 13) + Me.txtNumbOne.Name = "txtNumbOne" + Me.txtNumbOne.Size = New System.Drawing.Size(140, 20) + Me.txtNumbOne.TabIndex = 3 + ' + 'txtNumbTwo + ' + Me.txtNumbTwo.Location = New System.Drawing.Point(132, 56) + Me.txtNumbTwo.Name = "txtNumbTwo" + Me.txtNumbTwo.Size = New System.Drawing.Size(140, 20) + Me.txtNumbTwo.TabIndex = 4 + ' + 'ProcessNumbersBackgroundWorker + ' + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(284, 138) + Me.Controls.Add(Me.txtNumbTwo) + Me.Controls.Add(Me.txtNumbOne) + Me.Controls.Add(Me.btnAdd) + Me.Controls.Add(Me.Label2) + Me.Controls.Add(Me.Label1) + Me.Name = "MainForm" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Add with Threads (GUI!)" + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents Label2 As System.Windows.Forms.Label + Friend WithEvents btnAdd As System.Windows.Forms.Button + Friend WithEvents txtNumbOne As System.Windows.Forms.TextBox + Friend WithEvents txtNumbTwo As System.Windows.Forms.TextBox + Friend WithEvents ProcessNumbersBackgroundWorker As System.ComponentModel.BackgroundWorker + +End Class diff --git a/Code/Chapter 18/WinFormsBackgroundWorkerThread/MainForm.resx b/Code/Chapter 18/WinFormsBackgroundWorkerThread/MainForm.resx new file mode 100644 index 0000000..6d86ef1 --- /dev/null +++ b/Code/Chapter 18/WinFormsBackgroundWorkerThread/MainForm.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/Code/Chapter 18/WinFormsBackgroundWorkerThread/MainForm.vb b/Code/Chapter 18/WinFormsBackgroundWorkerThread/MainForm.vb new file mode 100644 index 0000000..244beab --- /dev/null +++ b/Code/Chapter 18/WinFormsBackgroundWorkerThread/MainForm.vb @@ -0,0 +1,42 @@ +Public Class MainForm + + Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click + Try + ' First get the user data (as numerical). + Dim numbOne As Integer = Integer.Parse(txtNumbOne.Text) + Dim numbTwo As Integer = Integer.Parse(txtNumbTwo.Text) + Dim args As New AddParams(numbOne, numbTwo) + + ' Now spin up the new thread and pass args variable. + ProcessNumbersBackgroundWorker.RunWorkerAsync(args) + Catch ex As Exception + MessageBox.Show(ex.Message) + End Try + End Sub + + Private Sub ProcessNumbersBackgroundWorker_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles ProcessNumbersBackgroundWorker.DoWork + ' Get the incoming AddParam object. + Dim args As AddParams = DirectCast(e.Argument, AddParams) + + ' Artifical lag. + System.Threading.Thread.Sleep(5000) + + ' Return the value. + e.Result = args.a + args.b + End Sub + + Private Sub ProcessNumbersBackgroundWorker_RunWorkerCompleted(ByVal sender As System.Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles ProcessNumbersBackgroundWorker.RunWorkerCompleted + MessageBox.Show(e.Result.ToString(), "Your result is") + End Sub +End Class + +#Region "Add params helper class" +Class AddParams + Public a, b As Integer + + Public Sub New(ByVal numb1 As Integer, ByVal numb2 As Integer) + a = numb1 + b = numb2 + End Sub +End Class +#End Region diff --git a/Code/Chapter 18/WinFormsBackgroundWorkerThread/My Project/Application.Designer.vb b/Code/Chapter 18/WinFormsBackgroundWorkerThread/My Project/Application.Designer.vb new file mode 100644 index 0000000..741e5ee --- /dev/null +++ b/Code/Chapter 18/WinFormsBackgroundWorkerThread/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.WinFormsBackgroundWorkerThread.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 18/WinFormsBackgroundWorkerThread/My Project/Application.myapp b/Code/Chapter 18/WinFormsBackgroundWorkerThread/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 18/WinFormsBackgroundWorkerThread/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 18/WinFormsBackgroundWorkerThread/My Project/AssemblyInfo.vb b/Code/Chapter 18/WinFormsBackgroundWorkerThread/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..de6d152 --- /dev/null +++ b/Code/Chapter 18/WinFormsBackgroundWorkerThread/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/Code/Chapter 18/WinFormsBackgroundWorkerThread/My Project/Resources.Designer.vb b/Code/Chapter 18/WinFormsBackgroundWorkerThread/My Project/Resources.Designer.vb new file mode 100644 index 0000000..cbd50d0 --- /dev/null +++ b/Code/Chapter 18/WinFormsBackgroundWorkerThread/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("WinFormsBackgroundWorkerThread.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/Code/Chapter 18/WinFormsBackgroundWorkerThread/My Project/Resources.resx b/Code/Chapter 18/WinFormsBackgroundWorkerThread/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 18/WinFormsBackgroundWorkerThread/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/Code/Chapter 18/WinFormsBackgroundWorkerThread/My Project/Settings.Designer.vb b/Code/Chapter 18/WinFormsBackgroundWorkerThread/My Project/Settings.Designer.vb new file mode 100644 index 0000000..18083b9 --- /dev/null +++ b/Code/Chapter 18/WinFormsBackgroundWorkerThread/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.WinFormsBackgroundWorkerThread.My.MySettings + Get + Return Global.WinFormsBackgroundWorkerThread.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 18/WinFormsBackgroundWorkerThread/My Project/Settings.settings b/Code/Chapter 18/WinFormsBackgroundWorkerThread/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 18/WinFormsBackgroundWorkerThread/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 18/WinFormsBackgroundWorkerThread/WinFormsBackgroundWorkerThread.sln b/Code/Chapter 18/WinFormsBackgroundWorkerThread/WinFormsBackgroundWorkerThread.sln new file mode 100644 index 0000000..764381c --- /dev/null +++ b/Code/Chapter 18/WinFormsBackgroundWorkerThread/WinFormsBackgroundWorkerThread.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "WinFormsBackgroundWorkerThread", "WinFormsBackgroundWorkerThread.vbproj", "{D8EB2E8F-ED53-4A48-9D9B-B2B6EFB6709E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D8EB2E8F-ED53-4A48-9D9B-B2B6EFB6709E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D8EB2E8F-ED53-4A48-9D9B-B2B6EFB6709E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D8EB2E8F-ED53-4A48-9D9B-B2B6EFB6709E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D8EB2E8F-ED53-4A48-9D9B-B2B6EFB6709E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 18/WinFormsBackgroundWorkerThread/WinFormsBackgroundWorkerThread.suo b/Code/Chapter 18/WinFormsBackgroundWorkerThread/WinFormsBackgroundWorkerThread.suo new file mode 100644 index 0000000..0205681 Binary files /dev/null and b/Code/Chapter 18/WinFormsBackgroundWorkerThread/WinFormsBackgroundWorkerThread.suo differ diff --git a/Code/Chapter 18/WinFormsBackgroundWorkerThread/WinFormsBackgroundWorkerThread.vbproj b/Code/Chapter 18/WinFormsBackgroundWorkerThread/WinFormsBackgroundWorkerThread.vbproj new file mode 100644 index 0000000..63d1bd1 --- /dev/null +++ b/Code/Chapter 18/WinFormsBackgroundWorkerThread/WinFormsBackgroundWorkerThread.vbproj @@ -0,0 +1,123 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {D8EB2E8F-ED53-4A48-9D9B-B2B6EFB6709E} + WinExe + WinFormsBackgroundWorkerThread.My.MyApplication + WinFormsBackgroundWorkerThread + WinFormsBackgroundWorkerThread + 512 + WindowsForms + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + WinFormsBackgroundWorkerThread.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + WinFormsBackgroundWorkerThread.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + MainForm.vb + Designer + + + 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/Code/Chapter 19/ComUsableDotNetServer/ComUsableDotNetServer.sln b/Code/Chapter 19/ComUsableDotNetServer/ComUsableDotNetServer.sln new file mode 100644 index 0000000..297b3ff --- /dev/null +++ b/Code/Chapter 19/ComUsableDotNetServer/ComUsableDotNetServer.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ComUsableDotNetServer", "ComUsableDotNetServer.vbproj", "{E244787D-6D1B-4133-9A2B-AF4879363EC3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E244787D-6D1B-4133-9A2B-AF4879363EC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E244787D-6D1B-4133-9A2B-AF4879363EC3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E244787D-6D1B-4133-9A2B-AF4879363EC3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E244787D-6D1B-4133-9A2B-AF4879363EC3}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 19/ComUsableDotNetServer/ComUsableDotNetServer.suo b/Code/Chapter 19/ComUsableDotNetServer/ComUsableDotNetServer.suo new file mode 100644 index 0000000..3d2ed29 Binary files /dev/null and b/Code/Chapter 19/ComUsableDotNetServer/ComUsableDotNetServer.suo differ diff --git a/Code/Chapter 19/ComUsableDotNetServer/ComUsableDotNetServer.vbproj b/Code/Chapter 19/ComUsableDotNetServer/ComUsableDotNetServer.vbproj new file mode 100644 index 0000000..500d24b --- /dev/null +++ b/Code/Chapter 19/ComUsableDotNetServer/ComUsableDotNetServer.vbproj @@ -0,0 +1,101 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {E244787D-6D1B-4133-9A2B-AF4879363EC3} + Library + ComUsableDotNetServer + ComUsableDotNetServer + Windows + true + TestKey.snk + + + 2.0 + + + + + true + full + true + true + bin\Debug\ + ComUsableDotNetServer.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + true + + + pdbonly + false + true + true + bin\Release\ + ComUsableDotNetServer.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + true + + + + + + + + + + + + + + + + + + + + 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/Code/Chapter 19/ComUsableDotNetServer/ComUsableDotNetServer.vbproj.user b/Code/Chapter 19/ComUsableDotNetServer/ComUsableDotNetServer.vbproj.user new file mode 100644 index 0000000..6a34e7d --- /dev/null +++ b/Code/Chapter 19/ComUsableDotNetServer/ComUsableDotNetServer.vbproj.user @@ -0,0 +1,5 @@ + + + ShowAllFiles + + \ No newline at end of file diff --git a/Code/Chapter 19/ComUsableDotNetServer/DotNetCalc.vb b/Code/Chapter 19/ComUsableDotNetServer/DotNetCalc.vb new file mode 100644 index 0000000..f98acf1 --- /dev/null +++ b/Code/Chapter 19/ComUsableDotNetServer/DotNetCalc.vb @@ -0,0 +1,14 @@ +' We need this to obtain the necessary +' interop attributes. +Imports System.Runtime.InteropServices + + _ + _ +Public Class DotNetCalc + Public Function Add(ByVal x As Integer, ByVal y As Integer) As Integer + Return x + y + End Function + Public Function Subtract(ByVal x As Integer, ByVal y As Integer) As Integer + Return x - y + End Function +End Class diff --git a/Code/Chapter 19/ComUsableDotNetServer/DotNetPerson.vb b/Code/Chapter 19/ComUsableDotNetServer/DotNetPerson.vb new file mode 100644 index 0000000..7cee111 --- /dev/null +++ b/Code/Chapter 19/ComUsableDotNetServer/DotNetPerson.vb @@ -0,0 +1,27 @@ + _ +Public Class DotNetPerson + +#Region "COM GUIDs" + ' These GUIDs provide the COM identity for this class + ' and its COM interfaces. If you change them, existing + ' clients will no longer be able to access the class. + Public Const ClassId As String = "6ff9b796-d080-4515-9fed-ddd7ffe225b2" + Public Const InterfaceId As String = "14147f5a-a7b9-48c5-a545-3c2d66f089ad" + Public Const EventsId As String = "19d005f1-4164-4116-8066-585f6ad6b2eb" +#End Region + + ' A creatable COM class must have a Public Sub New() + ' with no parameters, otherwise, the class will not be + ' registered in the COM registry and cannot be created + ' via CreateObject. + Public Sub New() + MyBase.New() + End Sub + + Public Function GetMessage() As String + Return "I am alive..." + End Function + +End Class + + diff --git a/Code/Chapter 19/ComUsableDotNetServer/My Project/Application.Designer.vb b/Code/Chapter 19/ComUsableDotNetServer/My Project/Application.Designer.vb new file mode 100644 index 0000000..0e8f9f4 --- /dev/null +++ b/Code/Chapter 19/ComUsableDotNetServer/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1378 +' +' 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/Code/Chapter 19/ComUsableDotNetServer/My Project/Application.myapp b/Code/Chapter 19/ComUsableDotNetServer/My Project/Application.myapp new file mode 100644 index 0000000..758895d --- /dev/null +++ b/Code/Chapter 19/ComUsableDotNetServer/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/Code/Chapter 19/ComUsableDotNetServer/My Project/AssemblyInfo.vb b/Code/Chapter 19/ComUsableDotNetServer/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..00b02e8 --- /dev/null +++ b/Code/Chapter 19/ComUsableDotNetServer/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/Code/Chapter 19/ComUsableDotNetServer/My Project/Resources.Designer.vb b/Code/Chapter 19/ComUsableDotNetServer/My Project/Resources.Designer.vb new file mode 100644 index 0000000..5bb830d --- /dev/null +++ b/Code/Chapter 19/ComUsableDotNetServer/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1378 +' +' 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("ComUsableDotNetServer.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/Code/Chapter 19/ComUsableDotNetServer/My Project/Resources.resx b/Code/Chapter 19/ComUsableDotNetServer/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 19/ComUsableDotNetServer/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/Code/Chapter 19/ComUsableDotNetServer/My Project/Settings.Designer.vb b/Code/Chapter 19/ComUsableDotNetServer/My Project/Settings.Designer.vb new file mode 100644 index 0000000..6fde97b --- /dev/null +++ b/Code/Chapter 19/ComUsableDotNetServer/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1378 +' +' 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.ComUsableDotNetServer.My.MySettings + Get + Return Global.ComUsableDotNetServer.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 19/ComUsableDotNetServer/My Project/Settings.settings b/Code/Chapter 19/ComUsableDotNetServer/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 19/ComUsableDotNetServer/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 19/ComUsableDotNetServer/TestKey.snk b/Code/Chapter 19/ComUsableDotNetServer/TestKey.snk new file mode 100644 index 0000000..a8eaf38 Binary files /dev/null and b/Code/Chapter 19/ComUsableDotNetServer/TestKey.snk differ diff --git a/Code/Chapter 19/SimpleComServer/ComCalc.cls b/Code/Chapter 19/SimpleComServer/ComCalc.cls new file mode 100644 index 0000000..45ec7bc --- /dev/null +++ b/Code/Chapter 19/SimpleComServer/ComCalc.cls @@ -0,0 +1,23 @@ +VERSION 1.0 CLASS +BEGIN + MultiUse = -1 'True + Persistable = 0 'NotPersistable + DataBindingBehavior = 0 'vbNone + DataSourceBehavior = 0 'vbNone + MTSTransactionMode = 0 'NotAnMTSObject +END +Attribute VB_Name = "ComCalc" +Attribute VB_GlobalNameSpace = False +Attribute VB_Creatable = True +Attribute VB_PredeclaredId = False +Attribute VB_Exposed = True +' The VB 6.0 COM object +Option Explicit + +Public Function Add(ByVal x As Integer, ByVal y As Integer) As Integer + Add = x + y +End Function +Public Function Subtract(ByVal x As Integer, ByVal y As Integer) As Integer + Subtract = x - y +End Function + diff --git a/Code/Chapter 19/SimpleComServer/SimpleComServer.dll b/Code/Chapter 19/SimpleComServer/SimpleComServer.dll new file mode 100644 index 0000000..d2c537e Binary files /dev/null and b/Code/Chapter 19/SimpleComServer/SimpleComServer.dll differ diff --git a/Code/Chapter 19/SimpleComServer/SimpleComServer.exp b/Code/Chapter 19/SimpleComServer/SimpleComServer.exp new file mode 100644 index 0000000..0058424 Binary files /dev/null and b/Code/Chapter 19/SimpleComServer/SimpleComServer.exp differ diff --git a/Code/Chapter 19/SimpleComServer/SimpleComServer.lib b/Code/Chapter 19/SimpleComServer/SimpleComServer.lib new file mode 100644 index 0000000..70a55f9 Binary files /dev/null and b/Code/Chapter 19/SimpleComServer/SimpleComServer.lib differ diff --git a/Code/Chapter 19/SimpleComServer/SimpleComServer.vbp b/Code/Chapter 19/SimpleComServer/SimpleComServer.vbp new file mode 100644 index 0000000..2c23160 --- /dev/null +++ b/Code/Chapter 19/SimpleComServer/SimpleComServer.vbp @@ -0,0 +1,33 @@ +Type=OleDll +Class=ComCalc; ComCalc.cls +Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\Windows\system32\stdole2.tlb#OLE Automation +Startup="(None)" +HelpFile="" +ExeName32="SimpleComServer.dll" +Command32="" +Name="SimpleComServer" +HelpContextID="0" +CompatibleMode="2" +CompatibleEXE32="SimpleComServer.dll" +VersionCompatible32="1" +MajorVer=1 +MinorVer=0 +RevisionVer=0 +AutoIncrementVer=0 +ServerSupportFiles=0 +CompilationType=0 +OptimizationType=0 +FavorPentiumPro(tm)=0 +CodeViewDebugInfo=0 +NoAliasing=0 +BoundsCheck=0 +OverflowCheck=0 +FlPointCheck=0 +FDIVCheck=0 +UnroundedFP=0 +StartMode=1 +Unattended=0 +Retained=0 +ThreadPerObject=0 +MaxNumberOfThreads=1 +ThreadingModel=1 diff --git a/Code/Chapter 19/SimpleComServer/SimpleComServer.vbw b/Code/Chapter 19/SimpleComServer/SimpleComServer.vbw new file mode 100644 index 0000000..c7ef535 --- /dev/null +++ b/Code/Chapter 19/SimpleComServer/SimpleComServer.vbw @@ -0,0 +1 @@ +ComCalc = 23, 23, 846, 731, C diff --git a/Code/Chapter 19/Vb6ComCarServer/CoCar.cls b/Code/Chapter 19/Vb6ComCarServer/CoCar.cls new file mode 100644 index 0000000..aec70c3 --- /dev/null +++ b/Code/Chapter 19/Vb6ComCarServer/CoCar.cls @@ -0,0 +1,77 @@ +VERSION 1.0 CLASS +BEGIN + MultiUse = -1 'True + Persistable = 0 'NotPersistable + DataBindingBehavior = 0 'vbNone + DataSourceBehavior = 0 'vbNone + MTSTransactionMode = 0 'NotAnMTSObject +END +Attribute VB_Name = "CoCar" +Attribute VB_GlobalNameSpace = False +Attribute VB_Creatable = True +Attribute VB_PredeclaredId = False +Attribute VB_Exposed = True +Implements IDriverInfo + +Option Explicit + +' A COM enum. +Enum CarType + Viper + Colt + BMW +End Enum + +' A COM Event. +Public Event BlewUp() + +' Member variables. +Private currSp As Integer +Private maxSp As Integer +Private make As CarType +Private driverName As String +Private eng As Engine + +' Remember! All Public members +' are exposed by the default interface! +Public Property Get currentSpeed() As Integer + currentSpeed = currSp +End Property + +Public Property Get carMake() As CarType + carMake = make +End Property + +Public Sub SpeedUp() + currSp = currSp + 10 + If currSp > maxSp Then + RaiseEvent BlewUp ' Fire event If you max out the engine. + End If +End Sub + +Private Sub Class_Initialize() + MsgBox "Init COM car" +End Sub + +Public Sub Create(ByVal maximumSpeed As Integer, _ + ByVal currentSpeed As Integer, ByVal carMake As CarType) + maxSp = maximumSpeed + currSp = currentSpeed + make = carMake + Set eng = New Engine +End Sub + +' ***** IDriverInfo impl ***** ' +Private Property Let IDriverInfo_DriverName(ByVal RHS As String) + driverName = RHS +End Property +Private Property Get IDriverInfo_DriverName() As String + IDriverInfo_DriverName = driverName +End Property + +' Return the Engine to the world. +Public Function GetEngine() As Engine + Set GetEngine = eng +End Function + + diff --git a/Code/Chapter 19/Vb6ComCarServer/Engine.cls b/Code/Chapter 19/Vb6ComCarServer/Engine.cls new file mode 100644 index 0000000..f3abe79 --- /dev/null +++ b/Code/Chapter 19/Vb6ComCarServer/Engine.cls @@ -0,0 +1,24 @@ +VERSION 1.0 CLASS +BEGIN + MultiUse = -1 'True + Persistable = 0 'NotPersistable + DataBindingBehavior = 0 'vbNone + DataSourceBehavior = 0 'vbNone + MTSTransactionMode = 0 'NotAnMTSObject +END +Attribute VB_Name = "Engine" +Attribute VB_GlobalNameSpace = False +Attribute VB_Creatable = False +Attribute VB_PredeclaredId = False +Attribute VB_Exposed = True +Option Explicit + +Public Function GetCylinders() As String() + Dim c(3) As String + c(0) = "Grimey" + c(1) = "Thumper" + c(2) = "Oily" + c(3) = "Crusher" + GetCylinders = c +End Function + diff --git a/Code/Chapter 19/Vb6ComCarServer/IDriverInfo.cls b/Code/Chapter 19/Vb6ComCarServer/IDriverInfo.cls new file mode 100644 index 0000000..5c4694b --- /dev/null +++ b/Code/Chapter 19/Vb6ComCarServer/IDriverInfo.cls @@ -0,0 +1,21 @@ +VERSION 1.0 CLASS +BEGIN + MultiUse = -1 'True + Persistable = 0 'NotPersistable + DataBindingBehavior = 0 'vbNone + DataSourceBehavior = 0 'vbNone + MTSTransactionMode = 0 'NotAnMTSObject +END +Attribute VB_Name = "IDriverInfo" +Attribute VB_GlobalNameSpace = False +Attribute VB_Creatable = False +Attribute VB_PredeclaredId = False +Attribute VB_Exposed = True +Option Explicit + +' Driver has a name +Public Property Let driverName(ByVal s As String) +End Property +Public Property Get driverName() As String +End Property + diff --git a/Code/Chapter 19/Vb6ComCarServer/Vb6ComCarServer.dll b/Code/Chapter 19/Vb6ComCarServer/Vb6ComCarServer.dll new file mode 100644 index 0000000..3453814 Binary files /dev/null and b/Code/Chapter 19/Vb6ComCarServer/Vb6ComCarServer.dll differ diff --git a/Code/Chapter 19/Vb6ComCarServer/Vb6ComCarServer.exp b/Code/Chapter 19/Vb6ComCarServer/Vb6ComCarServer.exp new file mode 100644 index 0000000..90dbc7d Binary files /dev/null and b/Code/Chapter 19/Vb6ComCarServer/Vb6ComCarServer.exp differ diff --git a/Code/Chapter 19/Vb6ComCarServer/Vb6ComCarServer.lib b/Code/Chapter 19/Vb6ComCarServer/Vb6ComCarServer.lib new file mode 100644 index 0000000..89ff360 Binary files /dev/null and b/Code/Chapter 19/Vb6ComCarServer/Vb6ComCarServer.lib differ diff --git a/Code/Chapter 19/Vb6ComCarServer/Vb6ComCarServer.vbp b/Code/Chapter 19/Vb6ComCarServer/Vb6ComCarServer.vbp new file mode 100644 index 0000000..e5a1e9c --- /dev/null +++ b/Code/Chapter 19/Vb6ComCarServer/Vb6ComCarServer.vbp @@ -0,0 +1,33 @@ +Type=OleDll +Class=CoCar; CoCar.cls +Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\Windows\system32\stdole2.tlb#OLE Automation +Class=IDriverInfo; IDriverInfo.cls +Class=Engine; Engine.cls +Startup="(None)" +ExeName32="Vb6ComCarServer.dll" +Command32="" +Name="Vb6ComCarServer" +HelpContextID="0" +CompatibleMode="1" +CompatibleEXE32="Vb6ComCarServer.dll" +MajorVer=1 +MinorVer=0 +RevisionVer=0 +AutoIncrementVer=0 +ServerSupportFiles=0 +CompilationType=0 +OptimizationType=0 +FavorPentiumPro(tm)=0 +CodeViewDebugInfo=0 +NoAliasing=0 +BoundsCheck=0 +OverflowCheck=0 +FlPointCheck=0 +FDIVCheck=0 +UnroundedFP=0 +StartMode=1 +Unattended=0 +Retained=0 +ThreadPerObject=0 +MaxNumberOfThreads=1 +ThreadingModel=1 diff --git a/Code/Chapter 19/Vb6ComCarServer/Vb6ComCarServer.vbw b/Code/Chapter 19/Vb6ComCarServer/Vb6ComCarServer.vbw new file mode 100644 index 0000000..a62e201 --- /dev/null +++ b/Code/Chapter 19/Vb6ComCarServer/Vb6ComCarServer.vbw @@ -0,0 +1,3 @@ +CoCar = 362, 193, 1185, 903, C +IDriverInfo = 131, 330, 954, 1038, C +Engine = 69, 69, 892, 777, C diff --git a/Code/Chapter 19/Vb6_DotNetClient/Form1.frm b/Code/Chapter 19/Vb6_DotNetClient/Form1.frm new file mode 100644 index 0000000..86d152c --- /dev/null +++ b/Code/Chapter 19/Vb6_DotNetClient/Form1.frm @@ -0,0 +1,34 @@ +VERSION 5.00 +Begin VB.Form Form1 + Caption = "A COM Application using a .NET Type" + ClientHeight = 3480 + ClientLeft = 120 + ClientTop = 420 + ClientWidth = 5040 + LinkTopic = "Form1" + ScaleHeight = 3480 + ScaleWidth = 5040 + StartUpPosition = 3 'Windows Default + Begin VB.CommandButton btnUseDotNetObject + Caption = "Use COM Object" + Height = 735 + Left = 240 + TabIndex = 0 + Top = 240 + Width = 4455 + End +End +Attribute VB_Name = "Form1" +Attribute VB_GlobalNameSpace = False +Attribute VB_Creatable = False +Attribute VB_PredeclaredId = True +Attribute VB_Exposed = False +Private Sub btnUseDotNetObject_Click() + ' Create the .NET object. + Dim c As New DotNetCalc + MsgBox c.Add(10, 10), , "Adding with .NET" + + ' Invoke some members of System.Object. + MsgBox c.ToString, , "ToString value" +End Sub + diff --git a/Code/Chapter 19/Vb6_DotNetClient/VB6_DotNetClient.exe b/Code/Chapter 19/Vb6_DotNetClient/VB6_DotNetClient.exe new file mode 100644 index 0000000..fbf07c9 Binary files /dev/null and b/Code/Chapter 19/Vb6_DotNetClient/VB6_DotNetClient.exe differ diff --git a/Code/Chapter 19/Vb6_DotNetClient/VB6_DotNetClient.vbp b/Code/Chapter 19/Vb6_DotNetClient/VB6_DotNetClient.vbp new file mode 100644 index 0000000..251965c --- /dev/null +++ b/Code/Chapter 19/Vb6_DotNetClient/VB6_DotNetClient.vbp @@ -0,0 +1,30 @@ +Type=Exe +Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\Windows\system32\stdole2.tlb#OLE Automation +Reference=*\G{3E77D6C8-9138-40C8-8178-014B1982BC4B}#1.0#0#..\ComUsableDotNetServer\bin\Debug\ComUsableDotNetServer.tlb#ComUsableDotNetServer +Form=Form1.frm +Startup="Form1" +ExeName32="VB6_DotNetClient.exe" +Command32="" +Name="VB6_DotNetClient" +HelpContextID="0" +CompatibleMode="0" +MajorVer=1 +MinorVer=0 +RevisionVer=0 +AutoIncrementVer=0 +ServerSupportFiles=0 +CompilationType=0 +OptimizationType=0 +FavorPentiumPro(tm)=0 +CodeViewDebugInfo=0 +NoAliasing=0 +BoundsCheck=0 +OverflowCheck=0 +FlPointCheck=0 +FDIVCheck=0 +UnroundedFP=0 +StartMode=0 +Unattended=0 +Retained=0 +ThreadPerObject=0 +MaxNumberOfThreads=1 diff --git a/Code/Chapter 19/Vb6_DotNetClient/VB6_DotNetClient.vbw b/Code/Chapter 19/Vb6_DotNetClient/VB6_DotNetClient.vbw new file mode 100644 index 0000000..e2e77d7 --- /dev/null +++ b/Code/Chapter 19/Vb6_DotNetClient/VB6_DotNetClient.vbw @@ -0,0 +1 @@ +Form1 = 69, 69, 892, 777, C, 23, 23, 846, 731, C diff --git a/Code/Chapter 19/VbNetCarClient/My Project/Application.Designer.vb b/Code/Chapter 19/VbNetCarClient/My Project/Application.Designer.vb new file mode 100644 index 0000000..0e8f9f4 --- /dev/null +++ b/Code/Chapter 19/VbNetCarClient/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1378 +' +' 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/Code/Chapter 19/VbNetCarClient/My Project/Application.myapp b/Code/Chapter 19/VbNetCarClient/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 19/VbNetCarClient/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 19/VbNetCarClient/My Project/AssemblyInfo.vb b/Code/Chapter 19/VbNetCarClient/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..f5d8758 --- /dev/null +++ b/Code/Chapter 19/VbNetCarClient/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/Code/Chapter 19/VbNetCarClient/My Project/Resources.Designer.vb b/Code/Chapter 19/VbNetCarClient/My Project/Resources.Designer.vb new file mode 100644 index 0000000..ff96504 --- /dev/null +++ b/Code/Chapter 19/VbNetCarClient/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1378 +' +' 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("VbNetCarClient.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/Code/Chapter 19/VbNetCarClient/My Project/Resources.resx b/Code/Chapter 19/VbNetCarClient/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 19/VbNetCarClient/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/Code/Chapter 19/VbNetCarClient/My Project/Settings.Designer.vb b/Code/Chapter 19/VbNetCarClient/My Project/Settings.Designer.vb new file mode 100644 index 0000000..981330a --- /dev/null +++ b/Code/Chapter 19/VbNetCarClient/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1378 +' +' 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.VbNetCarClient.My.MySettings + Get + Return Global.VbNetCarClient.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 19/VbNetCarClient/My Project/Settings.settings b/Code/Chapter 19/VbNetCarClient/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 19/VbNetCarClient/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 19/VbNetCarClient/Program.vb b/Code/Chapter 19/VbNetCarClient/Program.vb new file mode 100644 index 0000000..98aa915 --- /dev/null +++ b/Code/Chapter 19/VbNetCarClient/Program.vb @@ -0,0 +1,43 @@ +Imports Vb6ComCarServer + +Module Program + ' Create the COM class using + ' Early binding. + Public WithEvents myCar As New CoCar() + + Sub Main() + Console.WriteLine("***** CoCar Client App *****") + + ' Call the Create() method. + myCar.Create(50, 10, CarType.BMW) + + ' Set name of driver. + Dim itf As IDriverInfo + itf = myCar + itf.driverName = "Fred" + Console.WriteLine("Driver is named: {0}", itf.driverName) + + ' Print type of car. + Console.WriteLine("Your car is a {0}.", myCar.CarMake()) + Console.WriteLine() + + ' Get the Engine and print name of all Cylinders. + Dim eng As Engine = myCar.GetEngine() + Console.WriteLine("Your Cylinders are named:") + Dim names() As String = eng.GetCylinders() + For Each s As String In names + Console.WriteLine(s) + Next + Console.WriteLine() + + ' Speed up car to trigger event. + For i As Integer = 0 To 3 + myCar.SpeedUp() + Next + Console.ReadLine() + End Sub + + Private Sub myCar_BlewUp() Handles myCar.BlewUp + Console.WriteLine("***** Ek! Car is doomed...! *****") + End Sub +End Module diff --git a/Code/Chapter 19/VbNetCarClient/VbNetCarClient.sln b/Code/Chapter 19/VbNetCarClient/VbNetCarClient.sln new file mode 100644 index 0000000..5552161 --- /dev/null +++ b/Code/Chapter 19/VbNetCarClient/VbNetCarClient.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VbNetCarClient", "VbNetCarClient.vbproj", "{112E4781-AA4D-4426-B476-CA204ACA0D66}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {112E4781-AA4D-4426-B476-CA204ACA0D66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {112E4781-AA4D-4426-B476-CA204ACA0D66}.Debug|Any CPU.Build.0 = Debug|Any CPU + {112E4781-AA4D-4426-B476-CA204ACA0D66}.Release|Any CPU.ActiveCfg = Release|Any CPU + {112E4781-AA4D-4426-B476-CA204ACA0D66}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 19/VbNetCarClient/VbNetCarClient.suo b/Code/Chapter 19/VbNetCarClient/VbNetCarClient.suo new file mode 100644 index 0000000..74b01da Binary files /dev/null and b/Code/Chapter 19/VbNetCarClient/VbNetCarClient.suo differ diff --git a/Code/Chapter 19/VbNetCarClient/VbNetCarClient.vbproj b/Code/Chapter 19/VbNetCarClient/VbNetCarClient.vbproj new file mode 100644 index 0000000..90f4f9c --- /dev/null +++ b/Code/Chapter 19/VbNetCarClient/VbNetCarClient.vbproj @@ -0,0 +1,107 @@ + + + + Debug + AnyCPU + 9.0.20706 + 2.0 + {112E4781-AA4D-4426-B476-CA204ACA0D66} + Exe + VbNetCarClient.Program + VbNetCarClient + VbNetCarClient + Console + + + 2.0 + + + + + true + full + true + true + bin\Debug\ + VbNetCarClient.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + VbNetCarClient.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 + + + + + {266052E5-26B1-40F6-AE35-3220EE31CCD0} + 4 + 0 + 0 + tlbimp + False + + + + + \ No newline at end of file diff --git a/Code/Chapter 19/VbNetCarClient/VbNetCarClient.vbproj.user b/Code/Chapter 19/VbNetCarClient/VbNetCarClient.vbproj.user new file mode 100644 index 0000000..6a34e7d --- /dev/null +++ b/Code/Chapter 19/VbNetCarClient/VbNetCarClient.vbproj.user @@ -0,0 +1,5 @@ + + + ShowAllFiles + + \ No newline at end of file diff --git a/Code/Chapter 19/VbNetComClientLateBinding/My Project/Application.Designer.vb b/Code/Chapter 19/VbNetComClientLateBinding/My Project/Application.Designer.vb new file mode 100644 index 0000000..0e8f9f4 --- /dev/null +++ b/Code/Chapter 19/VbNetComClientLateBinding/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1378 +' +' 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/Code/Chapter 19/VbNetComClientLateBinding/My Project/Application.myapp b/Code/Chapter 19/VbNetComClientLateBinding/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 19/VbNetComClientLateBinding/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 19/VbNetComClientLateBinding/My Project/AssemblyInfo.vb b/Code/Chapter 19/VbNetComClientLateBinding/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..b954175 --- /dev/null +++ b/Code/Chapter 19/VbNetComClientLateBinding/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/Code/Chapter 19/VbNetComClientLateBinding/My Project/Resources.Designer.vb b/Code/Chapter 19/VbNetComClientLateBinding/My Project/Resources.Designer.vb new file mode 100644 index 0000000..20eb1c5 --- /dev/null +++ b/Code/Chapter 19/VbNetComClientLateBinding/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.312 +' +' 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("VBNetComClientLateBinding.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/Code/Chapter 19/VbNetComClientLateBinding/My Project/Resources.resx b/Code/Chapter 19/VbNetComClientLateBinding/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 19/VbNetComClientLateBinding/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/Code/Chapter 19/VbNetComClientLateBinding/My Project/Settings.Designer.vb b/Code/Chapter 19/VbNetComClientLateBinding/My Project/Settings.Designer.vb new file mode 100644 index 0000000..980f3d6 --- /dev/null +++ b/Code/Chapter 19/VbNetComClientLateBinding/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1378 +' +' 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.VBNetComClientLateBinding.My.MySettings + Get + Return Global.VBNetComClientLateBinding.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 19/VbNetComClientLateBinding/My Project/Settings.settings b/Code/Chapter 19/VbNetComClientLateBinding/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 19/VbNetComClientLateBinding/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 19/VbNetComClientLateBinding/Program.vb b/Code/Chapter 19/VbNetComClientLateBinding/Program.vb new file mode 100644 index 0000000..759fa88 --- /dev/null +++ b/Code/Chapter 19/VbNetComClientLateBinding/Program.vb @@ -0,0 +1,33 @@ +' If you uncomment the following line, +' using CreateObject() within Main() +' will result in a compiler error! +' Option Strict On + +Imports System.Reflection + +Module Program + Sub Main() + Console.WriteLine("***** The Late Bound .NET Client *****") + + ' First get IDispatch reference from coclass. + Dim calcObj As Type = _ + Type.GetTypeFromProgID("SimpleCOMServer.ComCalc") + Dim calcDisp As Object = Activator.CreateInstance(calcObj) + + ' Make the array of args. + Dim addArgs() As Object = {100, 24} + + ' Invoke the Add() method and obtain summation. + Dim sum As Object + sum = calcObj.InvokeMember("Add", BindingFlags.InvokeMethod, _ + Nothing, calcDisp, addArgs) + + ' Display result. + Console.WriteLine("Late bound adding: 100 + 24 is: {0}", sum) + + ' This will only compile if Option Strict is disabled. + Dim c As Object = CreateObject("SimpleCOMServer.ComCalc") + Console.WriteLine("10 + 10 = {0}", c.Add(10, 10)) + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 19/VbNetComClientLateBinding/VBNetComClientLateBinding.sln b/Code/Chapter 19/VbNetComClientLateBinding/VBNetComClientLateBinding.sln new file mode 100644 index 0000000..1d1c463 --- /dev/null +++ b/Code/Chapter 19/VbNetComClientLateBinding/VBNetComClientLateBinding.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VBNetComClientLateBinding", "VBNetComClientLateBinding.vbproj", "{D2138C69-D32B-4AB8-8B75-0068E1565D0A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D2138C69-D32B-4AB8-8B75-0068E1565D0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D2138C69-D32B-4AB8-8B75-0068E1565D0A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D2138C69-D32B-4AB8-8B75-0068E1565D0A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D2138C69-D32B-4AB8-8B75-0068E1565D0A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 19/VbNetComClientLateBinding/VBNetComClientLateBinding.suo b/Code/Chapter 19/VbNetComClientLateBinding/VBNetComClientLateBinding.suo new file mode 100644 index 0000000..de673aa Binary files /dev/null and b/Code/Chapter 19/VbNetComClientLateBinding/VBNetComClientLateBinding.suo differ diff --git a/Code/Chapter 19/VbNetComClientLateBinding/VBNetComClientLateBinding.vbproj b/Code/Chapter 19/VbNetComClientLateBinding/VBNetComClientLateBinding.vbproj new file mode 100644 index 0000000..f840423 --- /dev/null +++ b/Code/Chapter 19/VbNetComClientLateBinding/VBNetComClientLateBinding.vbproj @@ -0,0 +1,96 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {D2138C69-D32B-4AB8-8B75-0068E1565D0A} + Exe + VBNetComClientLateBinding.Program + VBNetComClientLateBinding + VBNetComClientLateBinding + Console + + + 2.0 + + + + + true + full + true + true + bin\Debug\ + VBNetComClientLateBinding.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + VBNetComClientLateBinding.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + VbMyResourcesResXFileCodeGenerator + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + \ No newline at end of file diff --git a/Code/Chapter 19/VbNetComClientLateBinding/VBNetComClientLateBinding.vbproj.user b/Code/Chapter 19/VbNetComClientLateBinding/VBNetComClientLateBinding.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 19/VbNetComClientLateBinding/VBNetComClientLateBinding.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 19/VbNetSimpleComClient/My Project/Application.Designer.vb b/Code/Chapter 19/VbNetSimpleComClient/My Project/Application.Designer.vb new file mode 100644 index 0000000..0e8f9f4 --- /dev/null +++ b/Code/Chapter 19/VbNetSimpleComClient/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1378 +' +' 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/Code/Chapter 19/VbNetSimpleComClient/My Project/Application.myapp b/Code/Chapter 19/VbNetSimpleComClient/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 19/VbNetSimpleComClient/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 19/VbNetSimpleComClient/My Project/AssemblyInfo.vb b/Code/Chapter 19/VbNetSimpleComClient/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..a227cbe --- /dev/null +++ b/Code/Chapter 19/VbNetSimpleComClient/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/Code/Chapter 19/VbNetSimpleComClient/My Project/Resources.Designer.vb b/Code/Chapter 19/VbNetSimpleComClient/My Project/Resources.Designer.vb new file mode 100644 index 0000000..c45a7ec --- /dev/null +++ b/Code/Chapter 19/VbNetSimpleComClient/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1378 +' +' 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("VBNetSimpleComClient.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/Code/Chapter 19/VbNetSimpleComClient/My Project/Resources.resx b/Code/Chapter 19/VbNetSimpleComClient/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 19/VbNetSimpleComClient/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/Code/Chapter 19/VbNetSimpleComClient/My Project/Settings.Designer.vb b/Code/Chapter 19/VbNetSimpleComClient/My Project/Settings.Designer.vb new file mode 100644 index 0000000..20125ba --- /dev/null +++ b/Code/Chapter 19/VbNetSimpleComClient/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1378 +' +' 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.VBNetSimpleComClient.My.MySettings + Get + Return Global.VBNetSimpleComClient.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 19/VbNetSimpleComClient/My Project/Settings.settings b/Code/Chapter 19/VbNetSimpleComClient/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 19/VbNetSimpleComClient/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 19/VbNetSimpleComClient/My Project/app.manifest b/Code/Chapter 19/VbNetSimpleComClient/My Project/app.manifest new file mode 100644 index 0000000..65cc22c --- /dev/null +++ b/Code/Chapter 19/VbNetSimpleComClient/My Project/app.manifest @@ -0,0 +1,22 @@ + + + + + + + + + + + + diff --git a/Code/Chapter 19/VbNetSimpleComClient/Program.vb b/Code/Chapter 19/VbNetSimpleComClient/Program.vb new file mode 100644 index 0000000..b65d493 --- /dev/null +++ b/Code/Chapter 19/VbNetSimpleComClient/Program.vb @@ -0,0 +1,33 @@ +' You will need to compile the VB 6 project +' included in Appendix A in order for VS 2008 +' to find the interop assembly. +Imports SimpleComServer + +' As explained the the text, there are THREE different +' ways to interact with a COM object, each shown below. +' Uncomment / Comment a block to test. + +Module Program + Sub Main() + Console.WriteLine("***** The .NET COM Client App *****") + + 'Dim comObj As New ComCalc() + 'Console.WriteLine("COM server says 10 + 832 is {0}", _ + ' comObj.Add(10, 832)) + 'Console.ReadLine() + + '' Now using the Class-suffixed type. + 'Dim comObj As New ComCalcClass() + 'Console.WriteLine("COM server says 10 + 832 is {0}", _ + ' comObj.Add(10, 832)) + 'Console.ReadLine() + + ' Now manually obtain the hidden interface. + Dim i As _ComCalc + Dim c As New ComCalc() + i = c + Console.WriteLine("COM server says 10 + 832 is {0}", _ + i.Add(10, 832)) + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 19/VbNetSimpleComClient/VBNetSimpleComClient.sln b/Code/Chapter 19/VbNetSimpleComClient/VBNetSimpleComClient.sln new file mode 100644 index 0000000..1c6efb0 --- /dev/null +++ b/Code/Chapter 19/VbNetSimpleComClient/VBNetSimpleComClient.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VBNetSimpleComClient", "VBNetSimpleComClient.vbproj", "{ED805B00-8B05-4028-A799-8D6218A51CD1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {ED805B00-8B05-4028-A799-8D6218A51CD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ED805B00-8B05-4028-A799-8D6218A51CD1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ED805B00-8B05-4028-A799-8D6218A51CD1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ED805B00-8B05-4028-A799-8D6218A51CD1}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 19/VbNetSimpleComClient/VBNetSimpleComClient.suo b/Code/Chapter 19/VbNetSimpleComClient/VBNetSimpleComClient.suo new file mode 100644 index 0000000..ded0c02 Binary files /dev/null and b/Code/Chapter 19/VbNetSimpleComClient/VBNetSimpleComClient.suo differ diff --git a/Code/Chapter 19/VbNetSimpleComClient/VBNetSimpleComClient.vbproj b/Code/Chapter 19/VbNetSimpleComClient/VBNetSimpleComClient.vbproj new file mode 100644 index 0000000..02d8871 --- /dev/null +++ b/Code/Chapter 19/VbNetSimpleComClient/VBNetSimpleComClient.vbproj @@ -0,0 +1,113 @@ + + + + Debug + AnyCPU + 9.0.20706 + 2.0 + {ED805B00-8B05-4028-A799-8D6218A51CD1} + Exe + VBNetSimpleComClient.Program + VBNetSimpleComClient + VBNetSimpleComClient + Console + + + 2.0 + + + My Project\app.manifest + v3.5 + + + true + full + true + true + bin\Debug\ + VBNetSimpleComClient.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + VBNetSimpleComClient.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + 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 + + + + + {36D90E8D-919C-47B3-AA93-0CB4DFEC1A75} + 1 + 0 + 0 + tlbimp + False + + + + + \ No newline at end of file diff --git a/Code/Chapter 19/VbNetSimpleComClient/VBNetSimpleComClient.vbproj.user b/Code/Chapter 19/VbNetSimpleComClient/VBNetSimpleComClient.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 19/VbNetSimpleComClient/VBNetSimpleComClient.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 2/VbcExample/HelloMsg.vb b/Code/Chapter 2/VbcExample/HelloMsg.vb new file mode 100644 index 0000000..ed2dfaa --- /dev/null +++ b/Code/Chapter 2/VbcExample/HelloMsg.vb @@ -0,0 +1,9 @@ +' The HelloMessage class +Imports System +Imports System.Windows.Forms + +Class HelloMessage + Sub Speak() + MessageBox.Show("Hello Again") + End Sub +End Class diff --git a/Code/Chapter 2/VbcExample/TestApp.rsp b/Code/Chapter 2/VbcExample/TestApp.rsp new file mode 100644 index 0000000..feb536e --- /dev/null +++ b/Code/Chapter 2/VbcExample/TestApp.rsp @@ -0,0 +1,9 @@ +# This is the response file +# for the TestApp.exe app +# of Chapter 2. + +# External assembly references. +/r:System.Windows.Forms.dll + +# output and files to compile (using wildcard syntax). +/target:exe /out:TestApp.exe *.vb diff --git a/Code/Chapter 2/VbcExample/TestApp.vb b/Code/Chapter 2/VbcExample/TestApp.vb new file mode 100644 index 0000000..63641b6 --- /dev/null +++ b/Code/Chapter 2/VbcExample/TestApp.vb @@ -0,0 +1,18 @@ +' A simple VB 2008 application. +Imports System + +' Don't need this anymore. +' Imports System.Windows.Forms + +Module TestApp + Sub Main() + Console.WriteLine("Testing! 1, 2, 3") + + ' Don't need this anymore either. + ' MessageBox.Show("Hello!") + + ' Exercise the HelloMessage class! + Dim hello As New HelloMessage() + hello.Speak() + End Sub +End Module diff --git a/Code/Chapter 20/AsyncFileStream/AsyncFileStream.sln b/Code/Chapter 20/AsyncFileStream/AsyncFileStream.sln new file mode 100644 index 0000000..e1f06a8 --- /dev/null +++ b/Code/Chapter 20/AsyncFileStream/AsyncFileStream.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AsyncFileStream", "AsyncFileStream.vbproj", "{CFD0A539-82D8-40A3-B9A0-0F07BCBDE61A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CFD0A539-82D8-40A3-B9A0-0F07BCBDE61A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CFD0A539-82D8-40A3-B9A0-0F07BCBDE61A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CFD0A539-82D8-40A3-B9A0-0F07BCBDE61A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CFD0A539-82D8-40A3-B9A0-0F07BCBDE61A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 20/AsyncFileStream/AsyncFileStream.suo b/Code/Chapter 20/AsyncFileStream/AsyncFileStream.suo new file mode 100644 index 0000000..dcf576d Binary files /dev/null and b/Code/Chapter 20/AsyncFileStream/AsyncFileStream.suo differ diff --git a/Code/Chapter 20/AsyncFileStream/AsyncFileStream.vbproj b/Code/Chapter 20/AsyncFileStream/AsyncFileStream.vbproj new file mode 100644 index 0000000..7136958 --- /dev/null +++ b/Code/Chapter 20/AsyncFileStream/AsyncFileStream.vbproj @@ -0,0 +1,97 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {CFD0A539-82D8-40A3-B9A0-0F07BCBDE61A} + Exe + AsyncFileStream.Program + AsyncFileStream + AsyncFileStream + Console + + + 2.0 + + + + + true + full + true + true + bin\Debug\ + AsyncFileStream.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + AsyncFileStream.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/Code/Chapter 20/AsyncFileStream/AsyncFileStream.vbproj.user b/Code/Chapter 20/AsyncFileStream/AsyncFileStream.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 20/AsyncFileStream/AsyncFileStream.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 20/AsyncFileStream/My Project/Application.Designer.vb b/Code/Chapter 20/AsyncFileStream/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 20/AsyncFileStream/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 20/AsyncFileStream/My Project/Application.myapp b/Code/Chapter 20/AsyncFileStream/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 20/AsyncFileStream/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 20/AsyncFileStream/My Project/AssemblyInfo.vb b/Code/Chapter 20/AsyncFileStream/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..319474b --- /dev/null +++ b/Code/Chapter 20/AsyncFileStream/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/Code/Chapter 20/AsyncFileStream/My Project/Resources.Designer.vb b/Code/Chapter 20/AsyncFileStream/My Project/Resources.Designer.vb new file mode 100644 index 0000000..836031f --- /dev/null +++ b/Code/Chapter 20/AsyncFileStream/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("AsyncFileStream.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/Code/Chapter 20/AsyncFileStream/My Project/Resources.resx b/Code/Chapter 20/AsyncFileStream/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 20/AsyncFileStream/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/Code/Chapter 20/AsyncFileStream/My Project/Settings.Designer.vb b/Code/Chapter 20/AsyncFileStream/My Project/Settings.Designer.vb new file mode 100644 index 0000000..b90d2a8 --- /dev/null +++ b/Code/Chapter 20/AsyncFileStream/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.AsyncFileStream.My.MySettings + Get + Return Global.AsyncFileStream.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 20/AsyncFileStream/My Project/Settings.settings b/Code/Chapter 20/AsyncFileStream/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 20/AsyncFileStream/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 20/AsyncFileStream/Program.vb b/Code/Chapter 20/AsyncFileStream/Program.vb new file mode 100644 index 0000000..5520002 --- /dev/null +++ b/Code/Chapter 20/AsyncFileStream/Program.vb @@ -0,0 +1,35 @@ +Option Explicit On +Option Strict On + +Imports System.IO +Imports System.Text +Imports System.Threading + +Module Program + Sub Main() + Console.WriteLine("**** Asynch File IO *****") + Console.WriteLine() + + Console.WriteLine("Main thread started. ThreadID = {0}", _ + Thread.CurrentThread.GetHashCode) + + ' Must use this ctor to get a FileStream with asynchronous + ' read or write access. + Dim fs As FileStream = New FileStream("logfile.txt", FileMode.Append, FileAccess.Write, FileShare.None, 4096, True) + Dim msg As String = "this is a test" + Dim buffer As Byte() = Encoding.ASCII.GetBytes(msg) + + ' Start the asynchronous write. WriteDone invoked when finished. + ' Note that the FileStream object is passed as state info to the + ' callback method. + fs.BeginWrite(buffer, 0, buffer.Length, AddressOf WriteDone, fs) + End Sub + + Private Sub WriteDone(ByVal ar As IAsyncResult) + Console.WriteLine("AsyncCallback method on ThreadID = {0}", _ + Thread.CurrentThread.GetHashCode) + Dim s As Stream = CType(ar.AsyncState, Stream) + s.EndWrite(ar) + s.Close() + End Sub +End Module diff --git a/Code/Chapter 20/BinaryWriterReader/BinaryWriterReader.sln b/Code/Chapter 20/BinaryWriterReader/BinaryWriterReader.sln new file mode 100644 index 0000000..0bd1ba3 --- /dev/null +++ b/Code/Chapter 20/BinaryWriterReader/BinaryWriterReader.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "BinaryWriterReader", "BinaryWriterReader.vbproj", "{FFB4361F-C139-4879-BF57-6CFB6528D5BB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FFB4361F-C139-4879-BF57-6CFB6528D5BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FFB4361F-C139-4879-BF57-6CFB6528D5BB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FFB4361F-C139-4879-BF57-6CFB6528D5BB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FFB4361F-C139-4879-BF57-6CFB6528D5BB}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 20/BinaryWriterReader/BinaryWriterReader.suo b/Code/Chapter 20/BinaryWriterReader/BinaryWriterReader.suo new file mode 100644 index 0000000..37dbdff Binary files /dev/null and b/Code/Chapter 20/BinaryWriterReader/BinaryWriterReader.suo differ diff --git a/Code/Chapter 20/BinaryWriterReader/BinaryWriterReader.vbproj b/Code/Chapter 20/BinaryWriterReader/BinaryWriterReader.vbproj new file mode 100644 index 0000000..0c45885 --- /dev/null +++ b/Code/Chapter 20/BinaryWriterReader/BinaryWriterReader.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {FFB4361F-C139-4879-BF57-6CFB6528D5BB} + Exe + BinaryWriterReader.Program + BinaryWriterReader + BinaryWriterReader + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + BinaryWriterReader.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + BinaryWriterReader.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 20/BinaryWriterReader/BinaryWriterReader.vbproj.user b/Code/Chapter 20/BinaryWriterReader/BinaryWriterReader.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 20/BinaryWriterReader/BinaryWriterReader.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 20/BinaryWriterReader/My Project/Application.Designer.vb b/Code/Chapter 20/BinaryWriterReader/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 20/BinaryWriterReader/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 20/BinaryWriterReader/My Project/Application.myapp b/Code/Chapter 20/BinaryWriterReader/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 20/BinaryWriterReader/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 20/BinaryWriterReader/My Project/AssemblyInfo.vb b/Code/Chapter 20/BinaryWriterReader/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..405c173 --- /dev/null +++ b/Code/Chapter 20/BinaryWriterReader/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/Code/Chapter 20/BinaryWriterReader/My Project/Resources.Designer.vb b/Code/Chapter 20/BinaryWriterReader/My Project/Resources.Designer.vb new file mode 100644 index 0000000..766a122 --- /dev/null +++ b/Code/Chapter 20/BinaryWriterReader/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("BinaryWriterReader.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/Code/Chapter 20/BinaryWriterReader/My Project/Resources.resx b/Code/Chapter 20/BinaryWriterReader/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 20/BinaryWriterReader/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/Code/Chapter 20/BinaryWriterReader/My Project/Settings.Designer.vb b/Code/Chapter 20/BinaryWriterReader/My Project/Settings.Designer.vb new file mode 100644 index 0000000..5512583 --- /dev/null +++ b/Code/Chapter 20/BinaryWriterReader/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.BinaryWriterReader.My.MySettings + Get + Return Global.BinaryWriterReader.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 20/BinaryWriterReader/My Project/Settings.settings b/Code/Chapter 20/BinaryWriterReader/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 20/BinaryWriterReader/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 20/BinaryWriterReader/Program.vb b/Code/Chapter 20/BinaryWriterReader/Program.vb new file mode 100644 index 0000000..856f1f8 --- /dev/null +++ b/Code/Chapter 20/BinaryWriterReader/Program.vb @@ -0,0 +1,38 @@ +Option Explicit On +Option Strict On + +Imports System.IO + +Module Program + Sub Main() + Console.WriteLine("***** Fun with Binary Writers / Readers *****" & vbLf) + + ' Open a binary writer for a file. + Dim f As New FileInfo("BinFile.dat") + + Using bw As New BinaryWriter(f.OpenWrite()) + ' Print out the type of BaseStream. + ' (System.IO.FileStream in this case). + Console.WriteLine("Base stream is: {0}", bw.BaseStream) + + ' Create some data to save in the file + Dim aDouble As Double = 1234.67 + Dim anInt As Integer = 34567 + Dim aString As String = "A, B, C" + + ' Write the data + bw.Write(aDouble) + bw.Write(anInt) + bw.Write(aString) + End Using + + ' Read the data as raw bytes + Using br As New BinaryReader(f.OpenRead()) + Console.WriteLine(br.ReadDouble()) + Console.WriteLine(br.ReadInt32()) + Console.WriteLine(br.ReadString()) + End Using + + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 20/DriveTypeApp/DriveTypeApp.sln b/Code/Chapter 20/DriveTypeApp/DriveTypeApp.sln new file mode 100644 index 0000000..408c57d --- /dev/null +++ b/Code/Chapter 20/DriveTypeApp/DriveTypeApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DriveTypeApp", "DriveTypeApp.vbproj", "{998A37BD-7EF2-4670-838A-628F2EF112AD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {998A37BD-7EF2-4670-838A-628F2EF112AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {998A37BD-7EF2-4670-838A-628F2EF112AD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {998A37BD-7EF2-4670-838A-628F2EF112AD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {998A37BD-7EF2-4670-838A-628F2EF112AD}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 20/DriveTypeApp/DriveTypeApp.suo b/Code/Chapter 20/DriveTypeApp/DriveTypeApp.suo new file mode 100644 index 0000000..03200cc Binary files /dev/null and b/Code/Chapter 20/DriveTypeApp/DriveTypeApp.suo differ diff --git a/Code/Chapter 20/DriveTypeApp/DriveTypeApp.vbproj b/Code/Chapter 20/DriveTypeApp/DriveTypeApp.vbproj new file mode 100644 index 0000000..cee640a --- /dev/null +++ b/Code/Chapter 20/DriveTypeApp/DriveTypeApp.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {998A37BD-7EF2-4670-838A-628F2EF112AD} + Exe + DriveTypeApp.Program + DriveTypeApp + DriveTypeApp + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + DriveTypeApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + DriveTypeApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 20/DriveTypeApp/DriveTypeApp.vbproj.user b/Code/Chapter 20/DriveTypeApp/DriveTypeApp.vbproj.user new file mode 100644 index 0000000..a9e2ad6 --- /dev/null +++ b/Code/Chapter 20/DriveTypeApp/DriveTypeApp.vbproj.user @@ -0,0 +1,16 @@ + + + ProjectFiles + publish\ + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 20/DriveTypeApp/My Project/Application.Designer.vb b/Code/Chapter 20/DriveTypeApp/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 20/DriveTypeApp/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 20/DriveTypeApp/My Project/Application.myapp b/Code/Chapter 20/DriveTypeApp/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 20/DriveTypeApp/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 20/DriveTypeApp/My Project/AssemblyInfo.vb b/Code/Chapter 20/DriveTypeApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..4747a3f --- /dev/null +++ b/Code/Chapter 20/DriveTypeApp/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/Code/Chapter 20/DriveTypeApp/My Project/Resources.Designer.vb b/Code/Chapter 20/DriveTypeApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..861823c --- /dev/null +++ b/Code/Chapter 20/DriveTypeApp/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("DriveTypeApp.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/Code/Chapter 20/DriveTypeApp/My Project/Resources.resx b/Code/Chapter 20/DriveTypeApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 20/DriveTypeApp/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/Code/Chapter 20/DriveTypeApp/My Project/Settings.Designer.vb b/Code/Chapter 20/DriveTypeApp/My Project/Settings.Designer.vb new file mode 100644 index 0000000..9e6004a --- /dev/null +++ b/Code/Chapter 20/DriveTypeApp/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.DriveTypeApp.My.MySettings + Get + Return Global.DriveTypeApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 20/DriveTypeApp/My Project/Settings.settings b/Code/Chapter 20/DriveTypeApp/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 20/DriveTypeApp/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 20/DriveTypeApp/Program.vb b/Code/Chapter 20/DriveTypeApp/Program.vb new file mode 100644 index 0000000..9c74d54 --- /dev/null +++ b/Code/Chapter 20/DriveTypeApp/Program.vb @@ -0,0 +1,26 @@ +Option Explicit On +Option Strict On + +Imports System.IO + +Module Program + Sub Main() + Console.WriteLine("***** Fun with DriveInfo *****") + Dim myDrives As DriveInfo() = DriveInfo.GetDrives() + + ' Print stats about each drive. + For Each d As DriveInfo In myDrives + Console.WriteLine("******************************") + Console.WriteLine("-> Name: {0}", d.Name) + Console.WriteLine("-> Type: {0}", d.DriveType) + + ' Is the drive mounted? + If d.IsReady Then + Console.WriteLine("-> Free space: {0}", d.TotalFreeSpace) + Console.WriteLine("-> Format: {0}", d.DriveFormat) + Console.WriteLine("-> Label: {0}", d.VolumeLabel) + End If + Next + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 20/FileStreamApp/FileStreamApp.sln b/Code/Chapter 20/FileStreamApp/FileStreamApp.sln new file mode 100644 index 0000000..af4fc88 --- /dev/null +++ b/Code/Chapter 20/FileStreamApp/FileStreamApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "FileStreamApp", "FileStreamApp.vbproj", "{EAAE0BEB-F9CD-41E4-BB3E-DEC0C2B19657}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EAAE0BEB-F9CD-41E4-BB3E-DEC0C2B19657}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EAAE0BEB-F9CD-41E4-BB3E-DEC0C2B19657}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EAAE0BEB-F9CD-41E4-BB3E-DEC0C2B19657}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EAAE0BEB-F9CD-41E4-BB3E-DEC0C2B19657}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 20/FileStreamApp/FileStreamApp.suo b/Code/Chapter 20/FileStreamApp/FileStreamApp.suo new file mode 100644 index 0000000..af77eff Binary files /dev/null and b/Code/Chapter 20/FileStreamApp/FileStreamApp.suo differ diff --git a/Code/Chapter 20/FileStreamApp/FileStreamApp.vbproj b/Code/Chapter 20/FileStreamApp/FileStreamApp.vbproj new file mode 100644 index 0000000..f625e2c --- /dev/null +++ b/Code/Chapter 20/FileStreamApp/FileStreamApp.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {EAAE0BEB-F9CD-41E4-BB3E-DEC0C2B19657} + Exe + FileStreamApp.Program + FileStreamApp + FileStreamApp + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + FileStreamApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + FileStreamApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 20/FileStreamApp/FileStreamApp.vbproj.user b/Code/Chapter 20/FileStreamApp/FileStreamApp.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 20/FileStreamApp/FileStreamApp.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 20/FileStreamApp/My Project/Application.Designer.vb b/Code/Chapter 20/FileStreamApp/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 20/FileStreamApp/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 20/FileStreamApp/My Project/Application.myapp b/Code/Chapter 20/FileStreamApp/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 20/FileStreamApp/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 20/FileStreamApp/My Project/AssemblyInfo.vb b/Code/Chapter 20/FileStreamApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..a7e8da8 --- /dev/null +++ b/Code/Chapter 20/FileStreamApp/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/Code/Chapter 20/FileStreamApp/My Project/Resources.Designer.vb b/Code/Chapter 20/FileStreamApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..fb00615 --- /dev/null +++ b/Code/Chapter 20/FileStreamApp/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("FileStreamApp.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/Code/Chapter 20/FileStreamApp/My Project/Resources.resx b/Code/Chapter 20/FileStreamApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 20/FileStreamApp/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/Code/Chapter 20/FileStreamApp/My Project/Settings.Designer.vb b/Code/Chapter 20/FileStreamApp/My Project/Settings.Designer.vb new file mode 100644 index 0000000..a577226 --- /dev/null +++ b/Code/Chapter 20/FileStreamApp/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.FileStreamApp.My.MySettings + Get + Return Global.FileStreamApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 20/FileStreamApp/My Project/Settings.settings b/Code/Chapter 20/FileStreamApp/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 20/FileStreamApp/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 20/FileStreamApp/Program.vb b/Code/Chapter 20/FileStreamApp/Program.vb new file mode 100644 index 0000000..f6f4e37 --- /dev/null +++ b/Code/Chapter 20/FileStreamApp/Program.vb @@ -0,0 +1,41 @@ +Option Explicit On +Option Strict On + +Imports System.IO +Imports System.Text + +Module Program + Sub Main() + Console.WriteLine("***** Fun with FileStreams *****") + Console.WriteLine() + + ' Obtain a FileStream object. + Using fStream As FileStream = File.Open("C:\myMessage.dat", FileMode.Create) + ' Encode a string as an array of bytes. + Dim msg As String = "Hello!" + Dim msgAsByteArray As Byte() = Encoding.Default.GetBytes(msg) + + ' Write byte[] to file. + fStream.Write(msgAsByteArray, 0, msgAsByteArray.Length) + + ' Reset internal position of stream. + fStream.Position = 0 + + ' Read the types from file and display to console. + Console.Write("Your message as an array of bytes: ") + Dim bytesFromFile(msgAsByteArray.Length) As Byte + Dim i As Integer = 0 + While i < msgAsByteArray.Length + bytesFromFile(i) = CType(fStream.ReadByte, Byte) + Console.Write(bytesFromFile(i)) + i = i + 1 + End While + + ' Display decoded messages. + Console.WriteLine() + Console.Write("Decoded Message: ") + Console.WriteLine(Encoding.Default.GetString(bytesFromFile)) + End Using + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 20/MyDirectoryApp/My Project/Application.Designer.vb b/Code/Chapter 20/MyDirectoryApp/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 20/MyDirectoryApp/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 20/MyDirectoryApp/My Project/Application.myapp b/Code/Chapter 20/MyDirectoryApp/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 20/MyDirectoryApp/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 20/MyDirectoryApp/My Project/AssemblyInfo.vb b/Code/Chapter 20/MyDirectoryApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..baa4039 --- /dev/null +++ b/Code/Chapter 20/MyDirectoryApp/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/Code/Chapter 20/MyDirectoryApp/My Project/Resources.Designer.vb b/Code/Chapter 20/MyDirectoryApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..e296040 --- /dev/null +++ b/Code/Chapter 20/MyDirectoryApp/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("MyDirectoryApp.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/Code/Chapter 20/MyDirectoryApp/My Project/Resources.resx b/Code/Chapter 20/MyDirectoryApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 20/MyDirectoryApp/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/Code/Chapter 20/MyDirectoryApp/My Project/Settings.Designer.vb b/Code/Chapter 20/MyDirectoryApp/My Project/Settings.Designer.vb new file mode 100644 index 0000000..b59cb69 --- /dev/null +++ b/Code/Chapter 20/MyDirectoryApp/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.MyDirectoryApp.My.MySettings + Get + Return Global.MyDirectoryApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 20/MyDirectoryApp/My Project/Settings.settings b/Code/Chapter 20/MyDirectoryApp/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 20/MyDirectoryApp/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 20/MyDirectoryApp/MyDirectoryApp.sln b/Code/Chapter 20/MyDirectoryApp/MyDirectoryApp.sln new file mode 100644 index 0000000..9b57b1d --- /dev/null +++ b/Code/Chapter 20/MyDirectoryApp/MyDirectoryApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MyDirectoryApp", "MyDirectoryApp.vbproj", "{2B6255BA-48D7-4ED3-B237-288B1B9FDB18}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2B6255BA-48D7-4ED3-B237-288B1B9FDB18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2B6255BA-48D7-4ED3-B237-288B1B9FDB18}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2B6255BA-48D7-4ED3-B237-288B1B9FDB18}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2B6255BA-48D7-4ED3-B237-288B1B9FDB18}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 20/MyDirectoryApp/MyDirectoryApp.suo b/Code/Chapter 20/MyDirectoryApp/MyDirectoryApp.suo new file mode 100644 index 0000000..88a6b7a Binary files /dev/null and b/Code/Chapter 20/MyDirectoryApp/MyDirectoryApp.suo differ diff --git a/Code/Chapter 20/MyDirectoryApp/MyDirectoryApp.vbproj b/Code/Chapter 20/MyDirectoryApp/MyDirectoryApp.vbproj new file mode 100644 index 0000000..40776ac --- /dev/null +++ b/Code/Chapter 20/MyDirectoryApp/MyDirectoryApp.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {2B6255BA-48D7-4ED3-B237-288B1B9FDB18} + Exe + MyDirectoryApp.Program + MyDirectoryApp + MyDirectoryApp + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + MyDirectoryApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + MyDirectoryApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 20/MyDirectoryApp/MyDirectoryApp.vbproj.user b/Code/Chapter 20/MyDirectoryApp/MyDirectoryApp.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 20/MyDirectoryApp/MyDirectoryApp.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 20/MyDirectoryApp/Program.vb b/Code/Chapter 20/MyDirectoryApp/Program.vb new file mode 100644 index 0000000..c18c128 --- /dev/null +++ b/Code/Chapter 20/MyDirectoryApp/Program.vb @@ -0,0 +1,81 @@ +Option Explicit On +Option Strict On + +Imports System.IO + +Module Program + Sub Main() + Console.WriteLine("***** Fun with Directory(Info) *****") + Console.WriteLine() + + ShowWindowsDirectoryInfo() + DisplayImageFiles() + ModifyWindowsDirectory() + FunWithDirectoryType() + + Console.ReadLine() + End Sub + +#Region "Helper methods" + Sub ShowWindowsDirectoryInfo() + ' Get basic info about C:\Windows + Dim dir As New DirectoryInfo("C:\Windows") + Console.WriteLine("***** Directory Info *****") + Console.WriteLine("FullName: {0} ", dir.FullName) + Console.WriteLine("Name: {0} ", dir.Name) + Console.WriteLine("Parent: {0} ", dir.Parent) + Console.WriteLine("Creation: {0} ", dir.CreationTime) + Console.WriteLine("Attributes: {0} ", dir.Attributes) + Console.WriteLine("Root: {0} ", dir.Root) + Console.WriteLine("**************************") + Console.WriteLine() + End Sub + + Sub DisplayImageFiles() + ' Get all files with a *.jpg extension. + Dim dir As New DirectoryInfo("C:\Windows\Web\Wallpaper") + Dim bitmapFiles As FileInfo() = dir.GetFiles("*.jpg") + Console.WriteLine("Found {0} *.jpg files", bitmapFiles.Length) + For Each f As FileInfo In bitmapFiles + Console.WriteLine() + Console.WriteLine("File name: {0}", f.Name) + Console.WriteLine("File size: {0}", f.Length) + Console.WriteLine("Creation: {0}", f.CreationTime) + Console.WriteLine("Attributes: {0}", f.Attributes) + Console.WriteLine() + Console.WriteLine("***************************") + Next + End Sub + + Sub ModifyWindowsDirectory() + Dim dir As New DirectoryInfo("C:\Windows") + + ' Create \MyFolder off initial directory. + dir.CreateSubdirectory("MyFolder") + + ' Create \MyFolder2\Data off initial directory. + dir.CreateSubdirectory("MyFolder2\Data") + End Sub + + Sub FunWithDirectoryType() + ' Use Directory type. + Dim drives As String() = Directory.GetLogicalDrives() + Console.WriteLine("Here are your drives:") + For Each s As String In drives + Console.WriteLine("—>{0}", s) + Next + + ' Delete the directories we created. + Console.WriteLine("Press Enter to delete directories") + Console.ReadLine() + Try + Directory.Delete("C:\Windows\MyFolder") + Directory.Delete("C:\Windows\MyFolder2\Data") + Catch e As IOException + Console.WriteLine(e.Message) + End Try + End Sub +#End Region + +End Module + diff --git a/Code/Chapter 20/MyDirectoryWatcher/My Project/Application.Designer.vb b/Code/Chapter 20/MyDirectoryWatcher/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 20/MyDirectoryWatcher/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 20/MyDirectoryWatcher/My Project/Application.myapp b/Code/Chapter 20/MyDirectoryWatcher/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 20/MyDirectoryWatcher/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 20/MyDirectoryWatcher/My Project/AssemblyInfo.vb b/Code/Chapter 20/MyDirectoryWatcher/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..a0648b0 --- /dev/null +++ b/Code/Chapter 20/MyDirectoryWatcher/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/Code/Chapter 20/MyDirectoryWatcher/My Project/Resources.Designer.vb b/Code/Chapter 20/MyDirectoryWatcher/My Project/Resources.Designer.vb new file mode 100644 index 0000000..c04e55e --- /dev/null +++ b/Code/Chapter 20/MyDirectoryWatcher/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("MyDirectoryWatcher.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/Code/Chapter 20/MyDirectoryWatcher/My Project/Resources.resx b/Code/Chapter 20/MyDirectoryWatcher/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 20/MyDirectoryWatcher/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/Code/Chapter 20/MyDirectoryWatcher/My Project/Settings.Designer.vb b/Code/Chapter 20/MyDirectoryWatcher/My Project/Settings.Designer.vb new file mode 100644 index 0000000..ba01c51 --- /dev/null +++ b/Code/Chapter 20/MyDirectoryWatcher/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.MyDirectoryWatcher.My.MySettings + Get + Return Global.MyDirectoryWatcher.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 20/MyDirectoryWatcher/My Project/Settings.settings b/Code/Chapter 20/MyDirectoryWatcher/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 20/MyDirectoryWatcher/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 20/MyDirectoryWatcher/MyDirectoryWatcher.sln b/Code/Chapter 20/MyDirectoryWatcher/MyDirectoryWatcher.sln new file mode 100644 index 0000000..99a90e3 --- /dev/null +++ b/Code/Chapter 20/MyDirectoryWatcher/MyDirectoryWatcher.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MyDirectoryWatcher", "MyDirectoryWatcher.vbproj", "{D7053C65-D85C-49B7-8DE3-2587F58B5C55}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D7053C65-D85C-49B7-8DE3-2587F58B5C55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D7053C65-D85C-49B7-8DE3-2587F58B5C55}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D7053C65-D85C-49B7-8DE3-2587F58B5C55}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D7053C65-D85C-49B7-8DE3-2587F58B5C55}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 20/MyDirectoryWatcher/MyDirectoryWatcher.suo b/Code/Chapter 20/MyDirectoryWatcher/MyDirectoryWatcher.suo new file mode 100644 index 0000000..5474a27 Binary files /dev/null and b/Code/Chapter 20/MyDirectoryWatcher/MyDirectoryWatcher.suo differ diff --git a/Code/Chapter 20/MyDirectoryWatcher/MyDirectoryWatcher.vbproj b/Code/Chapter 20/MyDirectoryWatcher/MyDirectoryWatcher.vbproj new file mode 100644 index 0000000..14fcee4 --- /dev/null +++ b/Code/Chapter 20/MyDirectoryWatcher/MyDirectoryWatcher.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {D7053C65-D85C-49B7-8DE3-2587F58B5C55} + Exe + MyDirectoryWatcher.Program + MyDirectoryWatcher + MyDirectoryWatcher + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + MyDirectoryWatcher.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + MyDirectoryWatcher.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 20/MyDirectoryWatcher/MyDirectoryWatcher.vbproj.user b/Code/Chapter 20/MyDirectoryWatcher/MyDirectoryWatcher.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 20/MyDirectoryWatcher/MyDirectoryWatcher.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 20/MyDirectoryWatcher/Program.vb b/Code/Chapter 20/MyDirectoryWatcher/Program.vb new file mode 100644 index 0000000..8562549 --- /dev/null +++ b/Code/Chapter 20/MyDirectoryWatcher/Program.vb @@ -0,0 +1,46 @@ +Option Explicit On +Option Strict On + +Imports System.IO + +Module Program + Sub Main() + Console.WriteLine("***** The Amazing File Watcher App *****") + + ' Create and configre the watcher. + Dim watcher As New FileSystemWatcher() + Try + watcher.Path = "C:\MyFolder" + Catch ex As ArgumentException + Console.WriteLine(ex.Message) + Return + End Try + watcher.NotifyFilter = NotifyFilters.LastAccess Or _ + NotifyFilters.LastWrite Or _ + NotifyFilters.FileName Or _ + NotifyFilters.DirectoryName + watcher.Filter = "*.txt" + + ' Establish event handlers. + AddHandler watcher.Changed, AddressOf OnFileModified + AddHandler watcher.Created, AddressOf OnFileModified + AddHandler watcher.Deleted, AddressOf OnFileModified + AddHandler watcher.Renamed, AddressOf OnFileRenamed + watcher.EnableRaisingEvents = True + + Console.WriteLine("Press 'q' to quit app.") + Console.ReadLine() + End Sub + + ' Event handlers. + Sub OnFileModified(ByVal source As Object, ByVal e As FileSystemEventArgs) + ' Specify what is done when a file is changed, created, or deleted. + Console.WriteLine("File: {0} {1}!", e.FullPath, e.ChangeType) + End Sub + + Sub OnFileRenamed(ByVal source As Object, ByVal e As RenamedEventArgs) + ' Specify what is done when a file is renamed. + Console.WriteLine("File: {0} renamed to {1}.", e.OldFullPath, e.FullPath) + End Sub +End Module + diff --git a/Code/Chapter 20/SimpleFileIO/My Project/Application.Designer.vb b/Code/Chapter 20/SimpleFileIO/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 20/SimpleFileIO/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 20/SimpleFileIO/My Project/Application.myapp b/Code/Chapter 20/SimpleFileIO/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 20/SimpleFileIO/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 20/SimpleFileIO/My Project/AssemblyInfo.vb b/Code/Chapter 20/SimpleFileIO/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..9178d16 --- /dev/null +++ b/Code/Chapter 20/SimpleFileIO/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/Code/Chapter 20/SimpleFileIO/My Project/Resources.Designer.vb b/Code/Chapter 20/SimpleFileIO/My Project/Resources.Designer.vb new file mode 100644 index 0000000..9961869 --- /dev/null +++ b/Code/Chapter 20/SimpleFileIO/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("SimpleFileIO.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/Code/Chapter 20/SimpleFileIO/My Project/Resources.resx b/Code/Chapter 20/SimpleFileIO/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 20/SimpleFileIO/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/Code/Chapter 20/SimpleFileIO/My Project/Settings.Designer.vb b/Code/Chapter 20/SimpleFileIO/My Project/Settings.Designer.vb new file mode 100644 index 0000000..91cc2f5 --- /dev/null +++ b/Code/Chapter 20/SimpleFileIO/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SimpleFileIO.My.MySettings + Get + Return Global.SimpleFileIO.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 20/SimpleFileIO/My Project/Settings.settings b/Code/Chapter 20/SimpleFileIO/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 20/SimpleFileIO/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 20/SimpleFileIO/Program.vb b/Code/Chapter 20/SimpleFileIO/Program.vb new file mode 100644 index 0000000..ea408a6 --- /dev/null +++ b/Code/Chapter 20/SimpleFileIO/Program.vb @@ -0,0 +1,19 @@ +Imports System.IO + +Module Program + Sub Main() + ' Write these strings to a new file on the C drive. + Dim myTasks As String() = {"Fix bathroom sink", _ + "Call Dave", "Call Mom and Dad", _ + "Play Xbox 360"} + File.WriteAllLines("C:\tasks.txt", myTasks) + + ' Now read in each one and print to the console. + For Each task As String In File.ReadAllLines("C:\tasks.txt") + Console.WriteLine("TODO: {0}.", task) + Next + + Console.ReadLine() + + End Sub +End Module diff --git a/Code/Chapter 20/SimpleFileIO/SimpleFileIO.sln b/Code/Chapter 20/SimpleFileIO/SimpleFileIO.sln new file mode 100644 index 0000000..1727966 --- /dev/null +++ b/Code/Chapter 20/SimpleFileIO/SimpleFileIO.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SimpleFileIO", "SimpleFileIO.vbproj", "{785A99ED-A908-4A22-A9A0-0404F2D39515}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {785A99ED-A908-4A22-A9A0-0404F2D39515}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {785A99ED-A908-4A22-A9A0-0404F2D39515}.Debug|Any CPU.Build.0 = Debug|Any CPU + {785A99ED-A908-4A22-A9A0-0404F2D39515}.Release|Any CPU.ActiveCfg = Release|Any CPU + {785A99ED-A908-4A22-A9A0-0404F2D39515}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 20/SimpleFileIO/SimpleFileIO.suo b/Code/Chapter 20/SimpleFileIO/SimpleFileIO.suo new file mode 100644 index 0000000..dbe010a Binary files /dev/null and b/Code/Chapter 20/SimpleFileIO/SimpleFileIO.suo differ diff --git a/Code/Chapter 20/SimpleFileIO/SimpleFileIO.vbproj b/Code/Chapter 20/SimpleFileIO/SimpleFileIO.vbproj new file mode 100644 index 0000000..c0c345c --- /dev/null +++ b/Code/Chapter 20/SimpleFileIO/SimpleFileIO.vbproj @@ -0,0 +1,109 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {785A99ED-A908-4A22-A9A0-0404F2D39515} + Exe + SimpleFileIO.Program + SimpleFileIO + SimpleFileIO + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + SimpleFileIO.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SimpleFileIO.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 20/StreamWriterReaderApp/My Project/Application.Designer.vb b/Code/Chapter 20/StreamWriterReaderApp/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 20/StreamWriterReaderApp/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 20/StreamWriterReaderApp/My Project/Application.myapp b/Code/Chapter 20/StreamWriterReaderApp/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 20/StreamWriterReaderApp/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 20/StreamWriterReaderApp/My Project/AssemblyInfo.vb b/Code/Chapter 20/StreamWriterReaderApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..197dd0e --- /dev/null +++ b/Code/Chapter 20/StreamWriterReaderApp/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/Code/Chapter 20/StreamWriterReaderApp/My Project/Resources.Designer.vb b/Code/Chapter 20/StreamWriterReaderApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..4659377 --- /dev/null +++ b/Code/Chapter 20/StreamWriterReaderApp/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("StreamWriterReaderApp.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/Code/Chapter 20/StreamWriterReaderApp/My Project/Resources.resx b/Code/Chapter 20/StreamWriterReaderApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 20/StreamWriterReaderApp/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/Code/Chapter 20/StreamWriterReaderApp/My Project/Settings.Designer.vb b/Code/Chapter 20/StreamWriterReaderApp/My Project/Settings.Designer.vb new file mode 100644 index 0000000..60dc233 --- /dev/null +++ b/Code/Chapter 20/StreamWriterReaderApp/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.StreamWriterReaderApp.My.MySettings + Get + Return Global.StreamWriterReaderApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 20/StreamWriterReaderApp/My Project/Settings.settings b/Code/Chapter 20/StreamWriterReaderApp/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 20/StreamWriterReaderApp/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 20/StreamWriterReaderApp/Program.vb b/Code/Chapter 20/StreamWriterReaderApp/Program.vb new file mode 100644 index 0000000..6758e77 --- /dev/null +++ b/Code/Chapter 20/StreamWriterReaderApp/Program.vb @@ -0,0 +1,31 @@ +Option Explicit On +Option Strict On + +Imports System.IO + +Module Program + Sub Main() + Console.WriteLine("***** Fun with StreamWriter / StreamReader *****") + Console.WriteLine() + + ' Get a StreamWriter and write string data. + Using writer As StreamWriter = File.CreateText("reminders.txt") + writer.WriteLine("Don't forget Mother's Day this year...") + writer.WriteLine("Don't forget Father's Day this year...") + writer.WriteLine("Don't forget these numbers:") + For i As Integer = 0 To 10 + writer.Write(String.Format("{0},", i)) + Next + + ' Insert a new line and close. + writer.Write(writer.NewLine) + End Using + Console.WriteLine("Created file and wrote some thoughts...") + + Console.WriteLine("Here are your thoughts:") + Using sr As StreamReader = File.OpenText("reminders.txt") + Console.WriteLine(sr.ReadToEnd()) + End Using + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 20/StreamWriterReaderApp/StreamWriterReaderApp.sln b/Code/Chapter 20/StreamWriterReaderApp/StreamWriterReaderApp.sln new file mode 100644 index 0000000..403c671 --- /dev/null +++ b/Code/Chapter 20/StreamWriterReaderApp/StreamWriterReaderApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "StreamWriterReaderApp", "StreamWriterReaderApp.vbproj", "{0AFD07A5-2964-4594-A6AC-9C4F17EA19A9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0AFD07A5-2964-4594-A6AC-9C4F17EA19A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0AFD07A5-2964-4594-A6AC-9C4F17EA19A9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0AFD07A5-2964-4594-A6AC-9C4F17EA19A9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0AFD07A5-2964-4594-A6AC-9C4F17EA19A9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 20/StreamWriterReaderApp/StreamWriterReaderApp.suo b/Code/Chapter 20/StreamWriterReaderApp/StreamWriterReaderApp.suo new file mode 100644 index 0000000..0617093 Binary files /dev/null and b/Code/Chapter 20/StreamWriterReaderApp/StreamWriterReaderApp.suo differ diff --git a/Code/Chapter 20/StreamWriterReaderApp/StreamWriterReaderApp.vbproj b/Code/Chapter 20/StreamWriterReaderApp/StreamWriterReaderApp.vbproj new file mode 100644 index 0000000..bda5f01 --- /dev/null +++ b/Code/Chapter 20/StreamWriterReaderApp/StreamWriterReaderApp.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {0AFD07A5-2964-4594-A6AC-9C4F17EA19A9} + Exe + StreamWriterReaderApp.Program + StreamWriterReaderApp + StreamWriterReaderApp + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + StreamWriterReaderApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + StreamWriterReaderApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 20/StreamWriterReaderApp/StreamWriterReaderApp.vbproj.user b/Code/Chapter 20/StreamWriterReaderApp/StreamWriterReaderApp.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 20/StreamWriterReaderApp/StreamWriterReaderApp.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 20/StringReaderWriterApp/My Project/Application.Designer.vb b/Code/Chapter 20/StringReaderWriterApp/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 20/StringReaderWriterApp/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 20/StringReaderWriterApp/My Project/Application.myapp b/Code/Chapter 20/StringReaderWriterApp/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 20/StringReaderWriterApp/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 20/StringReaderWriterApp/My Project/AssemblyInfo.vb b/Code/Chapter 20/StringReaderWriterApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..630bb4a --- /dev/null +++ b/Code/Chapter 20/StringReaderWriterApp/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/Code/Chapter 20/StringReaderWriterApp/My Project/Resources.Designer.vb b/Code/Chapter 20/StringReaderWriterApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..8006dc8 --- /dev/null +++ b/Code/Chapter 20/StringReaderWriterApp/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("StringReaderWriterApp.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/Code/Chapter 20/StringReaderWriterApp/My Project/Resources.resx b/Code/Chapter 20/StringReaderWriterApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 20/StringReaderWriterApp/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/Code/Chapter 20/StringReaderWriterApp/My Project/Settings.Designer.vb b/Code/Chapter 20/StringReaderWriterApp/My Project/Settings.Designer.vb new file mode 100644 index 0000000..da62f9c --- /dev/null +++ b/Code/Chapter 20/StringReaderWriterApp/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.StringReaderWriterApp.My.MySettings + Get + Return Global.StringReaderWriterApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 20/StringReaderWriterApp/My Project/Settings.settings b/Code/Chapter 20/StringReaderWriterApp/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 20/StringReaderWriterApp/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 20/StringReaderWriterApp/Program.vb b/Code/Chapter 20/StringReaderWriterApp/Program.vb new file mode 100644 index 0000000..86ba7ef --- /dev/null +++ b/Code/Chapter 20/StringReaderWriterApp/Program.vb @@ -0,0 +1,40 @@ +Option Explicit On +Option Strict On + +Imports System.IO +Imports System.Text + +Module Program + Sub Main() + Console.WriteLine("***** Fun with StringWriter / StringReader *****") + Console.WriteLine() + + ' Create a StringWriter and emit character data + ' to memory. + Using strWriter As New StringWriter() + strWriter.Write("Don't forget Mother's Day this year...") + ' Get a copy of the contents (stored in a string) and pump + ' to console. + Console.WriteLine("Contents of StringWriter: {0}", strWriter) + + + ' Get the internal StringBuilder. + Dim sb As StringBuilder = strWriter.GetStringBuilder() + sb.Insert(0, "Hey!! ") + Console.WriteLine("-> {0}", sb.ToString()) + + ' Remove the inserted string. + sb.Remove(0, "Hey!! ".Length) + Console.WriteLine("-> {0}", sb.ToString()) + + ' Now dump using a StringReader. + Console.WriteLine("-> Here are your thoughts:") + Using strReader As New StringReader(strWriter.ToString()) + Dim input As String = strReader.ReadToEnd() + Console.WriteLine(input) + End Using + End Using + + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 20/StringReaderWriterApp/StringReaderWriterApp.sln b/Code/Chapter 20/StringReaderWriterApp/StringReaderWriterApp.sln new file mode 100644 index 0000000..4d1f8d7 --- /dev/null +++ b/Code/Chapter 20/StringReaderWriterApp/StringReaderWriterApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "StringReaderWriterApp", "StringReaderWriterApp.vbproj", "{A61B2E5C-127C-4A97-BBA2-2FE8B758E351}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A61B2E5C-127C-4A97-BBA2-2FE8B758E351}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A61B2E5C-127C-4A97-BBA2-2FE8B758E351}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A61B2E5C-127C-4A97-BBA2-2FE8B758E351}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A61B2E5C-127C-4A97-BBA2-2FE8B758E351}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 20/StringReaderWriterApp/StringReaderWriterApp.suo b/Code/Chapter 20/StringReaderWriterApp/StringReaderWriterApp.suo new file mode 100644 index 0000000..fa475e0 Binary files /dev/null and b/Code/Chapter 20/StringReaderWriterApp/StringReaderWriterApp.suo differ diff --git a/Code/Chapter 20/StringReaderWriterApp/StringReaderWriterApp.vbproj b/Code/Chapter 20/StringReaderWriterApp/StringReaderWriterApp.vbproj new file mode 100644 index 0000000..36559a7 --- /dev/null +++ b/Code/Chapter 20/StringReaderWriterApp/StringReaderWriterApp.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {A61B2E5C-127C-4A97-BBA2-2FE8B758E351} + Exe + StringReaderWriterApp.Program + StringReaderWriterApp + StringReaderWriterApp + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + StringReaderWriterApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + StringReaderWriterApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 20/StringReaderWriterApp/StringReaderWriterApp.vbproj.user b/Code/Chapter 20/StringReaderWriterApp/StringReaderWriterApp.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 20/StringReaderWriterApp/StringReaderWriterApp.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 21/CustomSerialization/CustomData.vb b/Code/Chapter 21/CustomSerialization/CustomData.vb new file mode 100644 index 0000000..4083a00 --- /dev/null +++ b/Code/Chapter 21/CustomSerialization/CustomData.vb @@ -0,0 +1,55 @@ +Option Explicit On +Option Strict On + +Imports System.Runtime.Serialization + +#Region "Using ISerializable" + _ +Class MyStringData + Implements ISerializable + + Public dataItemOne As String + Public dataItemTwo As String + + Public Sub New() + End Sub + + ' Called by formatter when object graph is being deseralized. + Private Sub New(ByVal si As SerializationInfo, ByVal ctx As StreamingContext) + dataItemOne = si.GetString("First_Item").ToLower() + dataItemTwo = si.GetString("dataItemTwo").ToLower() + End Sub + + ' Called by formatter when object is being serialized. + Public Sub GetObjectData(ByVal info As SerializationInfo, _ + ByVal context As StreamingContext) Implements ISerializable.GetObjectData + info.AddValue("First_Item", dataItemOne.ToUpper()) + info.AddValue("dataItemTwo", dataItemTwo.ToUpper()) + End Sub +End Class +#End Region + +#Region "Using attributes" + _ +Class MoreStringData + Public dataItemOne As String + Public dataItemTwo As String + + ' This method is called by the formatter when the + ' object is being serialized. + _ + Private Sub OnSerializing(ByVal context As StreamingContext) + dataItemOne = dataItemOne.ToUpper() + dataItemTwo = dataItemTwo.ToUpper() + End Sub + + ' This method is called by the formatter when the + ' object is being deserialized. + _ + Private Sub OnDeserialized(ByVal context As StreamingContext) + dataItemOne = dataItemOne.ToLower() + dataItemTwo = dataItemTwo.ToLower() + End Sub +End Class + +#End Region \ No newline at end of file diff --git a/Code/Chapter 21/CustomSerialization/CustomSerialization.sln b/Code/Chapter 21/CustomSerialization/CustomSerialization.sln new file mode 100644 index 0000000..3527b5a --- /dev/null +++ b/Code/Chapter 21/CustomSerialization/CustomSerialization.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CustomSerialization", "CustomSerialization.vbproj", "{598D0255-E338-48C3-AD7C-AB284777EB64}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {598D0255-E338-48C3-AD7C-AB284777EB64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {598D0255-E338-48C3-AD7C-AB284777EB64}.Debug|Any CPU.Build.0 = Debug|Any CPU + {598D0255-E338-48C3-AD7C-AB284777EB64}.Release|Any CPU.ActiveCfg = Release|Any CPU + {598D0255-E338-48C3-AD7C-AB284777EB64}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 21/CustomSerialization/CustomSerialization.suo b/Code/Chapter 21/CustomSerialization/CustomSerialization.suo new file mode 100644 index 0000000..05bab49 Binary files /dev/null and b/Code/Chapter 21/CustomSerialization/CustomSerialization.suo differ diff --git a/Code/Chapter 21/CustomSerialization/CustomSerialization.vbproj b/Code/Chapter 21/CustomSerialization/CustomSerialization.vbproj new file mode 100644 index 0000000..a17d3ea --- /dev/null +++ b/Code/Chapter 21/CustomSerialization/CustomSerialization.vbproj @@ -0,0 +1,136 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {598D0255-E338-48C3-AD7C-AB284777EB64} + Exe + CustomSerialization.Program + CustomSerialization + CustomSerialization + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + CustomSerialization.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + CustomSerialization.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 21/CustomSerialization/CustomSerialization.vbproj.user b/Code/Chapter 21/CustomSerialization/CustomSerialization.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 21/CustomSerialization/CustomSerialization.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 21/CustomSerialization/My Project/Application.Designer.vb b/Code/Chapter 21/CustomSerialization/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 21/CustomSerialization/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 21/CustomSerialization/My Project/Application.myapp b/Code/Chapter 21/CustomSerialization/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 21/CustomSerialization/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 21/CustomSerialization/My Project/AssemblyInfo.vb b/Code/Chapter 21/CustomSerialization/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..c79bc15 --- /dev/null +++ b/Code/Chapter 21/CustomSerialization/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/Code/Chapter 21/CustomSerialization/My Project/Resources.Designer.vb b/Code/Chapter 21/CustomSerialization/My Project/Resources.Designer.vb new file mode 100644 index 0000000..aab8292 --- /dev/null +++ b/Code/Chapter 21/CustomSerialization/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("CustomSerialization.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/Code/Chapter 21/CustomSerialization/My Project/Resources.resx b/Code/Chapter 21/CustomSerialization/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 21/CustomSerialization/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/Code/Chapter 21/CustomSerialization/My Project/Settings.Designer.vb b/Code/Chapter 21/CustomSerialization/My Project/Settings.Designer.vb new file mode 100644 index 0000000..9b1fb87 --- /dev/null +++ b/Code/Chapter 21/CustomSerialization/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CustomSerialization.My.MySettings + Get + Return Global.CustomSerialization.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 21/CustomSerialization/My Project/Settings.settings b/Code/Chapter 21/CustomSerialization/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 21/CustomSerialization/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 21/CustomSerialization/Program.vb b/Code/Chapter 21/CustomSerialization/Program.vb new file mode 100644 index 0000000..9c83052 --- /dev/null +++ b/Code/Chapter 21/CustomSerialization/Program.vb @@ -0,0 +1,50 @@ +Option Explicit On +Option Strict On + +Imports System.Runtime.Serialization +Imports System.IO +Imports System.Runtime.Serialization.Formatters.Soap + +Module Program + Sub Main() + Console.WriteLine("***** Fun with Custom Serialization *****") + Console.WriteLine() + + ' Persist MyStringData + Dim sd As MyStringData = New MyStringData() + sd.dataItemOne = "This is some data." + sd.dataItemTwo = "Here is some more data" + Dim s As Stream = New FileStream("MyData.soap", FileMode.Create, _ + FileAccess.Write, FileShare.None) + Dim sf As SoapFormatter = New SoapFormatter() + sf.Serialize(s, sd) + s.Close() + + ' Deserialize. + s = File.OpenRead("MyData.soap") + sd = CType(sf.Deserialize(s), MyStringData) + Console.WriteLine("Item 1: {0}", sd.dataItemOne) + Console.WriteLine("Item 2: {0}", sd.dataItemTwo) + + ' Persist MoreData + Dim md As MoreStringData = New MoreStringData() + md.dataItemOne = "Testing 1, 2, 3." + md.dataItemTwo = "One more test..." + s = New FileStream("MoreStringData.soap", FileMode.Create, FileAccess.Write, FileShare.None) + sf = New SoapFormatter() + sf.Serialize(s, md) + s.Close() + + ' Deserialize + s = File.OpenRead("MoreStringData.soap") + md = CType(sf.Deserialize(s), MoreStringData) + Console.WriteLine("Item 1: {0}", md.dataItemOne) + Console.WriteLine("Item 2: {0}", md.dataItemTwo) + Console.WriteLine("Done!") + Console.ReadLine() + End Sub +End Module + + + + diff --git a/Code/Chapter 21/SimpleSerialization/My Project/Application.Designer.vb b/Code/Chapter 21/SimpleSerialization/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 21/SimpleSerialization/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 21/SimpleSerialization/My Project/Application.myapp b/Code/Chapter 21/SimpleSerialization/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 21/SimpleSerialization/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 21/SimpleSerialization/My Project/AssemblyInfo.vb b/Code/Chapter 21/SimpleSerialization/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..82076f6 --- /dev/null +++ b/Code/Chapter 21/SimpleSerialization/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/Code/Chapter 21/SimpleSerialization/My Project/Resources.Designer.vb b/Code/Chapter 21/SimpleSerialization/My Project/Resources.Designer.vb new file mode 100644 index 0000000..9a564e1 --- /dev/null +++ b/Code/Chapter 21/SimpleSerialization/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("SimpleSerialization.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/Code/Chapter 21/SimpleSerialization/My Project/Resources.resx b/Code/Chapter 21/SimpleSerialization/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 21/SimpleSerialization/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/Code/Chapter 21/SimpleSerialization/My Project/Settings.Designer.vb b/Code/Chapter 21/SimpleSerialization/My Project/Settings.Designer.vb new file mode 100644 index 0000000..fff256d --- /dev/null +++ b/Code/Chapter 21/SimpleSerialization/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SimpleSerialization.My.MySettings + Get + Return Global.SimpleSerialization.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 21/SimpleSerialization/My Project/Settings.settings b/Code/Chapter 21/SimpleSerialization/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 21/SimpleSerialization/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 21/SimpleSerialization/Program.vb b/Code/Chapter 21/SimpleSerialization/Program.vb new file mode 100644 index 0000000..64e9ada --- /dev/null +++ b/Code/Chapter 21/SimpleSerialization/Program.vb @@ -0,0 +1,67 @@ +Option Explicit On +Option Strict On + +Imports System.Runtime.Serialization.Formatters.Binary +Imports System.Runtime.Serialization.Formatters.Soap +Imports System.Xml.Serialization +Imports System.IO + +Module Program + Sub Main() + Console.WriteLine("***** Fun with Object Serialization *****") + ' Make a new object to persist. + Dim jbc As New JamesBondCar() + jbc.canFly = True + jbc.canSubmerge = False + jbc.theRadio.stationPresets = New Double() {89.3, 105.1, 97.1} + jbc.theRadio.hasTweeters = True + + ' Save the object in a binary format to + ' a local file. + Dim binFormat As New BinaryFormatter() + Dim fStream As Stream = New FileStream("CarData.dat", FileMode.Create, _ + FileAccess.Write, FileShare.None) + binFormat.Serialize(fStream, jbc) + fStream.Close() + Console.WriteLine("-> Saved JamesBondCar in binary format.") + + ' Now deserialize the object. + fStream = File.OpenRead("CarData.dat") + Dim carFromDisk As JamesBondCar = _ + CType(binFormat.Deserialize(fStream), JamesBondCar) + Console.WriteLine("Can this car fly? : {0} ", carFromDisk.canFly) + fStream.Close() + + ' Save object to a file named CarData.soap in SOAP format. + Dim soapFormat As New SoapFormatter() + fStream = New FileStream("CarData.soap", _ + FileMode.Create, FileAccess.Write, FileShare.None) + soapFormat.Serialize(fStream, jbc) + fStream.Close() + Console.WriteLine("-> Saved JamesBondCar in SOAP format.") + + ' Now as an XML format. + Dim xmlFormat As New XmlSerializer(GetType(JamesBondCar), _ + New Type() {GetType(Radio), GetType(Car)}) + fStream = New FileStream("CarData.xml", FileMode.Create, _ + FileAccess.Write, FileShare.None) + xmlFormat.Serialize(fStream, jbc) + fStream.Close() + Console.WriteLine("-> Saved JamesBondCar in XML format.") + + ' Now save a batch of objects. + Dim myCars As New List(Of JamesBondCar)() + myCars.Add(New JamesBondCar(True, True)) + myCars.Add(New JamesBondCar(True, False)) + myCars.Add(New JamesBondCar(False, True)) + myCars.Add(New JamesBondCar(False, False)) + fStream = New FileStream("CarCollection.xml", FileMode.Create, FileAccess.Write, FileShare.None) + xmlFormat = New XmlSerializer(GetType(List(Of JamesBondCar)), _ + New Type() {GetType(JamesBondCar), GetType(Car), GetType(Radio)}) + xmlFormat.Serialize(fStream, myCars) + fStream.Close() + Console.WriteLine("-> Saved List of JamesBondCar in XML format.") + Console.WriteLine("Done!") + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 21/SimpleSerialization/SerializableCars.vb b/Code/Chapter 21/SimpleSerialization/SerializableCars.vb new file mode 100644 index 0000000..d95d75e --- /dev/null +++ b/Code/Chapter 21/SimpleSerialization/SerializableCars.vb @@ -0,0 +1,38 @@ +Option Explicit On +Option Strict On + +Imports System.Xml.Serialization + + _ +Public Class Radio + Public hasTweeters As Boolean + Public hasSubWoofers As Boolean + Public stationPresets As Double() + _ + Public radioID As String = "XF-552RR6" +End Class + + _ +Public Class Car + Public theRadio As Radio = New Radio + Public isHatchBack As Boolean +End Class + + _ +Public Class JamesBondCar + Inherits Car + + Public Sub New(ByVal SkyWorthy As Boolean, ByVal SeaWorthy As Boolean) + canFly = SkyWorthy + canSubmerge = SeaWorthy + End Sub + + Public Sub New() + End Sub + _ + Public canFly As Boolean + _ + Public canSubmerge As Boolean +End Class + + diff --git a/Code/Chapter 21/SimpleSerialization/SimpleSerialization.sln b/Code/Chapter 21/SimpleSerialization/SimpleSerialization.sln new file mode 100644 index 0000000..8cd68af --- /dev/null +++ b/Code/Chapter 21/SimpleSerialization/SimpleSerialization.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SimpleSerialization", "SimpleSerialization.vbproj", "{60A2D13A-43FC-4F6E-8531-23622D710C94}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {60A2D13A-43FC-4F6E-8531-23622D710C94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {60A2D13A-43FC-4F6E-8531-23622D710C94}.Debug|Any CPU.Build.0 = Debug|Any CPU + {60A2D13A-43FC-4F6E-8531-23622D710C94}.Release|Any CPU.ActiveCfg = Release|Any CPU + {60A2D13A-43FC-4F6E-8531-23622D710C94}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 21/SimpleSerialization/SimpleSerialization.suo b/Code/Chapter 21/SimpleSerialization/SimpleSerialization.suo new file mode 100644 index 0000000..8588dce Binary files /dev/null and b/Code/Chapter 21/SimpleSerialization/SimpleSerialization.suo differ diff --git a/Code/Chapter 21/SimpleSerialization/SimpleSerialization.vbproj b/Code/Chapter 21/SimpleSerialization/SimpleSerialization.vbproj new file mode 100644 index 0000000..2ed3dae --- /dev/null +++ b/Code/Chapter 21/SimpleSerialization/SimpleSerialization.vbproj @@ -0,0 +1,136 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {60A2D13A-43FC-4F6E-8531-23622D710C94} + Exe + SimpleSerialization.Program + SimpleSerialization + SimpleSerialization + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + SimpleSerialization.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SimpleSerialization.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 21/SimpleSerialization/SimpleSerialization.vbproj.user b/Code/Chapter 21/SimpleSerialization/SimpleSerialization.vbproj.user new file mode 100644 index 0000000..1659b79 --- /dev/null +++ b/Code/Chapter 21/SimpleSerialization/SimpleSerialization.vbproj.user @@ -0,0 +1,17 @@ + + + ShowAllFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 22/AdoNetTransaction/AdoNetTransaction.sln b/Code/Chapter 22/AdoNetTransaction/AdoNetTransaction.sln new file mode 100644 index 0000000..335ac4a --- /dev/null +++ b/Code/Chapter 22/AdoNetTransaction/AdoNetTransaction.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AdoNetTransaction", "AdoNetTransaction.vbproj", "{4FFA264B-A7C3-4591-89E9-CF7326E95F3D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4FFA264B-A7C3-4591-89E9-CF7326E95F3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4FFA264B-A7C3-4591-89E9-CF7326E95F3D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4FFA264B-A7C3-4591-89E9-CF7326E95F3D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4FFA264B-A7C3-4591-89E9-CF7326E95F3D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 22/AdoNetTransaction/AdoNetTransaction.suo b/Code/Chapter 22/AdoNetTransaction/AdoNetTransaction.suo new file mode 100644 index 0000000..6d5c956 Binary files /dev/null and b/Code/Chapter 22/AdoNetTransaction/AdoNetTransaction.suo differ diff --git a/Code/Chapter 22/AdoNetTransaction/AdoNetTransaction.vbproj b/Code/Chapter 22/AdoNetTransaction/AdoNetTransaction.vbproj new file mode 100644 index 0000000..045fe12 --- /dev/null +++ b/Code/Chapter 22/AdoNetTransaction/AdoNetTransaction.vbproj @@ -0,0 +1,113 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {4FFA264B-A7C3-4591-89E9-CF7326E95F3D} + Exe + AdoNetTransaction.Program + AdoNetTransaction + AdoNetTransaction + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + AdoNetTransaction.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + AdoNetTransaction.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + False + ..\AutoLotDAL\bin\Debug\AutoLotDAL.dll + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 22/AdoNetTransaction/My Project/Application.Designer.vb b/Code/Chapter 22/AdoNetTransaction/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 22/AdoNetTransaction/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 22/AdoNetTransaction/My Project/Application.myapp b/Code/Chapter 22/AdoNetTransaction/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 22/AdoNetTransaction/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 22/AdoNetTransaction/My Project/AssemblyInfo.vb b/Code/Chapter 22/AdoNetTransaction/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..4cc87cb --- /dev/null +++ b/Code/Chapter 22/AdoNetTransaction/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/Code/Chapter 22/AdoNetTransaction/My Project/Resources.Designer.vb b/Code/Chapter 22/AdoNetTransaction/My Project/Resources.Designer.vb new file mode 100644 index 0000000..cd7a798 --- /dev/null +++ b/Code/Chapter 22/AdoNetTransaction/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("AdoNetTransaction.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/Code/Chapter 22/AdoNetTransaction/My Project/Resources.resx b/Code/Chapter 22/AdoNetTransaction/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 22/AdoNetTransaction/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/Code/Chapter 22/AdoNetTransaction/My Project/Settings.Designer.vb b/Code/Chapter 22/AdoNetTransaction/My Project/Settings.Designer.vb new file mode 100644 index 0000000..2068ba0 --- /dev/null +++ b/Code/Chapter 22/AdoNetTransaction/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.AdoNetTransaction.My.MySettings + Get + Return Global.AdoNetTransaction.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 22/AdoNetTransaction/My Project/Settings.settings b/Code/Chapter 22/AdoNetTransaction/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 22/AdoNetTransaction/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 22/AdoNetTransaction/Program.vb b/Code/Chapter 22/AdoNetTransaction/Program.vb new file mode 100644 index 0000000..c59c97d --- /dev/null +++ b/Code/Chapter 22/AdoNetTransaction/Program.vb @@ -0,0 +1,27 @@ +Imports AutoLotConnectedLayer + +Module Program + + Sub Main() + Console.WriteLine("***** Simple Transaction Example *****" & vbLf) + + ' A simple way to allow the tx to work or not. + Dim throwEx As Boolean = True + Dim userAnswer As String = String.Empty + + Console.Write("Do you want to throw an exception (Y or N): ") + userAnswer = Console.ReadLine() + If userAnswer.ToLower() = "n" Then + throwEx = False + End If + + Dim dal As New InventoryDAL() + dal.OpenConnection("Data Source=(local);Integrated Security=SSPI;" & _ + "Initial Catalog=AutoLot") + + ' Process customer 999. + dal.ProcessCreditRisk(throwEx, 333) + Console.ReadLine() + End Sub + +End Module diff --git a/Code/Chapter 22/AsyncCmdObjectApp/AsyncCmdObjectApp.sln b/Code/Chapter 22/AsyncCmdObjectApp/AsyncCmdObjectApp.sln new file mode 100644 index 0000000..0de5670 --- /dev/null +++ b/Code/Chapter 22/AsyncCmdObjectApp/AsyncCmdObjectApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AsyncCmdObjectApp", "AsyncCmdObjectApp.vbproj", "{D19DB5C6-44DB-4EE6-8FE2-4713C2C85B48}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D19DB5C6-44DB-4EE6-8FE2-4713C2C85B48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D19DB5C6-44DB-4EE6-8FE2-4713C2C85B48}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D19DB5C6-44DB-4EE6-8FE2-4713C2C85B48}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D19DB5C6-44DB-4EE6-8FE2-4713C2C85B48}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 22/AsyncCmdObjectApp/AsyncCmdObjectApp.suo b/Code/Chapter 22/AsyncCmdObjectApp/AsyncCmdObjectApp.suo new file mode 100644 index 0000000..22cc50e Binary files /dev/null and b/Code/Chapter 22/AsyncCmdObjectApp/AsyncCmdObjectApp.suo differ diff --git a/Code/Chapter 22/AsyncCmdObjectApp/AsyncCmdObjectApp.vbproj b/Code/Chapter 22/AsyncCmdObjectApp/AsyncCmdObjectApp.vbproj new file mode 100644 index 0000000..a892d9d --- /dev/null +++ b/Code/Chapter 22/AsyncCmdObjectApp/AsyncCmdObjectApp.vbproj @@ -0,0 +1,109 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {D19DB5C6-44DB-4EE6-8FE2-4713C2C85B48} + Exe + AsyncCmdObjectApp.Program + AsyncCmdObjectApp + AsyncCmdObjectApp + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + AsyncCmdObjectApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + AsyncCmdObjectApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 22/AsyncCmdObjectApp/My Project/Application.Designer.vb b/Code/Chapter 22/AsyncCmdObjectApp/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 22/AsyncCmdObjectApp/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 22/AsyncCmdObjectApp/My Project/Application.myapp b/Code/Chapter 22/AsyncCmdObjectApp/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 22/AsyncCmdObjectApp/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 22/AsyncCmdObjectApp/My Project/AssemblyInfo.vb b/Code/Chapter 22/AsyncCmdObjectApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..c16a179 --- /dev/null +++ b/Code/Chapter 22/AsyncCmdObjectApp/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/Code/Chapter 22/AsyncCmdObjectApp/My Project/Resources.Designer.vb b/Code/Chapter 22/AsyncCmdObjectApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..1f18051 --- /dev/null +++ b/Code/Chapter 22/AsyncCmdObjectApp/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("AsyncCmdObjectApp.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/Code/Chapter 22/AsyncCmdObjectApp/My Project/Resources.resx b/Code/Chapter 22/AsyncCmdObjectApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 22/AsyncCmdObjectApp/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/Code/Chapter 22/AsyncCmdObjectApp/My Project/Settings.Designer.vb b/Code/Chapter 22/AsyncCmdObjectApp/My Project/Settings.Designer.vb new file mode 100644 index 0000000..a5dce9f --- /dev/null +++ b/Code/Chapter 22/AsyncCmdObjectApp/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.AsyncCmdObjectApp.My.MySettings + Get + Return Global.AsyncCmdObjectApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 22/AsyncCmdObjectApp/My Project/Settings.settings b/Code/Chapter 22/AsyncCmdObjectApp/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 22/AsyncCmdObjectApp/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 22/AsyncCmdObjectApp/Program.vb b/Code/Chapter 22/AsyncCmdObjectApp/Program.vb new file mode 100644 index 0000000..63e3b7d --- /dev/null +++ b/Code/Chapter 22/AsyncCmdObjectApp/Program.vb @@ -0,0 +1,40 @@ +Imports System.Data.SqlClient +Imports System.Threading + +Module Program + Sub Main() + Console.WriteLine("***** Fun with ASNYC Data Readers *****" & vbLf) + + ' Create and open a connection that is async-aware. + Dim cn As New SqlConnection() + cn.ConnectionString = "Data Source=(local)\SQLEXPRESS" & _ + ";Integrated Security=SSPI;" & _ + "Initial Catalog=AutoLot;Asynchronous Processing=true" + cn.Open() + + ' Create a SQL command object that waits for approx 2 seconds. + Dim strSQL As String = "WaitFor Delay '00:00:02';Select * From Inventory" + Dim myCommand As New SqlCommand(strSQL, cn) + + ' Execute the reader on a second thread. + Dim itfAsynch As IAsyncResult + itfAsynch = myCommand.BeginExecuteReader(CommandBehavior.CloseConnection) + + ' Do something while other thread works. + While Not itfAsynch.IsCompleted + Console.WriteLine("Working on main thread...") + Thread.Sleep(1000) + End While + Console.WriteLine() + + ' All done! Get reader and loop over results. + Dim myDataReader As SqlDataReader = myCommand.EndExecuteReader(itfAsynch) + While myDataReader.Read() + Console.WriteLine("-> Make: {0}, PetName: {1}, Color: {2}.", _ + myDataReader("Make").ToString().Trim(), _ + myDataReader("PetName").ToString().Trim(), _ + myDataReader("Color").ToString().Trim()) + End While + myDataReader.Close() + End Sub +End Module diff --git a/Code/Chapter 22/AutoLotCUIClient/AutoLotCUIClient.sln b/Code/Chapter 22/AutoLotCUIClient/AutoLotCUIClient.sln new file mode 100644 index 0000000..1833d48 --- /dev/null +++ b/Code/Chapter 22/AutoLotCUIClient/AutoLotCUIClient.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AutoLotCUIClient", "AutoLotCUIClient.vbproj", "{B8C11D34-D3CA-49C5-8CE7-3575E81EF0D9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B8C11D34-D3CA-49C5-8CE7-3575E81EF0D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B8C11D34-D3CA-49C5-8CE7-3575E81EF0D9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B8C11D34-D3CA-49C5-8CE7-3575E81EF0D9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B8C11D34-D3CA-49C5-8CE7-3575E81EF0D9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 22/AutoLotCUIClient/AutoLotCUIClient.suo b/Code/Chapter 22/AutoLotCUIClient/AutoLotCUIClient.suo new file mode 100644 index 0000000..7dfb3bd Binary files /dev/null and b/Code/Chapter 22/AutoLotCUIClient/AutoLotCUIClient.suo differ diff --git a/Code/Chapter 22/AutoLotCUIClient/AutoLotCUIClient.vbproj b/Code/Chapter 22/AutoLotCUIClient/AutoLotCUIClient.vbproj new file mode 100644 index 0000000..9720756 --- /dev/null +++ b/Code/Chapter 22/AutoLotCUIClient/AutoLotCUIClient.vbproj @@ -0,0 +1,115 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {B8C11D34-D3CA-49C5-8CE7-3575E81EF0D9} + Exe + AutoLotCUIClient.Program + AutoLotCUIClient + AutoLotCUIClient + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + AutoLotCUIClient.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + AutoLotCUIClient.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + False + ..\AutoLotDAL\bin\Debug\AutoLotDAL.dll + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 22/AutoLotCUIClient/My Project/Application.Designer.vb b/Code/Chapter 22/AutoLotCUIClient/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 22/AutoLotCUIClient/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 22/AutoLotCUIClient/My Project/Application.myapp b/Code/Chapter 22/AutoLotCUIClient/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 22/AutoLotCUIClient/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 22/AutoLotCUIClient/My Project/AssemblyInfo.vb b/Code/Chapter 22/AutoLotCUIClient/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..2ccd277 --- /dev/null +++ b/Code/Chapter 22/AutoLotCUIClient/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/Code/Chapter 22/AutoLotCUIClient/My Project/Resources.Designer.vb b/Code/Chapter 22/AutoLotCUIClient/My Project/Resources.Designer.vb new file mode 100644 index 0000000..f7a480d --- /dev/null +++ b/Code/Chapter 22/AutoLotCUIClient/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("AutoLotCUIClient.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/Code/Chapter 22/AutoLotCUIClient/My Project/Resources.resx b/Code/Chapter 22/AutoLotCUIClient/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 22/AutoLotCUIClient/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/Code/Chapter 22/AutoLotCUIClient/My Project/Settings.Designer.vb b/Code/Chapter 22/AutoLotCUIClient/My Project/Settings.Designer.vb new file mode 100644 index 0000000..906cc80 --- /dev/null +++ b/Code/Chapter 22/AutoLotCUIClient/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.AutoLotCUIClient.My.MySettings + Get + Return Global.AutoLotCUIClient.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 22/AutoLotCUIClient/My Project/Settings.settings b/Code/Chapter 22/AutoLotCUIClient/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 22/AutoLotCUIClient/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 22/AutoLotCUIClient/Program.vb b/Code/Chapter 22/AutoLotCUIClient/Program.vb new file mode 100644 index 0000000..67cd7ae --- /dev/null +++ b/Code/Chapter 22/AutoLotCUIClient/Program.vb @@ -0,0 +1,163 @@ +Imports AutoLotConnectedLayer +Imports System.Configuration + +Module Program + Sub Main() + Console.WriteLine("***** The AutoLot Console UI *****" & vbLf) + + ' Get connection string from app.config. + Dim cnStr As String = ConfigurationManager.ConnectionStrings("AutoLotSqlProvider").ConnectionString + Dim userDone As Boolean = False + Dim userCommand As String = String.Empty + + ' Create our InventoryDAL object. + Dim invDAL As New InventoryDAL() + invDAL.OpenConnection(cnStr) + + ' Keep asking for input until user clicks the Q key. + Try + ShowInstructions() + + Do + Console.Write("Please enter your command: ") + userCommand = Console.ReadLine() + Console.WriteLine() + Select Case userCommand.ToUpper() + Case "I" + InsertNewCar(invDAL) + Exit Select + Case "U" + UpdateCarPetName(invDAL) + Exit Select + Case "D" + DeleteCar(invDAL) + Exit Select + Case "L" + ListInventory(invDAL) + Exit Select + Case "S" + ShowInstructions() + Exit Select + Case "C" + ClearConsole() + Exit Select + Case "P" + LookUpPetName(invDAL) + Exit Select + Case "Q" + userDone = True + Exit Select + Case Else + Console.WriteLine("Bad data! Try again") + Exit Select + End Select + Loop While Not userDone + Catch ex As Exception + Console.WriteLine(ex.Message) + Finally + invDAL.CloseConnection() + End Try + End Sub + +#Region "Show Instructions / Clear" + Private Sub ShowInstructions() + Console.WriteLine("I: Inserts a new car.") + Console.WriteLine("U: Updates an existing car.") + Console.WriteLine("D: Deletes an existing car.") + Console.WriteLine("L: Lists current inventory.") + Console.WriteLine("S: Shows these instructions.") + Console.WriteLine("C: Clears console and show instructions.") + Console.WriteLine("P: Looks up pet name.") + Console.WriteLine("Q: Quits program.") + End Sub + + Private Sub ClearConsole() + Console.Clear() + ShowInstructions() + End Sub +#End Region + +#Region "ListInventory method" + Private Sub ListInventory(ByVal invDAL As InventoryDAL) + Dim dt As DataTable = invDAL.GetAllInventory() + DisplayTable(dt) + End Sub + + Private Sub DisplayTable(ByVal dt As DataTable) + For curCol As Integer = 0 To dt.Columns.Count - 1 + ' Print out the column names. + Console.Write(dt.Columns(curCol).ColumnName.Trim() & vbTab) + Next + Console.WriteLine(vbLf & "----------------------------------") + For curRow As Integer = 0 To dt.Rows.Count - 1 + + ' Print the DataTable. + For curCol As Integer = 0 To dt.Columns.Count - 1 + Console.Write(dt.Rows(curRow)(curCol).ToString().Trim() & vbTab) + Next + Console.WriteLine() + Next + End Sub +#End Region + +#Region "Delete Car" + Private Sub DeleteCar(ByVal invDAL As InventoryDAL) + ' Get ID of car to delete. + Console.Write("Enter ID of Car to delete: ") + Dim id As Integer = Integer.Parse(Console.ReadLine()) + + ' Just in case we have a primary key + ' violation! + Try + invDAL.DeleteCar(id) + Catch ex As Exception + Console.WriteLine(ex.Message) + End Try + End Sub +#End Region + +#Region "Update pet name / Get pet name" + Private Sub UpdateCarPetName(ByVal invDAL As InventoryDAL) + ' First get the user data. + Dim carID As Integer + Dim newCarPetName As String + + Console.Write("Enter Car ID: ") + carID = Integer.Parse(Console.ReadLine()) + Console.Write("Enter New Pet Name: ") + newCarPetName = Console.ReadLine() + + ' Now pass to data access library. + invDAL.UpdateCarPetName(carID, newCarPetName) + End Sub + + Private Sub LookUpPetName(ByVal invDAL As InventoryDAL) + ' Get ID of car to look up. + Console.Write("Enter ID of Car to look up: ") + Dim id As Integer = Integer.Parse(Console.ReadLine()) + + Console.WriteLine("Petname of {0} is {1}.", id, invDAL.LookUpPetName(id)) + End Sub +#End Region + +#Region "Insert new car" + Private Sub InsertNewCar(ByVal invDAL As InventoryDAL) + ' First get the user data. + Dim newCarID As Integer + Dim newCarColor As String, newCarMake As String, newCarPetName As String + + Console.Write("Enter Car ID: ") + newCarID = Integer.Parse(Console.ReadLine()) + Console.Write("Enter Car Color: ") + newCarColor = Console.ReadLine() + Console.Write("Enter Car Make: ") + newCarMake = Console.ReadLine() + Console.Write("Enter Pet Name: ") + newCarPetName = Console.ReadLine() + + ' Now pass to data access library. + invDAL.InsertAuto(newCarID, newCarColor, newCarMake, newCarPetName) + End Sub +#End Region + +End Module diff --git a/Code/Chapter 22/AutoLotCUIClient/app.config b/Code/Chapter 22/AutoLotCUIClient/app.config new file mode 100644 index 0000000..3de1a9c --- /dev/null +++ b/Code/Chapter 22/AutoLotCUIClient/app.config @@ -0,0 +1,7 @@ + + + + + diff --git a/Code/Chapter 22/AutoLotDAL/AutoLotDAL.sln b/Code/Chapter 22/AutoLotDAL/AutoLotDAL.sln new file mode 100644 index 0000000..d9f0d95 --- /dev/null +++ b/Code/Chapter 22/AutoLotDAL/AutoLotDAL.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AutoLotDAL", "AutoLotDAL.vbproj", "{E497BF9D-A4DE-430C-BF17-597F24A35474}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E497BF9D-A4DE-430C-BF17-597F24A35474}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E497BF9D-A4DE-430C-BF17-597F24A35474}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E497BF9D-A4DE-430C-BF17-597F24A35474}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E497BF9D-A4DE-430C-BF17-597F24A35474}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 22/AutoLotDAL/AutoLotDAL.suo b/Code/Chapter 22/AutoLotDAL/AutoLotDAL.suo new file mode 100644 index 0000000..5a96402 Binary files /dev/null and b/Code/Chapter 22/AutoLotDAL/AutoLotDAL.suo differ diff --git a/Code/Chapter 22/AutoLotDAL/AutoLotDAL.vbproj b/Code/Chapter 22/AutoLotDAL/AutoLotDAL.vbproj new file mode 100644 index 0000000..107a832 --- /dev/null +++ b/Code/Chapter 22/AutoLotDAL/AutoLotDAL.vbproj @@ -0,0 +1,108 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {E497BF9D-A4DE-430C-BF17-597F24A35474} + Library + + + AutoLotDAL + 512 + Windows + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + AutoLotDAL.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + AutoLotDAL.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 22/AutoLotDAL/InventoryDAL.vb b/Code/Chapter 22/AutoLotDAL/InventoryDAL.vb new file mode 100644 index 0000000..9e5ebbe --- /dev/null +++ b/Code/Chapter 22/AutoLotDAL/InventoryDAL.vb @@ -0,0 +1,203 @@ +' We will make use of the SQL server +' provider, however it would also be +' permissible to make use of the ADO.NET +' factory pattern for greater flexibility. +Imports System.Data.SqlClient + +Namespace AutoLotConnectedLayer + Public Class InventoryDAL + +#Region "Connection and Disconnection details." + ' This member will be used by all methods. + Private sqlCn As New SqlConnection() + + Public Sub OpenConnection(ByVal connectionString As String) + sqlCn.ConnectionString = connectionString + sqlCn.Open() + End Sub + Public Sub CloseConnection() + sqlCn.Close() + End Sub +#End Region + +#Region "Insert logic (both versions)" + 'Public Sub InsertAuto(ByVal id As Integer, ByVal color As String, _ + ' ByVal make As String, ByVal petName As String) + ' ' Format and execute SQL statement. + ' Dim sql As String = String.Format("Insert Into Inventory" & _ + ' "(CarID, Make, Color, PetName) Values" & _ + ' "('{0}', '{1}', '{2}', '{3}')", id, make, color, petName) + + ' ' Execute using our connection. + ' Using cmd As New SqlCommand(sql, Me.sqlCn) + ' cmd.ExecuteNonQuery() + ' End Using + 'End Sub + + Public Sub InsertAuto(ByVal id As Integer, ByVal color As String, ByVal make As String, ByVal petName As String) + ' Note the 'placeholders' in the SQL query. + Dim sql As String = String.Format("Insert Into Inventory" + "(CarID, Make, Color, PetName) Values" + "(@CarID, @Make, @Color, @PetName)") + + ' This command will have internal parameters. + Using cmd As New SqlCommand(sql, Me.sqlCn) + ' Fill params collection. + Dim param As New SqlParameter() + param.ParameterName = "@CarID" + param.Value = id + param.SqlDbType = SqlDbType.Int + cmd.Parameters.Add(param) + + param = New SqlParameter() + param.ParameterName = "@Make" + param.Value = make + param.SqlDbType = SqlDbType.[Char] + param.Size = 10 + cmd.Parameters.Add(param) + + param = New SqlParameter() + param.ParameterName = "@Color" + param.Value = color + param.SqlDbType = SqlDbType.[Char] + param.Size = 10 + cmd.Parameters.Add(param) + + param = New SqlParameter() + param.ParameterName = "@PetName" + param.Value = petName + param.SqlDbType = SqlDbType.[Char] + param.Size = 10 + cmd.Parameters.Add(param) + + cmd.ExecuteNonQuery() + End Using + End Sub +#End Region + +#Region "Delete logic" + Public Sub DeleteCar(ByVal id As Integer) + ' Get ID of car to delete, then do so. + Dim sql As String = String.Format("Delete from Inventory where CarID = '{0}'", id) + Using cmd As New SqlCommand(sql, Me.sqlCn) + Try + cmd.ExecuteNonQuery() + Catch ex As SqlException + Dim er As New Exception("Sorry! That car is on order!", ex) + Throw er + End Try + End Using + End Sub +#End Region + +#Region "Update logic" + Public Sub UpdateCarPetName(ByVal id As Integer, ByVal newPetName As String) + ' Get ID of car to modify and new pet name. + Dim sql As String = String.Format("Update Inventory Set PetName = '{0}' Where CarID = '{1}'", newPetName, id) + Using cmd As New SqlCommand(sql, Me.sqlCn) + cmd.ExecuteNonQuery() + End Using + End Sub +#End Region + +#Region "Select logic" + Public Function GetAllInventory() As DataTable + ' This will hold the records. + Dim inv As New DataTable() + + ' Prep command object. + Dim sql As String = "Select * From Inventory" + Using cmd As New SqlCommand(sql, Me.sqlCn) + Dim dr As SqlDataReader = cmd.ExecuteReader() + ' Fill the DataTable with data from the reader and clean up. + inv.Load(dr) + dr.Close() + End Using + Return inv + End Function +#End Region + +#Region "Trigger stored proc logic" + Public Function LookUpPetName(ByVal carID As Integer) As String + Dim carPetName As String = String.Empty + + ' Establish name of stored proc. + Using cmd As New SqlCommand("GetPetName", Me.sqlCn) + cmd.CommandType = CommandType.StoredProcedure + + ' Input param. + Dim param As New SqlParameter() + param.ParameterName = "@carID" + param.SqlDbType = SqlDbType.Int + param.Value = carID + param.Direction = ParameterDirection.Input + cmd.Parameters.Add(param) + + ' Output param. + param = New SqlParameter() + param.ParameterName = "@petName" + param.SqlDbType = SqlDbType.[Char] + param.Size = 10 + param.Direction = ParameterDirection.Output + cmd.Parameters.Add(param) + + ' Execute the stored proc. + cmd.ExecuteNonQuery() + + ' Return output param. + carPetName = DirectCast(cmd.Parameters("@petName").Value, String).Trim() + End Using + Return carPetName + End Function +#End Region + +#Region "Tx Method" + ' A new member of the InventoryDAL class. + Public Sub ProcessCreditRisk(ByVal throwEx As Boolean, ByVal custID As Integer) + ' First, look up current name based on customer ID. + Dim fName As String = String.Empty + Dim lName As String = String.Empty + + Dim cmdSelect As New SqlCommand(String.Format("Select * from Customers where CustID = {0}", custID), sqlCn) + Using dr As SqlDataReader = cmdSelect.ExecuteReader() + While dr.Read() + fName = DirectCast(dr("FirstName"), String) + lName = DirectCast(dr("LastName"), String) + End While + End Using + + ' Create command objects which represent each step of the operation. + Dim cmdRemove As New SqlCommand(String.Format("Delete from Customers where CustID = {0}", custID), sqlCn) + + Dim cmdInsert As New SqlCommand(String.Format("Insert Into CreditRisks" & _ + "(CustID, FirstName, LastName) Values" & _ + "({0}, '{1}', '{2}')", custID, fName, lName), sqlCn) + + ' We will get this from the Connection object. + Dim tx As SqlTransaction = Nothing + Try + tx = sqlCn.BeginTransaction() + + ' Enlist the commands into this transaction. + cmdInsert.Transaction = tx + cmdRemove.Transaction = tx + + ' Execute the commands. + cmdInsert.ExecuteNonQuery() + cmdRemove.ExecuteNonQuery() + + ' Simulate error. + If throwEx Then + Throw New ApplicationException("Sorry! Database error! Tx failed...") + End If + + ' Commit it! + tx.Commit() + Catch ex As Exception + Console.WriteLine(ex.Message) + ' Any error will rollback transaction. + tx.Rollback() + End Try + End Sub +#End Region + + End Class +End Namespace diff --git a/Code/Chapter 22/AutoLotDAL/My Project/Application.Designer.vb b/Code/Chapter 22/AutoLotDAL/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 22/AutoLotDAL/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 22/AutoLotDAL/My Project/Application.myapp b/Code/Chapter 22/AutoLotDAL/My Project/Application.myapp new file mode 100644 index 0000000..758895d --- /dev/null +++ b/Code/Chapter 22/AutoLotDAL/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/Code/Chapter 22/AutoLotDAL/My Project/AssemblyInfo.vb b/Code/Chapter 22/AutoLotDAL/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..7ba989c --- /dev/null +++ b/Code/Chapter 22/AutoLotDAL/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/Code/Chapter 22/AutoLotDAL/My Project/Resources.Designer.vb b/Code/Chapter 22/AutoLotDAL/My Project/Resources.Designer.vb new file mode 100644 index 0000000..5036910 --- /dev/null +++ b/Code/Chapter 22/AutoLotDAL/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("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/Code/Chapter 22/AutoLotDAL/My Project/Resources.resx b/Code/Chapter 22/AutoLotDAL/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 22/AutoLotDAL/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/Code/Chapter 22/AutoLotDAL/My Project/Settings.Designer.vb b/Code/Chapter 22/AutoLotDAL/My Project/Settings.Designer.vb new file mode 100644 index 0000000..616219e --- /dev/null +++ b/Code/Chapter 22/AutoLotDAL/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.My.MySettings + Get + Return Global.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 22/AutoLotDAL/My Project/Settings.settings b/Code/Chapter 22/AutoLotDAL/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 22/AutoLotDAL/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 22/AutoLotDataReader/AutoLotDataReader.sln b/Code/Chapter 22/AutoLotDataReader/AutoLotDataReader.sln new file mode 100644 index 0000000..3455e4f --- /dev/null +++ b/Code/Chapter 22/AutoLotDataReader/AutoLotDataReader.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AutoLotDataReader", "AutoLotDataReader.vbproj", "{3AC88DB7-4970-4770-90E0-218858D8A454}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3AC88DB7-4970-4770-90E0-218858D8A454}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3AC88DB7-4970-4770-90E0-218858D8A454}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3AC88DB7-4970-4770-90E0-218858D8A454}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3AC88DB7-4970-4770-90E0-218858D8A454}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 22/AutoLotDataReader/AutoLotDataReader.suo b/Code/Chapter 22/AutoLotDataReader/AutoLotDataReader.suo new file mode 100644 index 0000000..1870593 Binary files /dev/null and b/Code/Chapter 22/AutoLotDataReader/AutoLotDataReader.suo differ diff --git a/Code/Chapter 22/AutoLotDataReader/AutoLotDataReader.vbproj b/Code/Chapter 22/AutoLotDataReader/AutoLotDataReader.vbproj new file mode 100644 index 0000000..18fe333 --- /dev/null +++ b/Code/Chapter 22/AutoLotDataReader/AutoLotDataReader.vbproj @@ -0,0 +1,109 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {3AC88DB7-4970-4770-90E0-218858D8A454} + Exe + AutoLotDataReader.Program + AutoLotDataReader + AutoLotDataReader + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + AutoLotDataReader.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + AutoLotDataReader.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 22/AutoLotDataReader/My Project/Application.Designer.vb b/Code/Chapter 22/AutoLotDataReader/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 22/AutoLotDataReader/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 22/AutoLotDataReader/My Project/Application.myapp b/Code/Chapter 22/AutoLotDataReader/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 22/AutoLotDataReader/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 22/AutoLotDataReader/My Project/AssemblyInfo.vb b/Code/Chapter 22/AutoLotDataReader/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..37c8891 --- /dev/null +++ b/Code/Chapter 22/AutoLotDataReader/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/Code/Chapter 22/AutoLotDataReader/My Project/Resources.Designer.vb b/Code/Chapter 22/AutoLotDataReader/My Project/Resources.Designer.vb new file mode 100644 index 0000000..8acc2c7 --- /dev/null +++ b/Code/Chapter 22/AutoLotDataReader/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("AutoLotDataReader.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/Code/Chapter 22/AutoLotDataReader/My Project/Resources.resx b/Code/Chapter 22/AutoLotDataReader/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 22/AutoLotDataReader/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/Code/Chapter 22/AutoLotDataReader/My Project/Settings.Designer.vb b/Code/Chapter 22/AutoLotDataReader/My Project/Settings.Designer.vb new file mode 100644 index 0000000..4639db3 --- /dev/null +++ b/Code/Chapter 22/AutoLotDataReader/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.AutoLotDataReader.My.MySettings + Get + Return Global.AutoLotDataReader.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 22/AutoLotDataReader/My Project/Settings.settings b/Code/Chapter 22/AutoLotDataReader/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 22/AutoLotDataReader/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 22/AutoLotDataReader/Program.vb b/Code/Chapter 22/AutoLotDataReader/Program.vb new file mode 100644 index 0000000..1f1939e --- /dev/null +++ b/Code/Chapter 22/AutoLotDataReader/Program.vb @@ -0,0 +1,58 @@ +Imports System.Data.SqlClient +Imports System.Data.Common + +Module Program + + Sub Main() + Console.WriteLine("***** Fun with Data Readers *****" & vbLf) + + ' Create a connection string via the builder object. + Dim cnStrBuilder As New SqlConnectionStringBuilder() + cnStrBuilder.InitialCatalog = "AutoLot" + cnStrBuilder.DataSource = "(local)\SQLEXPRESS" + cnStrBuilder.ConnectTimeout = 30 + cnStrBuilder.IntegratedSecurity = True + + Dim cn As New SqlConnection() + cn.ConnectionString = cnStrBuilder.ConnectionString + cn.Open() + + ShowConnectionStatus(cn) + + ' Create a SQL command object. + Dim strSQL As String = "Select * From Inventory;Select * from Customers" + Dim myCommand As New SqlCommand(strSQL, cn) + + ' Obtain a data reader a la ExecuteReader(). + Dim myDataReader As SqlDataReader + myDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection) + + ' Loop over the results. + Do + While myDataReader.Read() + Console.WriteLine("***** Record *****") + For i As Integer = 0 To myDataReader.FieldCount - 1 + Console.WriteLine("{0} = {1}", myDataReader.GetName(i), myDataReader.GetValue(i).ToString().Trim()) + Next + Console.WriteLine() + End While + Loop While myDataReader.NextResult() + + ' Because we specified CommandBehavior.CloseConnection, we + ' don't need to explicitly call Close() on the connection. + myDataReader.Close() + Console.ReadLine() + End Sub + +#Region "Show Cn Helper method" + Sub ShowConnectionStatus(ByVal cn As DbConnection) + ' Show various stats about current connection object. + Console.WriteLine("***** Info about your connection *****") + Console.WriteLine("Database location: {0}", cn.DataSource) + Console.WriteLine("Database name: {0}", cn.Database) + Console.WriteLine("Timeout: {0}", cn.ConnectionTimeout) + Console.WriteLine("Connection state: {0}" & Chr(10), cn.State.ToString()) + End Sub +#End Region + +End Module diff --git a/Code/Chapter 22/DataProviderFactory/DataProviderFactory.sln b/Code/Chapter 22/DataProviderFactory/DataProviderFactory.sln new file mode 100644 index 0000000..8c86e09 --- /dev/null +++ b/Code/Chapter 22/DataProviderFactory/DataProviderFactory.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DataProviderFactory", "DataProviderFactory.vbproj", "{5E3E8495-6CC1-4A0B-B82E-6BDB143B9CAA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5E3E8495-6CC1-4A0B-B82E-6BDB143B9CAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5E3E8495-6CC1-4A0B-B82E-6BDB143B9CAA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5E3E8495-6CC1-4A0B-B82E-6BDB143B9CAA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5E3E8495-6CC1-4A0B-B82E-6BDB143B9CAA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 22/DataProviderFactory/DataProviderFactory.suo b/Code/Chapter 22/DataProviderFactory/DataProviderFactory.suo new file mode 100644 index 0000000..b37cdfd Binary files /dev/null and b/Code/Chapter 22/DataProviderFactory/DataProviderFactory.suo differ diff --git a/Code/Chapter 22/DataProviderFactory/DataProviderFactory.vbproj b/Code/Chapter 22/DataProviderFactory/DataProviderFactory.vbproj new file mode 100644 index 0000000..35f8ebd --- /dev/null +++ b/Code/Chapter 22/DataProviderFactory/DataProviderFactory.vbproj @@ -0,0 +1,111 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {5E3E8495-6CC1-4A0B-B82E-6BDB143B9CAA} + Exe + DataProviderFactory.Program + DataProviderFactory + DataProviderFactory + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + DataProviderFactory.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + DataProviderFactory.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 22/DataProviderFactory/My Project/Application.Designer.vb b/Code/Chapter 22/DataProviderFactory/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 22/DataProviderFactory/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 22/DataProviderFactory/My Project/Application.myapp b/Code/Chapter 22/DataProviderFactory/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 22/DataProviderFactory/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 22/DataProviderFactory/My Project/AssemblyInfo.vb b/Code/Chapter 22/DataProviderFactory/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..5ada217 --- /dev/null +++ b/Code/Chapter 22/DataProviderFactory/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/Code/Chapter 22/DataProviderFactory/My Project/Resources.Designer.vb b/Code/Chapter 22/DataProviderFactory/My Project/Resources.Designer.vb new file mode 100644 index 0000000..57f140e --- /dev/null +++ b/Code/Chapter 22/DataProviderFactory/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("DataProviderFactory.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/Code/Chapter 22/DataProviderFactory/My Project/Resources.resx b/Code/Chapter 22/DataProviderFactory/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 22/DataProviderFactory/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/Code/Chapter 22/DataProviderFactory/My Project/Settings.Designer.vb b/Code/Chapter 22/DataProviderFactory/My Project/Settings.Designer.vb new file mode 100644 index 0000000..14c26b9 --- /dev/null +++ b/Code/Chapter 22/DataProviderFactory/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.DataProviderFactory.My.MySettings + Get + Return Global.DataProviderFactory.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 22/DataProviderFactory/My Project/Settings.settings b/Code/Chapter 22/DataProviderFactory/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 22/DataProviderFactory/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 22/DataProviderFactory/Program.vb b/Code/Chapter 22/DataProviderFactory/Program.vb new file mode 100644 index 0000000..7b97bd0 --- /dev/null +++ b/Code/Chapter 22/DataProviderFactory/Program.vb @@ -0,0 +1,44 @@ +Imports System.Configuration +Imports System.Data.Common + +Module Program + + Sub Main() + Console.WriteLine("***** Fun with Data Provider Factories *****" & vbLf) + Dim dp As String = _ + ConfigurationManager.AppSettings("provider") + Dim cnStr As String = _ + ConfigurationManager.ConnectionStrings("AutoLotSqlProvider").ConnectionString + + + ' Get the factory provider. + Dim df As DbProviderFactory = DbProviderFactories.GetFactory(dp) + + ' Now make connection object. + Dim cn As DbConnection = df.CreateConnection() + Console.WriteLine("Your connection object is a: {0}", cn.GetType().FullName) + cn.ConnectionString = cnStr + cn.Open() + + ' Make command object. + Dim cmd As DbCommand = df.CreateCommand() + Console.WriteLine("Your command object is a: {0}", cmd.GetType().FullName) + cmd.Connection = cn + cmd.CommandText = "Select * From Inventory" + + ' Print out data with data reader. + ' Because we specified CommandBehavior.CloseConnection, we + ' don't need to explicitly call Close() on the connection. + Dim dr As DbDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection) + Console.WriteLine("Your data reader object is a: {0}", dr.GetType().FullName) + + Console.WriteLine(vbLf & "***** Current Inventory *****") + While dr.Read() + Console.WriteLine("-> Car #{0} is a {1}.", dr("CarID"), dr("Make").ToString().Trim()) + End While + dr.Close() + + Console.ReadLine() + End Sub + +End Module diff --git a/Code/Chapter 22/DataProviderFactory/app.config b/Code/Chapter 22/DataProviderFactory/app.config new file mode 100644 index 0000000..65f3b95 --- /dev/null +++ b/Code/Chapter 22/DataProviderFactory/app.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/Code/Chapter 22/MyConnectionFactory/My Project/Application.Designer.vb b/Code/Chapter 22/MyConnectionFactory/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 22/MyConnectionFactory/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 22/MyConnectionFactory/My Project/Application.myapp b/Code/Chapter 22/MyConnectionFactory/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 22/MyConnectionFactory/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 22/MyConnectionFactory/My Project/AssemblyInfo.vb b/Code/Chapter 22/MyConnectionFactory/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..b6cad4d --- /dev/null +++ b/Code/Chapter 22/MyConnectionFactory/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/Code/Chapter 22/MyConnectionFactory/My Project/Resources.Designer.vb b/Code/Chapter 22/MyConnectionFactory/My Project/Resources.Designer.vb new file mode 100644 index 0000000..a3ac360 --- /dev/null +++ b/Code/Chapter 22/MyConnectionFactory/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("MyConnectionFactory.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/Code/Chapter 22/MyConnectionFactory/My Project/Resources.resx b/Code/Chapter 22/MyConnectionFactory/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 22/MyConnectionFactory/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/Code/Chapter 22/MyConnectionFactory/My Project/Settings.Designer.vb b/Code/Chapter 22/MyConnectionFactory/My Project/Settings.Designer.vb new file mode 100644 index 0000000..a319898 --- /dev/null +++ b/Code/Chapter 22/MyConnectionFactory/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.MyConnectionFactory.My.MySettings + Get + Return Global.MyConnectionFactory.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 22/MyConnectionFactory/My Project/Settings.settings b/Code/Chapter 22/MyConnectionFactory/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 22/MyConnectionFactory/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 22/MyConnectionFactory/MyConnectionFactory.sln b/Code/Chapter 22/MyConnectionFactory/MyConnectionFactory.sln new file mode 100644 index 0000000..73e6e3a --- /dev/null +++ b/Code/Chapter 22/MyConnectionFactory/MyConnectionFactory.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MyConnectionFactory", "MyConnectionFactory.vbproj", "{B4EE5E52-A26E-4DED-AECB-F4867D474DB6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B4EE5E52-A26E-4DED-AECB-F4867D474DB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B4EE5E52-A26E-4DED-AECB-F4867D474DB6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B4EE5E52-A26E-4DED-AECB-F4867D474DB6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B4EE5E52-A26E-4DED-AECB-F4867D474DB6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 22/MyConnectionFactory/MyConnectionFactory.suo b/Code/Chapter 22/MyConnectionFactory/MyConnectionFactory.suo new file mode 100644 index 0000000..1fca97d Binary files /dev/null and b/Code/Chapter 22/MyConnectionFactory/MyConnectionFactory.suo differ diff --git a/Code/Chapter 22/MyConnectionFactory/MyConnectionFactory.vbproj b/Code/Chapter 22/MyConnectionFactory/MyConnectionFactory.vbproj new file mode 100644 index 0000000..4f61349 --- /dev/null +++ b/Code/Chapter 22/MyConnectionFactory/MyConnectionFactory.vbproj @@ -0,0 +1,112 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {B4EE5E52-A26E-4DED-AECB-F4867D474DB6} + Exe + MyConnectionFactory.Program + MyConnectionFactory + MyConnectionFactory + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + MyConnectionFactory.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + MyConnectionFactory.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 22/MyConnectionFactory/Program.vb b/Code/Chapter 22/MyConnectionFactory/Program.vb new file mode 100644 index 0000000..9e915f5 --- /dev/null +++ b/Code/Chapter 22/MyConnectionFactory/Program.vb @@ -0,0 +1,68 @@ +' Need these to get definitions of common interfaces, +' and various Connection objects for our test. +Imports System.Data.SqlClient +Imports System.Data.Odbc +Imports System.Data.OleDb + +' Need to reference System.Data.OracleClient.dll to nab this namespace! +Imports System.Data.OracleClient +Imports System.Configuration + +' A list of possible providers. +Enum DataProvider + SqlServer + OleDb + Odbc + Oracle + None +End Enum + +Module Program + + Sub Main() + Console.WriteLine("**** Very Simple Connection Factory *****" & vbLf) + + ' Read the provider key. + Dim dataProvString As String = ConfigurationManager.AppSettings("provider") + + ' Transform string to enum. + Dim dp As DataProvider = DataProvider.None + If [Enum].IsDefined(GetType(DataProvider), dataProvString) Then + dp = DirectCast([Enum].Parse(GetType(DataProvider), dataProvString), DataProvider) + Else + Console.WriteLine("Sorry, no provider exists!") + End If + + ' Get a specific connection. + Dim myCn As IDbConnection = GetConnection(dp) + If myCn IsNot Nothing Then + Console.WriteLine("Your connection is a {0}", myCn.GetType().Name) + End If + + ' Open, use, and close connection. + Console.ReadLine() + End Sub + +#Region "GetConnection() helper method" + ' This method returns a specific connection object + ' based on the value of a DataProvider enum. + Private Function GetConnection(ByVal dp As DataProvider) As IDbConnection + Dim conn As IDbConnection = Nothing + Select Case dp + Case DataProvider.SqlServer + conn = New SqlConnection() + Exit Select + Case DataProvider.OleDb + conn = New OleDbConnection() + Exit Select + Case DataProvider.Odbc + conn = New OdbcConnection() + Exit Select + Case DataProvider.Oracle + conn = New OracleConnection() + Exit Select + End Select + Return conn + End Function +#End Region +End Module diff --git a/Code/Chapter 22/MyConnectionFactory/app.config b/Code/Chapter 22/MyConnectionFactory/app.config new file mode 100644 index 0000000..5cd268c --- /dev/null +++ b/Code/Chapter 22/MyConnectionFactory/app.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/Code/Chapter 23/AutoLotDAL (Part 2)/AutoLotDAL.sln b/Code/Chapter 23/AutoLotDAL (Part 2)/AutoLotDAL.sln new file mode 100644 index 0000000..d9f0d95 --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 2)/AutoLotDAL.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AutoLotDAL", "AutoLotDAL.vbproj", "{E497BF9D-A4DE-430C-BF17-597F24A35474}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E497BF9D-A4DE-430C-BF17-597F24A35474}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E497BF9D-A4DE-430C-BF17-597F24A35474}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E497BF9D-A4DE-430C-BF17-597F24A35474}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E497BF9D-A4DE-430C-BF17-597F24A35474}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 23/AutoLotDAL (Part 2)/AutoLotDAL.suo b/Code/Chapter 23/AutoLotDAL (Part 2)/AutoLotDAL.suo new file mode 100644 index 0000000..ee0a2c5 Binary files /dev/null and b/Code/Chapter 23/AutoLotDAL (Part 2)/AutoLotDAL.suo differ diff --git a/Code/Chapter 23/AutoLotDAL (Part 2)/AutoLotDAL.vbproj b/Code/Chapter 23/AutoLotDAL (Part 2)/AutoLotDAL.vbproj new file mode 100644 index 0000000..294ae87 --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 2)/AutoLotDAL.vbproj @@ -0,0 +1,109 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {E497BF9D-A4DE-430C-BF17-597F24A35474} + Library + + + AutoLotDAL + 512 + Windows + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + AutoLotDAL.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + AutoLotDAL.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + + 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/Code/Chapter 23/AutoLotDAL (Part 2)/InventoryDAL.vb b/Code/Chapter 23/AutoLotDAL (Part 2)/InventoryDAL.vb new file mode 100644 index 0000000..9043d6a --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 2)/InventoryDAL.vb @@ -0,0 +1,206 @@ +Option Strict On +Option Explicit On + +' We will make use of the SQL server +' provider, however it would also be +' permissible to make use of the ADO.NET +' factory pattern for greater flexibility. +Imports System.Data.SqlClient + +Namespace AutoLotConnectedLayer + Public Class InventoryDAL + +#Region "Connection and Disconnection details." + ' This member will be used by all methods. + Private sqlCn As New SqlConnection() + + Public Sub OpenConnection(ByVal connectionString As String) + sqlCn.ConnectionString = connectionString + sqlCn.Open() + End Sub + Public Sub CloseConnection() + sqlCn.Close() + End Sub +#End Region + +#Region "Insert logic (both versions)" + 'Public Sub InsertAuto(ByVal id As Integer, ByVal color As String, _ + ' ByVal make As String, ByVal petName As String) + ' ' Format and execute SQL statement. + ' Dim sql As String = String.Format("Insert Into Inventory" & _ + ' "(CarID, Make, Color, PetName) Values" & _ + ' "('{0}', '{1}', '{2}', '{3}')", id, make, color, petName) + + ' ' Execute using our connection. + ' Using cmd As New SqlCommand(sql, Me.sqlCn) + ' cmd.ExecuteNonQuery() + ' End Using + 'End Sub + + Public Sub InsertAuto(ByVal id As Integer, ByVal color As String, ByVal make As String, ByVal petName As String) + ' Note the 'placeholders' in the SQL query. + Dim sql As String = String.Format("Insert Into Inventory" + "(CarID, Make, Color, PetName) Values" + "(@CarID, @Make, @Color, @PetName)") + + ' This command will have internal parameters. + Using cmd As New SqlCommand(sql, Me.sqlCn) + ' Fill params collection. + Dim param As New SqlParameter() + param.ParameterName = "@CarID" + param.Value = id + param.SqlDbType = SqlDbType.Int + cmd.Parameters.Add(param) + + param = New SqlParameter() + param.ParameterName = "@Make" + param.Value = make + param.SqlDbType = SqlDbType.[Char] + param.Size = 10 + cmd.Parameters.Add(param) + + param = New SqlParameter() + param.ParameterName = "@Color" + param.Value = color + param.SqlDbType = SqlDbType.[Char] + param.Size = 10 + cmd.Parameters.Add(param) + + param = New SqlParameter() + param.ParameterName = "@PetName" + param.Value = petName + param.SqlDbType = SqlDbType.[Char] + param.Size = 10 + cmd.Parameters.Add(param) + + cmd.ExecuteNonQuery() + End Using + End Sub +#End Region + +#Region "Delete logic" + Public Sub DeleteCar(ByVal id As Integer) + ' Get ID of car to delete, then do so. + Dim sql As String = String.Format("Delete from Inventory where CarID = '{0}'", id) + Using cmd As New SqlCommand(sql, Me.sqlCn) + Try + cmd.ExecuteNonQuery() + Catch ex As SqlException + Dim er As New Exception("Sorry! That car is on order!", ex) + Throw er + End Try + End Using + End Sub +#End Region + +#Region "Update logic" + Public Sub UpdateCarPetName(ByVal id As Integer, ByVal newPetName As String) + ' Get ID of car to modify and new pet name. + Dim sql As String = String.Format("Update Inventory Set PetName = '{0}' Where CarID = '{1}'", newPetName, id) + Using cmd As New SqlCommand(sql, Me.sqlCn) + cmd.ExecuteNonQuery() + End Using + End Sub +#End Region + +#Region "Select logic" + Public Function GetAllInventory() As DataTable + ' This will hold the records. + Dim inv As New DataTable() + + ' Prep command object. + Dim sql As String = "Select * From Inventory" + Using cmd As New SqlCommand(sql, Me.sqlCn) + Dim dr As SqlDataReader = cmd.ExecuteReader() + ' Fill the DataTable with data from the reader and clean up. + inv.Load(dr) + dr.Close() + End Using + Return inv + End Function +#End Region + +#Region "Trigger stored proc logic" + Public Function LookUpPetName(ByVal carID As Integer) As String + Dim carPetName As String = String.Empty + + ' Establish name of stored proc. + Using cmd As New SqlCommand("GetPetName", Me.sqlCn) + cmd.CommandType = CommandType.StoredProcedure + + ' Input param. + Dim param As New SqlParameter() + param.ParameterName = "@carID" + param.SqlDbType = SqlDbType.Int + param.Value = carID + param.Direction = ParameterDirection.Input + cmd.Parameters.Add(param) + + ' Output param. + param = New SqlParameter() + param.ParameterName = "@petName" + param.SqlDbType = SqlDbType.[Char] + param.Size = 10 + param.Direction = ParameterDirection.Output + cmd.Parameters.Add(param) + + ' Execute the stored proc. + cmd.ExecuteNonQuery() + + ' Return output param. + carPetName = DirectCast(cmd.Parameters("@petName").Value, String).Trim() + End Using + Return carPetName + End Function +#End Region + +#Region "Tx Method" + ' A new member of the InventoryDAL class. + Public Sub ProcessCreditRisk(ByVal throwEx As Boolean, ByVal custID As Integer) + ' First, look up current name based on customer ID. + Dim fName As String = String.Empty + Dim lName As String = String.Empty + + Dim cmdSelect As New SqlCommand(String.Format("Select * from Customers where CustID = {0}", custID), sqlCn) + Using dr As SqlDataReader = cmdSelect.ExecuteReader() + While dr.Read() + fName = DirectCast(dr("FirstName"), String) + lName = DirectCast(dr("LastName"), String) + End While + End Using + + ' Create command objects which represent each step of the operation. + Dim cmdRemove As New SqlCommand(String.Format("Delete from Customers where CustID = {0}", custID), sqlCn) + + Dim cmdInsert As New SqlCommand(String.Format("Insert Into CreditRisks" & _ + "(CustID, FirstName, LastName) Values" & _ + "({0}, '{1}', '{2}')", custID, fName, lName), sqlCn) + + ' We will get this from the Connection object. + Dim tx As SqlTransaction = Nothing + Try + tx = sqlCn.BeginTransaction() + + ' Enlist the commands into this transaction. + cmdInsert.Transaction = tx + cmdRemove.Transaction = tx + + ' Execute the commands. + cmdInsert.ExecuteNonQuery() + cmdRemove.ExecuteNonQuery() + + ' Simulate error. + If throwEx Then + Throw New ApplicationException("Sorry! Database error! Tx failed...") + End If + + ' Commit it! + tx.Commit() + Catch ex As Exception + Console.WriteLine(ex.Message) + ' Any error will rollback transaction. + tx.Rollback() + End Try + End Sub +#End Region + + End Class +End Namespace diff --git a/Code/Chapter 23/AutoLotDAL (Part 2)/InventoryDALDisconnected.vb b/Code/Chapter 23/AutoLotDAL (Part 2)/InventoryDALDisconnected.vb new file mode 100644 index 0000000..fdde709 --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 2)/InventoryDALDisconnected.vb @@ -0,0 +1,38 @@ +Option Strict On +Option Explicit On + +Imports System.Data.SqlClient + +Namespace AutoLotDisconnectedLayer + Public Class InventoryDALDisLayer + ' Field data. + Private cnString As String = String.Empty + Private dAdapt As SqlDataAdapter = Nothing + + Public Sub New(ByVal connectionString As String) + cnString = connectionString + + ' Configure the SqlDataAdapter. + ConfigureAdapter(dAdapt) + End Sub + + Private Sub ConfigureAdapter(ByRef dAdapt As SqlDataAdapter) + ' Create the adapter and set up the SelectCommand + dAdapt = New SqlDataAdapter("Select * From Inventory", cnString) + + ' Obtain the remaining Command objects dynamically at runime + ' using the SqlCommandBuilder. + Dim builder As New SqlCommandBuilder(dAdapt) + End Sub + + Public Function GetAllInventory() As DataTable + Dim inv As New DataTable("Inventory") + dAdapt.Fill(inv) + Return inv + End Function + + Public Sub UpdateInventory(ByVal modifiedTable As DataTable) + dAdapt.Update(modifiedTable) + End Sub + End Class +End Namespace diff --git a/Code/Chapter 23/AutoLotDAL (Part 2)/My Project/Application.Designer.vb b/Code/Chapter 23/AutoLotDAL (Part 2)/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 2)/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 23/AutoLotDAL (Part 2)/My Project/Application.myapp b/Code/Chapter 23/AutoLotDAL (Part 2)/My Project/Application.myapp new file mode 100644 index 0000000..758895d --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 2)/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/Code/Chapter 23/AutoLotDAL (Part 2)/My Project/AssemblyInfo.vb b/Code/Chapter 23/AutoLotDAL (Part 2)/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..7ba989c --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 2)/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/Code/Chapter 23/AutoLotDAL (Part 2)/My Project/Resources.Designer.vb b/Code/Chapter 23/AutoLotDAL (Part 2)/My Project/Resources.Designer.vb new file mode 100644 index 0000000..5036910 --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 2)/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("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/Code/Chapter 23/AutoLotDAL (Part 2)/My Project/Resources.resx b/Code/Chapter 23/AutoLotDAL (Part 2)/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 2)/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/Code/Chapter 23/AutoLotDAL (Part 2)/My Project/Settings.Designer.vb b/Code/Chapter 23/AutoLotDAL (Part 2)/My Project/Settings.Designer.vb new file mode 100644 index 0000000..616219e --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 2)/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.My.MySettings + Get + Return Global.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 23/AutoLotDAL (Part 2)/My Project/Settings.settings b/Code/Chapter 23/AutoLotDAL (Part 2)/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 2)/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 23/AutoLotDAL (Part 3)/AutoLotDAL.sln b/Code/Chapter 23/AutoLotDAL (Part 3)/AutoLotDAL.sln new file mode 100644 index 0000000..d9f0d95 --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 3)/AutoLotDAL.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AutoLotDAL", "AutoLotDAL.vbproj", "{E497BF9D-A4DE-430C-BF17-597F24A35474}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E497BF9D-A4DE-430C-BF17-597F24A35474}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E497BF9D-A4DE-430C-BF17-597F24A35474}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E497BF9D-A4DE-430C-BF17-597F24A35474}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E497BF9D-A4DE-430C-BF17-597F24A35474}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 23/AutoLotDAL (Part 3)/AutoLotDAL.suo b/Code/Chapter 23/AutoLotDAL (Part 3)/AutoLotDAL.suo new file mode 100644 index 0000000..9f5bafc Binary files /dev/null and b/Code/Chapter 23/AutoLotDAL (Part 3)/AutoLotDAL.suo differ diff --git a/Code/Chapter 23/AutoLotDAL (Part 3)/AutoLotDAL.vbproj b/Code/Chapter 23/AutoLotDAL (Part 3)/AutoLotDAL.vbproj new file mode 100644 index 0000000..bfd0dd2 --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 3)/AutoLotDAL.vbproj @@ -0,0 +1,128 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {E497BF9D-A4DE-430C-BF17-597F24A35474} + Library + + + AutoLotDAL + 512 + Windows + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + AutoLotDAL.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + AutoLotDAL.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + True + True + AutoLotDataSet.xsd + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + + AutoLotDataSet.xsd + + + Designer + MSDataSetGenerator + AutoLotDataSet.Designer.vb + + + AutoLotDataSet.xsd + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + \ No newline at end of file diff --git a/Code/Chapter 23/AutoLotDAL (Part 3)/AutoLotDataSet.Designer.vb b/Code/Chapter 23/AutoLotDAL (Part 3)/AutoLotDataSet.Designer.vb new file mode 100644 index 0000000..23c8f8f --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 3)/AutoLotDataSet.Designer.vb @@ -0,0 +1,3044 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict Off +Option Explicit On + + + +''' +'''Represents a strongly typed in-memory cache of data. +''' + _ +Partial Public Class AutoLotDataSet + Inherits Global.System.Data.DataSet + + Private tableCustomers As CustomersDataTable + + Private tableInventory As InventoryDataTable + + Private tableOrders As OrdersDataTable + + Private relationFK_Orders_Customers As Global.System.Data.DataRelation + + Private relationFK_Orders_Inventory As Global.System.Data.DataRelation + + Private _schemaSerializationMode As Global.System.Data.SchemaSerializationMode = Global.System.Data.SchemaSerializationMode.IncludeSchema + + _ + Public Sub New() + MyBase.New + Me.BeginInit + Me.InitClass + Dim schemaChangedHandler As Global.System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged + AddHandler MyBase.Tables.CollectionChanged, schemaChangedHandler + AddHandler MyBase.Relations.CollectionChanged, schemaChangedHandler + Me.EndInit + End Sub + + _ + Protected Sub New(ByVal info As Global.System.Runtime.Serialization.SerializationInfo, ByVal context As Global.System.Runtime.Serialization.StreamingContext) + MyBase.New(info, context, false) + If (Me.IsBinarySerialized(info, context) = true) Then + Me.InitVars(false) + Dim schemaChangedHandler1 As Global.System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged + AddHandler Me.Tables.CollectionChanged, schemaChangedHandler1 + AddHandler Me.Relations.CollectionChanged, schemaChangedHandler1 + Return + End If + Dim strSchema As String = CType(info.GetValue("XmlSchema", GetType(String)),String) + If (Me.DetermineSchemaSerializationMode(info, context) = Global.System.Data.SchemaSerializationMode.IncludeSchema) Then + Dim ds As Global.System.Data.DataSet = New Global.System.Data.DataSet + ds.ReadXmlSchema(New Global.System.Xml.XmlTextReader(New Global.System.IO.StringReader(strSchema))) + If (Not (ds.Tables("Customers")) Is Nothing) Then + MyBase.Tables.Add(New CustomersDataTable(ds.Tables("Customers"))) + End If + If (Not (ds.Tables("Inventory")) Is Nothing) Then + MyBase.Tables.Add(New InventoryDataTable(ds.Tables("Inventory"))) + End If + If (Not (ds.Tables("Orders")) Is Nothing) Then + MyBase.Tables.Add(New OrdersDataTable(ds.Tables("Orders"))) + End If + Me.DataSetName = ds.DataSetName + Me.Prefix = ds.Prefix + Me.Namespace = ds.Namespace + Me.Locale = ds.Locale + Me.CaseSensitive = ds.CaseSensitive + Me.EnforceConstraints = ds.EnforceConstraints + Me.Merge(ds, false, Global.System.Data.MissingSchemaAction.Add) + Me.InitVars + Else + Me.ReadXmlSchema(New Global.System.Xml.XmlTextReader(New Global.System.IO.StringReader(strSchema))) + End If + Me.GetSerializationData(info, context) + Dim schemaChangedHandler As Global.System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged + AddHandler MyBase.Tables.CollectionChanged, schemaChangedHandler + AddHandler Me.Relations.CollectionChanged, schemaChangedHandler + End Sub + + _ + Public ReadOnly Property Customers() As CustomersDataTable + Get + Return Me.tableCustomers + End Get + End Property + + _ + Public ReadOnly Property Inventory() As InventoryDataTable + Get + Return Me.tableInventory + End Get + End Property + + _ + Public ReadOnly Property Orders() As OrdersDataTable + Get + Return Me.tableOrders + End Get + End Property + + _ + Public Overrides Property SchemaSerializationMode() As Global.System.Data.SchemaSerializationMode + Get + Return Me._schemaSerializationMode + End Get + Set + Me._schemaSerializationMode = value + End Set + End Property + + _ + Public Shadows ReadOnly Property Tables() As Global.System.Data.DataTableCollection + Get + Return MyBase.Tables + End Get + End Property + + _ + Public Shadows ReadOnly Property Relations() As Global.System.Data.DataRelationCollection + Get + Return MyBase.Relations + End Get + End Property + + _ + Protected Overrides Sub InitializeDerivedDataSet() + Me.BeginInit + Me.InitClass + Me.EndInit + End Sub + + _ + Public Overrides Function Clone() As Global.System.Data.DataSet + Dim cln As AutoLotDataSet = CType(MyBase.Clone,AutoLotDataSet) + cln.InitVars + cln.SchemaSerializationMode = Me.SchemaSerializationMode + Return cln + End Function + + _ + Protected Overrides Function ShouldSerializeTables() As Boolean + Return false + End Function + + _ + Protected Overrides Function ShouldSerializeRelations() As Boolean + Return false + End Function + + _ + Protected Overrides Sub ReadXmlSerializable(ByVal reader As Global.System.Xml.XmlReader) + If (Me.DetermineSchemaSerializationMode(reader) = Global.System.Data.SchemaSerializationMode.IncludeSchema) Then + Me.Reset + Dim ds As Global.System.Data.DataSet = New Global.System.Data.DataSet + ds.ReadXml(reader) + If (Not (ds.Tables("Customers")) Is Nothing) Then + MyBase.Tables.Add(New CustomersDataTable(ds.Tables("Customers"))) + End If + If (Not (ds.Tables("Inventory")) Is Nothing) Then + MyBase.Tables.Add(New InventoryDataTable(ds.Tables("Inventory"))) + End If + If (Not (ds.Tables("Orders")) Is Nothing) Then + MyBase.Tables.Add(New OrdersDataTable(ds.Tables("Orders"))) + End If + Me.DataSetName = ds.DataSetName + Me.Prefix = ds.Prefix + Me.Namespace = ds.Namespace + Me.Locale = ds.Locale + Me.CaseSensitive = ds.CaseSensitive + Me.EnforceConstraints = ds.EnforceConstraints + Me.Merge(ds, false, Global.System.Data.MissingSchemaAction.Add) + Me.InitVars + Else + Me.ReadXml(reader) + Me.InitVars + End If + End Sub + + _ + Protected Overrides Function GetSchemaSerializable() As Global.System.Xml.Schema.XmlSchema + Dim stream As Global.System.IO.MemoryStream = New Global.System.IO.MemoryStream + Me.WriteXmlSchema(New Global.System.Xml.XmlTextWriter(stream, Nothing)) + stream.Position = 0 + Return Global.System.Xml.Schema.XmlSchema.Read(New Global.System.Xml.XmlTextReader(stream), Nothing) + End Function + + _ + Friend Overloads Sub InitVars() + Me.InitVars(true) + End Sub + + _ + Friend Overloads Sub InitVars(ByVal initTable As Boolean) + Me.tableCustomers = CType(MyBase.Tables("Customers"),CustomersDataTable) + If (initTable = true) Then + If (Not (Me.tableCustomers) Is Nothing) Then + Me.tableCustomers.InitVars + End If + End If + Me.tableInventory = CType(MyBase.Tables("Inventory"),InventoryDataTable) + If (initTable = true) Then + If (Not (Me.tableInventory) Is Nothing) Then + Me.tableInventory.InitVars + End If + End If + Me.tableOrders = CType(MyBase.Tables("Orders"),OrdersDataTable) + If (initTable = true) Then + If (Not (Me.tableOrders) Is Nothing) Then + Me.tableOrders.InitVars + End If + End If + Me.relationFK_Orders_Customers = Me.Relations("FK_Orders_Customers") + Me.relationFK_Orders_Inventory = Me.Relations("FK_Orders_Inventory") + End Sub + + _ + Private Sub InitClass() + Me.DataSetName = "AutoLotDataSet" + Me.Prefix = "" + Me.Namespace = "http://tempuri.org/AutoLotDataSet.xsd" + Me.EnforceConstraints = true + Me.SchemaSerializationMode = Global.System.Data.SchemaSerializationMode.IncludeSchema + Me.tableCustomers = New CustomersDataTable + MyBase.Tables.Add(Me.tableCustomers) + Me.tableInventory = New InventoryDataTable + MyBase.Tables.Add(Me.tableInventory) + Me.tableOrders = New OrdersDataTable + MyBase.Tables.Add(Me.tableOrders) + Me.relationFK_Orders_Customers = New Global.System.Data.DataRelation("FK_Orders_Customers", New Global.System.Data.DataColumn() {Me.tableCustomers.CustIDColumn}, New Global.System.Data.DataColumn() {Me.tableOrders.CustIDColumn}, false) + Me.Relations.Add(Me.relationFK_Orders_Customers) + Me.relationFK_Orders_Inventory = New Global.System.Data.DataRelation("FK_Orders_Inventory", New Global.System.Data.DataColumn() {Me.tableInventory.CarIDColumn}, New Global.System.Data.DataColumn() {Me.tableOrders.CarIDColumn}, false) + Me.Relations.Add(Me.relationFK_Orders_Inventory) + End Sub + + _ + Private Function ShouldSerializeCustomers() As Boolean + Return false + End Function + + _ + Private Function ShouldSerializeInventory() As Boolean + Return false + End Function + + _ + Private Function ShouldSerializeOrders() As Boolean + Return false + End Function + + _ + Private Sub SchemaChanged(ByVal sender As Object, ByVal e As Global.System.ComponentModel.CollectionChangeEventArgs) + If (e.Action = Global.System.ComponentModel.CollectionChangeAction.Remove) Then + Me.InitVars + End If + End Sub + + _ + Public Shared Function GetTypedDataSetSchema(ByVal xs As Global.System.Xml.Schema.XmlSchemaSet) As Global.System.Xml.Schema.XmlSchemaComplexType + Dim ds As AutoLotDataSet = New AutoLotDataSet + Dim type As Global.System.Xml.Schema.XmlSchemaComplexType = New Global.System.Xml.Schema.XmlSchemaComplexType + Dim sequence As Global.System.Xml.Schema.XmlSchemaSequence = New Global.System.Xml.Schema.XmlSchemaSequence + Dim any As Global.System.Xml.Schema.XmlSchemaAny = New Global.System.Xml.Schema.XmlSchemaAny + any.Namespace = ds.Namespace + sequence.Items.Add(any) + type.Particle = sequence + Dim dsSchema As Global.System.Xml.Schema.XmlSchema = ds.GetSchemaSerializable + If xs.Contains(dsSchema.TargetNamespace) Then + Dim s1 As Global.System.IO.MemoryStream = New Global.System.IO.MemoryStream + Dim s2 As Global.System.IO.MemoryStream = New Global.System.IO.MemoryStream + Try + Dim schema As Global.System.Xml.Schema.XmlSchema = Nothing + dsSchema.Write(s1) + Dim schemas As Global.System.Collections.IEnumerator = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator + Do While schemas.MoveNext + schema = CType(schemas.Current,Global.System.Xml.Schema.XmlSchema) + s2.SetLength(0) + schema.Write(s2) + If (s1.Length = s2.Length) Then + s1.Position = 0 + s2.Position = 0 + + Do While ((s1.Position <> s1.Length) _ + AndAlso (s1.ReadByte = s2.ReadByte)) + + + Loop + If (s1.Position = s1.Length) Then + Return type + End If + End If + + Loop + Finally + If (Not (s1) Is Nothing) Then + s1.Close + End If + If (Not (s2) Is Nothing) Then + s2.Close + End If + End Try + End If + xs.Add(dsSchema) + Return type + End Function + + Public Delegate Sub CustomersRowChangeEventHandler(ByVal sender As Object, ByVal e As CustomersRowChangeEvent) + + Public Delegate Sub InventoryRowChangeEventHandler(ByVal sender As Object, ByVal e As InventoryRowChangeEvent) + + Public Delegate Sub OrdersRowChangeEventHandler(ByVal sender As Object, ByVal e As OrdersRowChangeEvent) + + ''' + '''Represents the strongly named DataTable class. + ''' + _ + Partial Public Class CustomersDataTable + Inherits Global.System.Data.TypedTableBase(Of CustomersRow) + + Private columnCustID As Global.System.Data.DataColumn + + Private columnFirstName As Global.System.Data.DataColumn + + Private columnLastName As Global.System.Data.DataColumn + + _ + Public Sub New() + MyBase.New + Me.TableName = "Customers" + Me.BeginInit + Me.InitClass + Me.EndInit + End Sub + + _ + Friend Sub New(ByVal table As Global.System.Data.DataTable) + MyBase.New + Me.TableName = table.TableName + If (table.CaseSensitive <> table.DataSet.CaseSensitive) Then + Me.CaseSensitive = table.CaseSensitive + End If + If (table.Locale.ToString <> table.DataSet.Locale.ToString) Then + Me.Locale = table.Locale + End If + If (table.Namespace <> table.DataSet.Namespace) Then + Me.Namespace = table.Namespace + End If + Me.Prefix = table.Prefix + Me.MinimumCapacity = table.MinimumCapacity + End Sub + + _ + Protected Sub New(ByVal info As Global.System.Runtime.Serialization.SerializationInfo, ByVal context As Global.System.Runtime.Serialization.StreamingContext) + MyBase.New(info, context) + Me.InitVars + End Sub + + _ + Public ReadOnly Property CustIDColumn() As Global.System.Data.DataColumn + Get + Return Me.columnCustID + End Get + End Property + + _ + Public ReadOnly Property FirstNameColumn() As Global.System.Data.DataColumn + Get + Return Me.columnFirstName + End Get + End Property + + _ + Public ReadOnly Property LastNameColumn() As Global.System.Data.DataColumn + Get + Return Me.columnLastName + End Get + End Property + + _ + Public ReadOnly Property Count() As Integer + Get + Return Me.Rows.Count + End Get + End Property + + _ + Public Default ReadOnly Property Item(ByVal index As Integer) As CustomersRow + Get + Return CType(Me.Rows(index),CustomersRow) + End Get + End Property + + Public Event CustomersRowChanging As CustomersRowChangeEventHandler + + Public Event CustomersRowChanged As CustomersRowChangeEventHandler + + Public Event CustomersRowDeleting As CustomersRowChangeEventHandler + + Public Event CustomersRowDeleted As CustomersRowChangeEventHandler + + _ + Public Overloads Sub AddCustomersRow(ByVal row As CustomersRow) + Me.Rows.Add(row) + End Sub + + _ + Public Overloads Function AddCustomersRow(ByVal CustID As Integer, ByVal FirstName As String, ByVal LastName As String) As CustomersRow + Dim rowCustomersRow As CustomersRow = CType(Me.NewRow,CustomersRow) + Dim columnValuesArray() As Object = New Object() {CustID, FirstName, LastName} + rowCustomersRow.ItemArray = columnValuesArray + Me.Rows.Add(rowCustomersRow) + Return rowCustomersRow + End Function + + _ + Public Function FindByCustID(ByVal CustID As Integer) As CustomersRow + Return CType(Me.Rows.Find(New Object() {CustID}),CustomersRow) + End Function + + _ + Public Overrides Function Clone() As Global.System.Data.DataTable + Dim cln As CustomersDataTable = CType(MyBase.Clone,CustomersDataTable) + cln.InitVars + Return cln + End Function + + _ + Protected Overrides Function CreateInstance() As Global.System.Data.DataTable + Return New CustomersDataTable + End Function + + _ + Friend Sub InitVars() + Me.columnCustID = MyBase.Columns("CustID") + Me.columnFirstName = MyBase.Columns("FirstName") + Me.columnLastName = MyBase.Columns("LastName") + End Sub + + _ + Private Sub InitClass() + Me.columnCustID = New Global.System.Data.DataColumn("CustID", GetType(Integer), Nothing, Global.System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnCustID) + Me.columnFirstName = New Global.System.Data.DataColumn("FirstName", GetType(String), Nothing, Global.System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnFirstName) + Me.columnLastName = New Global.System.Data.DataColumn("LastName", GetType(String), Nothing, Global.System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnLastName) + Me.Constraints.Add(New Global.System.Data.UniqueConstraint("Constraint1", New Global.System.Data.DataColumn() {Me.columnCustID}, true)) + Me.columnCustID.AllowDBNull = false + Me.columnCustID.Unique = true + Me.columnFirstName.AllowDBNull = false + Me.columnFirstName.MaxLength = 50 + Me.columnLastName.AllowDBNull = false + Me.columnLastName.MaxLength = 50 + End Sub + + _ + Public Function NewCustomersRow() As CustomersRow + Return CType(Me.NewRow,CustomersRow) + End Function + + _ + Protected Overrides Function NewRowFromBuilder(ByVal builder As Global.System.Data.DataRowBuilder) As Global.System.Data.DataRow + Return New CustomersRow(builder) + End Function + + _ + Protected Overrides Function GetRowType() As Global.System.Type + Return GetType(CustomersRow) + End Function + + _ + Protected Overrides Sub OnRowChanged(ByVal e As Global.System.Data.DataRowChangeEventArgs) + MyBase.OnRowChanged(e) + If (Not (Me.CustomersRowChangedEvent) Is Nothing) Then + RaiseEvent CustomersRowChanged(Me, New CustomersRowChangeEvent(CType(e.Row,CustomersRow), e.Action)) + End If + End Sub + + _ + Protected Overrides Sub OnRowChanging(ByVal e As Global.System.Data.DataRowChangeEventArgs) + MyBase.OnRowChanging(e) + If (Not (Me.CustomersRowChangingEvent) Is Nothing) Then + RaiseEvent CustomersRowChanging(Me, New CustomersRowChangeEvent(CType(e.Row,CustomersRow), e.Action)) + End If + End Sub + + _ + Protected Overrides Sub OnRowDeleted(ByVal e As Global.System.Data.DataRowChangeEventArgs) + MyBase.OnRowDeleted(e) + If (Not (Me.CustomersRowDeletedEvent) Is Nothing) Then + RaiseEvent CustomersRowDeleted(Me, New CustomersRowChangeEvent(CType(e.Row,CustomersRow), e.Action)) + End If + End Sub + + _ + Protected Overrides Sub OnRowDeleting(ByVal e As Global.System.Data.DataRowChangeEventArgs) + MyBase.OnRowDeleting(e) + If (Not (Me.CustomersRowDeletingEvent) Is Nothing) Then + RaiseEvent CustomersRowDeleting(Me, New CustomersRowChangeEvent(CType(e.Row,CustomersRow), e.Action)) + End If + End Sub + + _ + Public Sub RemoveCustomersRow(ByVal row As CustomersRow) + Me.Rows.Remove(row) + End Sub + + _ + Public Shared Function GetTypedTableSchema(ByVal xs As Global.System.Xml.Schema.XmlSchemaSet) As Global.System.Xml.Schema.XmlSchemaComplexType + Dim type As Global.System.Xml.Schema.XmlSchemaComplexType = New Global.System.Xml.Schema.XmlSchemaComplexType + Dim sequence As Global.System.Xml.Schema.XmlSchemaSequence = New Global.System.Xml.Schema.XmlSchemaSequence + Dim ds As AutoLotDataSet = New AutoLotDataSet + Dim any1 As Global.System.Xml.Schema.XmlSchemaAny = New Global.System.Xml.Schema.XmlSchemaAny + any1.Namespace = "http://www.w3.org/2001/XMLSchema" + any1.MinOccurs = New Decimal(0) + any1.MaxOccurs = Decimal.MaxValue + any1.ProcessContents = Global.System.Xml.Schema.XmlSchemaContentProcessing.Lax + sequence.Items.Add(any1) + Dim any2 As Global.System.Xml.Schema.XmlSchemaAny = New Global.System.Xml.Schema.XmlSchemaAny + any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1" + any2.MinOccurs = New Decimal(1) + any2.ProcessContents = Global.System.Xml.Schema.XmlSchemaContentProcessing.Lax + sequence.Items.Add(any2) + Dim attribute1 As Global.System.Xml.Schema.XmlSchemaAttribute = New Global.System.Xml.Schema.XmlSchemaAttribute + attribute1.Name = "namespace" + attribute1.FixedValue = ds.Namespace + type.Attributes.Add(attribute1) + Dim attribute2 As Global.System.Xml.Schema.XmlSchemaAttribute = New Global.System.Xml.Schema.XmlSchemaAttribute + attribute2.Name = "tableTypeName" + attribute2.FixedValue = "CustomersDataTable" + type.Attributes.Add(attribute2) + type.Particle = sequence + Dim dsSchema As Global.System.Xml.Schema.XmlSchema = ds.GetSchemaSerializable + If xs.Contains(dsSchema.TargetNamespace) Then + Dim s1 As Global.System.IO.MemoryStream = New Global.System.IO.MemoryStream + Dim s2 As Global.System.IO.MemoryStream = New Global.System.IO.MemoryStream + Try + Dim schema As Global.System.Xml.Schema.XmlSchema = Nothing + dsSchema.Write(s1) + Dim schemas As Global.System.Collections.IEnumerator = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator + Do While schemas.MoveNext + schema = CType(schemas.Current,Global.System.Xml.Schema.XmlSchema) + s2.SetLength(0) + schema.Write(s2) + If (s1.Length = s2.Length) Then + s1.Position = 0 + s2.Position = 0 + + Do While ((s1.Position <> s1.Length) _ + AndAlso (s1.ReadByte = s2.ReadByte)) + + + Loop + If (s1.Position = s1.Length) Then + Return type + End If + End If + + Loop + Finally + If (Not (s1) Is Nothing) Then + s1.Close + End If + If (Not (s2) Is Nothing) Then + s2.Close + End If + End Try + End If + xs.Add(dsSchema) + Return type + End Function + End Class + + ''' + '''Represents the strongly named DataTable class. + ''' + _ + Partial Public Class InventoryDataTable + Inherits Global.System.Data.TypedTableBase(Of InventoryRow) + + Private columnCarID As Global.System.Data.DataColumn + + Private columnMake As Global.System.Data.DataColumn + + Private columnColor As Global.System.Data.DataColumn + + Private columnPetName As Global.System.Data.DataColumn + + _ + Public Sub New() + MyBase.New + Me.TableName = "Inventory" + Me.BeginInit + Me.InitClass + Me.EndInit + End Sub + + _ + Friend Sub New(ByVal table As Global.System.Data.DataTable) + MyBase.New + Me.TableName = table.TableName + If (table.CaseSensitive <> table.DataSet.CaseSensitive) Then + Me.CaseSensitive = table.CaseSensitive + End If + If (table.Locale.ToString <> table.DataSet.Locale.ToString) Then + Me.Locale = table.Locale + End If + If (table.Namespace <> table.DataSet.Namespace) Then + Me.Namespace = table.Namespace + End If + Me.Prefix = table.Prefix + Me.MinimumCapacity = table.MinimumCapacity + End Sub + + _ + Protected Sub New(ByVal info As Global.System.Runtime.Serialization.SerializationInfo, ByVal context As Global.System.Runtime.Serialization.StreamingContext) + MyBase.New(info, context) + Me.InitVars + End Sub + + _ + Public ReadOnly Property CarIDColumn() As Global.System.Data.DataColumn + Get + Return Me.columnCarID + End Get + End Property + + _ + Public ReadOnly Property MakeColumn() As Global.System.Data.DataColumn + Get + Return Me.columnMake + End Get + End Property + + _ + Public ReadOnly Property ColorColumn() As Global.System.Data.DataColumn + Get + Return Me.columnColor + End Get + End Property + + _ + Public ReadOnly Property PetNameColumn() As Global.System.Data.DataColumn + Get + Return Me.columnPetName + End Get + End Property + + _ + Public ReadOnly Property Count() As Integer + Get + Return Me.Rows.Count + End Get + End Property + + _ + Public Default ReadOnly Property Item(ByVal index As Integer) As InventoryRow + Get + Return CType(Me.Rows(index),InventoryRow) + End Get + End Property + + Public Event InventoryRowChanging As InventoryRowChangeEventHandler + + Public Event InventoryRowChanged As InventoryRowChangeEventHandler + + Public Event InventoryRowDeleting As InventoryRowChangeEventHandler + + Public Event InventoryRowDeleted As InventoryRowChangeEventHandler + + _ + Public Overloads Sub AddInventoryRow(ByVal row As InventoryRow) + Me.Rows.Add(row) + End Sub + + _ + Public Overloads Function AddInventoryRow(ByVal CarID As Integer, ByVal Make As String, ByVal Color As String, ByVal PetName As String) As InventoryRow + Dim rowInventoryRow As InventoryRow = CType(Me.NewRow,InventoryRow) + Dim columnValuesArray() As Object = New Object() {CarID, Make, Color, PetName} + rowInventoryRow.ItemArray = columnValuesArray + Me.Rows.Add(rowInventoryRow) + Return rowInventoryRow + End Function + + _ + Public Function FindByCarID(ByVal CarID As Integer) As InventoryRow + Return CType(Me.Rows.Find(New Object() {CarID}),InventoryRow) + End Function + + _ + Public Overrides Function Clone() As Global.System.Data.DataTable + Dim cln As InventoryDataTable = CType(MyBase.Clone,InventoryDataTable) + cln.InitVars + Return cln + End Function + + _ + Protected Overrides Function CreateInstance() As Global.System.Data.DataTable + Return New InventoryDataTable + End Function + + _ + Friend Sub InitVars() + Me.columnCarID = MyBase.Columns("CarID") + Me.columnMake = MyBase.Columns("Make") + Me.columnColor = MyBase.Columns("Color") + Me.columnPetName = MyBase.Columns("PetName") + End Sub + + _ + Private Sub InitClass() + Me.columnCarID = New Global.System.Data.DataColumn("CarID", GetType(Integer), Nothing, Global.System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnCarID) + Me.columnMake = New Global.System.Data.DataColumn("Make", GetType(String), Nothing, Global.System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnMake) + Me.columnColor = New Global.System.Data.DataColumn("Color", GetType(String), Nothing, Global.System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnColor) + Me.columnPetName = New Global.System.Data.DataColumn("PetName", GetType(String), Nothing, Global.System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnPetName) + Me.Constraints.Add(New Global.System.Data.UniqueConstraint("Constraint1", New Global.System.Data.DataColumn() {Me.columnCarID}, true)) + Me.columnCarID.AllowDBNull = false + Me.columnCarID.Unique = true + Me.columnMake.AllowDBNull = false + Me.columnMake.MaxLength = 50 + Me.columnColor.AllowDBNull = false + Me.columnColor.MaxLength = 50 + Me.columnPetName.MaxLength = 50 + End Sub + + _ + Public Function NewInventoryRow() As InventoryRow + Return CType(Me.NewRow,InventoryRow) + End Function + + _ + Protected Overrides Function NewRowFromBuilder(ByVal builder As Global.System.Data.DataRowBuilder) As Global.System.Data.DataRow + Return New InventoryRow(builder) + End Function + + _ + Protected Overrides Function GetRowType() As Global.System.Type + Return GetType(InventoryRow) + End Function + + _ + Protected Overrides Sub OnRowChanged(ByVal e As Global.System.Data.DataRowChangeEventArgs) + MyBase.OnRowChanged(e) + If (Not (Me.InventoryRowChangedEvent) Is Nothing) Then + RaiseEvent InventoryRowChanged(Me, New InventoryRowChangeEvent(CType(e.Row,InventoryRow), e.Action)) + End If + End Sub + + _ + Protected Overrides Sub OnRowChanging(ByVal e As Global.System.Data.DataRowChangeEventArgs) + MyBase.OnRowChanging(e) + If (Not (Me.InventoryRowChangingEvent) Is Nothing) Then + RaiseEvent InventoryRowChanging(Me, New InventoryRowChangeEvent(CType(e.Row,InventoryRow), e.Action)) + End If + End Sub + + _ + Protected Overrides Sub OnRowDeleted(ByVal e As Global.System.Data.DataRowChangeEventArgs) + MyBase.OnRowDeleted(e) + If (Not (Me.InventoryRowDeletedEvent) Is Nothing) Then + RaiseEvent InventoryRowDeleted(Me, New InventoryRowChangeEvent(CType(e.Row,InventoryRow), e.Action)) + End If + End Sub + + _ + Protected Overrides Sub OnRowDeleting(ByVal e As Global.System.Data.DataRowChangeEventArgs) + MyBase.OnRowDeleting(e) + If (Not (Me.InventoryRowDeletingEvent) Is Nothing) Then + RaiseEvent InventoryRowDeleting(Me, New InventoryRowChangeEvent(CType(e.Row,InventoryRow), e.Action)) + End If + End Sub + + _ + Public Sub RemoveInventoryRow(ByVal row As InventoryRow) + Me.Rows.Remove(row) + End Sub + + _ + Public Shared Function GetTypedTableSchema(ByVal xs As Global.System.Xml.Schema.XmlSchemaSet) As Global.System.Xml.Schema.XmlSchemaComplexType + Dim type As Global.System.Xml.Schema.XmlSchemaComplexType = New Global.System.Xml.Schema.XmlSchemaComplexType + Dim sequence As Global.System.Xml.Schema.XmlSchemaSequence = New Global.System.Xml.Schema.XmlSchemaSequence + Dim ds As AutoLotDataSet = New AutoLotDataSet + Dim any1 As Global.System.Xml.Schema.XmlSchemaAny = New Global.System.Xml.Schema.XmlSchemaAny + any1.Namespace = "http://www.w3.org/2001/XMLSchema" + any1.MinOccurs = New Decimal(0) + any1.MaxOccurs = Decimal.MaxValue + any1.ProcessContents = Global.System.Xml.Schema.XmlSchemaContentProcessing.Lax + sequence.Items.Add(any1) + Dim any2 As Global.System.Xml.Schema.XmlSchemaAny = New Global.System.Xml.Schema.XmlSchemaAny + any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1" + any2.MinOccurs = New Decimal(1) + any2.ProcessContents = Global.System.Xml.Schema.XmlSchemaContentProcessing.Lax + sequence.Items.Add(any2) + Dim attribute1 As Global.System.Xml.Schema.XmlSchemaAttribute = New Global.System.Xml.Schema.XmlSchemaAttribute + attribute1.Name = "namespace" + attribute1.FixedValue = ds.Namespace + type.Attributes.Add(attribute1) + Dim attribute2 As Global.System.Xml.Schema.XmlSchemaAttribute = New Global.System.Xml.Schema.XmlSchemaAttribute + attribute2.Name = "tableTypeName" + attribute2.FixedValue = "InventoryDataTable" + type.Attributes.Add(attribute2) + type.Particle = sequence + Dim dsSchema As Global.System.Xml.Schema.XmlSchema = ds.GetSchemaSerializable + If xs.Contains(dsSchema.TargetNamespace) Then + Dim s1 As Global.System.IO.MemoryStream = New Global.System.IO.MemoryStream + Dim s2 As Global.System.IO.MemoryStream = New Global.System.IO.MemoryStream + Try + Dim schema As Global.System.Xml.Schema.XmlSchema = Nothing + dsSchema.Write(s1) + Dim schemas As Global.System.Collections.IEnumerator = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator + Do While schemas.MoveNext + schema = CType(schemas.Current,Global.System.Xml.Schema.XmlSchema) + s2.SetLength(0) + schema.Write(s2) + If (s1.Length = s2.Length) Then + s1.Position = 0 + s2.Position = 0 + + Do While ((s1.Position <> s1.Length) _ + AndAlso (s1.ReadByte = s2.ReadByte)) + + + Loop + If (s1.Position = s1.Length) Then + Return type + End If + End If + + Loop + Finally + If (Not (s1) Is Nothing) Then + s1.Close + End If + If (Not (s2) Is Nothing) Then + s2.Close + End If + End Try + End If + xs.Add(dsSchema) + Return type + End Function + End Class + + ''' + '''Represents the strongly named DataTable class. + ''' + _ + Partial Public Class OrdersDataTable + Inherits Global.System.Data.TypedTableBase(Of OrdersRow) + + Private columnOrderID As Global.System.Data.DataColumn + + Private columnCustID As Global.System.Data.DataColumn + + Private columnCarID As Global.System.Data.DataColumn + + _ + Public Sub New() + MyBase.New + Me.TableName = "Orders" + Me.BeginInit + Me.InitClass + Me.EndInit + End Sub + + _ + Friend Sub New(ByVal table As Global.System.Data.DataTable) + MyBase.New + Me.TableName = table.TableName + If (table.CaseSensitive <> table.DataSet.CaseSensitive) Then + Me.CaseSensitive = table.CaseSensitive + End If + If (table.Locale.ToString <> table.DataSet.Locale.ToString) Then + Me.Locale = table.Locale + End If + If (table.Namespace <> table.DataSet.Namespace) Then + Me.Namespace = table.Namespace + End If + Me.Prefix = table.Prefix + Me.MinimumCapacity = table.MinimumCapacity + End Sub + + _ + Protected Sub New(ByVal info As Global.System.Runtime.Serialization.SerializationInfo, ByVal context As Global.System.Runtime.Serialization.StreamingContext) + MyBase.New(info, context) + Me.InitVars + End Sub + + _ + Public ReadOnly Property OrderIDColumn() As Global.System.Data.DataColumn + Get + Return Me.columnOrderID + End Get + End Property + + _ + Public ReadOnly Property CustIDColumn() As Global.System.Data.DataColumn + Get + Return Me.columnCustID + End Get + End Property + + _ + Public ReadOnly Property CarIDColumn() As Global.System.Data.DataColumn + Get + Return Me.columnCarID + End Get + End Property + + _ + Public ReadOnly Property Count() As Integer + Get + Return Me.Rows.Count + End Get + End Property + + _ + Public Default ReadOnly Property Item(ByVal index As Integer) As OrdersRow + Get + Return CType(Me.Rows(index),OrdersRow) + End Get + End Property + + Public Event OrdersRowChanging As OrdersRowChangeEventHandler + + Public Event OrdersRowChanged As OrdersRowChangeEventHandler + + Public Event OrdersRowDeleting As OrdersRowChangeEventHandler + + Public Event OrdersRowDeleted As OrdersRowChangeEventHandler + + _ + Public Overloads Sub AddOrdersRow(ByVal row As OrdersRow) + Me.Rows.Add(row) + End Sub + + _ + Public Overloads Function AddOrdersRow(ByVal OrderID As Integer, ByVal parentCustomersRowByFK_Orders_Customers As CustomersRow, ByVal parentInventoryRowByFK_Orders_Inventory As InventoryRow) As OrdersRow + Dim rowOrdersRow As OrdersRow = CType(Me.NewRow,OrdersRow) + Dim columnValuesArray() As Object = New Object() {OrderID, Nothing, Nothing} + If (Not (parentCustomersRowByFK_Orders_Customers) Is Nothing) Then + columnValuesArray(1) = parentCustomersRowByFK_Orders_Customers(0) + End If + If (Not (parentInventoryRowByFK_Orders_Inventory) Is Nothing) Then + columnValuesArray(2) = parentInventoryRowByFK_Orders_Inventory(0) + End If + rowOrdersRow.ItemArray = columnValuesArray + Me.Rows.Add(rowOrdersRow) + Return rowOrdersRow + End Function + + _ + Public Function FindByOrderID(ByVal OrderID As Integer) As OrdersRow + Return CType(Me.Rows.Find(New Object() {OrderID}),OrdersRow) + End Function + + _ + Public Overrides Function Clone() As Global.System.Data.DataTable + Dim cln As OrdersDataTable = CType(MyBase.Clone,OrdersDataTable) + cln.InitVars + Return cln + End Function + + _ + Protected Overrides Function CreateInstance() As Global.System.Data.DataTable + Return New OrdersDataTable + End Function + + _ + Friend Sub InitVars() + Me.columnOrderID = MyBase.Columns("OrderID") + Me.columnCustID = MyBase.Columns("CustID") + Me.columnCarID = MyBase.Columns("CarID") + End Sub + + _ + Private Sub InitClass() + Me.columnOrderID = New Global.System.Data.DataColumn("OrderID", GetType(Integer), Nothing, Global.System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnOrderID) + Me.columnCustID = New Global.System.Data.DataColumn("CustID", GetType(Integer), Nothing, Global.System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnCustID) + Me.columnCarID = New Global.System.Data.DataColumn("CarID", GetType(Integer), Nothing, Global.System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnCarID) + Me.Constraints.Add(New Global.System.Data.UniqueConstraint("Constraint1", New Global.System.Data.DataColumn() {Me.columnOrderID}, true)) + Me.columnOrderID.AllowDBNull = false + Me.columnOrderID.Unique = true + Me.columnCustID.AllowDBNull = false + Me.columnCarID.AllowDBNull = false + End Sub + + _ + Public Function NewOrdersRow() As OrdersRow + Return CType(Me.NewRow,OrdersRow) + End Function + + _ + Protected Overrides Function NewRowFromBuilder(ByVal builder As Global.System.Data.DataRowBuilder) As Global.System.Data.DataRow + Return New OrdersRow(builder) + End Function + + _ + Protected Overrides Function GetRowType() As Global.System.Type + Return GetType(OrdersRow) + End Function + + _ + Protected Overrides Sub OnRowChanged(ByVal e As Global.System.Data.DataRowChangeEventArgs) + MyBase.OnRowChanged(e) + If (Not (Me.OrdersRowChangedEvent) Is Nothing) Then + RaiseEvent OrdersRowChanged(Me, New OrdersRowChangeEvent(CType(e.Row,OrdersRow), e.Action)) + End If + End Sub + + _ + Protected Overrides Sub OnRowChanging(ByVal e As Global.System.Data.DataRowChangeEventArgs) + MyBase.OnRowChanging(e) + If (Not (Me.OrdersRowChangingEvent) Is Nothing) Then + RaiseEvent OrdersRowChanging(Me, New OrdersRowChangeEvent(CType(e.Row,OrdersRow), e.Action)) + End If + End Sub + + _ + Protected Overrides Sub OnRowDeleted(ByVal e As Global.System.Data.DataRowChangeEventArgs) + MyBase.OnRowDeleted(e) + If (Not (Me.OrdersRowDeletedEvent) Is Nothing) Then + RaiseEvent OrdersRowDeleted(Me, New OrdersRowChangeEvent(CType(e.Row,OrdersRow), e.Action)) + End If + End Sub + + _ + Protected Overrides Sub OnRowDeleting(ByVal e As Global.System.Data.DataRowChangeEventArgs) + MyBase.OnRowDeleting(e) + If (Not (Me.OrdersRowDeletingEvent) Is Nothing) Then + RaiseEvent OrdersRowDeleting(Me, New OrdersRowChangeEvent(CType(e.Row,OrdersRow), e.Action)) + End If + End Sub + + _ + Public Sub RemoveOrdersRow(ByVal row As OrdersRow) + Me.Rows.Remove(row) + End Sub + + _ + Public Shared Function GetTypedTableSchema(ByVal xs As Global.System.Xml.Schema.XmlSchemaSet) As Global.System.Xml.Schema.XmlSchemaComplexType + Dim type As Global.System.Xml.Schema.XmlSchemaComplexType = New Global.System.Xml.Schema.XmlSchemaComplexType + Dim sequence As Global.System.Xml.Schema.XmlSchemaSequence = New Global.System.Xml.Schema.XmlSchemaSequence + Dim ds As AutoLotDataSet = New AutoLotDataSet + Dim any1 As Global.System.Xml.Schema.XmlSchemaAny = New Global.System.Xml.Schema.XmlSchemaAny + any1.Namespace = "http://www.w3.org/2001/XMLSchema" + any1.MinOccurs = New Decimal(0) + any1.MaxOccurs = Decimal.MaxValue + any1.ProcessContents = Global.System.Xml.Schema.XmlSchemaContentProcessing.Lax + sequence.Items.Add(any1) + Dim any2 As Global.System.Xml.Schema.XmlSchemaAny = New Global.System.Xml.Schema.XmlSchemaAny + any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1" + any2.MinOccurs = New Decimal(1) + any2.ProcessContents = Global.System.Xml.Schema.XmlSchemaContentProcessing.Lax + sequence.Items.Add(any2) + Dim attribute1 As Global.System.Xml.Schema.XmlSchemaAttribute = New Global.System.Xml.Schema.XmlSchemaAttribute + attribute1.Name = "namespace" + attribute1.FixedValue = ds.Namespace + type.Attributes.Add(attribute1) + Dim attribute2 As Global.System.Xml.Schema.XmlSchemaAttribute = New Global.System.Xml.Schema.XmlSchemaAttribute + attribute2.Name = "tableTypeName" + attribute2.FixedValue = "OrdersDataTable" + type.Attributes.Add(attribute2) + type.Particle = sequence + Dim dsSchema As Global.System.Xml.Schema.XmlSchema = ds.GetSchemaSerializable + If xs.Contains(dsSchema.TargetNamespace) Then + Dim s1 As Global.System.IO.MemoryStream = New Global.System.IO.MemoryStream + Dim s2 As Global.System.IO.MemoryStream = New Global.System.IO.MemoryStream + Try + Dim schema As Global.System.Xml.Schema.XmlSchema = Nothing + dsSchema.Write(s1) + Dim schemas As Global.System.Collections.IEnumerator = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator + Do While schemas.MoveNext + schema = CType(schemas.Current,Global.System.Xml.Schema.XmlSchema) + s2.SetLength(0) + schema.Write(s2) + If (s1.Length = s2.Length) Then + s1.Position = 0 + s2.Position = 0 + + Do While ((s1.Position <> s1.Length) _ + AndAlso (s1.ReadByte = s2.ReadByte)) + + + Loop + If (s1.Position = s1.Length) Then + Return type + End If + End If + + Loop + Finally + If (Not (s1) Is Nothing) Then + s1.Close + End If + If (Not (s2) Is Nothing) Then + s2.Close + End If + End Try + End If + xs.Add(dsSchema) + Return type + End Function + End Class + + ''' + '''Represents strongly named DataRow class. + ''' + _ + Partial Public Class CustomersRow + Inherits Global.System.Data.DataRow + + Private tableCustomers As CustomersDataTable + + _ + Friend Sub New(ByVal rb As Global.System.Data.DataRowBuilder) + MyBase.New(rb) + Me.tableCustomers = CType(Me.Table,CustomersDataTable) + End Sub + + _ + Public Property CustID() As Integer + Get + Return CType(Me(Me.tableCustomers.CustIDColumn),Integer) + End Get + Set + Me(Me.tableCustomers.CustIDColumn) = value + End Set + End Property + + _ + Public Property FirstName() As String + Get + Return CType(Me(Me.tableCustomers.FirstNameColumn),String) + End Get + Set + Me(Me.tableCustomers.FirstNameColumn) = value + End Set + End Property + + _ + Public Property LastName() As String + Get + Return CType(Me(Me.tableCustomers.LastNameColumn),String) + End Get + Set + Me(Me.tableCustomers.LastNameColumn) = value + End Set + End Property + + _ + Public Function GetOrdersRows() As OrdersRow() + If (Me.Table.ChildRelations("FK_Orders_Customers") Is Nothing) Then + Return New OrdersRow(-1) {} + Else + Return CType(MyBase.GetChildRows(Me.Table.ChildRelations("FK_Orders_Customers")),OrdersRow()) + End If + End Function + End Class + + ''' + '''Represents strongly named DataRow class. + ''' + _ + Partial Public Class InventoryRow + Inherits Global.System.Data.DataRow + + Private tableInventory As InventoryDataTable + + _ + Friend Sub New(ByVal rb As Global.System.Data.DataRowBuilder) + MyBase.New(rb) + Me.tableInventory = CType(Me.Table,InventoryDataTable) + End Sub + + _ + Public Property CarID() As Integer + Get + Return CType(Me(Me.tableInventory.CarIDColumn),Integer) + End Get + Set + Me(Me.tableInventory.CarIDColumn) = value + End Set + End Property + + _ + Public Property Make() As String + Get + Return CType(Me(Me.tableInventory.MakeColumn),String) + End Get + Set + Me(Me.tableInventory.MakeColumn) = value + End Set + End Property + + _ + Public Property Color() As String + Get + Return CType(Me(Me.tableInventory.ColorColumn),String) + End Get + Set + Me(Me.tableInventory.ColorColumn) = value + End Set + End Property + + _ + Public Property PetName() As String + Get + Try + Return CType(Me(Me.tableInventory.PetNameColumn),String) + Catch e As Global.System.InvalidCastException + Throw New Global.System.Data.StrongTypingException("The value for column 'PetName' in table 'Inventory' is DBNull.", e) + End Try + End Get + Set + Me(Me.tableInventory.PetNameColumn) = value + End Set + End Property + + _ + Public Function IsPetNameNull() As Boolean + Return Me.IsNull(Me.tableInventory.PetNameColumn) + End Function + + _ + Public Sub SetPetNameNull() + Me(Me.tableInventory.PetNameColumn) = Global.System.Convert.DBNull + End Sub + + _ + Public Function GetOrdersRows() As OrdersRow() + If (Me.Table.ChildRelations("FK_Orders_Inventory") Is Nothing) Then + Return New OrdersRow(-1) {} + Else + Return CType(MyBase.GetChildRows(Me.Table.ChildRelations("FK_Orders_Inventory")),OrdersRow()) + End If + End Function + End Class + + ''' + '''Represents strongly named DataRow class. + ''' + _ + Partial Public Class OrdersRow + Inherits Global.System.Data.DataRow + + Private tableOrders As OrdersDataTable + + _ + Friend Sub New(ByVal rb As Global.System.Data.DataRowBuilder) + MyBase.New(rb) + Me.tableOrders = CType(Me.Table,OrdersDataTable) + End Sub + + _ + Public Property OrderID() As Integer + Get + Return CType(Me(Me.tableOrders.OrderIDColumn),Integer) + End Get + Set + Me(Me.tableOrders.OrderIDColumn) = value + End Set + End Property + + _ + Public Property CustID() As Integer + Get + Return CType(Me(Me.tableOrders.CustIDColumn),Integer) + End Get + Set + Me(Me.tableOrders.CustIDColumn) = value + End Set + End Property + + _ + Public Property CarID() As Integer + Get + Return CType(Me(Me.tableOrders.CarIDColumn),Integer) + End Get + Set + Me(Me.tableOrders.CarIDColumn) = value + End Set + End Property + + _ + Public Property CustomersRow() As CustomersRow + Get + Return CType(Me.GetParentRow(Me.Table.ParentRelations("FK_Orders_Customers")),CustomersRow) + End Get + Set + Me.SetParentRow(value, Me.Table.ParentRelations("FK_Orders_Customers")) + End Set + End Property + + _ + Public Property InventoryRow() As InventoryRow + Get + Return CType(Me.GetParentRow(Me.Table.ParentRelations("FK_Orders_Inventory")),InventoryRow) + End Get + Set + Me.SetParentRow(value, Me.Table.ParentRelations("FK_Orders_Inventory")) + End Set + End Property + End Class + + ''' + '''Row event argument class + ''' + _ + Public Class CustomersRowChangeEvent + Inherits Global.System.EventArgs + + Private eventRow As CustomersRow + + Private eventAction As Global.System.Data.DataRowAction + + _ + Public Sub New(ByVal row As CustomersRow, ByVal action As Global.System.Data.DataRowAction) + MyBase.New + Me.eventRow = row + Me.eventAction = action + End Sub + + _ + Public ReadOnly Property Row() As CustomersRow + Get + Return Me.eventRow + End Get + End Property + + _ + Public ReadOnly Property Action() As Global.System.Data.DataRowAction + Get + Return Me.eventAction + End Get + End Property + End Class + + ''' + '''Row event argument class + ''' + _ + Public Class InventoryRowChangeEvent + Inherits Global.System.EventArgs + + Private eventRow As InventoryRow + + Private eventAction As Global.System.Data.DataRowAction + + _ + Public Sub New(ByVal row As InventoryRow, ByVal action As Global.System.Data.DataRowAction) + MyBase.New + Me.eventRow = row + Me.eventAction = action + End Sub + + _ + Public ReadOnly Property Row() As InventoryRow + Get + Return Me.eventRow + End Get + End Property + + _ + Public ReadOnly Property Action() As Global.System.Data.DataRowAction + Get + Return Me.eventAction + End Get + End Property + End Class + + ''' + '''Row event argument class + ''' + _ + Public Class OrdersRowChangeEvent + Inherits Global.System.EventArgs + + Private eventRow As OrdersRow + + Private eventAction As Global.System.Data.DataRowAction + + _ + Public Sub New(ByVal row As OrdersRow, ByVal action As Global.System.Data.DataRowAction) + MyBase.New + Me.eventRow = row + Me.eventAction = action + End Sub + + _ + Public ReadOnly Property Row() As OrdersRow + Get + Return Me.eventRow + End Get + End Property + + _ + Public ReadOnly Property Action() As Global.System.Data.DataRowAction + Get + Return Me.eventAction + End Get + End Property + End Class +End Class + +Namespace AutoLotDataSetTableAdapters + + ''' + '''Represents the connection and commands used to retrieve and save data. + ''' + _ + Partial Public Class CustomersTableAdapter + Inherits Global.System.ComponentModel.Component + + Private WithEvents _adapter As Global.System.Data.SqlClient.SqlDataAdapter + + Private _connection As Global.System.Data.SqlClient.SqlConnection + + Private _transaction As Global.System.Data.SqlClient.SqlTransaction + + Private _commandCollection() As Global.System.Data.SqlClient.SqlCommand + + Private _clearBeforeFill As Boolean + + _ + Public Sub New() + MyBase.New + Me.ClearBeforeFill = true + End Sub + + _ + Protected Friend ReadOnly Property Adapter() As Global.System.Data.SqlClient.SqlDataAdapter + Get + If (Me._adapter Is Nothing) Then + Me.InitAdapter + End If + Return Me._adapter + End Get + End Property + + _ + Friend Property Connection() As Global.System.Data.SqlClient.SqlConnection + Get + If (Me._connection Is Nothing) Then + Me.InitConnection + End If + Return Me._connection + End Get + Set + Me._connection = value + If (Not (Me.Adapter.InsertCommand) Is Nothing) Then + Me.Adapter.InsertCommand.Connection = value + End If + If (Not (Me.Adapter.DeleteCommand) Is Nothing) Then + Me.Adapter.DeleteCommand.Connection = value + End If + If (Not (Me.Adapter.UpdateCommand) Is Nothing) Then + Me.Adapter.UpdateCommand.Connection = value + End If + Dim i As Integer = 0 + Do While (i < Me.CommandCollection.Length) + If (Not (Me.CommandCollection(i)) Is Nothing) Then + CType(Me.CommandCollection(i),Global.System.Data.SqlClient.SqlCommand).Connection = value + End If + i = (i + 1) + Loop + End Set + End Property + + _ + Friend Property Transaction() As Global.System.Data.SqlClient.SqlTransaction + Get + Return Me._transaction + End Get + Set + Me._transaction = value + Dim i As Integer = 0 + Do While (i < Me.CommandCollection.Length) + Me.CommandCollection(i).Transaction = Me._transaction + i = (i + 1) + Loop + If ((Not (Me.Adapter) Is Nothing) _ + AndAlso (Not (Me.Adapter.DeleteCommand) Is Nothing)) Then + Me.Adapter.DeleteCommand.Transaction = Me._transaction + End If + If ((Not (Me.Adapter) Is Nothing) _ + AndAlso (Not (Me.Adapter.InsertCommand) Is Nothing)) Then + Me.Adapter.InsertCommand.Transaction = Me._transaction + End If + If ((Not (Me.Adapter) Is Nothing) _ + AndAlso (Not (Me.Adapter.UpdateCommand) Is Nothing)) Then + Me.Adapter.UpdateCommand.Transaction = Me._transaction + End If + End Set + End Property + + _ + Protected ReadOnly Property CommandCollection() As Global.System.Data.SqlClient.SqlCommand() + Get + If (Me._commandCollection Is Nothing) Then + Me.InitCommandCollection + End If + Return Me._commandCollection + End Get + End Property + + _ + Public Property ClearBeforeFill() As Boolean + Get + Return Me._clearBeforeFill + End Get + Set + Me._clearBeforeFill = value + End Set + End Property + + _ + Private Sub InitAdapter() + Me._adapter = New Global.System.Data.SqlClient.SqlDataAdapter + Dim tableMapping As Global.System.Data.Common.DataTableMapping = New Global.System.Data.Common.DataTableMapping + tableMapping.SourceTable = "Table" + tableMapping.DataSetTable = "Customers" + tableMapping.ColumnMappings.Add("CustID", "CustID") + tableMapping.ColumnMappings.Add("FirstName", "FirstName") + tableMapping.ColumnMappings.Add("LastName", "LastName") + Me._adapter.TableMappings.Add(tableMapping) + Me._adapter.DeleteCommand = New Global.System.Data.SqlClient.SqlCommand + Me._adapter.DeleteCommand.Connection = Me.Connection + Me._adapter.DeleteCommand.CommandText = "DELETE FROM [dbo].[Customers] WHERE (([CustID] = @Original_CustID) AND ([FirstNam"& _ + "e] = @Original_FirstName) AND ([LastName] = @Original_LastName))" + Me._adapter.DeleteCommand.CommandType = Global.System.Data.CommandType.Text + Me._adapter.DeleteCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_CustID", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "CustID", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.DeleteCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_FirstName", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "FirstName", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.DeleteCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_LastName", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "LastName", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.InsertCommand = New Global.System.Data.SqlClient.SqlCommand + Me._adapter.InsertCommand.Connection = Me.Connection + Me._adapter.InsertCommand.CommandText = "INSERT INTO [dbo].[Customers] ([CustID], [FirstName], [LastName]) VALUES (@CustID"& _ + ", @FirstName, @LastName);"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"SELECT CustID, FirstName, LastName FROM Customers WHE"& _ + "RE (CustID = @CustID)" + Me._adapter.InsertCommand.CommandType = Global.System.Data.CommandType.Text + Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@CustID", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "CustID", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@FirstName", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "FirstName", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@LastName", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "LastName", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand = New Global.System.Data.SqlClient.SqlCommand + Me._adapter.UpdateCommand.Connection = Me.Connection + Me._adapter.UpdateCommand.CommandText = "UPDATE [dbo].[Customers] SET [CustID] = @CustID, [FirstName] = @FirstName, [LastN"& _ + "ame] = @LastName WHERE (([CustID] = @Original_CustID) AND ([FirstName] = @Origin"& _ + "al_FirstName) AND ([LastName] = @Original_LastName));"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"SELECT CustID, FirstName,"& _ + " LastName FROM Customers WHERE (CustID = @CustID)" + Me._adapter.UpdateCommand.CommandType = Global.System.Data.CommandType.Text + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@CustID", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "CustID", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@FirstName", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "FirstName", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@LastName", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "LastName", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_CustID", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "CustID", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_FirstName", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "FirstName", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_LastName", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "LastName", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + End Sub + + _ + Private Sub InitConnection() + Me._connection = New Global.System.Data.SqlClient.SqlConnection + Me._connection.ConnectionString = Global.My.MySettings.Default.AutoLotConnectionString + End Sub + + _ + Private Sub InitCommandCollection() + Me._commandCollection = New Global.System.Data.SqlClient.SqlCommand(0) {} + Me._commandCollection(0) = New Global.System.Data.SqlClient.SqlCommand + Me._commandCollection(0).Connection = Me.Connection + Me._commandCollection(0).CommandText = "SELECT CustID, FirstName, LastName FROM dbo.Customers" + Me._commandCollection(0).CommandType = Global.System.Data.CommandType.Text + End Sub + + _ + Public Overloads Overridable Function Fill(ByVal dataTable As AutoLotDataSet.CustomersDataTable) As Integer + Me.Adapter.SelectCommand = Me.CommandCollection(0) + If (Me.ClearBeforeFill = true) Then + dataTable.Clear + End If + Dim returnValue As Integer = Me.Adapter.Fill(dataTable) + Return returnValue + End Function + + _ + Public Overloads Overridable Function GetData() As AutoLotDataSet.CustomersDataTable + Me.Adapter.SelectCommand = Me.CommandCollection(0) + Dim dataTable As AutoLotDataSet.CustomersDataTable = New AutoLotDataSet.CustomersDataTable + Me.Adapter.Fill(dataTable) + Return dataTable + End Function + + _ + Public Overloads Overridable Function Update(ByVal dataTable As AutoLotDataSet.CustomersDataTable) As Integer + Return Me.Adapter.Update(dataTable) + End Function + + _ + Public Overloads Overridable Function Update(ByVal dataSet As AutoLotDataSet) As Integer + Return Me.Adapter.Update(dataSet, "Customers") + End Function + + _ + Public Overloads Overridable Function Update(ByVal dataRow As Global.System.Data.DataRow) As Integer + Return Me.Adapter.Update(New Global.System.Data.DataRow() {dataRow}) + End Function + + _ + Public Overloads Overridable Function Update(ByVal dataRows() As Global.System.Data.DataRow) As Integer + Return Me.Adapter.Update(dataRows) + End Function + + _ + Public Overloads Overridable Function Delete(ByVal Original_CustID As Integer, ByVal Original_FirstName As String, ByVal Original_LastName As String) As Integer + Me.Adapter.DeleteCommand.Parameters(0).Value = CType(Original_CustID,Integer) + If (Original_FirstName Is Nothing) Then + Throw New Global.System.ArgumentNullException("Original_FirstName") + Else + Me.Adapter.DeleteCommand.Parameters(1).Value = CType(Original_FirstName,String) + End If + If (Original_LastName Is Nothing) Then + Throw New Global.System.ArgumentNullException("Original_LastName") + Else + Me.Adapter.DeleteCommand.Parameters(2).Value = CType(Original_LastName,String) + End If + Dim previousConnectionState As Global.System.Data.ConnectionState = Me.Adapter.DeleteCommand.Connection.State + If ((Me.Adapter.DeleteCommand.Connection.State And Global.System.Data.ConnectionState.Open) _ + <> Global.System.Data.ConnectionState.Open) Then + Me.Adapter.DeleteCommand.Connection.Open + End If + Try + Dim returnValue As Integer = Me.Adapter.DeleteCommand.ExecuteNonQuery + Return returnValue + Finally + If (previousConnectionState = Global.System.Data.ConnectionState.Closed) Then + Me.Adapter.DeleteCommand.Connection.Close + End If + End Try + End Function + + _ + Public Overloads Overridable Function Insert(ByVal CustID As Integer, ByVal FirstName As String, ByVal LastName As String) As Integer + Me.Adapter.InsertCommand.Parameters(0).Value = CType(CustID,Integer) + If (FirstName Is Nothing) Then + Throw New Global.System.ArgumentNullException("FirstName") + Else + Me.Adapter.InsertCommand.Parameters(1).Value = CType(FirstName,String) + End If + If (LastName Is Nothing) Then + Throw New Global.System.ArgumentNullException("LastName") + Else + Me.Adapter.InsertCommand.Parameters(2).Value = CType(LastName,String) + End If + Dim previousConnectionState As Global.System.Data.ConnectionState = Me.Adapter.InsertCommand.Connection.State + If ((Me.Adapter.InsertCommand.Connection.State And Global.System.Data.ConnectionState.Open) _ + <> Global.System.Data.ConnectionState.Open) Then + Me.Adapter.InsertCommand.Connection.Open + End If + Try + Dim returnValue As Integer = Me.Adapter.InsertCommand.ExecuteNonQuery + Return returnValue + Finally + If (previousConnectionState = Global.System.Data.ConnectionState.Closed) Then + Me.Adapter.InsertCommand.Connection.Close + End If + End Try + End Function + + _ + Public Overloads Overridable Function Update(ByVal CustID As Integer, ByVal FirstName As String, ByVal LastName As String, ByVal Original_CustID As Integer, ByVal Original_FirstName As String, ByVal Original_LastName As String) As Integer + Me.Adapter.UpdateCommand.Parameters(0).Value = CType(CustID,Integer) + If (FirstName Is Nothing) Then + Throw New Global.System.ArgumentNullException("FirstName") + Else + Me.Adapter.UpdateCommand.Parameters(1).Value = CType(FirstName,String) + End If + If (LastName Is Nothing) Then + Throw New Global.System.ArgumentNullException("LastName") + Else + Me.Adapter.UpdateCommand.Parameters(2).Value = CType(LastName,String) + End If + Me.Adapter.UpdateCommand.Parameters(3).Value = CType(Original_CustID,Integer) + If (Original_FirstName Is Nothing) Then + Throw New Global.System.ArgumentNullException("Original_FirstName") + Else + Me.Adapter.UpdateCommand.Parameters(4).Value = CType(Original_FirstName,String) + End If + If (Original_LastName Is Nothing) Then + Throw New Global.System.ArgumentNullException("Original_LastName") + Else + Me.Adapter.UpdateCommand.Parameters(5).Value = CType(Original_LastName,String) + End If + Dim previousConnectionState As Global.System.Data.ConnectionState = Me.Adapter.UpdateCommand.Connection.State + If ((Me.Adapter.UpdateCommand.Connection.State And Global.System.Data.ConnectionState.Open) _ + <> Global.System.Data.ConnectionState.Open) Then + Me.Adapter.UpdateCommand.Connection.Open + End If + Try + Dim returnValue As Integer = Me.Adapter.UpdateCommand.ExecuteNonQuery + Return returnValue + Finally + If (previousConnectionState = Global.System.Data.ConnectionState.Closed) Then + Me.Adapter.UpdateCommand.Connection.Close + End If + End Try + End Function + + _ + Public Overloads Overridable Function Update(ByVal FirstName As String, ByVal LastName As String, ByVal Original_CustID As Integer, ByVal Original_FirstName As String, ByVal Original_LastName As String) As Integer + Return Me.Update(Original_CustID, FirstName, LastName, Original_CustID, Original_FirstName, Original_LastName) + End Function + End Class + + ''' + '''Represents the connection and commands used to retrieve and save data. + ''' + _ + Partial Public Class InventoryTableAdapter + Inherits Global.System.ComponentModel.Component + + Private WithEvents _adapter As Global.System.Data.SqlClient.SqlDataAdapter + + Private _connection As Global.System.Data.SqlClient.SqlConnection + + Private _transaction As Global.System.Data.SqlClient.SqlTransaction + + Private _commandCollection() As Global.System.Data.SqlClient.SqlCommand + + Private _clearBeforeFill As Boolean + + _ + Public Sub New() + MyBase.New + Me.ClearBeforeFill = true + End Sub + + _ + Protected Friend ReadOnly Property Adapter() As Global.System.Data.SqlClient.SqlDataAdapter + Get + If (Me._adapter Is Nothing) Then + Me.InitAdapter + End If + Return Me._adapter + End Get + End Property + + _ + Friend Property Connection() As Global.System.Data.SqlClient.SqlConnection + Get + If (Me._connection Is Nothing) Then + Me.InitConnection + End If + Return Me._connection + End Get + Set + Me._connection = value + If (Not (Me.Adapter.InsertCommand) Is Nothing) Then + Me.Adapter.InsertCommand.Connection = value + End If + If (Not (Me.Adapter.DeleteCommand) Is Nothing) Then + Me.Adapter.DeleteCommand.Connection = value + End If + If (Not (Me.Adapter.UpdateCommand) Is Nothing) Then + Me.Adapter.UpdateCommand.Connection = value + End If + Dim i As Integer = 0 + Do While (i < Me.CommandCollection.Length) + If (Not (Me.CommandCollection(i)) Is Nothing) Then + CType(Me.CommandCollection(i),Global.System.Data.SqlClient.SqlCommand).Connection = value + End If + i = (i + 1) + Loop + End Set + End Property + + _ + Friend Property Transaction() As Global.System.Data.SqlClient.SqlTransaction + Get + Return Me._transaction + End Get + Set + Me._transaction = value + Dim i As Integer = 0 + Do While (i < Me.CommandCollection.Length) + Me.CommandCollection(i).Transaction = Me._transaction + i = (i + 1) + Loop + If ((Not (Me.Adapter) Is Nothing) _ + AndAlso (Not (Me.Adapter.DeleteCommand) Is Nothing)) Then + Me.Adapter.DeleteCommand.Transaction = Me._transaction + End If + If ((Not (Me.Adapter) Is Nothing) _ + AndAlso (Not (Me.Adapter.InsertCommand) Is Nothing)) Then + Me.Adapter.InsertCommand.Transaction = Me._transaction + End If + If ((Not (Me.Adapter) Is Nothing) _ + AndAlso (Not (Me.Adapter.UpdateCommand) Is Nothing)) Then + Me.Adapter.UpdateCommand.Transaction = Me._transaction + End If + End Set + End Property + + _ + Protected ReadOnly Property CommandCollection() As Global.System.Data.SqlClient.SqlCommand() + Get + If (Me._commandCollection Is Nothing) Then + Me.InitCommandCollection + End If + Return Me._commandCollection + End Get + End Property + + _ + Public Property ClearBeforeFill() As Boolean + Get + Return Me._clearBeforeFill + End Get + Set + Me._clearBeforeFill = value + End Set + End Property + + _ + Private Sub InitAdapter() + Me._adapter = New Global.System.Data.SqlClient.SqlDataAdapter + Dim tableMapping As Global.System.Data.Common.DataTableMapping = New Global.System.Data.Common.DataTableMapping + tableMapping.SourceTable = "Table" + tableMapping.DataSetTable = "Inventory" + tableMapping.ColumnMappings.Add("CarID", "CarID") + tableMapping.ColumnMappings.Add("Make", "Make") + tableMapping.ColumnMappings.Add("Color", "Color") + tableMapping.ColumnMappings.Add("PetName", "PetName") + Me._adapter.TableMappings.Add(tableMapping) + Me._adapter.DeleteCommand = New Global.System.Data.SqlClient.SqlCommand + Me._adapter.DeleteCommand.Connection = Me.Connection + Me._adapter.DeleteCommand.CommandText = "DELETE FROM [dbo].[Inventory] WHERE (([CarID] = @Original_CarID) AND ([Make] = @O"& _ + "riginal_Make) AND ([Color] = @Original_Color) AND ((@IsNull_PetName = 1 AND [Pet"& _ + "Name] IS NULL) OR ([PetName] = @Original_PetName)))" + Me._adapter.DeleteCommand.CommandType = Global.System.Data.CommandType.Text + Me._adapter.DeleteCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_CarID", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "CarID", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.DeleteCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_Make", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "Make", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.DeleteCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_Color", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "Color", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.DeleteCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@IsNull_PetName", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "PetName", Global.System.Data.DataRowVersion.Original, true, Nothing, "", "", "")) + Me._adapter.DeleteCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_PetName", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "PetName", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.InsertCommand = New Global.System.Data.SqlClient.SqlCommand + Me._adapter.InsertCommand.Connection = Me.Connection + Me._adapter.InsertCommand.CommandText = "INSERT INTO [dbo].[Inventory] ([CarID], [Make], [Color], [PetName]) VALUES (@CarI"& _ + "D, @Make, @Color, @PetName);"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"SELECT CarID, Make, Color, PetName FROM Inventory "& _ + "WHERE (CarID = @CarID)" + Me._adapter.InsertCommand.CommandType = Global.System.Data.CommandType.Text + Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@CarID", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "CarID", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Make", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "Make", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Color", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "Color", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@PetName", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "PetName", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand = New Global.System.Data.SqlClient.SqlCommand + Me._adapter.UpdateCommand.Connection = Me.Connection + Me._adapter.UpdateCommand.CommandText = "UPDATE [dbo].[Inventory] SET [CarID] = @CarID, [Make] = @Make, [Color] = @Color, "& _ + "[PetName] = @PetName WHERE (([CarID] = @Original_CarID) AND ([Make] = @Original_"& _ + "Make) AND ([Color] = @Original_Color) AND ((@IsNull_PetName = 1 AND [PetName] IS"& _ + " NULL) OR ([PetName] = @Original_PetName)));"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"SELECT CarID, Make, Color, PetName"& _ + " FROM Inventory WHERE (CarID = @CarID)" + Me._adapter.UpdateCommand.CommandType = Global.System.Data.CommandType.Text + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@CarID", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "CarID", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Make", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "Make", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Color", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "Color", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@PetName", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "PetName", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_CarID", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "CarID", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_Make", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "Make", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_Color", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "Color", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@IsNull_PetName", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "PetName", Global.System.Data.DataRowVersion.Original, true, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_PetName", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "PetName", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + End Sub + + _ + Private Sub InitConnection() + Me._connection = New Global.System.Data.SqlClient.SqlConnection + Me._connection.ConnectionString = Global.My.MySettings.Default.AutoLotConnectionString + End Sub + + _ + Private Sub InitCommandCollection() + Me._commandCollection = New Global.System.Data.SqlClient.SqlCommand(0) {} + Me._commandCollection(0) = New Global.System.Data.SqlClient.SqlCommand + Me._commandCollection(0).Connection = Me.Connection + Me._commandCollection(0).CommandText = "SELECT CarID, Make, Color, PetName FROM dbo.Inventory" + Me._commandCollection(0).CommandType = Global.System.Data.CommandType.Text + End Sub + + _ + Public Overloads Overridable Function Fill(ByVal dataTable As AutoLotDataSet.InventoryDataTable) As Integer + Me.Adapter.SelectCommand = Me.CommandCollection(0) + If (Me.ClearBeforeFill = true) Then + dataTable.Clear + End If + Dim returnValue As Integer = Me.Adapter.Fill(dataTable) + Return returnValue + End Function + + _ + Public Overloads Overridable Function GetData() As AutoLotDataSet.InventoryDataTable + Me.Adapter.SelectCommand = Me.CommandCollection(0) + Dim dataTable As AutoLotDataSet.InventoryDataTable = New AutoLotDataSet.InventoryDataTable + Me.Adapter.Fill(dataTable) + Return dataTable + End Function + + _ + Public Overloads Overridable Function Update(ByVal dataTable As AutoLotDataSet.InventoryDataTable) As Integer + Return Me.Adapter.Update(dataTable) + End Function + + _ + Public Overloads Overridable Function Update(ByVal dataSet As AutoLotDataSet) As Integer + Return Me.Adapter.Update(dataSet, "Inventory") + End Function + + _ + Public Overloads Overridable Function Update(ByVal dataRow As Global.System.Data.DataRow) As Integer + Return Me.Adapter.Update(New Global.System.Data.DataRow() {dataRow}) + End Function + + _ + Public Overloads Overridable Function Update(ByVal dataRows() As Global.System.Data.DataRow) As Integer + Return Me.Adapter.Update(dataRows) + End Function + + _ + Public Overloads Overridable Function Delete(ByVal Original_CarID As Integer, ByVal Original_Make As String, ByVal Original_Color As String, ByVal Original_PetName As String) As Integer + Me.Adapter.DeleteCommand.Parameters(0).Value = CType(Original_CarID,Integer) + If (Original_Make Is Nothing) Then + Throw New Global.System.ArgumentNullException("Original_Make") + Else + Me.Adapter.DeleteCommand.Parameters(1).Value = CType(Original_Make,String) + End If + If (Original_Color Is Nothing) Then + Throw New Global.System.ArgumentNullException("Original_Color") + Else + Me.Adapter.DeleteCommand.Parameters(2).Value = CType(Original_Color,String) + End If + If (Original_PetName Is Nothing) Then + Me.Adapter.DeleteCommand.Parameters(3).Value = CType(1,Object) + Me.Adapter.DeleteCommand.Parameters(4).Value = Global.System.DBNull.Value + Else + Me.Adapter.DeleteCommand.Parameters(3).Value = CType(0,Object) + Me.Adapter.DeleteCommand.Parameters(4).Value = CType(Original_PetName,String) + End If + Dim previousConnectionState As Global.System.Data.ConnectionState = Me.Adapter.DeleteCommand.Connection.State + If ((Me.Adapter.DeleteCommand.Connection.State And Global.System.Data.ConnectionState.Open) _ + <> Global.System.Data.ConnectionState.Open) Then + Me.Adapter.DeleteCommand.Connection.Open + End If + Try + Dim returnValue As Integer = Me.Adapter.DeleteCommand.ExecuteNonQuery + Return returnValue + Finally + If (previousConnectionState = Global.System.Data.ConnectionState.Closed) Then + Me.Adapter.DeleteCommand.Connection.Close + End If + End Try + End Function + + _ + Public Overloads Overridable Function Insert(ByVal CarID As Integer, ByVal Make As String, ByVal Color As String, ByVal PetName As String) As Integer + Me.Adapter.InsertCommand.Parameters(0).Value = CType(CarID,Integer) + If (Make Is Nothing) Then + Throw New Global.System.ArgumentNullException("Make") + Else + Me.Adapter.InsertCommand.Parameters(1).Value = CType(Make,String) + End If + If (Color Is Nothing) Then + Throw New Global.System.ArgumentNullException("Color") + Else + Me.Adapter.InsertCommand.Parameters(2).Value = CType(Color,String) + End If + If (PetName Is Nothing) Then + Me.Adapter.InsertCommand.Parameters(3).Value = Global.System.DBNull.Value + Else + Me.Adapter.InsertCommand.Parameters(3).Value = CType(PetName,String) + End If + Dim previousConnectionState As Global.System.Data.ConnectionState = Me.Adapter.InsertCommand.Connection.State + If ((Me.Adapter.InsertCommand.Connection.State And Global.System.Data.ConnectionState.Open) _ + <> Global.System.Data.ConnectionState.Open) Then + Me.Adapter.InsertCommand.Connection.Open + End If + Try + Dim returnValue As Integer = Me.Adapter.InsertCommand.ExecuteNonQuery + Return returnValue + Finally + If (previousConnectionState = Global.System.Data.ConnectionState.Closed) Then + Me.Adapter.InsertCommand.Connection.Close + End If + End Try + End Function + + _ + Public Overloads Overridable Function Update(ByVal CarID As Integer, ByVal Make As String, ByVal Color As String, ByVal PetName As String, ByVal Original_CarID As Integer, ByVal Original_Make As String, ByVal Original_Color As String, ByVal Original_PetName As String) As Integer + Me.Adapter.UpdateCommand.Parameters(0).Value = CType(CarID,Integer) + If (Make Is Nothing) Then + Throw New Global.System.ArgumentNullException("Make") + Else + Me.Adapter.UpdateCommand.Parameters(1).Value = CType(Make,String) + End If + If (Color Is Nothing) Then + Throw New Global.System.ArgumentNullException("Color") + Else + Me.Adapter.UpdateCommand.Parameters(2).Value = CType(Color,String) + End If + If (PetName Is Nothing) Then + Me.Adapter.UpdateCommand.Parameters(3).Value = Global.System.DBNull.Value + Else + Me.Adapter.UpdateCommand.Parameters(3).Value = CType(PetName,String) + End If + Me.Adapter.UpdateCommand.Parameters(4).Value = CType(Original_CarID,Integer) + If (Original_Make Is Nothing) Then + Throw New Global.System.ArgumentNullException("Original_Make") + Else + Me.Adapter.UpdateCommand.Parameters(5).Value = CType(Original_Make,String) + End If + If (Original_Color Is Nothing) Then + Throw New Global.System.ArgumentNullException("Original_Color") + Else + Me.Adapter.UpdateCommand.Parameters(6).Value = CType(Original_Color,String) + End If + If (Original_PetName Is Nothing) Then + Me.Adapter.UpdateCommand.Parameters(7).Value = CType(1,Object) + Me.Adapter.UpdateCommand.Parameters(8).Value = Global.System.DBNull.Value + Else + Me.Adapter.UpdateCommand.Parameters(7).Value = CType(0,Object) + Me.Adapter.UpdateCommand.Parameters(8).Value = CType(Original_PetName,String) + End If + Dim previousConnectionState As Global.System.Data.ConnectionState = Me.Adapter.UpdateCommand.Connection.State + If ((Me.Adapter.UpdateCommand.Connection.State And Global.System.Data.ConnectionState.Open) _ + <> Global.System.Data.ConnectionState.Open) Then + Me.Adapter.UpdateCommand.Connection.Open + End If + Try + Dim returnValue As Integer = Me.Adapter.UpdateCommand.ExecuteNonQuery + Return returnValue + Finally + If (previousConnectionState = Global.System.Data.ConnectionState.Closed) Then + Me.Adapter.UpdateCommand.Connection.Close + End If + End Try + End Function + + _ + Public Overloads Overridable Function Update(ByVal Make As String, ByVal Color As String, ByVal PetName As String, ByVal Original_CarID As Integer, ByVal Original_Make As String, ByVal Original_Color As String, ByVal Original_PetName As String) As Integer + Return Me.Update(Original_CarID, Make, Color, PetName, Original_CarID, Original_Make, Original_Color, Original_PetName) + End Function + End Class + + ''' + '''Represents the connection and commands used to retrieve and save data. + ''' + _ + Partial Public Class OrdersTableAdapter + Inherits Global.System.ComponentModel.Component + + Private WithEvents _adapter As Global.System.Data.SqlClient.SqlDataAdapter + + Private _connection As Global.System.Data.SqlClient.SqlConnection + + Private _transaction As Global.System.Data.SqlClient.SqlTransaction + + Private _commandCollection() As Global.System.Data.SqlClient.SqlCommand + + Private _clearBeforeFill As Boolean + + _ + Public Sub New() + MyBase.New + Me.ClearBeforeFill = true + End Sub + + _ + Protected Friend ReadOnly Property Adapter() As Global.System.Data.SqlClient.SqlDataAdapter + Get + If (Me._adapter Is Nothing) Then + Me.InitAdapter + End If + Return Me._adapter + End Get + End Property + + _ + Friend Property Connection() As Global.System.Data.SqlClient.SqlConnection + Get + If (Me._connection Is Nothing) Then + Me.InitConnection + End If + Return Me._connection + End Get + Set + Me._connection = value + If (Not (Me.Adapter.InsertCommand) Is Nothing) Then + Me.Adapter.InsertCommand.Connection = value + End If + If (Not (Me.Adapter.DeleteCommand) Is Nothing) Then + Me.Adapter.DeleteCommand.Connection = value + End If + If (Not (Me.Adapter.UpdateCommand) Is Nothing) Then + Me.Adapter.UpdateCommand.Connection = value + End If + Dim i As Integer = 0 + Do While (i < Me.CommandCollection.Length) + If (Not (Me.CommandCollection(i)) Is Nothing) Then + CType(Me.CommandCollection(i),Global.System.Data.SqlClient.SqlCommand).Connection = value + End If + i = (i + 1) + Loop + End Set + End Property + + _ + Friend Property Transaction() As Global.System.Data.SqlClient.SqlTransaction + Get + Return Me._transaction + End Get + Set + Me._transaction = value + Dim i As Integer = 0 + Do While (i < Me.CommandCollection.Length) + Me.CommandCollection(i).Transaction = Me._transaction + i = (i + 1) + Loop + If ((Not (Me.Adapter) Is Nothing) _ + AndAlso (Not (Me.Adapter.DeleteCommand) Is Nothing)) Then + Me.Adapter.DeleteCommand.Transaction = Me._transaction + End If + If ((Not (Me.Adapter) Is Nothing) _ + AndAlso (Not (Me.Adapter.InsertCommand) Is Nothing)) Then + Me.Adapter.InsertCommand.Transaction = Me._transaction + End If + If ((Not (Me.Adapter) Is Nothing) _ + AndAlso (Not (Me.Adapter.UpdateCommand) Is Nothing)) Then + Me.Adapter.UpdateCommand.Transaction = Me._transaction + End If + End Set + End Property + + _ + Protected ReadOnly Property CommandCollection() As Global.System.Data.SqlClient.SqlCommand() + Get + If (Me._commandCollection Is Nothing) Then + Me.InitCommandCollection + End If + Return Me._commandCollection + End Get + End Property + + _ + Public Property ClearBeforeFill() As Boolean + Get + Return Me._clearBeforeFill + End Get + Set + Me._clearBeforeFill = value + End Set + End Property + + _ + Private Sub InitAdapter() + Me._adapter = New Global.System.Data.SqlClient.SqlDataAdapter + Dim tableMapping As Global.System.Data.Common.DataTableMapping = New Global.System.Data.Common.DataTableMapping + tableMapping.SourceTable = "Table" + tableMapping.DataSetTable = "Orders" + tableMapping.ColumnMappings.Add("OrderID", "OrderID") + tableMapping.ColumnMappings.Add("CustID", "CustID") + tableMapping.ColumnMappings.Add("CarID", "CarID") + Me._adapter.TableMappings.Add(tableMapping) + Me._adapter.DeleteCommand = New Global.System.Data.SqlClient.SqlCommand + Me._adapter.DeleteCommand.Connection = Me.Connection + Me._adapter.DeleteCommand.CommandText = "DELETE FROM [dbo].[Orders] WHERE (([OrderID] = @Original_OrderID) AND ([CustID] ="& _ + " @Original_CustID) AND ([CarID] = @Original_CarID))" + Me._adapter.DeleteCommand.CommandType = Global.System.Data.CommandType.Text + Me._adapter.DeleteCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_OrderID", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "OrderID", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.DeleteCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_CustID", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "CustID", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.DeleteCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_CarID", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "CarID", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.InsertCommand = New Global.System.Data.SqlClient.SqlCommand + Me._adapter.InsertCommand.Connection = Me.Connection + Me._adapter.InsertCommand.CommandText = "INSERT INTO [dbo].[Orders] ([OrderID], [CustID], [CarID]) VALUES (@OrderID, @Cust"& _ + "ID, @CarID);"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"SELECT OrderID, CustID, CarID FROM Orders WHERE (OrderID = @OrderI"& _ + "D)" + Me._adapter.InsertCommand.CommandType = Global.System.Data.CommandType.Text + Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@OrderID", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "OrderID", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@CustID", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "CustID", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@CarID", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "CarID", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand = New Global.System.Data.SqlClient.SqlCommand + Me._adapter.UpdateCommand.Connection = Me.Connection + Me._adapter.UpdateCommand.CommandText = "UPDATE [dbo].[Orders] SET [OrderID] = @OrderID, [CustID] = @CustID, [CarID] = @Ca"& _ + "rID WHERE (([OrderID] = @Original_OrderID) AND ([CustID] = @Original_CustID) AND"& _ + " ([CarID] = @Original_CarID));"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"SELECT OrderID, CustID, CarID FROM Orders WHERE "& _ + "(OrderID = @OrderID)" + Me._adapter.UpdateCommand.CommandType = Global.System.Data.CommandType.Text + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@OrderID", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "OrderID", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@CustID", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "CustID", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@CarID", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "CarID", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_OrderID", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "OrderID", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_CustID", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "CustID", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_CarID", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "CarID", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + End Sub + + _ + Private Sub InitConnection() + Me._connection = New Global.System.Data.SqlClient.SqlConnection + Me._connection.ConnectionString = Global.My.MySettings.Default.AutoLotConnectionString + End Sub + + _ + Private Sub InitCommandCollection() + Me._commandCollection = New Global.System.Data.SqlClient.SqlCommand(0) {} + Me._commandCollection(0) = New Global.System.Data.SqlClient.SqlCommand + Me._commandCollection(0).Connection = Me.Connection + Me._commandCollection(0).CommandText = "SELECT OrderID, CustID, CarID FROM dbo.Orders" + Me._commandCollection(0).CommandType = Global.System.Data.CommandType.Text + End Sub + + _ + Public Overloads Overridable Function Fill(ByVal dataTable As AutoLotDataSet.OrdersDataTable) As Integer + Me.Adapter.SelectCommand = Me.CommandCollection(0) + If (Me.ClearBeforeFill = true) Then + dataTable.Clear + End If + Dim returnValue As Integer = Me.Adapter.Fill(dataTable) + Return returnValue + End Function + + _ + Public Overloads Overridable Function GetData() As AutoLotDataSet.OrdersDataTable + Me.Adapter.SelectCommand = Me.CommandCollection(0) + Dim dataTable As AutoLotDataSet.OrdersDataTable = New AutoLotDataSet.OrdersDataTable + Me.Adapter.Fill(dataTable) + Return dataTable + End Function + + _ + Public Overloads Overridable Function Update(ByVal dataTable As AutoLotDataSet.OrdersDataTable) As Integer + Return Me.Adapter.Update(dataTable) + End Function + + _ + Public Overloads Overridable Function Update(ByVal dataSet As AutoLotDataSet) As Integer + Return Me.Adapter.Update(dataSet, "Orders") + End Function + + _ + Public Overloads Overridable Function Update(ByVal dataRow As Global.System.Data.DataRow) As Integer + Return Me.Adapter.Update(New Global.System.Data.DataRow() {dataRow}) + End Function + + _ + Public Overloads Overridable Function Update(ByVal dataRows() As Global.System.Data.DataRow) As Integer + Return Me.Adapter.Update(dataRows) + End Function + + _ + Public Overloads Overridable Function Delete(ByVal Original_OrderID As Integer, ByVal Original_CustID As Integer, ByVal Original_CarID As Integer) As Integer + Me.Adapter.DeleteCommand.Parameters(0).Value = CType(Original_OrderID,Integer) + Me.Adapter.DeleteCommand.Parameters(1).Value = CType(Original_CustID,Integer) + Me.Adapter.DeleteCommand.Parameters(2).Value = CType(Original_CarID,Integer) + Dim previousConnectionState As Global.System.Data.ConnectionState = Me.Adapter.DeleteCommand.Connection.State + If ((Me.Adapter.DeleteCommand.Connection.State And Global.System.Data.ConnectionState.Open) _ + <> Global.System.Data.ConnectionState.Open) Then + Me.Adapter.DeleteCommand.Connection.Open + End If + Try + Dim returnValue As Integer = Me.Adapter.DeleteCommand.ExecuteNonQuery + Return returnValue + Finally + If (previousConnectionState = Global.System.Data.ConnectionState.Closed) Then + Me.Adapter.DeleteCommand.Connection.Close + End If + End Try + End Function + + _ + Public Overloads Overridable Function Insert(ByVal OrderID As Integer, ByVal CustID As Integer, ByVal CarID As Integer) As Integer + Me.Adapter.InsertCommand.Parameters(0).Value = CType(OrderID,Integer) + Me.Adapter.InsertCommand.Parameters(1).Value = CType(CustID,Integer) + Me.Adapter.InsertCommand.Parameters(2).Value = CType(CarID,Integer) + Dim previousConnectionState As Global.System.Data.ConnectionState = Me.Adapter.InsertCommand.Connection.State + If ((Me.Adapter.InsertCommand.Connection.State And Global.System.Data.ConnectionState.Open) _ + <> Global.System.Data.ConnectionState.Open) Then + Me.Adapter.InsertCommand.Connection.Open + End If + Try + Dim returnValue As Integer = Me.Adapter.InsertCommand.ExecuteNonQuery + Return returnValue + Finally + If (previousConnectionState = Global.System.Data.ConnectionState.Closed) Then + Me.Adapter.InsertCommand.Connection.Close + End If + End Try + End Function + + _ + Public Overloads Overridable Function Update(ByVal OrderID As Integer, ByVal CustID As Integer, ByVal CarID As Integer, ByVal Original_OrderID As Integer, ByVal Original_CustID As Integer, ByVal Original_CarID As Integer) As Integer + Me.Adapter.UpdateCommand.Parameters(0).Value = CType(OrderID,Integer) + Me.Adapter.UpdateCommand.Parameters(1).Value = CType(CustID,Integer) + Me.Adapter.UpdateCommand.Parameters(2).Value = CType(CarID,Integer) + Me.Adapter.UpdateCommand.Parameters(3).Value = CType(Original_OrderID,Integer) + Me.Adapter.UpdateCommand.Parameters(4).Value = CType(Original_CustID,Integer) + Me.Adapter.UpdateCommand.Parameters(5).Value = CType(Original_CarID,Integer) + Dim previousConnectionState As Global.System.Data.ConnectionState = Me.Adapter.UpdateCommand.Connection.State + If ((Me.Adapter.UpdateCommand.Connection.State And Global.System.Data.ConnectionState.Open) _ + <> Global.System.Data.ConnectionState.Open) Then + Me.Adapter.UpdateCommand.Connection.Open + End If + Try + Dim returnValue As Integer = Me.Adapter.UpdateCommand.ExecuteNonQuery + Return returnValue + Finally + If (previousConnectionState = Global.System.Data.ConnectionState.Closed) Then + Me.Adapter.UpdateCommand.Connection.Close + End If + End Try + End Function + + _ + Public Overloads Overridable Function Update(ByVal CustID As Integer, ByVal CarID As Integer, ByVal Original_OrderID As Integer, ByVal Original_CustID As Integer, ByVal Original_CarID As Integer) As Integer + Return Me.Update(Original_OrderID, CustID, CarID, Original_OrderID, Original_CustID, Original_CarID) + End Function + End Class + + ''' + '''Represents the connection and commands used to retrieve and save data. + ''' + _ + Partial Public Class QueriesTableAdapter + Inherits Global.System.ComponentModel.Component + + Private _commandCollection() As Global.System.Data.IDbCommand + + _ + Protected ReadOnly Property CommandCollection() As Global.System.Data.IDbCommand() + Get + If (Me._commandCollection Is Nothing) Then + Me.InitCommandCollection + End If + Return Me._commandCollection + End Get + End Property + + _ + Private Sub InitCommandCollection() + Me._commandCollection = New Global.System.Data.IDbCommand(0) {} + Me._commandCollection(0) = New Global.System.Data.SqlClient.SqlCommand + CType(Me._commandCollection(0),Global.System.Data.SqlClient.SqlCommand).Connection = New Global.System.Data.SqlClient.SqlConnection(Global.My.MySettings.Default.AutoLotConnectionString) + CType(Me._commandCollection(0),Global.System.Data.SqlClient.SqlCommand).CommandText = "dbo.GetPetName" + CType(Me._commandCollection(0),Global.System.Data.SqlClient.SqlCommand).CommandType = Global.System.Data.CommandType.StoredProcedure + CType(Me._commandCollection(0),Global.System.Data.SqlClient.SqlCommand).Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@RETURN_VALUE", Global.System.Data.SqlDbType.Int, 4, Global.System.Data.ParameterDirection.ReturnValue, 10, 0, Nothing, Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + CType(Me._commandCollection(0),Global.System.Data.SqlClient.SqlCommand).Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@carID", Global.System.Data.SqlDbType.Int, 4, Global.System.Data.ParameterDirection.Input, 10, 0, Nothing, Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + CType(Me._commandCollection(0),Global.System.Data.SqlClient.SqlCommand).Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@petName", Global.System.Data.SqlDbType.[Char], 10, Global.System.Data.ParameterDirection.InputOutput, 0, 0, Nothing, Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + End Sub + + _ + Public Overloads Overridable Function GetPetName(ByVal carID As Global.System.Nullable(Of Integer), ByRef petName As String) As Integer + Dim command As Global.System.Data.SqlClient.SqlCommand = CType(Me.CommandCollection(0),Global.System.Data.SqlClient.SqlCommand) + If (carID.HasValue = true) Then + command.Parameters(1).Value = CType(carID.Value,Integer) + Else + command.Parameters(1).Value = Global.System.DBNull.Value + End If + If (petName Is Nothing) Then + command.Parameters(2).Value = Global.System.DBNull.Value + Else + command.Parameters(2).Value = CType(petName,String) + End If + Dim previousConnectionState As Global.System.Data.ConnectionState = command.Connection.State + If ((command.Connection.State And Global.System.Data.ConnectionState.Open) _ + <> Global.System.Data.ConnectionState.Open) Then + command.Connection.Open + End If + Dim returnValue As Integer + Try + returnValue = command.ExecuteNonQuery + Finally + If (previousConnectionState = Global.System.Data.ConnectionState.Closed) Then + command.Connection.Close + End If + End Try + If ((command.Parameters(2).Value Is Nothing) _ + OrElse (command.Parameters(2).Value.GetType Is GetType(Global.System.DBNull))) Then + petName = Nothing + Else + petName = CType(command.Parameters(2).Value,String) + End If + Return returnValue + End Function + End Class + + ''' + '''TableAdapterManager is used to coordinate TableAdapters in the dataset to enable Hierarchical Update scenarios + ''' + _ + Partial Public Class TableAdapterManager + Inherits Global.System.ComponentModel.Component + + Private _updateOrder As UpdateOrderOption + + Private _customersTableAdapter As CustomersTableAdapter + + Private _inventoryTableAdapter As InventoryTableAdapter + + Private _ordersTableAdapter As OrdersTableAdapter + + Private _backupDataSetBeforeUpdate As Boolean + + Private _connection As Global.System.Data.IDbConnection + + _ + Public Property UpdateOrder() As UpdateOrderOption + Get + Return Me._updateOrder + End Get + Set + Me._updateOrder = value + End Set + End Property + + _ + Public Property CustomersTableAdapter() As CustomersTableAdapter + Get + Return Me._customersTableAdapter + End Get + Set + If ((Not (Me._customersTableAdapter) Is Nothing) _ + AndAlso (Me.TableAdapterInstanceCount = 1)) Then + Me._customersTableAdapter = value + Return + End If + If ((Not (value) Is Nothing) _ + AndAlso (Me.MatchTableAdapterConnection(value.Connection) = false)) Then + Throw New Global.System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s"& _ + "tring.") + End If + Me._customersTableAdapter = value + End Set + End Property + + _ + Public Property InventoryTableAdapter() As InventoryTableAdapter + Get + Return Me._inventoryTableAdapter + End Get + Set + If ((Not (Me._inventoryTableAdapter) Is Nothing) _ + AndAlso (Me.TableAdapterInstanceCount = 1)) Then + Me._inventoryTableAdapter = value + Return + End If + If ((Not (value) Is Nothing) _ + AndAlso (Me.MatchTableAdapterConnection(value.Connection) = false)) Then + Throw New Global.System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s"& _ + "tring.") + End If + Me._inventoryTableAdapter = value + End Set + End Property + + _ + Public Property OrdersTableAdapter() As OrdersTableAdapter + Get + Return Me._ordersTableAdapter + End Get + Set + If ((Not (Me._ordersTableAdapter) Is Nothing) _ + AndAlso (Me.TableAdapterInstanceCount = 1)) Then + Me._ordersTableAdapter = value + Return + End If + If ((Not (value) Is Nothing) _ + AndAlso (Me.MatchTableAdapterConnection(value.Connection) = false)) Then + Throw New Global.System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s"& _ + "tring.") + End If + Me._ordersTableAdapter = value + End Set + End Property + + _ + Public Property BackupDataSetBeforeUpdate() As Boolean + Get + Return Me._backupDataSetBeforeUpdate + End Get + Set + Me._backupDataSetBeforeUpdate = value + End Set + End Property + + _ + Public Property Connection() As Global.System.Data.IDbConnection + Get + If (Not (Me._connection) Is Nothing) Then + Return Me._connection + End If + If ((Not (Me._customersTableAdapter) Is Nothing) _ + AndAlso (Not (Me._customersTableAdapter.Connection) Is Nothing)) Then + Return Me._customersTableAdapter.Connection + End If + If ((Not (Me._inventoryTableAdapter) Is Nothing) _ + AndAlso (Not (Me._inventoryTableAdapter.Connection) Is Nothing)) Then + Return Me._inventoryTableAdapter.Connection + End If + If ((Not (Me._ordersTableAdapter) Is Nothing) _ + AndAlso (Not (Me._ordersTableAdapter.Connection) Is Nothing)) Then + Return Me._ordersTableAdapter.Connection + End If + Return Nothing + End Get + Set + Me._connection = value + End Set + End Property + + _ + Public ReadOnly Property TableAdapterInstanceCount() As Integer + Get + Dim count As Integer = 0 + If (Not (Me._customersTableAdapter) Is Nothing) Then + count = (count + 1) + End If + If (Not (Me._inventoryTableAdapter) Is Nothing) Then + count = (count + 1) + End If + If (Not (Me._ordersTableAdapter) Is Nothing) Then + count = (count + 1) + End If + Return count + End Get + End Property + + ''' + '''Update rows in top-down order. + ''' + _ + Private Function UpdateUpdatedRows(ByVal dataSet As AutoLotDataSet, ByVal allChangedRows As Global.System.Collections.Generic.List(Of Global.System.Data.DataRow), ByVal allAddedRows As Global.System.Collections.Generic.List(Of Global.System.Data.DataRow)) As Integer + Dim result As Integer = 0 + If (Not (Me._inventoryTableAdapter) Is Nothing) Then + Dim updatedRows() As Global.System.Data.DataRow = dataSet.Inventory.Select(Nothing, Nothing, Global.System.Data.DataViewRowState.ModifiedCurrent) + updatedRows = Me.GetRealUpdatedRows(updatedRows, allAddedRows) + If ((Not (updatedRows) Is Nothing) _ + AndAlso (0 < updatedRows.Length)) Then + result = (result + Me._inventoryTableAdapter.Update(updatedRows)) + allChangedRows.AddRange(updatedRows) + End If + End If + If (Not (Me._customersTableAdapter) Is Nothing) Then + Dim updatedRows() As Global.System.Data.DataRow = dataSet.Customers.Select(Nothing, Nothing, Global.System.Data.DataViewRowState.ModifiedCurrent) + updatedRows = Me.GetRealUpdatedRows(updatedRows, allAddedRows) + If ((Not (updatedRows) Is Nothing) _ + AndAlso (0 < updatedRows.Length)) Then + result = (result + Me._customersTableAdapter.Update(updatedRows)) + allChangedRows.AddRange(updatedRows) + End If + End If + If (Not (Me._ordersTableAdapter) Is Nothing) Then + Dim updatedRows() As Global.System.Data.DataRow = dataSet.Orders.Select(Nothing, Nothing, Global.System.Data.DataViewRowState.ModifiedCurrent) + updatedRows = Me.GetRealUpdatedRows(updatedRows, allAddedRows) + If ((Not (updatedRows) Is Nothing) _ + AndAlso (0 < updatedRows.Length)) Then + result = (result + Me._ordersTableAdapter.Update(updatedRows)) + allChangedRows.AddRange(updatedRows) + End If + End If + Return result + End Function + + ''' + '''Insert rows in top-down order. + ''' + _ + Private Function UpdateInsertedRows(ByVal dataSet As AutoLotDataSet, ByVal allAddedRows As Global.System.Collections.Generic.List(Of Global.System.Data.DataRow)) As Integer + Dim result As Integer = 0 + If (Not (Me._inventoryTableAdapter) Is Nothing) Then + Dim addedRows() As Global.System.Data.DataRow = dataSet.Inventory.Select(Nothing, Nothing, Global.System.Data.DataViewRowState.Added) + If ((Not (addedRows) Is Nothing) _ + AndAlso (0 < addedRows.Length)) Then + result = (result + Me._inventoryTableAdapter.Update(addedRows)) + allAddedRows.AddRange(addedRows) + End If + End If + If (Not (Me._customersTableAdapter) Is Nothing) Then + Dim addedRows() As Global.System.Data.DataRow = dataSet.Customers.Select(Nothing, Nothing, Global.System.Data.DataViewRowState.Added) + If ((Not (addedRows) Is Nothing) _ + AndAlso (0 < addedRows.Length)) Then + result = (result + Me._customersTableAdapter.Update(addedRows)) + allAddedRows.AddRange(addedRows) + End If + End If + If (Not (Me._ordersTableAdapter) Is Nothing) Then + Dim addedRows() As Global.System.Data.DataRow = dataSet.Orders.Select(Nothing, Nothing, Global.System.Data.DataViewRowState.Added) + If ((Not (addedRows) Is Nothing) _ + AndAlso (0 < addedRows.Length)) Then + result = (result + Me._ordersTableAdapter.Update(addedRows)) + allAddedRows.AddRange(addedRows) + End If + End If + Return result + End Function + + ''' + '''Delete rows in bottom-up order. + ''' + _ + Private Function UpdateDeletedRows(ByVal dataSet As AutoLotDataSet, ByVal allChangedRows As Global.System.Collections.Generic.List(Of Global.System.Data.DataRow)) As Integer + Dim result As Integer = 0 + If (Not (Me._ordersTableAdapter) Is Nothing) Then + Dim deletedRows() As Global.System.Data.DataRow = dataSet.Orders.Select(Nothing, Nothing, Global.System.Data.DataViewRowState.Deleted) + If ((Not (deletedRows) Is Nothing) _ + AndAlso (0 < deletedRows.Length)) Then + result = (result + Me._ordersTableAdapter.Update(deletedRows)) + allChangedRows.AddRange(deletedRows) + End If + End If + If (Not (Me._customersTableAdapter) Is Nothing) Then + Dim deletedRows() As Global.System.Data.DataRow = dataSet.Customers.Select(Nothing, Nothing, Global.System.Data.DataViewRowState.Deleted) + If ((Not (deletedRows) Is Nothing) _ + AndAlso (0 < deletedRows.Length)) Then + result = (result + Me._customersTableAdapter.Update(deletedRows)) + allChangedRows.AddRange(deletedRows) + End If + End If + If (Not (Me._inventoryTableAdapter) Is Nothing) Then + Dim deletedRows() As Global.System.Data.DataRow = dataSet.Inventory.Select(Nothing, Nothing, Global.System.Data.DataViewRowState.Deleted) + If ((Not (deletedRows) Is Nothing) _ + AndAlso (0 < deletedRows.Length)) Then + result = (result + Me._inventoryTableAdapter.Update(deletedRows)) + allChangedRows.AddRange(deletedRows) + End If + End If + Return result + End Function + + ''' + '''Remove inserted rows that become updated rows after calling TableAdapter.Update(inserted rows) first + ''' + _ + Private Function GetRealUpdatedRows(ByVal updatedRows() As Global.System.Data.DataRow, ByVal allAddedRows As Global.System.Collections.Generic.List(Of Global.System.Data.DataRow)) As Global.System.Data.DataRow() + If ((updatedRows Is Nothing) _ + OrElse (updatedRows.Length < 1)) Then + Return updatedRows + End If + If ((allAddedRows Is Nothing) _ + OrElse (allAddedRows.Count < 1)) Then + Return updatedRows + End If + Dim realUpdatedRows As Global.System.Collections.Generic.List(Of Global.System.Data.DataRow) = New Global.System.Collections.Generic.List(Of Global.System.Data.DataRow) + Dim i As Integer = 0 + Do While (i < updatedRows.Length) + Dim row As Global.System.Data.DataRow = updatedRows(i) + If (allAddedRows.Contains(row) = false) Then + realUpdatedRows.Add(row) + End If + i = (i + 1) + Loop + Return realUpdatedRows.ToArray + End Function + + ''' + '''Update all changes to the dataset. + ''' + _ + Public Overridable Function UpdateAll(ByVal dataSet As AutoLotDataSet) As Integer + If (dataSet Is Nothing) Then + Throw New Global.System.ArgumentNullException("dataSet") + End If + If (dataSet.HasChanges = false) Then + Return 0 + End If + Dim workConnection As Global.System.Data.IDbConnection = Me.Connection + If (workConnection Is Nothing) Then + Throw New Global.System.ApplicationException("TableAdapterManager contains no connection information. Set each TableAdapterMana"& _ + "ger TableAdapter property to a valid TableAdapter instance.") + End If + Dim workConnOpened As Boolean = false + If ((workConnection.State And Global.System.Data.ConnectionState.Closed) _ + = Global.System.Data.ConnectionState.Closed) Then + workConnection.Open + workConnOpened = true + End If + Dim workTransaction As Global.System.Data.IDbTransaction = workConnection.BeginTransaction + If (workTransaction Is Nothing) Then + Throw New Global.System.ApplicationException("The transaction cannot begin. The current data connection does not support transa"& _ + "ctions or the current state is not allowing the transaction to begin.") + End If + Dim allChangedRows As Global.System.Collections.Generic.List(Of Global.System.Data.DataRow) = New Global.System.Collections.Generic.List(Of Global.System.Data.DataRow) + Dim allAddedRows As Global.System.Collections.Generic.List(Of Global.System.Data.DataRow) = New Global.System.Collections.Generic.List(Of Global.System.Data.DataRow) + Dim adaptersWithAcceptChangesDuringUpdate As Global.System.Collections.Generic.List(Of Global.System.Data.Common.DataAdapter) = New Global.System.Collections.Generic.List(Of Global.System.Data.Common.DataAdapter) + Dim revertConnections As Global.System.Collections.Generic.Dictionary(Of Object, Global.System.Data.IDbConnection) = New Global.System.Collections.Generic.Dictionary(Of Object, Global.System.Data.IDbConnection) + Dim result As Integer = 0 + Dim backupDataSet As Global.System.Data.DataSet = Nothing + If Me.BackupDataSetBeforeUpdate Then + backupDataSet = New Global.System.Data.DataSet + backupDataSet.Merge(dataSet) + End If + Try + '---- Prepare for update ----------- + ' + If (Not (Me._customersTableAdapter) Is Nothing) Then + revertConnections.Add(Me._customersTableAdapter, Me._customersTableAdapter.Connection) + Me._customersTableAdapter.Connection = CType(workConnection,Global.System.Data.SqlClient.SqlConnection) + Me._customersTableAdapter.Transaction = CType(workTransaction,Global.System.Data.SqlClient.SqlTransaction) + If Me._customersTableAdapter.Adapter.AcceptChangesDuringUpdate Then + Me._customersTableAdapter.Adapter.AcceptChangesDuringUpdate = false + adaptersWithAcceptChangesDuringUpdate.Add(Me._customersTableAdapter.Adapter) + End If + End If + If (Not (Me._inventoryTableAdapter) Is Nothing) Then + revertConnections.Add(Me._inventoryTableAdapter, Me._inventoryTableAdapter.Connection) + Me._inventoryTableAdapter.Connection = CType(workConnection,Global.System.Data.SqlClient.SqlConnection) + Me._inventoryTableAdapter.Transaction = CType(workTransaction,Global.System.Data.SqlClient.SqlTransaction) + If Me._inventoryTableAdapter.Adapter.AcceptChangesDuringUpdate Then + Me._inventoryTableAdapter.Adapter.AcceptChangesDuringUpdate = false + adaptersWithAcceptChangesDuringUpdate.Add(Me._inventoryTableAdapter.Adapter) + End If + End If + If (Not (Me._ordersTableAdapter) Is Nothing) Then + revertConnections.Add(Me._ordersTableAdapter, Me._ordersTableAdapter.Connection) + Me._ordersTableAdapter.Connection = CType(workConnection,Global.System.Data.SqlClient.SqlConnection) + Me._ordersTableAdapter.Transaction = CType(workTransaction,Global.System.Data.SqlClient.SqlTransaction) + If Me._ordersTableAdapter.Adapter.AcceptChangesDuringUpdate Then + Me._ordersTableAdapter.Adapter.AcceptChangesDuringUpdate = false + adaptersWithAcceptChangesDuringUpdate.Add(Me._ordersTableAdapter.Adapter) + End If + End If + ' + '---- Perform updates ----------- + ' + If (Me.UpdateOrder = UpdateOrderOption.UpdateInsertDelete) Then + result = (result + Me.UpdateUpdatedRows(dataSet, allChangedRows, allAddedRows)) + result = (result + Me.UpdateInsertedRows(dataSet, allAddedRows)) + Else + result = (result + Me.UpdateInsertedRows(dataSet, allAddedRows)) + result = (result + Me.UpdateUpdatedRows(dataSet, allChangedRows, allAddedRows)) + End If + result = (result + Me.UpdateDeletedRows(dataSet, allChangedRows)) + ' + '---- Commit updates ----------- + ' + workTransaction.Commit + If (0 < allAddedRows.Count) Then + Dim rows((allAddedRows.Count) - 1) As Global.System.Data.DataRow + allAddedRows.CopyTo(rows) + Dim i As Integer = 0 + Do While (i < rows.Length) + Dim row As Global.System.Data.DataRow = rows(i) + row.AcceptChanges + i = (i + 1) + Loop + End If + If (0 < allChangedRows.Count) Then + Dim rows((allChangedRows.Count) - 1) As Global.System.Data.DataRow + allChangedRows.CopyTo(rows) + Dim i As Integer = 0 + Do While (i < rows.Length) + Dim row As Global.System.Data.DataRow = rows(i) + row.AcceptChanges + i = (i + 1) + Loop + End If + Catch ex As Global.System.Exception + workTransaction.Rollback + '---- Restore the dataset ----------- + If Me.BackupDataSetBeforeUpdate Then + Global.System.Diagnostics.Debug.Assert((Not (backupDataSet) Is Nothing)) + dataSet.Clear + dataSet.Merge(backupDataSet) + Else + If (0 < allAddedRows.Count) Then + Dim rows((allAddedRows.Count) - 1) As Global.System.Data.DataRow + allAddedRows.CopyTo(rows) + Dim i As Integer = 0 + Do While (i < rows.Length) + Dim row As Global.System.Data.DataRow = rows(i) + row.AcceptChanges + row.SetAdded + i = (i + 1) + Loop + End If + End If + Throw ex + Finally + If workConnOpened Then + workConnection.Close + End If + If (Not (Me._customersTableAdapter) Is Nothing) Then + Me._customersTableAdapter.Connection = CType(revertConnections(Me._customersTableAdapter),Global.System.Data.SqlClient.SqlConnection) + Me._customersTableAdapter.Transaction = Nothing + End If + If (Not (Me._inventoryTableAdapter) Is Nothing) Then + Me._inventoryTableAdapter.Connection = CType(revertConnections(Me._inventoryTableAdapter),Global.System.Data.SqlClient.SqlConnection) + Me._inventoryTableAdapter.Transaction = Nothing + End If + If (Not (Me._ordersTableAdapter) Is Nothing) Then + Me._ordersTableAdapter.Connection = CType(revertConnections(Me._ordersTableAdapter),Global.System.Data.SqlClient.SqlConnection) + Me._ordersTableAdapter.Transaction = Nothing + End If + If (0 < adaptersWithAcceptChangesDuringUpdate.Count) Then + Dim adapters((adaptersWithAcceptChangesDuringUpdate.Count) - 1) As Global.System.Data.Common.DataAdapter + adaptersWithAcceptChangesDuringUpdate.CopyTo(adapters) + Dim i As Integer = 0 + Do While (i < adapters.Length) + Dim adapter As Global.System.Data.Common.DataAdapter = adapters(i) + adapter.AcceptChangesDuringUpdate = true + i = (i + 1) + Loop + End If + End Try + Return result + End Function + + _ + Protected Overridable Sub SortSelfReferenceRows(ByVal rows() As Global.System.Data.DataRow, ByVal relation As Global.System.Data.DataRelation, ByVal childFirst As Boolean) + Global.System.Array.Sort(Of Global.System.Data.DataRow)(rows, New SelfReferenceComparer(relation, childFirst)) + End Sub + + _ + Protected Overridable Function MatchTableAdapterConnection(ByVal inputConnection As Global.System.Data.IDbConnection) As Boolean + If (Not (Me._connection) Is Nothing) Then + Return true + End If + If ((Me.Connection Is Nothing) _ + OrElse (inputConnection Is Nothing)) Then + Return true + End If + If String.Equals(Me.Connection.ConnectionString, inputConnection.ConnectionString, Global.System.StringComparison.Ordinal) Then + Return true + End If + Return false + End Function + + ''' + '''Update Order Option + ''' + _ + Public Enum UpdateOrderOption + + InsertUpdateDelete = 0 + + UpdateInsertDelete = 1 + End Enum + + ''' + '''Used to sort self-referenced table's rows + ''' + _ + Private Class SelfReferenceComparer + Inherits Object + Implements Global.System.Collections.Generic.IComparer(Of Global.System.Data.DataRow) + + Private _relation As Global.System.Data.DataRelation + + Private _childFirst As Integer + + _ + Friend Sub New(ByVal relation As Global.System.Data.DataRelation, ByVal childFirst As Boolean) + MyBase.New + Me._relation = relation + If childFirst Then + Me._childFirst = -1 + Else + Me._childFirst = 1 + End If + End Sub + + _ + Private Function IsChildAndParent(ByVal child As Global.System.Data.DataRow, ByVal parent As Global.System.Data.DataRow) As Boolean + Global.System.Diagnostics.Debug.Assert((Not (child) Is Nothing)) + Global.System.Diagnostics.Debug.Assert((Not (parent) Is Nothing)) + Dim newParent As Global.System.Data.DataRow = child.GetParentRow(Me._relation, Global.System.Data.DataRowVersion.[Default]) + + Do While ((Not (newParent) Is Nothing) _ + AndAlso ((Object.ReferenceEquals(newParent, child) = false) _ + AndAlso (Object.ReferenceEquals(newParent, parent) = false))) + newParent = newParent.GetParentRow(Me._relation, Global.System.Data.DataRowVersion.[Default]) + + Loop + If (newParent Is Nothing) Then + newParent = child.GetParentRow(Me._relation, Global.System.Data.DataRowVersion.Original) + Do While ((Not (newParent) Is Nothing) _ + AndAlso ((Object.ReferenceEquals(newParent, child) = false) _ + AndAlso (Object.ReferenceEquals(newParent, parent) = false))) + newParent = newParent.GetParentRow(Me._relation, Global.System.Data.DataRowVersion.Original) + + Loop + End If + If Object.ReferenceEquals(newParent, parent) Then + Return true + End If + Return false + End Function + + _ + Public Function Compare(ByVal row1 As Global.System.Data.DataRow, ByVal row2 As Global.System.Data.DataRow) As Integer Implements Global.System.Collections.Generic.IComparer(Of Global.System.Data.DataRow).Compare + If Object.ReferenceEquals(row1, row2) Then + Return 0 + End If + If (row1 Is Nothing) Then + Return -1 + End If + If (row2 Is Nothing) Then + Return 1 + End If + + 'Is row1 the child or grandchild of row2 + If Me.IsChildAndParent(row1, row2) Then + Return Me._childFirst + End If + + 'Is row2 the child or grandchild of row1 + If Me.IsChildAndParent(row2, row1) Then + Return (-1 * Me._childFirst) + End If + Return 0 + End Function + End Class + End Class +End Namespace diff --git a/Code/Chapter 23/AutoLotDAL (Part 3)/AutoLotDataSet.xsc b/Code/Chapter 23/AutoLotDAL (Part 3)/AutoLotDataSet.xsc new file mode 100644 index 0000000..05b0199 --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 3)/AutoLotDataSet.xsc @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/Code/Chapter 23/AutoLotDAL (Part 3)/AutoLotDataSet.xsd b/Code/Chapter 23/AutoLotDAL (Part 3)/AutoLotDataSet.xsd new file mode 100644 index 0000000..9ccec95 --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 3)/AutoLotDataSet.xsd @@ -0,0 +1,276 @@ + + + + + + + + + + + + + + + DELETE FROM [dbo].[Customers] WHERE (([CustID] = @Original_CustID) AND ([FirstName] = @Original_FirstName) AND ([LastName] = @Original_LastName)) + + + + + + + + + + INSERT INTO [dbo].[Customers] ([CustID], [FirstName], [LastName]) VALUES (@CustID, @FirstName, @LastName); +SELECT CustID, FirstName, LastName FROM Customers WHERE (CustID = @CustID) + + + + + + + + + + SELECT CustID, FirstName, LastName FROM dbo.Customers + + + + + + UPDATE [dbo].[Customers] SET [CustID] = @CustID, [FirstName] = @FirstName, [LastName] = @LastName WHERE (([CustID] = @Original_CustID) AND ([FirstName] = @Original_FirstName) AND ([LastName] = @Original_LastName)); +SELECT CustID, FirstName, LastName FROM Customers WHERE (CustID = @CustID) + + + + + + + + + + + + + + + + + + + + + + + + + DELETE FROM [dbo].[Inventory] WHERE (([CarID] = @Original_CarID) AND ([Make] = @Original_Make) AND ([Color] = @Original_Color) AND ((@IsNull_PetName = 1 AND [PetName] IS NULL) OR ([PetName] = @Original_PetName))) + + + + + + + + + + + + INSERT INTO [dbo].[Inventory] ([CarID], [Make], [Color], [PetName]) VALUES (@CarID, @Make, @Color, @PetName); +SELECT CarID, Make, Color, PetName FROM Inventory WHERE (CarID = @CarID) + + + + + + + + + + + SELECT CarID, Make, Color, PetName FROM dbo.Inventory + + + + + + UPDATE [dbo].[Inventory] SET [CarID] = @CarID, [Make] = @Make, [Color] = @Color, [PetName] = @PetName WHERE (([CarID] = @Original_CarID) AND ([Make] = @Original_Make) AND ([Color] = @Original_Color) AND ((@IsNull_PetName = 1 AND [PetName] IS NULL) OR ([PetName] = @Original_PetName))); +SELECT CarID, Make, Color, PetName FROM Inventory WHERE (CarID = @CarID) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DELETE FROM [dbo].[Orders] WHERE (([OrderID] = @Original_OrderID) AND ([CustID] = @Original_CustID) AND ([CarID] = @Original_CarID)) + + + + + + + + + + INSERT INTO [dbo].[Orders] ([OrderID], [CustID], [CarID]) VALUES (@OrderID, @CustID, @CarID); +SELECT OrderID, CustID, CarID FROM Orders WHERE (OrderID = @OrderID) + + + + + + + + + + SELECT OrderID, CustID, CarID FROM dbo.Orders + + + + + + UPDATE [dbo].[Orders] SET [OrderID] = @OrderID, [CustID] = @CustID, [CarID] = @CarID WHERE (([OrderID] = @Original_OrderID) AND ([CustID] = @Original_CustID) AND ([CarID] = @Original_CarID)); +SELECT OrderID, CustID, CarID FROM Orders WHERE (OrderID = @OrderID) + + + + + + + + + + + + + + + + + + + + + + + + + dbo.GetPetName + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 23/AutoLotDAL (Part 3)/AutoLotDataSet.xss b/Code/Chapter 23/AutoLotDAL (Part 3)/AutoLotDataSet.xss new file mode 100644 index 0000000..43466d8 --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 3)/AutoLotDataSet.xss @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + 431 + 192 + + + 253 + 192 + + + + + + + 354 + 381 + + + 236 + 381 + + + 236 + 204 + + + + + \ No newline at end of file diff --git a/Code/Chapter 23/AutoLotDAL (Part 3)/InventoryDAL.vb b/Code/Chapter 23/AutoLotDAL (Part 3)/InventoryDAL.vb new file mode 100644 index 0000000..9e5ebbe --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 3)/InventoryDAL.vb @@ -0,0 +1,203 @@ +' We will make use of the SQL server +' provider, however it would also be +' permissible to make use of the ADO.NET +' factory pattern for greater flexibility. +Imports System.Data.SqlClient + +Namespace AutoLotConnectedLayer + Public Class InventoryDAL + +#Region "Connection and Disconnection details." + ' This member will be used by all methods. + Private sqlCn As New SqlConnection() + + Public Sub OpenConnection(ByVal connectionString As String) + sqlCn.ConnectionString = connectionString + sqlCn.Open() + End Sub + Public Sub CloseConnection() + sqlCn.Close() + End Sub +#End Region + +#Region "Insert logic (both versions)" + 'Public Sub InsertAuto(ByVal id As Integer, ByVal color As String, _ + ' ByVal make As String, ByVal petName As String) + ' ' Format and execute SQL statement. + ' Dim sql As String = String.Format("Insert Into Inventory" & _ + ' "(CarID, Make, Color, PetName) Values" & _ + ' "('{0}', '{1}', '{2}', '{3}')", id, make, color, petName) + + ' ' Execute using our connection. + ' Using cmd As New SqlCommand(sql, Me.sqlCn) + ' cmd.ExecuteNonQuery() + ' End Using + 'End Sub + + Public Sub InsertAuto(ByVal id As Integer, ByVal color As String, ByVal make As String, ByVal petName As String) + ' Note the 'placeholders' in the SQL query. + Dim sql As String = String.Format("Insert Into Inventory" + "(CarID, Make, Color, PetName) Values" + "(@CarID, @Make, @Color, @PetName)") + + ' This command will have internal parameters. + Using cmd As New SqlCommand(sql, Me.sqlCn) + ' Fill params collection. + Dim param As New SqlParameter() + param.ParameterName = "@CarID" + param.Value = id + param.SqlDbType = SqlDbType.Int + cmd.Parameters.Add(param) + + param = New SqlParameter() + param.ParameterName = "@Make" + param.Value = make + param.SqlDbType = SqlDbType.[Char] + param.Size = 10 + cmd.Parameters.Add(param) + + param = New SqlParameter() + param.ParameterName = "@Color" + param.Value = color + param.SqlDbType = SqlDbType.[Char] + param.Size = 10 + cmd.Parameters.Add(param) + + param = New SqlParameter() + param.ParameterName = "@PetName" + param.Value = petName + param.SqlDbType = SqlDbType.[Char] + param.Size = 10 + cmd.Parameters.Add(param) + + cmd.ExecuteNonQuery() + End Using + End Sub +#End Region + +#Region "Delete logic" + Public Sub DeleteCar(ByVal id As Integer) + ' Get ID of car to delete, then do so. + Dim sql As String = String.Format("Delete from Inventory where CarID = '{0}'", id) + Using cmd As New SqlCommand(sql, Me.sqlCn) + Try + cmd.ExecuteNonQuery() + Catch ex As SqlException + Dim er As New Exception("Sorry! That car is on order!", ex) + Throw er + End Try + End Using + End Sub +#End Region + +#Region "Update logic" + Public Sub UpdateCarPetName(ByVal id As Integer, ByVal newPetName As String) + ' Get ID of car to modify and new pet name. + Dim sql As String = String.Format("Update Inventory Set PetName = '{0}' Where CarID = '{1}'", newPetName, id) + Using cmd As New SqlCommand(sql, Me.sqlCn) + cmd.ExecuteNonQuery() + End Using + End Sub +#End Region + +#Region "Select logic" + Public Function GetAllInventory() As DataTable + ' This will hold the records. + Dim inv As New DataTable() + + ' Prep command object. + Dim sql As String = "Select * From Inventory" + Using cmd As New SqlCommand(sql, Me.sqlCn) + Dim dr As SqlDataReader = cmd.ExecuteReader() + ' Fill the DataTable with data from the reader and clean up. + inv.Load(dr) + dr.Close() + End Using + Return inv + End Function +#End Region + +#Region "Trigger stored proc logic" + Public Function LookUpPetName(ByVal carID As Integer) As String + Dim carPetName As String = String.Empty + + ' Establish name of stored proc. + Using cmd As New SqlCommand("GetPetName", Me.sqlCn) + cmd.CommandType = CommandType.StoredProcedure + + ' Input param. + Dim param As New SqlParameter() + param.ParameterName = "@carID" + param.SqlDbType = SqlDbType.Int + param.Value = carID + param.Direction = ParameterDirection.Input + cmd.Parameters.Add(param) + + ' Output param. + param = New SqlParameter() + param.ParameterName = "@petName" + param.SqlDbType = SqlDbType.[Char] + param.Size = 10 + param.Direction = ParameterDirection.Output + cmd.Parameters.Add(param) + + ' Execute the stored proc. + cmd.ExecuteNonQuery() + + ' Return output param. + carPetName = DirectCast(cmd.Parameters("@petName").Value, String).Trim() + End Using + Return carPetName + End Function +#End Region + +#Region "Tx Method" + ' A new member of the InventoryDAL class. + Public Sub ProcessCreditRisk(ByVal throwEx As Boolean, ByVal custID As Integer) + ' First, look up current name based on customer ID. + Dim fName As String = String.Empty + Dim lName As String = String.Empty + + Dim cmdSelect As New SqlCommand(String.Format("Select * from Customers where CustID = {0}", custID), sqlCn) + Using dr As SqlDataReader = cmdSelect.ExecuteReader() + While dr.Read() + fName = DirectCast(dr("FirstName"), String) + lName = DirectCast(dr("LastName"), String) + End While + End Using + + ' Create command objects which represent each step of the operation. + Dim cmdRemove As New SqlCommand(String.Format("Delete from Customers where CustID = {0}", custID), sqlCn) + + Dim cmdInsert As New SqlCommand(String.Format("Insert Into CreditRisks" & _ + "(CustID, FirstName, LastName) Values" & _ + "({0}, '{1}', '{2}')", custID, fName, lName), sqlCn) + + ' We will get this from the Connection object. + Dim tx As SqlTransaction = Nothing + Try + tx = sqlCn.BeginTransaction() + + ' Enlist the commands into this transaction. + cmdInsert.Transaction = tx + cmdRemove.Transaction = tx + + ' Execute the commands. + cmdInsert.ExecuteNonQuery() + cmdRemove.ExecuteNonQuery() + + ' Simulate error. + If throwEx Then + Throw New ApplicationException("Sorry! Database error! Tx failed...") + End If + + ' Commit it! + tx.Commit() + Catch ex As Exception + Console.WriteLine(ex.Message) + ' Any error will rollback transaction. + tx.Rollback() + End Try + End Sub +#End Region + + End Class +End Namespace diff --git a/Code/Chapter 23/AutoLotDAL (Part 3)/InventoryDALDisconnected.vb b/Code/Chapter 23/AutoLotDAL (Part 3)/InventoryDALDisconnected.vb new file mode 100644 index 0000000..6b673ad --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 3)/InventoryDALDisconnected.vb @@ -0,0 +1,35 @@ +Imports System.Data.SqlClient + +Namespace AutoLotDisconnectedLayer + Public Class InventoryDALDisLayer + ' Field data. + Private cnString As String = String.Empty + Private dAdapt As SqlDataAdapter = Nothing + + Public Sub New(ByVal connectionString As String) + cnString = connectionString + + ' Configure the SqlDataAdapter. + ConfigureAdapter(dAdapt) + End Sub + + Private Sub ConfigureAdapter(ByRef dAdapt As SqlDataAdapter) + ' Create the adapter and set up the SelectCommand + dAdapt = New SqlDataAdapter("Select * From Inventory", cnString) + + ' Obtain the remaining Command objects dynamically at runime + ' using the SqlCommandBuilder. + Dim builder As New SqlCommandBuilder(dAdapt) + End Sub + + Public Function GetAllInventory() As DataTable + Dim inv As New DataTable("Inventory") + dAdapt.Fill(inv) + Return inv + End Function + + Public Sub UpdateInventory(ByVal modifiedTable As DataTable) + dAdapt.Update(modifiedTable) + End Sub + End Class +End Namespace diff --git a/Code/Chapter 23/AutoLotDAL (Part 3)/My Project/Application.Designer.vb b/Code/Chapter 23/AutoLotDAL (Part 3)/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 3)/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 23/AutoLotDAL (Part 3)/My Project/Application.myapp b/Code/Chapter 23/AutoLotDAL (Part 3)/My Project/Application.myapp new file mode 100644 index 0000000..758895d --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 3)/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/Code/Chapter 23/AutoLotDAL (Part 3)/My Project/AssemblyInfo.vb b/Code/Chapter 23/AutoLotDAL (Part 3)/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..7ba989c --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 3)/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/Code/Chapter 23/AutoLotDAL (Part 3)/My Project/Resources.Designer.vb b/Code/Chapter 23/AutoLotDAL (Part 3)/My Project/Resources.Designer.vb new file mode 100644 index 0000000..5036910 --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 3)/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("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/Code/Chapter 23/AutoLotDAL (Part 3)/My Project/Resources.resx b/Code/Chapter 23/AutoLotDAL (Part 3)/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 3)/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/Code/Chapter 23/AutoLotDAL (Part 3)/My Project/Settings.Designer.vb b/Code/Chapter 23/AutoLotDAL (Part 3)/My Project/Settings.Designer.vb new file mode 100644 index 0000000..acafd9e --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 3)/My Project/Settings.Designer.vb @@ -0,0 +1,84 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings),MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + + _ + Public ReadOnly Property AutoLotConnectionString() As String + Get + Return CType(Me("AutoLotConnectionString"),String) + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.My.MySettings + Get + Return Global.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 23/AutoLotDAL (Part 3)/My Project/Settings.settings b/Code/Chapter 23/AutoLotDAL (Part 3)/My Project/Settings.settings new file mode 100644 index 0000000..03c3afc --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 3)/My Project/Settings.settings @@ -0,0 +1,14 @@ + + + + + + <?xml version="1.0" encoding="utf-16"?> +<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <ConnectionString>Data Source=INTERUBER\SQLEXPRESS;Initial Catalog=AutoLot;Integrated Security=True</ConnectionString> + <ProviderName>System.Data.SqlClient</ProviderName> +</SerializableConnectionString> + Data Source=INTERUBER\SQLEXPRESS;Initial Catalog=AutoLot;Integrated Security=True + + + \ No newline at end of file diff --git a/Code/Chapter 23/AutoLotDAL (Part 3)/Wizard Generated DB Objects.cd b/Code/Chapter 23/AutoLotDAL (Part 3)/Wizard Generated DB Objects.cd new file mode 100644 index 0000000..a0c25be --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 3)/Wizard Generated DB Objects.cd @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + BAEAAAAAAwAAgAJABAACQAAAIAgCQDgAAAAiAgEAFBA= + + + + + + AAAAAAAAASAABAAAAAAAABAAASABAIAgAAAAAAAAAAA= + InventoryDAL.vb + + + + + + AAAAAAAAAAAABAAAEAAAAAAAAAAAAAAAAEACACAAAAA= + InventoryDALDisconnected.vb + + + + + + AAAAAAAAAAAAAAAAAAAAIAAAAAABAAAgAAAAAAAAAAA= + + + + + + AAAAAAAAAAAAAAAAAAABEAAAAQAAAAAAAAAAAAAAAIA= + + + + + + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAA= + + + + \ No newline at end of file diff --git a/Code/Chapter 23/AutoLotDAL (Part 3)/app.config b/Code/Chapter 23/AutoLotDAL (Part 3)/app.config new file mode 100644 index 0000000..0e2c3dc --- /dev/null +++ b/Code/Chapter 23/AutoLotDAL (Part 3)/app.config @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 23/FillDataSetWithSqlDataAdapter/FillDataSetWithSqlDataAdapter.sln b/Code/Chapter 23/FillDataSetWithSqlDataAdapter/FillDataSetWithSqlDataAdapter.sln new file mode 100644 index 0000000..3951249 --- /dev/null +++ b/Code/Chapter 23/FillDataSetWithSqlDataAdapter/FillDataSetWithSqlDataAdapter.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "FillDataSetWithSqlDataAdapter", "FillDataSetWithSqlDataAdapter.vbproj", "{31DC28F5-D9A7-4F1C-A736-E15EB6A2894A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {31DC28F5-D9A7-4F1C-A736-E15EB6A2894A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {31DC28F5-D9A7-4F1C-A736-E15EB6A2894A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {31DC28F5-D9A7-4F1C-A736-E15EB6A2894A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {31DC28F5-D9A7-4F1C-A736-E15EB6A2894A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 23/FillDataSetWithSqlDataAdapter/FillDataSetWithSqlDataAdapter.suo b/Code/Chapter 23/FillDataSetWithSqlDataAdapter/FillDataSetWithSqlDataAdapter.suo new file mode 100644 index 0000000..654dfb2 Binary files /dev/null and b/Code/Chapter 23/FillDataSetWithSqlDataAdapter/FillDataSetWithSqlDataAdapter.suo differ diff --git a/Code/Chapter 23/FillDataSetWithSqlDataAdapter/FillDataSetWithSqlDataAdapter.vbproj b/Code/Chapter 23/FillDataSetWithSqlDataAdapter/FillDataSetWithSqlDataAdapter.vbproj new file mode 100644 index 0000000..173372a --- /dev/null +++ b/Code/Chapter 23/FillDataSetWithSqlDataAdapter/FillDataSetWithSqlDataAdapter.vbproj @@ -0,0 +1,109 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {31DC28F5-D9A7-4F1C-A736-E15EB6A2894A} + Exe + FillDataSetWithSqlDataAdapter.Program + FillDataSetWithSqlDataAdapter + FillDataSetWithSqlDataAdapter + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + FillDataSetWithSqlDataAdapter.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + FillDataSetWithSqlDataAdapter.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 23/FillDataSetWithSqlDataAdapter/My Project/Application.Designer.vb b/Code/Chapter 23/FillDataSetWithSqlDataAdapter/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 23/FillDataSetWithSqlDataAdapter/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 23/FillDataSetWithSqlDataAdapter/My Project/Application.myapp b/Code/Chapter 23/FillDataSetWithSqlDataAdapter/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 23/FillDataSetWithSqlDataAdapter/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 23/FillDataSetWithSqlDataAdapter/My Project/AssemblyInfo.vb b/Code/Chapter 23/FillDataSetWithSqlDataAdapter/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..08c28bd --- /dev/null +++ b/Code/Chapter 23/FillDataSetWithSqlDataAdapter/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/Code/Chapter 23/FillDataSetWithSqlDataAdapter/My Project/Resources.Designer.vb b/Code/Chapter 23/FillDataSetWithSqlDataAdapter/My Project/Resources.Designer.vb new file mode 100644 index 0000000..40bda28 --- /dev/null +++ b/Code/Chapter 23/FillDataSetWithSqlDataAdapter/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("FillDataSetWithSqlDataAdapter.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/Code/Chapter 23/FillDataSetWithSqlDataAdapter/My Project/Resources.resx b/Code/Chapter 23/FillDataSetWithSqlDataAdapter/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 23/FillDataSetWithSqlDataAdapter/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/Code/Chapter 23/FillDataSetWithSqlDataAdapter/My Project/Settings.Designer.vb b/Code/Chapter 23/FillDataSetWithSqlDataAdapter/My Project/Settings.Designer.vb new file mode 100644 index 0000000..5c1eabb --- /dev/null +++ b/Code/Chapter 23/FillDataSetWithSqlDataAdapter/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.FillDataSetWithSqlDataAdapter.My.MySettings + Get + Return Global.FillDataSetWithSqlDataAdapter.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 23/FillDataSetWithSqlDataAdapter/My Project/Settings.settings b/Code/Chapter 23/FillDataSetWithSqlDataAdapter/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 23/FillDataSetWithSqlDataAdapter/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 23/FillDataSetWithSqlDataAdapter/Program.vb b/Code/Chapter 23/FillDataSetWithSqlDataAdapter/Program.vb new file mode 100644 index 0000000..9b0947f --- /dev/null +++ b/Code/Chapter 23/FillDataSetWithSqlDataAdapter/Program.vb @@ -0,0 +1,68 @@ +Imports System.Data.SqlClient +Imports System.Data.Common + +Module Program + + Sub Main() + Console.WriteLine("***** Fun with Data Adapters *****" & vbLf) + + ' Hard-coded connection string (modify if needed). + Dim cnStr As String = "Integrated Security = SSPI;Initial Catalog=AutoLot;" & "Data Source=(local)\SQLEXPRESS" + + ' Caller creates the DataSet object. + Dim ds As New DataSet("AutoLot") + + ' Inform adapter of the Select command text and connection. + Dim dAdapt As New SqlDataAdapter("Select * From Inventory", cnStr) + + ' Now map DB column names to user-friendly names. + Dim custMap As DataTableMapping = _ + dAdapt.TableMappings.Add("Inventory", "Current Inventory") + custMap.ColumnMappings.Add("CarID", "Car ID") + custMap.ColumnMappings.Add("PetName", "Name") + + ' Fill our DataSet with a new table, named Inventory. + dAdapt.Fill(ds, "Inventory") + + ' Display contents of DataSet. + PrintDataSet(ds) + Console.ReadLine() + End Sub + +#Region "Print out DataSet" + Sub PrintDataSet(ByVal ds As DataSet) + ' Print out any name and extended properties. + Console.WriteLine("DataSet is named: {0}", ds.DataSetName) + For Each de As System.Collections.DictionaryEntry In ds.ExtendedProperties + Console.WriteLine("Key = {0}, Value = {1}", de.Key, de.Value) + Next + Console.WriteLine() + + For Each dt As DataTable In ds.Tables + Console.WriteLine("=> {0} Table:", dt.TableName) + For curCol As Integer = 0 To dt.Columns.Count - 1 + + ' Print out the column names. + Console.Write(dt.Columns(curCol).ColumnName.Trim() & vbTab) + Next + Console.WriteLine("" & Chr(10) & "----------------------------------") + PrintTable(dt) + Next + End Sub + + Sub PrintTable(ByVal dt As DataTable) + ' Get the DataTableReader type. + Dim dtReader As DataTableReader = dt.CreateDataReader() + + ' The DataTableReader works just like the DataReader. + While dtReader.Read() + For i As Integer = 0 To dtReader.FieldCount - 1 + Console.Write("{0}" & vbTab, dtReader.GetValue(i).ToString().Trim()) + Next + Console.WriteLine() + End While + dtReader.Close() + End Sub +#End Region + +End Module diff --git a/Code/Chapter 23/MultitabledDataSetApp - Redux/MainForm.Designer.vb b/Code/Chapter 23/MultitabledDataSetApp - Redux/MainForm.Designer.vb new file mode 100644 index 0000000..6f73694 --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp - Redux/MainForm.Designer.vb @@ -0,0 +1,174 @@ + _ +Partial Class MainForm + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + 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.groupBox1 = New System.Windows.Forms.GroupBox + Me.btnGetOrderInfo = New System.Windows.Forms.Button + Me.label4 = New System.Windows.Forms.Label + Me.txtCustID = New System.Windows.Forms.TextBox + Me.label3 = New System.Windows.Forms.Label + Me.btnUpdateDatabase = New System.Windows.Forms.Button + Me.dataGridViewOrders = New System.Windows.Forms.DataGridView + Me.label2 = New System.Windows.Forms.Label + Me.dataGridViewCustomers = New System.Windows.Forms.DataGridView + Me.label1 = New System.Windows.Forms.Label + Me.dataGridViewInventory = New System.Windows.Forms.DataGridView + Me.groupBox1.SuspendLayout() + CType(Me.dataGridViewOrders, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.dataGridViewCustomers, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.dataGridViewInventory, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'groupBox1 + ' + Me.groupBox1.Controls.Add(Me.btnGetOrderInfo) + Me.groupBox1.Controls.Add(Me.label4) + Me.groupBox1.Controls.Add(Me.txtCustID) + Me.groupBox1.Location = New System.Drawing.Point(26, 348) + Me.groupBox1.Name = "groupBox1" + Me.groupBox1.Size = New System.Drawing.Size(200, 100) + Me.groupBox1.TabIndex = 18 + Me.groupBox1.TabStop = False + Me.groupBox1.Text = "Lookup Customer Order" + ' + 'btnGetOrderInfo + ' + Me.btnGetOrderInfo.Location = New System.Drawing.Point(84, 71) + Me.btnGetOrderInfo.Name = "btnGetOrderInfo" + Me.btnGetOrderInfo.Size = New System.Drawing.Size(110, 23) + Me.btnGetOrderInfo.TabIndex = 7 + Me.btnGetOrderInfo.Text = "Get Order Details" + ' + 'label4 + ' + Me.label4.AutoSize = True + Me.label4.Location = New System.Drawing.Point(10, 29) + Me.label4.Name = "label4" + Me.label4.Size = New System.Drawing.Size(68, 13) + Me.label4.TabIndex = 9 + Me.label4.Text = "Customer ID:" + ' + 'txtCustID + ' + Me.txtCustID.Location = New System.Drawing.Point(84, 29) + Me.txtCustID.Name = "txtCustID" + Me.txtCustID.Size = New System.Drawing.Size(110, 20) + Me.txtCustID.TabIndex = 8 + ' + 'label3 + ' + Me.label3.AutoSize = True + Me.label3.Location = New System.Drawing.Point(23, 224) + Me.label3.Name = "label3" + Me.label3.Size = New System.Drawing.Size(75, 13) + Me.label3.TabIndex = 16 + Me.label3.Text = "Current Orders" + ' + 'btnUpdateDatabase + ' + Me.btnUpdateDatabase.Location = New System.Drawing.Point(418, 348) + Me.btnUpdateDatabase.Name = "btnUpdateDatabase" + Me.btnUpdateDatabase.Size = New System.Drawing.Size(114, 23) + Me.btnUpdateDatabase.TabIndex = 17 + Me.btnUpdateDatabase.Text = "Update Database" + ' + 'dataGridViewOrders + ' + Me.dataGridViewOrders.Location = New System.Drawing.Point(24, 240) + Me.dataGridViewOrders.Name = "dataGridViewOrders" + Me.dataGridViewOrders.Size = New System.Drawing.Size(509, 90) + Me.dataGridViewOrders.TabIndex = 15 + Me.dataGridViewOrders.Text = "dataGridView3" + ' + 'label2 + ' + Me.label2.AutoSize = True + Me.label2.Location = New System.Drawing.Point(23, 106) + Me.label2.Name = "label2" + Me.label2.Size = New System.Drawing.Size(93, 13) + Me.label2.TabIndex = 14 + Me.label2.Text = "Current Customers" + ' + 'dataGridViewCustomers + ' + Me.dataGridViewCustomers.Location = New System.Drawing.Point(24, 122) + Me.dataGridViewCustomers.Name = "dataGridViewCustomers" + Me.dataGridViewCustomers.Size = New System.Drawing.Size(509, 90) + Me.dataGridViewCustomers.TabIndex = 13 + Me.dataGridViewCustomers.Text = "dataGridView2" + ' + 'label1 + ' + Me.label1.AutoSize = True + Me.label1.Location = New System.Drawing.Point(22, -2) + Me.label1.Name = "label1" + Me.label1.Size = New System.Drawing.Size(88, 13) + Me.label1.TabIndex = 12 + Me.label1.Text = "Current Inventory" + ' + 'dataGridViewInventory + ' + Me.dataGridViewInventory.Location = New System.Drawing.Point(23, 14) + Me.dataGridViewInventory.Name = "dataGridViewInventory" + Me.dataGridViewInventory.Size = New System.Drawing.Size(509, 82) + Me.dataGridViewInventory.TabIndex = 11 + Me.dataGridViewInventory.Text = "dataGridView1" + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(545, 462) + Me.Controls.Add(Me.groupBox1) + Me.Controls.Add(Me.label3) + Me.Controls.Add(Me.btnUpdateDatabase) + Me.Controls.Add(Me.dataGridViewOrders) + Me.Controls.Add(Me.label2) + Me.Controls.Add(Me.dataGridViewCustomers) + Me.Controls.Add(Me.label1) + Me.Controls.Add(Me.dataGridViewInventory) + Me.Name = "MainForm" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "AutoLot Database Manipulator" + Me.groupBox1.ResumeLayout(False) + Me.groupBox1.PerformLayout() + CType(Me.dataGridViewOrders, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.dataGridViewCustomers, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.dataGridViewInventory, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Private WithEvents groupBox1 As System.Windows.Forms.GroupBox + Private WithEvents btnGetOrderInfo As System.Windows.Forms.Button + Private WithEvents label4 As System.Windows.Forms.Label + Private WithEvents txtCustID As System.Windows.Forms.TextBox + Private WithEvents label3 As System.Windows.Forms.Label + Private WithEvents btnUpdateDatabase As System.Windows.Forms.Button + Private WithEvents dataGridViewOrders As System.Windows.Forms.DataGridView + Private WithEvents label2 As System.Windows.Forms.Label + Private WithEvents dataGridViewCustomers As System.Windows.Forms.DataGridView + Private WithEvents label1 As System.Windows.Forms.Label + Private WithEvents dataGridViewInventory As System.Windows.Forms.DataGridView + +End Class diff --git a/Code/Chapter 23/MultitabledDataSetApp - Redux/MainForm.resx b/Code/Chapter 23/MultitabledDataSetApp - Redux/MainForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp - Redux/MainForm.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/Code/Chapter 23/MultitabledDataSetApp - Redux/MainForm.vb b/Code/Chapter 23/MultitabledDataSetApp - Redux/MainForm.vb new file mode 100644 index 0000000..405abe4 --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp - Redux/MainForm.vb @@ -0,0 +1,88 @@ +Imports System.Data.SqlClient +Imports System.Configuration + +Imports AutoLotDataSetTableAdapters +Imports AutoLotDataSet + +Public Class MainForm + ' Form wide strongly typed DataSet. + Private autoLotDS As New AutoLotDataSet() + + ' Custom data adapters (for each table). + Private invTableAdapter As InventoryTableAdapter + Private custTableAdapter As CustomersTableAdapter + Private ordersTableAdapter As OrdersTableAdapter + + +#Region "Ctor logic" + Public Sub New() + InitializeComponent() + + ' Get Adapters. + invTableAdapter = New InventoryTableAdapter() + custTableAdapter = New CustomersTableAdapter() + ordersTableAdapter = New OrdersTableAdapter() + + ' Add tables to DS. + invTableAdapter.Fill(autoLotDS.Inventory) + custTableAdapter.Fill(autoLotDS.Customers) + ordersTableAdapter.Fill(autoLotDS.Orders) + + ' Bind to grids + dataGridViewInventory.DataSource = autoLotDS.Tables("Inventory") + dataGridViewCustomers.DataSource = autoLotDS.Tables("Customers") + dataGridViewOrders.DataSource = autoLotDS.Tables("Orders") + End Sub +#End Region + +#Region "Button Click handlers" + Private Sub btnUpdateDatabase_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateDatabase.Click + Try + invTableAdapter.Update(autoLotDS.Inventory) + custTableAdapter.Update(autoLotDS.Customers) + ordersTableAdapter.Update(autoLotDS.Orders) + Catch ex As Exception + MessageBox.Show(ex.Message) + End Try + End Sub + + Private Sub btnGetOrderInfo_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles btnGetOrderInfo.Click + Dim strOrderInfo As String = String.Empty + Dim drsCust As DataRow() = Nothing + Dim drsOrder As DataRow() = Nothing + + ' Get the customer ID in the text box. + Dim custID As Integer = Integer.Parse(Me.txtCustID.Text) + + ' Now based on custID, get the correct row in Customers table. + drsCust = autoLotDS.Tables("Customers").Select( _ + String.Format("CustID = {0}", custID)) + strOrderInfo += String.Format("Customer {0}: {1} {2}" & Chr(10), _ + drsCust(0)("CustID").ToString(), _ + drsCust(0)("FirstName").ToString().Trim(), _ + drsCust(0)("LastName").ToString().Trim()) + + ' Navigate from customer table to order table. + drsOrder = drsCust(0).GetChildRows(autoLotDS.Relations("FK_Orders_Customers")) + + ' Get order number. + For Each r As DataRow In drsOrder + strOrderInfo += String.Format("Order Number: {0}" & Chr(10), r("OrderID")) + Next + + ' Now navigate from order table to inventory table. + Dim drsInv As DataRow() = _ + drsOrder(0).GetParentRows(autoLotDS.Relations("FK_Orders_Inventory")) + + ' Get Car info. + For Each r As DataRow In drsInv + strOrderInfo += String.Format("Make: {0}" & Chr(10), r("Make")) + strOrderInfo += String.Format("Color: {0}" & Chr(10), r("Color")) + strOrderInfo += String.Format("Pet Name: {0}" & Chr(10), r("PetName")) + Next + MessageBox.Show(strOrderInfo, "Order Details") + End Sub +#End Region + +End Class diff --git a/Code/Chapter 23/MultitabledDataSetApp - Redux/MultitabledDataSetApp.sln b/Code/Chapter 23/MultitabledDataSetApp - Redux/MultitabledDataSetApp.sln new file mode 100644 index 0000000..c21462c --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp - Redux/MultitabledDataSetApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MultitabledDataSetApp", "MultitabledDataSetApp.vbproj", "{943DE939-E2E7-4E86-9037-87772E45AC75}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {943DE939-E2E7-4E86-9037-87772E45AC75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {943DE939-E2E7-4E86-9037-87772E45AC75}.Debug|Any CPU.Build.0 = Debug|Any CPU + {943DE939-E2E7-4E86-9037-87772E45AC75}.Release|Any CPU.ActiveCfg = Release|Any CPU + {943DE939-E2E7-4E86-9037-87772E45AC75}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 23/MultitabledDataSetApp - Redux/MultitabledDataSetApp.suo b/Code/Chapter 23/MultitabledDataSetApp - Redux/MultitabledDataSetApp.suo new file mode 100644 index 0000000..f891eeb Binary files /dev/null and b/Code/Chapter 23/MultitabledDataSetApp - Redux/MultitabledDataSetApp.suo differ diff --git a/Code/Chapter 23/MultitabledDataSetApp - Redux/MultitabledDataSetApp.vbproj b/Code/Chapter 23/MultitabledDataSetApp - Redux/MultitabledDataSetApp.vbproj new file mode 100644 index 0000000..070a57f --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp - Redux/MultitabledDataSetApp.vbproj @@ -0,0 +1,127 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {943DE939-E2E7-4E86-9037-87772E45AC75} + WinExe + MultitabledDataSetApp.My.MyApplication + MultitabledDataSetApp + MultitabledDataSetApp + 512 + WindowsForms + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + MultitabledDataSetApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + MultitabledDataSetApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + False + ..\AutoLotDAL (Part 3)\bin\Debug\AutoLotDAL.dll + + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + MainForm.vb + Designer + + + 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/Code/Chapter 23/MultitabledDataSetApp - Redux/MultitabledDataSetApp.vbproj.user b/Code/Chapter 23/MultitabledDataSetApp - Redux/MultitabledDataSetApp.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp - Redux/MultitabledDataSetApp.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 23/MultitabledDataSetApp - Redux/My Project/Application.Designer.vb b/Code/Chapter 23/MultitabledDataSetApp - Redux/My Project/Application.Designer.vb new file mode 100644 index 0000000..1928afb --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp - Redux/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.MultitabledDataSetApp.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 23/MultitabledDataSetApp - Redux/My Project/Application.myapp b/Code/Chapter 23/MultitabledDataSetApp - Redux/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp - Redux/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 23/MultitabledDataSetApp - Redux/My Project/AssemblyInfo.vb b/Code/Chapter 23/MultitabledDataSetApp - Redux/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..3e47486 --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp - Redux/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/Code/Chapter 23/MultitabledDataSetApp - Redux/My Project/Resources.Designer.vb b/Code/Chapter 23/MultitabledDataSetApp - Redux/My Project/Resources.Designer.vb new file mode 100644 index 0000000..1ba789f --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp - Redux/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("MultitabledDataSetApp.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/Code/Chapter 23/MultitabledDataSetApp - Redux/My Project/Resources.resx b/Code/Chapter 23/MultitabledDataSetApp - Redux/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp - Redux/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/Code/Chapter 23/MultitabledDataSetApp - Redux/My Project/Settings.Designer.vb b/Code/Chapter 23/MultitabledDataSetApp - Redux/My Project/Settings.Designer.vb new file mode 100644 index 0000000..8d361cc --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp - Redux/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.MultitabledDataSetApp.My.MySettings + Get + Return Global.MultitabledDataSetApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 23/MultitabledDataSetApp - Redux/My Project/Settings.settings b/Code/Chapter 23/MultitabledDataSetApp - Redux/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp - Redux/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 23/MultitabledDataSetApp/MainForm.Designer.vb b/Code/Chapter 23/MultitabledDataSetApp/MainForm.Designer.vb new file mode 100644 index 0000000..6f73694 --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp/MainForm.Designer.vb @@ -0,0 +1,174 @@ + _ +Partial Class MainForm + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + 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.groupBox1 = New System.Windows.Forms.GroupBox + Me.btnGetOrderInfo = New System.Windows.Forms.Button + Me.label4 = New System.Windows.Forms.Label + Me.txtCustID = New System.Windows.Forms.TextBox + Me.label3 = New System.Windows.Forms.Label + Me.btnUpdateDatabase = New System.Windows.Forms.Button + Me.dataGridViewOrders = New System.Windows.Forms.DataGridView + Me.label2 = New System.Windows.Forms.Label + Me.dataGridViewCustomers = New System.Windows.Forms.DataGridView + Me.label1 = New System.Windows.Forms.Label + Me.dataGridViewInventory = New System.Windows.Forms.DataGridView + Me.groupBox1.SuspendLayout() + CType(Me.dataGridViewOrders, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.dataGridViewCustomers, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.dataGridViewInventory, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'groupBox1 + ' + Me.groupBox1.Controls.Add(Me.btnGetOrderInfo) + Me.groupBox1.Controls.Add(Me.label4) + Me.groupBox1.Controls.Add(Me.txtCustID) + Me.groupBox1.Location = New System.Drawing.Point(26, 348) + Me.groupBox1.Name = "groupBox1" + Me.groupBox1.Size = New System.Drawing.Size(200, 100) + Me.groupBox1.TabIndex = 18 + Me.groupBox1.TabStop = False + Me.groupBox1.Text = "Lookup Customer Order" + ' + 'btnGetOrderInfo + ' + Me.btnGetOrderInfo.Location = New System.Drawing.Point(84, 71) + Me.btnGetOrderInfo.Name = "btnGetOrderInfo" + Me.btnGetOrderInfo.Size = New System.Drawing.Size(110, 23) + Me.btnGetOrderInfo.TabIndex = 7 + Me.btnGetOrderInfo.Text = "Get Order Details" + ' + 'label4 + ' + Me.label4.AutoSize = True + Me.label4.Location = New System.Drawing.Point(10, 29) + Me.label4.Name = "label4" + Me.label4.Size = New System.Drawing.Size(68, 13) + Me.label4.TabIndex = 9 + Me.label4.Text = "Customer ID:" + ' + 'txtCustID + ' + Me.txtCustID.Location = New System.Drawing.Point(84, 29) + Me.txtCustID.Name = "txtCustID" + Me.txtCustID.Size = New System.Drawing.Size(110, 20) + Me.txtCustID.TabIndex = 8 + ' + 'label3 + ' + Me.label3.AutoSize = True + Me.label3.Location = New System.Drawing.Point(23, 224) + Me.label3.Name = "label3" + Me.label3.Size = New System.Drawing.Size(75, 13) + Me.label3.TabIndex = 16 + Me.label3.Text = "Current Orders" + ' + 'btnUpdateDatabase + ' + Me.btnUpdateDatabase.Location = New System.Drawing.Point(418, 348) + Me.btnUpdateDatabase.Name = "btnUpdateDatabase" + Me.btnUpdateDatabase.Size = New System.Drawing.Size(114, 23) + Me.btnUpdateDatabase.TabIndex = 17 + Me.btnUpdateDatabase.Text = "Update Database" + ' + 'dataGridViewOrders + ' + Me.dataGridViewOrders.Location = New System.Drawing.Point(24, 240) + Me.dataGridViewOrders.Name = "dataGridViewOrders" + Me.dataGridViewOrders.Size = New System.Drawing.Size(509, 90) + Me.dataGridViewOrders.TabIndex = 15 + Me.dataGridViewOrders.Text = "dataGridView3" + ' + 'label2 + ' + Me.label2.AutoSize = True + Me.label2.Location = New System.Drawing.Point(23, 106) + Me.label2.Name = "label2" + Me.label2.Size = New System.Drawing.Size(93, 13) + Me.label2.TabIndex = 14 + Me.label2.Text = "Current Customers" + ' + 'dataGridViewCustomers + ' + Me.dataGridViewCustomers.Location = New System.Drawing.Point(24, 122) + Me.dataGridViewCustomers.Name = "dataGridViewCustomers" + Me.dataGridViewCustomers.Size = New System.Drawing.Size(509, 90) + Me.dataGridViewCustomers.TabIndex = 13 + Me.dataGridViewCustomers.Text = "dataGridView2" + ' + 'label1 + ' + Me.label1.AutoSize = True + Me.label1.Location = New System.Drawing.Point(22, -2) + Me.label1.Name = "label1" + Me.label1.Size = New System.Drawing.Size(88, 13) + Me.label1.TabIndex = 12 + Me.label1.Text = "Current Inventory" + ' + 'dataGridViewInventory + ' + Me.dataGridViewInventory.Location = New System.Drawing.Point(23, 14) + Me.dataGridViewInventory.Name = "dataGridViewInventory" + Me.dataGridViewInventory.Size = New System.Drawing.Size(509, 82) + Me.dataGridViewInventory.TabIndex = 11 + Me.dataGridViewInventory.Text = "dataGridView1" + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(545, 462) + Me.Controls.Add(Me.groupBox1) + Me.Controls.Add(Me.label3) + Me.Controls.Add(Me.btnUpdateDatabase) + Me.Controls.Add(Me.dataGridViewOrders) + Me.Controls.Add(Me.label2) + Me.Controls.Add(Me.dataGridViewCustomers) + Me.Controls.Add(Me.label1) + Me.Controls.Add(Me.dataGridViewInventory) + Me.Name = "MainForm" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "AutoLot Database Manipulator" + Me.groupBox1.ResumeLayout(False) + Me.groupBox1.PerformLayout() + CType(Me.dataGridViewOrders, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.dataGridViewCustomers, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.dataGridViewInventory, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Private WithEvents groupBox1 As System.Windows.Forms.GroupBox + Private WithEvents btnGetOrderInfo As System.Windows.Forms.Button + Private WithEvents label4 As System.Windows.Forms.Label + Private WithEvents txtCustID As System.Windows.Forms.TextBox + Private WithEvents label3 As System.Windows.Forms.Label + Private WithEvents btnUpdateDatabase As System.Windows.Forms.Button + Private WithEvents dataGridViewOrders As System.Windows.Forms.DataGridView + Private WithEvents label2 As System.Windows.Forms.Label + Private WithEvents dataGridViewCustomers As System.Windows.Forms.DataGridView + Private WithEvents label1 As System.Windows.Forms.Label + Private WithEvents dataGridViewInventory As System.Windows.Forms.DataGridView + +End Class diff --git a/Code/Chapter 23/MultitabledDataSetApp/MainForm.resx b/Code/Chapter 23/MultitabledDataSetApp/MainForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp/MainForm.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/Code/Chapter 23/MultitabledDataSetApp/MainForm.vb b/Code/Chapter 23/MultitabledDataSetApp/MainForm.vb new file mode 100644 index 0000000..a7abdca --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp/MainForm.vb @@ -0,0 +1,120 @@ +Imports System.Data.SqlClient +Imports System.Configuration + +Public Class MainForm + ' Form wide DataSet. + Private autoLotDS As New DataSet("AutoLot") + + ' Make use of command builders to simplify data adapter configuration. + Private sqlCBInventory As SqlCommandBuilder + Private sqlCBCustomers As SqlCommandBuilder + Private sqlCBOrders As SqlCommandBuilder + + ' Our data adapters (for each table). + Private invTableAdapter As SqlDataAdapter + Private custTableAdapter As SqlDataAdapter + Private ordersTableAdapter As SqlDataAdapter + + ' Form wide connection string. + Private cnStr As String = String.Empty + + +#Region "Ctor logic" + Public Sub New() + InitializeComponent() + + ' Get connection string. + cnStr = ConfigurationManager.ConnectionStrings("AutoLotSqlProvider").ConnectionString + + ' Create adapters. + invTableAdapter = New SqlDataAdapter("Select * from Inventory", cnStr) + custTableAdapter = New SqlDataAdapter("Select * from Customers", cnStr) + ordersTableAdapter = New SqlDataAdapter("Select * from Orders", cnStr) + + ' Autogenerate commands. + sqlCBInventory = New SqlCommandBuilder(invTableAdapter) + sqlCBOrders = New SqlCommandBuilder(ordersTableAdapter) + sqlCBCustomers = New SqlCommandBuilder(custTableAdapter) + + ' Add tables to DS. + invTableAdapter.Fill(autoLotDS, "Inventory") + custTableAdapter.Fill(autoLotDS, "Customers") + ordersTableAdapter.Fill(autoLotDS, "Orders") + + ' Build relations between tables. + BuildTableRelationship() + + ' Bind to grids + dataGridViewInventory.DataSource = autoLotDS.Tables("Inventory") + dataGridViewCustomers.DataSource = autoLotDS.Tables("Customers") + dataGridViewOrders.DataSource = autoLotDS.Tables("Orders") + End Sub +#End Region + +#Region "Build table relationships" + Private Sub BuildTableRelationship() + ' Create CustomerOrder data relation object. + Dim dr As New DataRelation("CustomerOrder", _ + autoLotDS.Tables("Customers").Columns("CustID"), _ + autoLotDS.Tables("Orders").Columns("CustID")) + autoLotDS.Relations.Add(dr) + + ' Create InventoryOrder data relation object. + dr = New DataRelation("InventoryOrder", _ + autoLotDS.Tables("Inventory").Columns("CarID"), _ + autoLotDS.Tables("Orders").Columns("CarID")) + autoLotDS.Relations.Add(dr) + End Sub +#End Region + +#Region "Button Click handlers" + Private Sub btnUpdateDatabase_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateDatabase.Click + Try + invTableAdapter.Update(autoLotDS, "Inventory") + custTableAdapter.Update(autoLotDS, "Customers") + ordersTableAdapter.Update(autoLotDS, "Orders") + Catch ex As Exception + MessageBox.Show(ex.Message) + End Try + End Sub + + Private Sub btnGetOrderInfo_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles btnGetOrderInfo.Click + Dim strOrderInfo As String = String.Empty + Dim drsCust As DataRow() = Nothing + Dim drsOrder As DataRow() = Nothing + + ' Get the customer ID in the text box. + Dim custID As Integer = Integer.Parse(Me.txtCustID.Text) + + ' Now based on custID, get the correct row in Customers table. + drsCust = autoLotDS.Tables("Customers").Select( _ + String.Format("CustID = {0}", custID)) + strOrderInfo += String.Format("Customer {0}: {1} {2}" & Chr(10), _ + drsCust(0)("CustID").ToString(), _ + drsCust(0)("FirstName").ToString().Trim(), _ + drsCust(0)("LastName").ToString().Trim()) + + ' Navigate from customer table to order table. + drsOrder = drsCust(0).GetChildRows(autoLotDS.Relations("CustomerOrder")) + + ' Get order number. + For Each r As DataRow In drsOrder + strOrderInfo += String.Format("Order Number: {0}" & Chr(10), r("OrderID")) + Next + + ' Now navigate from order table to inventory table. + Dim drsInv As DataRow() = _ + drsOrder(0).GetParentRows(autoLotDS.Relations("InventoryOrder")) + + ' Get Car info. + For Each r As DataRow In drsInv + strOrderInfo += String.Format("Make: {0}" & Chr(10), r("Make")) + strOrderInfo += String.Format("Color: {0}" & Chr(10), r("Color")) + strOrderInfo += String.Format("Pet Name: {0}" & Chr(10), r("PetName")) + Next + MessageBox.Show(strOrderInfo, "Order Details") + End Sub +#End Region + +End Class diff --git a/Code/Chapter 23/MultitabledDataSetApp/MultitabledDataSetApp.sln b/Code/Chapter 23/MultitabledDataSetApp/MultitabledDataSetApp.sln new file mode 100644 index 0000000..c21462c --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp/MultitabledDataSetApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MultitabledDataSetApp", "MultitabledDataSetApp.vbproj", "{943DE939-E2E7-4E86-9037-87772E45AC75}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {943DE939-E2E7-4E86-9037-87772E45AC75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {943DE939-E2E7-4E86-9037-87772E45AC75}.Debug|Any CPU.Build.0 = Debug|Any CPU + {943DE939-E2E7-4E86-9037-87772E45AC75}.Release|Any CPU.ActiveCfg = Release|Any CPU + {943DE939-E2E7-4E86-9037-87772E45AC75}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 23/MultitabledDataSetApp/MultitabledDataSetApp.suo b/Code/Chapter 23/MultitabledDataSetApp/MultitabledDataSetApp.suo new file mode 100644 index 0000000..7e1c1b3 Binary files /dev/null and b/Code/Chapter 23/MultitabledDataSetApp/MultitabledDataSetApp.suo differ diff --git a/Code/Chapter 23/MultitabledDataSetApp/MultitabledDataSetApp.vbproj b/Code/Chapter 23/MultitabledDataSetApp/MultitabledDataSetApp.vbproj new file mode 100644 index 0000000..874f1d4 --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp/MultitabledDataSetApp.vbproj @@ -0,0 +1,125 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {943DE939-E2E7-4E86-9037-87772E45AC75} + WinExe + MultitabledDataSetApp.My.MyApplication + MultitabledDataSetApp + MultitabledDataSetApp + 512 + WindowsForms + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + MultitabledDataSetApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + MultitabledDataSetApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + MainForm.vb + Designer + + + 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/Code/Chapter 23/MultitabledDataSetApp/MultitabledDataSetApp.vbproj.user b/Code/Chapter 23/MultitabledDataSetApp/MultitabledDataSetApp.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp/MultitabledDataSetApp.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 23/MultitabledDataSetApp/My Project/Application.Designer.vb b/Code/Chapter 23/MultitabledDataSetApp/My Project/Application.Designer.vb new file mode 100644 index 0000000..1928afb --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.MultitabledDataSetApp.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 23/MultitabledDataSetApp/My Project/Application.myapp b/Code/Chapter 23/MultitabledDataSetApp/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 23/MultitabledDataSetApp/My Project/AssemblyInfo.vb b/Code/Chapter 23/MultitabledDataSetApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..3e47486 --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp/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/Code/Chapter 23/MultitabledDataSetApp/My Project/Resources.Designer.vb b/Code/Chapter 23/MultitabledDataSetApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..1ba789f --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("MultitabledDataSetApp.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/Code/Chapter 23/MultitabledDataSetApp/My Project/Resources.resx b/Code/Chapter 23/MultitabledDataSetApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp/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/Code/Chapter 23/MultitabledDataSetApp/My Project/Settings.Designer.vb b/Code/Chapter 23/MultitabledDataSetApp/My Project/Settings.Designer.vb new file mode 100644 index 0000000..8d361cc --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.MultitabledDataSetApp.My.MySettings + Get + Return Global.MultitabledDataSetApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 23/MultitabledDataSetApp/My Project/Settings.settings b/Code/Chapter 23/MultitabledDataSetApp/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 23/MultitabledDataSetApp/app.config b/Code/Chapter 23/MultitabledDataSetApp/app.config new file mode 100644 index 0000000..4e833eb --- /dev/null +++ b/Code/Chapter 23/MultitabledDataSetApp/app.config @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/Code/Chapter 23/SimpleDataSet/My Project/Application.Designer.vb b/Code/Chapter 23/SimpleDataSet/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 23/SimpleDataSet/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 23/SimpleDataSet/My Project/Application.myapp b/Code/Chapter 23/SimpleDataSet/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 23/SimpleDataSet/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 23/SimpleDataSet/My Project/AssemblyInfo.vb b/Code/Chapter 23/SimpleDataSet/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..779915d --- /dev/null +++ b/Code/Chapter 23/SimpleDataSet/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/Code/Chapter 23/SimpleDataSet/My Project/Resources.Designer.vb b/Code/Chapter 23/SimpleDataSet/My Project/Resources.Designer.vb new file mode 100644 index 0000000..1f47daf --- /dev/null +++ b/Code/Chapter 23/SimpleDataSet/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("SimpleDataSet.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/Code/Chapter 23/SimpleDataSet/My Project/Resources.resx b/Code/Chapter 23/SimpleDataSet/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 23/SimpleDataSet/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/Code/Chapter 23/SimpleDataSet/My Project/Settings.Designer.vb b/Code/Chapter 23/SimpleDataSet/My Project/Settings.Designer.vb new file mode 100644 index 0000000..9dca6ae --- /dev/null +++ b/Code/Chapter 23/SimpleDataSet/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SimpleDataSet.My.MySettings + Get + Return Global.SimpleDataSet.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 23/SimpleDataSet/My Project/Settings.settings b/Code/Chapter 23/SimpleDataSet/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 23/SimpleDataSet/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 23/SimpleDataSet/Program.vb b/Code/Chapter 23/SimpleDataSet/Program.vb new file mode 100644 index 0000000..54167f4 --- /dev/null +++ b/Code/Chapter 23/SimpleDataSet/Program.vb @@ -0,0 +1,182 @@ +Option Explicit On +Option Strict On + +Imports System.IO +Imports System.Runtime.Serialization.Formatters.Binary + +Module Program + + Sub Main() + Console.WriteLine("***** Fun with DataSets *****" & vbLf) + + ' Create the DataSet object and add a few properties. + Dim carsInventoryDS As New DataSet("Car Inventory") + + carsInventoryDS.ExtendedProperties("TimeStamp") = DateTime.Now + carsInventoryDS.ExtendedProperties("DataSetID") = Guid.NewGuid() + carsInventoryDS.ExtendedProperties("Company") = "Intertech Training" + + ' Create data columns that map to the + ' 'real' columns in the Inventory table + ' of the AutoLot database. + Dim carIDColumn As New DataColumn("CarID", GetType(Integer)) + carIDColumn.Caption = "Car ID" + carIDColumn.ReadOnly = True + carIDColumn.AllowDBNull = False + carIDColumn.Unique = True + carIDColumn.AutoIncrement = True + carIDColumn.AutoIncrementSeed = 0 + carIDColumn.AutoIncrementStep = 1 + + Dim carMakeColumn As New DataColumn("Make", GetType(String)) + Dim carColorColumn As New DataColumn("Color", GetType(String)) + Dim carPetNameColumn As New DataColumn("PetName", GetType(String)) + carPetNameColumn.Caption = "Pet Name" + + ' Now add DataColumns to a DataTable. + Dim inventoryTable As New DataTable("Inventory") + inventoryTable.Columns.AddRange(New DataColumn() {carIDColumn, carMakeColumn, _ + carColorColumn, carPetNameColumn}) + + ' Now add some rows to the Inventory Table. + Dim carRow As DataRow = inventoryTable.NewRow() + carRow("Make") = "BMW" + carRow("Color") = "Black" + carRow("PetName") = "Hamlet" + inventoryTable.Rows.Add(carRow) + + carRow = inventoryTable.NewRow() + ' Column 0 is the autoincremented ID field, + ' so start at 1. + + carRow(1) = "Saab" + carRow(2) = "Red" + carRow(3) = "Sea Breeze" + inventoryTable.Rows.Add(carRow) + + ' Mark the primary key of this table. + inventoryTable.PrimaryKey = New DataColumn() {inventoryTable.Columns(0)} + + ' Finally, add our table to the DataSet. + carsInventoryDS.Tables.Add(inventoryTable) + + ' Now print the DataSet. + PrintDataSet(carsInventoryDS) + + ' Save and load as XML. + DataSetAsXml(carsInventoryDS) + + ' Save and load as binary. + DataSetAsBinary(carsInventoryDS) + + ' Uncomment to test. + ManipulateDataRowState() + Console.ReadLine() + End Sub + +#Region "DataSet as XML" + Private Sub DataSetAsXml(ByVal carsInventoryDS As DataSet) + ' Save this DataSet as XML. + carsInventoryDS.WriteXml("carsDataSet.xml") + carsInventoryDS.WriteXmlSchema("carsDataSet.xsd") + + ' Clear out DataSet. + carsInventoryDS.Clear() + + ' Load DataSet from XML file. + carsInventoryDS.ReadXml("carsDataSet.xml") + End Sub +#End Region + +#Region "DataSet as Binary" + Private Sub DataSetAsBinary(ByVal carsInventoryDS As DataSet) + ' Set binary serialization flag. + carsInventoryDS.RemotingFormat = SerializationFormat.Binary + + ' Save this DataSet as binary. + Dim fs As New FileStream("BinaryCars.bin", FileMode.Create) + Dim bFormat As New BinaryFormatter() + bFormat.Serialize(fs, carsInventoryDS) + fs.Close() + + ' Clear out DataSet. + carsInventoryDS.Clear() + + ' Load DataSet from binary file. + fs = New FileStream("BinaryCars.bin", FileMode.Open) + Dim data As DataSet = DirectCast(bFormat.Deserialize(fs), DataSet) + End Sub +#End Region + +#Region "DataRowState manipulation test" + Private Sub ManipulateDataRowState() + Console.WriteLine(vbLf & vbLf & "***** Fun with RowState *****" & vbLf) + ' Create a temp DataTable for testing. + Dim temp As New DataTable("Temp") + temp.Columns.Add(New DataColumn("TempColumn", GetType(Integer))) + + ' RowState = Detatched. + Dim row As DataRow = temp.NewRow() + Console.WriteLine("After calling NewRow(): {0}", row.RowState) + + ' RowState = Added. + temp.Rows.Add(row) + Console.WriteLine("After calling Rows.Add(): {0}", row.RowState) + + ' RowState = Added. + row("TempColumn") = 10 + Console.WriteLine("After first assignment: {0}", row.RowState) + + ' RowState = Unchanged. + temp.AcceptChanges() + Console.WriteLine("After calling AcceptChanges: {0}", row.RowState) + + ' RowState = Modified. + row("TempColumn") = 11 + Console.WriteLine("After second assignment: {0}", row.RowState) + + ' RowState = Deleted. + temp.Rows(0).Delete() + Console.WriteLine("After calling Delete: {0}", row.RowState) + End Sub +#End Region + +#Region "Print out DataSet" + Private Sub PrintDataSet(ByVal ds As DataSet) + ' Print out any name and extended properties. + Console.WriteLine("DataSet is named: {0}", ds.DataSetName) + For Each de As System.Collections.DictionaryEntry In ds.ExtendedProperties + Console.WriteLine("Key = {0}, Value = {1}", de.Key, de.Value) + Next + Console.WriteLine() + + For Each dt As DataTable In ds.Tables + Console.WriteLine("=> {0} Table:", dt.TableName) + For curCol As Integer = 0 To dt.Columns.Count - 1 + + ' Print out the column names. + Console.Write(dt.Columns(curCol).ColumnName + "" & vbTab) + Next + Console.WriteLine("" & vbLf & "----------------------------------") + PrintTable(dt) + Next + End Sub +#End Region + +#Region "Print out DataTable using DataTableReader" + Private Sub PrintTable(ByVal dt As DataTable) + ' Get the DataTableReader type. + Dim dtReader As DataTableReader = dt.CreateDataReader() + + ' The DataTableReader works just like the DataReader. + While dtReader.Read() + For i As Integer = 0 To dtReader.FieldCount - 1 + Console.Write("{0}" & vbTab, dtReader.GetValue(i).ToString().Trim()) + Next + Console.WriteLine() + End While + dtReader.Close() + End Sub +#End Region + +End Module diff --git a/Code/Chapter 23/SimpleDataSet/SimpleDataSet.sln b/Code/Chapter 23/SimpleDataSet/SimpleDataSet.sln new file mode 100644 index 0000000..11a21d6 --- /dev/null +++ b/Code/Chapter 23/SimpleDataSet/SimpleDataSet.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SimpleDataSet", "SimpleDataSet.vbproj", "{00A45FAE-1DC2-41E4-9FD9-23B08F49428A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {00A45FAE-1DC2-41E4-9FD9-23B08F49428A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {00A45FAE-1DC2-41E4-9FD9-23B08F49428A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {00A45FAE-1DC2-41E4-9FD9-23B08F49428A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {00A45FAE-1DC2-41E4-9FD9-23B08F49428A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 23/SimpleDataSet/SimpleDataSet.suo b/Code/Chapter 23/SimpleDataSet/SimpleDataSet.suo new file mode 100644 index 0000000..ac63511 Binary files /dev/null and b/Code/Chapter 23/SimpleDataSet/SimpleDataSet.suo differ diff --git a/Code/Chapter 23/SimpleDataSet/SimpleDataSet.vbproj b/Code/Chapter 23/SimpleDataSet/SimpleDataSet.vbproj new file mode 100644 index 0000000..58695c4 --- /dev/null +++ b/Code/Chapter 23/SimpleDataSet/SimpleDataSet.vbproj @@ -0,0 +1,109 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {00A45FAE-1DC2-41E4-9FD9-23B08F49428A} + Exe + SimpleDataSet.Program + SimpleDataSet + SimpleDataSet + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + SimpleDataSet.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SimpleDataSet.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 23/SimpleDataSet/SimpleDataSet.vbproj.user b/Code/Chapter 23/SimpleDataSet/SimpleDataSet.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 23/SimpleDataSet/SimpleDataSet.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 23/VisualDataGridViewApp/InventoryDataSet.Designer.vb b/Code/Chapter 23/VisualDataGridViewApp/InventoryDataSet.Designer.vb new file mode 100644 index 0000000..e42807e --- /dev/null +++ b/Code/Chapter 23/VisualDataGridViewApp/InventoryDataSet.Designer.vb @@ -0,0 +1,1406 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict Off +Option Explicit On + + + +''' +'''Represents a strongly typed in-memory cache of data. +''' + _ +Partial Public Class InventoryDataSet + Inherits Global.System.Data.DataSet + + Private tableInventory As InventoryDataTable + + Private _schemaSerializationMode As Global.System.Data.SchemaSerializationMode = Global.System.Data.SchemaSerializationMode.IncludeSchema + + _ + Public Sub New() + MyBase.New + Me.BeginInit + Me.InitClass + Dim schemaChangedHandler As Global.System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged + AddHandler MyBase.Tables.CollectionChanged, schemaChangedHandler + AddHandler MyBase.Relations.CollectionChanged, schemaChangedHandler + Me.EndInit + End Sub + + _ + Protected Sub New(ByVal info As Global.System.Runtime.Serialization.SerializationInfo, ByVal context As Global.System.Runtime.Serialization.StreamingContext) + MyBase.New(info, context, false) + If (Me.IsBinarySerialized(info, context) = true) Then + Me.InitVars(false) + Dim schemaChangedHandler1 As Global.System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged + AddHandler Me.Tables.CollectionChanged, schemaChangedHandler1 + AddHandler Me.Relations.CollectionChanged, schemaChangedHandler1 + Return + End If + Dim strSchema As String = CType(info.GetValue("XmlSchema", GetType(String)),String) + If (Me.DetermineSchemaSerializationMode(info, context) = Global.System.Data.SchemaSerializationMode.IncludeSchema) Then + Dim ds As Global.System.Data.DataSet = New Global.System.Data.DataSet + ds.ReadXmlSchema(New Global.System.Xml.XmlTextReader(New Global.System.IO.StringReader(strSchema))) + If (Not (ds.Tables("Inventory")) Is Nothing) Then + MyBase.Tables.Add(New InventoryDataTable(ds.Tables("Inventory"))) + End If + Me.DataSetName = ds.DataSetName + Me.Prefix = ds.Prefix + Me.Namespace = ds.Namespace + Me.Locale = ds.Locale + Me.CaseSensitive = ds.CaseSensitive + Me.EnforceConstraints = ds.EnforceConstraints + Me.Merge(ds, false, Global.System.Data.MissingSchemaAction.Add) + Me.InitVars + Else + Me.ReadXmlSchema(New Global.System.Xml.XmlTextReader(New Global.System.IO.StringReader(strSchema))) + End If + Me.GetSerializationData(info, context) + Dim schemaChangedHandler As Global.System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged + AddHandler MyBase.Tables.CollectionChanged, schemaChangedHandler + AddHandler Me.Relations.CollectionChanged, schemaChangedHandler + End Sub + + _ + Public ReadOnly Property Inventory() As InventoryDataTable + Get + Return Me.tableInventory + End Get + End Property + + _ + Public Overrides Property SchemaSerializationMode() As Global.System.Data.SchemaSerializationMode + Get + Return Me._schemaSerializationMode + End Get + Set + Me._schemaSerializationMode = value + End Set + End Property + + _ + Public Shadows ReadOnly Property Tables() As Global.System.Data.DataTableCollection + Get + Return MyBase.Tables + End Get + End Property + + _ + Public Shadows ReadOnly Property Relations() As Global.System.Data.DataRelationCollection + Get + Return MyBase.Relations + End Get + End Property + + _ + Protected Overrides Sub InitializeDerivedDataSet() + Me.BeginInit + Me.InitClass + Me.EndInit + End Sub + + _ + Public Overrides Function Clone() As Global.System.Data.DataSet + Dim cln As InventoryDataSet = CType(MyBase.Clone,InventoryDataSet) + cln.InitVars + cln.SchemaSerializationMode = Me.SchemaSerializationMode + Return cln + End Function + + _ + Protected Overrides Function ShouldSerializeTables() As Boolean + Return false + End Function + + _ + Protected Overrides Function ShouldSerializeRelations() As Boolean + Return false + End Function + + _ + Protected Overrides Sub ReadXmlSerializable(ByVal reader As Global.System.Xml.XmlReader) + If (Me.DetermineSchemaSerializationMode(reader) = Global.System.Data.SchemaSerializationMode.IncludeSchema) Then + Me.Reset + Dim ds As Global.System.Data.DataSet = New Global.System.Data.DataSet + ds.ReadXml(reader) + If (Not (ds.Tables("Inventory")) Is Nothing) Then + MyBase.Tables.Add(New InventoryDataTable(ds.Tables("Inventory"))) + End If + Me.DataSetName = ds.DataSetName + Me.Prefix = ds.Prefix + Me.Namespace = ds.Namespace + Me.Locale = ds.Locale + Me.CaseSensitive = ds.CaseSensitive + Me.EnforceConstraints = ds.EnforceConstraints + Me.Merge(ds, false, Global.System.Data.MissingSchemaAction.Add) + Me.InitVars + Else + Me.ReadXml(reader) + Me.InitVars + End If + End Sub + + _ + Protected Overrides Function GetSchemaSerializable() As Global.System.Xml.Schema.XmlSchema + Dim stream As Global.System.IO.MemoryStream = New Global.System.IO.MemoryStream + Me.WriteXmlSchema(New Global.System.Xml.XmlTextWriter(stream, Nothing)) + stream.Position = 0 + Return Global.System.Xml.Schema.XmlSchema.Read(New Global.System.Xml.XmlTextReader(stream), Nothing) + End Function + + _ + Friend Overloads Sub InitVars() + Me.InitVars(true) + End Sub + + _ + Friend Overloads Sub InitVars(ByVal initTable As Boolean) + Me.tableInventory = CType(MyBase.Tables("Inventory"),InventoryDataTable) + If (initTable = true) Then + If (Not (Me.tableInventory) Is Nothing) Then + Me.tableInventory.InitVars + End If + End If + End Sub + + _ + Private Sub InitClass() + Me.DataSetName = "InventoryDataSet" + Me.Prefix = "" + Me.Namespace = "http://tempuri.org/InventoryDataSet.xsd" + Me.EnforceConstraints = true + Me.SchemaSerializationMode = Global.System.Data.SchemaSerializationMode.IncludeSchema + Me.tableInventory = New InventoryDataTable + MyBase.Tables.Add(Me.tableInventory) + End Sub + + _ + Private Function ShouldSerializeInventory() As Boolean + Return false + End Function + + _ + Private Sub SchemaChanged(ByVal sender As Object, ByVal e As Global.System.ComponentModel.CollectionChangeEventArgs) + If (e.Action = Global.System.ComponentModel.CollectionChangeAction.Remove) Then + Me.InitVars + End If + End Sub + + _ + Public Shared Function GetTypedDataSetSchema(ByVal xs As Global.System.Xml.Schema.XmlSchemaSet) As Global.System.Xml.Schema.XmlSchemaComplexType + Dim ds As InventoryDataSet = New InventoryDataSet + Dim type As Global.System.Xml.Schema.XmlSchemaComplexType = New Global.System.Xml.Schema.XmlSchemaComplexType + Dim sequence As Global.System.Xml.Schema.XmlSchemaSequence = New Global.System.Xml.Schema.XmlSchemaSequence + Dim any As Global.System.Xml.Schema.XmlSchemaAny = New Global.System.Xml.Schema.XmlSchemaAny + any.Namespace = ds.Namespace + sequence.Items.Add(any) + type.Particle = sequence + Dim dsSchema As Global.System.Xml.Schema.XmlSchema = ds.GetSchemaSerializable + If xs.Contains(dsSchema.TargetNamespace) Then + Dim s1 As Global.System.IO.MemoryStream = New Global.System.IO.MemoryStream + Dim s2 As Global.System.IO.MemoryStream = New Global.System.IO.MemoryStream + Try + Dim schema As Global.System.Xml.Schema.XmlSchema = Nothing + dsSchema.Write(s1) + Dim schemas As Global.System.Collections.IEnumerator = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator + Do While schemas.MoveNext + schema = CType(schemas.Current,Global.System.Xml.Schema.XmlSchema) + s2.SetLength(0) + schema.Write(s2) + If (s1.Length = s2.Length) Then + s1.Position = 0 + s2.Position = 0 + + Do While ((s1.Position <> s1.Length) _ + AndAlso (s1.ReadByte = s2.ReadByte)) + + + Loop + If (s1.Position = s1.Length) Then + Return type + End If + End If + + Loop + Finally + If (Not (s1) Is Nothing) Then + s1.Close + End If + If (Not (s2) Is Nothing) Then + s2.Close + End If + End Try + End If + xs.Add(dsSchema) + Return type + End Function + + Public Delegate Sub InventoryRowChangeEventHandler(ByVal sender As Object, ByVal e As InventoryRowChangeEvent) + + ''' + '''Represents the strongly named DataTable class. + ''' + _ + Partial Public Class InventoryDataTable + Inherits Global.System.Data.TypedTableBase(Of InventoryRow) + + Private columnCarID As Global.System.Data.DataColumn + + Private columnMake As Global.System.Data.DataColumn + + Private columnColor As Global.System.Data.DataColumn + + Private columnPetName As Global.System.Data.DataColumn + + _ + Public Sub New() + MyBase.New + Me.TableName = "Inventory" + Me.BeginInit + Me.InitClass + Me.EndInit + End Sub + + _ + Friend Sub New(ByVal table As Global.System.Data.DataTable) + MyBase.New + Me.TableName = table.TableName + If (table.CaseSensitive <> table.DataSet.CaseSensitive) Then + Me.CaseSensitive = table.CaseSensitive + End If + If (table.Locale.ToString <> table.DataSet.Locale.ToString) Then + Me.Locale = table.Locale + End If + If (table.Namespace <> table.DataSet.Namespace) Then + Me.Namespace = table.Namespace + End If + Me.Prefix = table.Prefix + Me.MinimumCapacity = table.MinimumCapacity + End Sub + + _ + Protected Sub New(ByVal info As Global.System.Runtime.Serialization.SerializationInfo, ByVal context As Global.System.Runtime.Serialization.StreamingContext) + MyBase.New(info, context) + Me.InitVars + End Sub + + _ + Public ReadOnly Property CarIDColumn() As Global.System.Data.DataColumn + Get + Return Me.columnCarID + End Get + End Property + + _ + Public ReadOnly Property MakeColumn() As Global.System.Data.DataColumn + Get + Return Me.columnMake + End Get + End Property + + _ + Public ReadOnly Property ColorColumn() As Global.System.Data.DataColumn + Get + Return Me.columnColor + End Get + End Property + + _ + Public ReadOnly Property PetNameColumn() As Global.System.Data.DataColumn + Get + Return Me.columnPetName + End Get + End Property + + _ + Public ReadOnly Property Count() As Integer + Get + Return Me.Rows.Count + End Get + End Property + + _ + Public Default ReadOnly Property Item(ByVal index As Integer) As InventoryRow + Get + Return CType(Me.Rows(index),InventoryRow) + End Get + End Property + + Public Event InventoryRowChanging As InventoryRowChangeEventHandler + + Public Event InventoryRowChanged As InventoryRowChangeEventHandler + + Public Event InventoryRowDeleting As InventoryRowChangeEventHandler + + Public Event InventoryRowDeleted As InventoryRowChangeEventHandler + + _ + Public Overloads Sub AddInventoryRow(ByVal row As InventoryRow) + Me.Rows.Add(row) + End Sub + + _ + Public Overloads Function AddInventoryRow(ByVal CarID As Integer, ByVal Make As String, ByVal Color As String, ByVal PetName As String) As InventoryRow + Dim rowInventoryRow As InventoryRow = CType(Me.NewRow,InventoryRow) + Dim columnValuesArray() As Object = New Object() {CarID, Make, Color, PetName} + rowInventoryRow.ItemArray = columnValuesArray + Me.Rows.Add(rowInventoryRow) + Return rowInventoryRow + End Function + + _ + Public Function FindByCarID(ByVal CarID As Integer) As InventoryRow + Return CType(Me.Rows.Find(New Object() {CarID}),InventoryRow) + End Function + + _ + Public Overrides Function Clone() As Global.System.Data.DataTable + Dim cln As InventoryDataTable = CType(MyBase.Clone,InventoryDataTable) + cln.InitVars + Return cln + End Function + + _ + Protected Overrides Function CreateInstance() As Global.System.Data.DataTable + Return New InventoryDataTable + End Function + + _ + Friend Sub InitVars() + Me.columnCarID = MyBase.Columns("CarID") + Me.columnMake = MyBase.Columns("Make") + Me.columnColor = MyBase.Columns("Color") + Me.columnPetName = MyBase.Columns("PetName") + End Sub + + _ + Private Sub InitClass() + Me.columnCarID = New Global.System.Data.DataColumn("CarID", GetType(Integer), Nothing, Global.System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnCarID) + Me.columnMake = New Global.System.Data.DataColumn("Make", GetType(String), Nothing, Global.System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnMake) + Me.columnColor = New Global.System.Data.DataColumn("Color", GetType(String), Nothing, Global.System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnColor) + Me.columnPetName = New Global.System.Data.DataColumn("PetName", GetType(String), Nothing, Global.System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnPetName) + Me.Constraints.Add(New Global.System.Data.UniqueConstraint("Constraint1", New Global.System.Data.DataColumn() {Me.columnCarID}, true)) + Me.columnCarID.AllowDBNull = false + Me.columnCarID.Unique = true + Me.columnMake.AllowDBNull = false + Me.columnMake.MaxLength = 50 + Me.columnColor.AllowDBNull = false + Me.columnColor.MaxLength = 50 + Me.columnPetName.MaxLength = 50 + End Sub + + _ + Public Function NewInventoryRow() As InventoryRow + Return CType(Me.NewRow,InventoryRow) + End Function + + _ + Protected Overrides Function NewRowFromBuilder(ByVal builder As Global.System.Data.DataRowBuilder) As Global.System.Data.DataRow + Return New InventoryRow(builder) + End Function + + _ + Protected Overrides Function GetRowType() As Global.System.Type + Return GetType(InventoryRow) + End Function + + _ + Protected Overrides Sub OnRowChanged(ByVal e As Global.System.Data.DataRowChangeEventArgs) + MyBase.OnRowChanged(e) + If (Not (Me.InventoryRowChangedEvent) Is Nothing) Then + RaiseEvent InventoryRowChanged(Me, New InventoryRowChangeEvent(CType(e.Row,InventoryRow), e.Action)) + End If + End Sub + + _ + Protected Overrides Sub OnRowChanging(ByVal e As Global.System.Data.DataRowChangeEventArgs) + MyBase.OnRowChanging(e) + If (Not (Me.InventoryRowChangingEvent) Is Nothing) Then + RaiseEvent InventoryRowChanging(Me, New InventoryRowChangeEvent(CType(e.Row,InventoryRow), e.Action)) + End If + End Sub + + _ + Protected Overrides Sub OnRowDeleted(ByVal e As Global.System.Data.DataRowChangeEventArgs) + MyBase.OnRowDeleted(e) + If (Not (Me.InventoryRowDeletedEvent) Is Nothing) Then + RaiseEvent InventoryRowDeleted(Me, New InventoryRowChangeEvent(CType(e.Row,InventoryRow), e.Action)) + End If + End Sub + + _ + Protected Overrides Sub OnRowDeleting(ByVal e As Global.System.Data.DataRowChangeEventArgs) + MyBase.OnRowDeleting(e) + If (Not (Me.InventoryRowDeletingEvent) Is Nothing) Then + RaiseEvent InventoryRowDeleting(Me, New InventoryRowChangeEvent(CType(e.Row,InventoryRow), e.Action)) + End If + End Sub + + _ + Public Sub RemoveInventoryRow(ByVal row As InventoryRow) + Me.Rows.Remove(row) + End Sub + + _ + Public Shared Function GetTypedTableSchema(ByVal xs As Global.System.Xml.Schema.XmlSchemaSet) As Global.System.Xml.Schema.XmlSchemaComplexType + Dim type As Global.System.Xml.Schema.XmlSchemaComplexType = New Global.System.Xml.Schema.XmlSchemaComplexType + Dim sequence As Global.System.Xml.Schema.XmlSchemaSequence = New Global.System.Xml.Schema.XmlSchemaSequence + Dim ds As InventoryDataSet = New InventoryDataSet + Dim any1 As Global.System.Xml.Schema.XmlSchemaAny = New Global.System.Xml.Schema.XmlSchemaAny + any1.Namespace = "http://www.w3.org/2001/XMLSchema" + any1.MinOccurs = New Decimal(0) + any1.MaxOccurs = Decimal.MaxValue + any1.ProcessContents = Global.System.Xml.Schema.XmlSchemaContentProcessing.Lax + sequence.Items.Add(any1) + Dim any2 As Global.System.Xml.Schema.XmlSchemaAny = New Global.System.Xml.Schema.XmlSchemaAny + any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1" + any2.MinOccurs = New Decimal(1) + any2.ProcessContents = Global.System.Xml.Schema.XmlSchemaContentProcessing.Lax + sequence.Items.Add(any2) + Dim attribute1 As Global.System.Xml.Schema.XmlSchemaAttribute = New Global.System.Xml.Schema.XmlSchemaAttribute + attribute1.Name = "namespace" + attribute1.FixedValue = ds.Namespace + type.Attributes.Add(attribute1) + Dim attribute2 As Global.System.Xml.Schema.XmlSchemaAttribute = New Global.System.Xml.Schema.XmlSchemaAttribute + attribute2.Name = "tableTypeName" + attribute2.FixedValue = "InventoryDataTable" + type.Attributes.Add(attribute2) + type.Particle = sequence + Dim dsSchema As Global.System.Xml.Schema.XmlSchema = ds.GetSchemaSerializable + If xs.Contains(dsSchema.TargetNamespace) Then + Dim s1 As Global.System.IO.MemoryStream = New Global.System.IO.MemoryStream + Dim s2 As Global.System.IO.MemoryStream = New Global.System.IO.MemoryStream + Try + Dim schema As Global.System.Xml.Schema.XmlSchema = Nothing + dsSchema.Write(s1) + Dim schemas As Global.System.Collections.IEnumerator = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator + Do While schemas.MoveNext + schema = CType(schemas.Current,Global.System.Xml.Schema.XmlSchema) + s2.SetLength(0) + schema.Write(s2) + If (s1.Length = s2.Length) Then + s1.Position = 0 + s2.Position = 0 + + Do While ((s1.Position <> s1.Length) _ + AndAlso (s1.ReadByte = s2.ReadByte)) + + + Loop + If (s1.Position = s1.Length) Then + Return type + End If + End If + + Loop + Finally + If (Not (s1) Is Nothing) Then + s1.Close + End If + If (Not (s2) Is Nothing) Then + s2.Close + End If + End Try + End If + xs.Add(dsSchema) + Return type + End Function + End Class + + ''' + '''Represents strongly named DataRow class. + ''' + _ + Partial Public Class InventoryRow + Inherits Global.System.Data.DataRow + + Private tableInventory As InventoryDataTable + + _ + Friend Sub New(ByVal rb As Global.System.Data.DataRowBuilder) + MyBase.New(rb) + Me.tableInventory = CType(Me.Table,InventoryDataTable) + End Sub + + _ + Public Property CarID() As Integer + Get + Return CType(Me(Me.tableInventory.CarIDColumn),Integer) + End Get + Set + Me(Me.tableInventory.CarIDColumn) = value + End Set + End Property + + _ + Public Property Make() As String + Get + Return CType(Me(Me.tableInventory.MakeColumn),String) + End Get + Set + Me(Me.tableInventory.MakeColumn) = value + End Set + End Property + + _ + Public Property Color() As String + Get + Return CType(Me(Me.tableInventory.ColorColumn),String) + End Get + Set + Me(Me.tableInventory.ColorColumn) = value + End Set + End Property + + _ + Public Property PetName() As String + Get + Try + Return CType(Me(Me.tableInventory.PetNameColumn),String) + Catch e As Global.System.InvalidCastException + Throw New Global.System.Data.StrongTypingException("The value for column 'PetName' in table 'Inventory' is DBNull.", e) + End Try + End Get + Set + Me(Me.tableInventory.PetNameColumn) = value + End Set + End Property + + _ + Public Function IsPetNameNull() As Boolean + Return Me.IsNull(Me.tableInventory.PetNameColumn) + End Function + + _ + Public Sub SetPetNameNull() + Me(Me.tableInventory.PetNameColumn) = Global.System.Convert.DBNull + End Sub + End Class + + ''' + '''Row event argument class + ''' + _ + Public Class InventoryRowChangeEvent + Inherits Global.System.EventArgs + + Private eventRow As InventoryRow + + Private eventAction As Global.System.Data.DataRowAction + + _ + Public Sub New(ByVal row As InventoryRow, ByVal action As Global.System.Data.DataRowAction) + MyBase.New + Me.eventRow = row + Me.eventAction = action + End Sub + + _ + Public ReadOnly Property Row() As InventoryRow + Get + Return Me.eventRow + End Get + End Property + + _ + Public ReadOnly Property Action() As Global.System.Data.DataRowAction + Get + Return Me.eventAction + End Get + End Property + End Class +End Class + +Namespace InventoryDataSetTableAdapters + + ''' + '''Represents the connection and commands used to retrieve and save data. + ''' + _ + Partial Public Class InventoryTableAdapter + Inherits Global.System.ComponentModel.Component + + Private WithEvents _adapter As Global.System.Data.SqlClient.SqlDataAdapter + + Private _connection As Global.System.Data.SqlClient.SqlConnection + + Private _transaction As Global.System.Data.SqlClient.SqlTransaction + + Private _commandCollection() As Global.System.Data.SqlClient.SqlCommand + + Private _clearBeforeFill As Boolean + + _ + Public Sub New() + MyBase.New + Me.ClearBeforeFill = true + End Sub + + _ + Protected Friend ReadOnly Property Adapter() As Global.System.Data.SqlClient.SqlDataAdapter + Get + If (Me._adapter Is Nothing) Then + Me.InitAdapter + End If + Return Me._adapter + End Get + End Property + + _ + Friend Property Connection() As Global.System.Data.SqlClient.SqlConnection + Get + If (Me._connection Is Nothing) Then + Me.InitConnection + End If + Return Me._connection + End Get + Set + Me._connection = value + If (Not (Me.Adapter.InsertCommand) Is Nothing) Then + Me.Adapter.InsertCommand.Connection = value + End If + If (Not (Me.Adapter.DeleteCommand) Is Nothing) Then + Me.Adapter.DeleteCommand.Connection = value + End If + If (Not (Me.Adapter.UpdateCommand) Is Nothing) Then + Me.Adapter.UpdateCommand.Connection = value + End If + Dim i As Integer = 0 + Do While (i < Me.CommandCollection.Length) + If (Not (Me.CommandCollection(i)) Is Nothing) Then + CType(Me.CommandCollection(i),Global.System.Data.SqlClient.SqlCommand).Connection = value + End If + i = (i + 1) + Loop + End Set + End Property + + _ + Friend Property Transaction() As Global.System.Data.SqlClient.SqlTransaction + Get + Return Me._transaction + End Get + Set + Me._transaction = value + Dim i As Integer = 0 + Do While (i < Me.CommandCollection.Length) + Me.CommandCollection(i).Transaction = Me._transaction + i = (i + 1) + Loop + If ((Not (Me.Adapter) Is Nothing) _ + AndAlso (Not (Me.Adapter.DeleteCommand) Is Nothing)) Then + Me.Adapter.DeleteCommand.Transaction = Me._transaction + End If + If ((Not (Me.Adapter) Is Nothing) _ + AndAlso (Not (Me.Adapter.InsertCommand) Is Nothing)) Then + Me.Adapter.InsertCommand.Transaction = Me._transaction + End If + If ((Not (Me.Adapter) Is Nothing) _ + AndAlso (Not (Me.Adapter.UpdateCommand) Is Nothing)) Then + Me.Adapter.UpdateCommand.Transaction = Me._transaction + End If + End Set + End Property + + _ + Protected ReadOnly Property CommandCollection() As Global.System.Data.SqlClient.SqlCommand() + Get + If (Me._commandCollection Is Nothing) Then + Me.InitCommandCollection + End If + Return Me._commandCollection + End Get + End Property + + _ + Public Property ClearBeforeFill() As Boolean + Get + Return Me._clearBeforeFill + End Get + Set + Me._clearBeforeFill = value + End Set + End Property + + _ + Private Sub InitAdapter() + Me._adapter = New Global.System.Data.SqlClient.SqlDataAdapter + Dim tableMapping As Global.System.Data.Common.DataTableMapping = New Global.System.Data.Common.DataTableMapping + tableMapping.SourceTable = "Table" + tableMapping.DataSetTable = "Inventory" + tableMapping.ColumnMappings.Add("CarID", "CarID") + tableMapping.ColumnMappings.Add("Make", "Make") + tableMapping.ColumnMappings.Add("Color", "Color") + tableMapping.ColumnMappings.Add("PetName", "PetName") + Me._adapter.TableMappings.Add(tableMapping) + Me._adapter.DeleteCommand = New Global.System.Data.SqlClient.SqlCommand + Me._adapter.DeleteCommand.Connection = Me.Connection + Me._adapter.DeleteCommand.CommandText = "DELETE FROM [dbo].[Inventory] WHERE (([CarID] = @Original_CarID) AND ([Make] = @O"& _ + "riginal_Make) AND ([Color] = @Original_Color) AND ((@IsNull_PetName = 1 AND [Pet"& _ + "Name] IS NULL) OR ([PetName] = @Original_PetName)))" + Me._adapter.DeleteCommand.CommandType = Global.System.Data.CommandType.Text + Me._adapter.DeleteCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_CarID", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "CarID", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.DeleteCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_Make", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "Make", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.DeleteCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_Color", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "Color", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.DeleteCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@IsNull_PetName", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "PetName", Global.System.Data.DataRowVersion.Original, true, Nothing, "", "", "")) + Me._adapter.DeleteCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_PetName", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "PetName", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.InsertCommand = New Global.System.Data.SqlClient.SqlCommand + Me._adapter.InsertCommand.Connection = Me.Connection + Me._adapter.InsertCommand.CommandText = "INSERT INTO [dbo].[Inventory] ([CarID], [Make], [Color], [PetName]) VALUES (@CarI"& _ + "D, @Make, @Color, @PetName);"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"SELECT CarID, Make, Color, PetName FROM Inventory "& _ + "WHERE (CarID = @CarID)" + Me._adapter.InsertCommand.CommandType = Global.System.Data.CommandType.Text + Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@CarID", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "CarID", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Make", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "Make", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Color", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "Color", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@PetName", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "PetName", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand = New Global.System.Data.SqlClient.SqlCommand + Me._adapter.UpdateCommand.Connection = Me.Connection + Me._adapter.UpdateCommand.CommandText = "UPDATE [dbo].[Inventory] SET [CarID] = @CarID, [Make] = @Make, [Color] = @Color, "& _ + "[PetName] = @PetName WHERE (([CarID] = @Original_CarID) AND ([Make] = @Original_"& _ + "Make) AND ([Color] = @Original_Color) AND ((@IsNull_PetName = 1 AND [PetName] IS"& _ + " NULL) OR ([PetName] = @Original_PetName)));"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"SELECT CarID, Make, Color, PetName"& _ + " FROM Inventory WHERE (CarID = @CarID)" + Me._adapter.UpdateCommand.CommandType = Global.System.Data.CommandType.Text + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@CarID", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "CarID", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Make", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "Make", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Color", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "Color", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@PetName", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "PetName", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_CarID", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "CarID", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_Make", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "Make", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_Color", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "Color", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@IsNull_PetName", Global.System.Data.SqlDbType.Int, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "PetName", Global.System.Data.DataRowVersion.Original, true, Nothing, "", "", "")) + Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@Original_PetName", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "PetName", Global.System.Data.DataRowVersion.Original, false, Nothing, "", "", "")) + End Sub + + _ + Private Sub InitConnection() + Me._connection = New Global.System.Data.SqlClient.SqlConnection + Me._connection.ConnectionString = Global.VisualDataGridViewApp.My.MySettings.Default.AutoLotConnectionString + End Sub + + _ + Private Sub InitCommandCollection() + Me._commandCollection = New Global.System.Data.SqlClient.SqlCommand(0) {} + Me._commandCollection(0) = New Global.System.Data.SqlClient.SqlCommand + Me._commandCollection(0).Connection = Me.Connection + Me._commandCollection(0).CommandText = "SELECT CarID, Make, Color, PetName FROM dbo.Inventory" + Me._commandCollection(0).CommandType = Global.System.Data.CommandType.Text + End Sub + + _ + Public Overloads Overridable Function Fill(ByVal dataTable As InventoryDataSet.InventoryDataTable) As Integer + Me.Adapter.SelectCommand = Me.CommandCollection(0) + If (Me.ClearBeforeFill = true) Then + dataTable.Clear + End If + Dim returnValue As Integer = Me.Adapter.Fill(dataTable) + Return returnValue + End Function + + _ + Public Overloads Overridable Function GetData() As InventoryDataSet.InventoryDataTable + Me.Adapter.SelectCommand = Me.CommandCollection(0) + Dim dataTable As InventoryDataSet.InventoryDataTable = New InventoryDataSet.InventoryDataTable + Me.Adapter.Fill(dataTable) + Return dataTable + End Function + + _ + Public Overloads Overridable Function Update(ByVal dataTable As InventoryDataSet.InventoryDataTable) As Integer + Return Me.Adapter.Update(dataTable) + End Function + + _ + Public Overloads Overridable Function Update(ByVal dataSet As InventoryDataSet) As Integer + Return Me.Adapter.Update(dataSet, "Inventory") + End Function + + _ + Public Overloads Overridable Function Update(ByVal dataRow As Global.System.Data.DataRow) As Integer + Return Me.Adapter.Update(New Global.System.Data.DataRow() {dataRow}) + End Function + + _ + Public Overloads Overridable Function Update(ByVal dataRows() As Global.System.Data.DataRow) As Integer + Return Me.Adapter.Update(dataRows) + End Function + + _ + Public Overloads Overridable Function Delete(ByVal Original_CarID As Integer, ByVal Original_Make As String, ByVal Original_Color As String, ByVal Original_PetName As String) As Integer + Me.Adapter.DeleteCommand.Parameters(0).Value = CType(Original_CarID,Integer) + If (Original_Make Is Nothing) Then + Throw New Global.System.ArgumentNullException("Original_Make") + Else + Me.Adapter.DeleteCommand.Parameters(1).Value = CType(Original_Make,String) + End If + If (Original_Color Is Nothing) Then + Throw New Global.System.ArgumentNullException("Original_Color") + Else + Me.Adapter.DeleteCommand.Parameters(2).Value = CType(Original_Color,String) + End If + If (Original_PetName Is Nothing) Then + Me.Adapter.DeleteCommand.Parameters(3).Value = CType(1,Object) + Me.Adapter.DeleteCommand.Parameters(4).Value = Global.System.DBNull.Value + Else + Me.Adapter.DeleteCommand.Parameters(3).Value = CType(0,Object) + Me.Adapter.DeleteCommand.Parameters(4).Value = CType(Original_PetName,String) + End If + Dim previousConnectionState As Global.System.Data.ConnectionState = Me.Adapter.DeleteCommand.Connection.State + If ((Me.Adapter.DeleteCommand.Connection.State And Global.System.Data.ConnectionState.Open) _ + <> Global.System.Data.ConnectionState.Open) Then + Me.Adapter.DeleteCommand.Connection.Open + End If + Try + Dim returnValue As Integer = Me.Adapter.DeleteCommand.ExecuteNonQuery + Return returnValue + Finally + If (previousConnectionState = Global.System.Data.ConnectionState.Closed) Then + Me.Adapter.DeleteCommand.Connection.Close + End If + End Try + End Function + + _ + Public Overloads Overridable Function Insert(ByVal CarID As Integer, ByVal Make As String, ByVal Color As String, ByVal PetName As String) As Integer + Me.Adapter.InsertCommand.Parameters(0).Value = CType(CarID,Integer) + If (Make Is Nothing) Then + Throw New Global.System.ArgumentNullException("Make") + Else + Me.Adapter.InsertCommand.Parameters(1).Value = CType(Make,String) + End If + If (Color Is Nothing) Then + Throw New Global.System.ArgumentNullException("Color") + Else + Me.Adapter.InsertCommand.Parameters(2).Value = CType(Color,String) + End If + If (PetName Is Nothing) Then + Me.Adapter.InsertCommand.Parameters(3).Value = Global.System.DBNull.Value + Else + Me.Adapter.InsertCommand.Parameters(3).Value = CType(PetName,String) + End If + Dim previousConnectionState As Global.System.Data.ConnectionState = Me.Adapter.InsertCommand.Connection.State + If ((Me.Adapter.InsertCommand.Connection.State And Global.System.Data.ConnectionState.Open) _ + <> Global.System.Data.ConnectionState.Open) Then + Me.Adapter.InsertCommand.Connection.Open + End If + Try + Dim returnValue As Integer = Me.Adapter.InsertCommand.ExecuteNonQuery + Return returnValue + Finally + If (previousConnectionState = Global.System.Data.ConnectionState.Closed) Then + Me.Adapter.InsertCommand.Connection.Close + End If + End Try + End Function + + _ + Public Overloads Overridable Function Update(ByVal CarID As Integer, ByVal Make As String, ByVal Color As String, ByVal PetName As String, ByVal Original_CarID As Integer, ByVal Original_Make As String, ByVal Original_Color As String, ByVal Original_PetName As String) As Integer + Me.Adapter.UpdateCommand.Parameters(0).Value = CType(CarID,Integer) + If (Make Is Nothing) Then + Throw New Global.System.ArgumentNullException("Make") + Else + Me.Adapter.UpdateCommand.Parameters(1).Value = CType(Make,String) + End If + If (Color Is Nothing) Then + Throw New Global.System.ArgumentNullException("Color") + Else + Me.Adapter.UpdateCommand.Parameters(2).Value = CType(Color,String) + End If + If (PetName Is Nothing) Then + Me.Adapter.UpdateCommand.Parameters(3).Value = Global.System.DBNull.Value + Else + Me.Adapter.UpdateCommand.Parameters(3).Value = CType(PetName,String) + End If + Me.Adapter.UpdateCommand.Parameters(4).Value = CType(Original_CarID,Integer) + If (Original_Make Is Nothing) Then + Throw New Global.System.ArgumentNullException("Original_Make") + Else + Me.Adapter.UpdateCommand.Parameters(5).Value = CType(Original_Make,String) + End If + If (Original_Color Is Nothing) Then + Throw New Global.System.ArgumentNullException("Original_Color") + Else + Me.Adapter.UpdateCommand.Parameters(6).Value = CType(Original_Color,String) + End If + If (Original_PetName Is Nothing) Then + Me.Adapter.UpdateCommand.Parameters(7).Value = CType(1,Object) + Me.Adapter.UpdateCommand.Parameters(8).Value = Global.System.DBNull.Value + Else + Me.Adapter.UpdateCommand.Parameters(7).Value = CType(0,Object) + Me.Adapter.UpdateCommand.Parameters(8).Value = CType(Original_PetName,String) + End If + Dim previousConnectionState As Global.System.Data.ConnectionState = Me.Adapter.UpdateCommand.Connection.State + If ((Me.Adapter.UpdateCommand.Connection.State And Global.System.Data.ConnectionState.Open) _ + <> Global.System.Data.ConnectionState.Open) Then + Me.Adapter.UpdateCommand.Connection.Open + End If + Try + Dim returnValue As Integer = Me.Adapter.UpdateCommand.ExecuteNonQuery + Return returnValue + Finally + If (previousConnectionState = Global.System.Data.ConnectionState.Closed) Then + Me.Adapter.UpdateCommand.Connection.Close + End If + End Try + End Function + + _ + Public Overloads Overridable Function Update(ByVal Make As String, ByVal Color As String, ByVal PetName As String, ByVal Original_CarID As Integer, ByVal Original_Make As String, ByVal Original_Color As String, ByVal Original_PetName As String) As Integer + Return Me.Update(Original_CarID, Make, Color, PetName, Original_CarID, Original_Make, Original_Color, Original_PetName) + End Function + End Class + + ''' + '''TableAdapterManager is used to coordinate TableAdapters in the dataset to enable Hierarchical Update scenarios + ''' + _ + Partial Public Class TableAdapterManager + Inherits Global.System.ComponentModel.Component + + Private _updateOrder As UpdateOrderOption + + Private _inventoryTableAdapter As InventoryTableAdapter + + Private _backupDataSetBeforeUpdate As Boolean + + Private _connection As Global.System.Data.IDbConnection + + _ + Public Property UpdateOrder() As UpdateOrderOption + Get + Return Me._updateOrder + End Get + Set + Me._updateOrder = value + End Set + End Property + + _ + Public Property InventoryTableAdapter() As InventoryTableAdapter + Get + Return Me._inventoryTableAdapter + End Get + Set + If ((Not (Me._inventoryTableAdapter) Is Nothing) _ + AndAlso (Me.TableAdapterInstanceCount = 1)) Then + Me._inventoryTableAdapter = value + Return + End If + If ((Not (value) Is Nothing) _ + AndAlso (Me.MatchTableAdapterConnection(value.Connection) = false)) Then + Throw New Global.System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s"& _ + "tring.") + End If + Me._inventoryTableAdapter = value + End Set + End Property + + _ + Public Property BackupDataSetBeforeUpdate() As Boolean + Get + Return Me._backupDataSetBeforeUpdate + End Get + Set + Me._backupDataSetBeforeUpdate = value + End Set + End Property + + _ + Public Property Connection() As Global.System.Data.IDbConnection + Get + If (Not (Me._connection) Is Nothing) Then + Return Me._connection + End If + If ((Not (Me._inventoryTableAdapter) Is Nothing) _ + AndAlso (Not (Me._inventoryTableAdapter.Connection) Is Nothing)) Then + Return Me._inventoryTableAdapter.Connection + End If + Return Nothing + End Get + Set + Me._connection = value + End Set + End Property + + _ + Public ReadOnly Property TableAdapterInstanceCount() As Integer + Get + Dim count As Integer = 0 + If (Not (Me._inventoryTableAdapter) Is Nothing) Then + count = (count + 1) + End If + Return count + End Get + End Property + + ''' + '''Update rows in top-down order. + ''' + _ + Private Function UpdateUpdatedRows(ByVal dataSet As InventoryDataSet, ByVal allChangedRows As Global.System.Collections.Generic.List(Of Global.System.Data.DataRow), ByVal allAddedRows As Global.System.Collections.Generic.List(Of Global.System.Data.DataRow)) As Integer + Dim result As Integer = 0 + If (Not (Me._inventoryTableAdapter) Is Nothing) Then + Dim updatedRows() As Global.System.Data.DataRow = dataSet.Inventory.Select(Nothing, Nothing, Global.System.Data.DataViewRowState.ModifiedCurrent) + updatedRows = Me.GetRealUpdatedRows(updatedRows, allAddedRows) + If ((Not (updatedRows) Is Nothing) _ + AndAlso (0 < updatedRows.Length)) Then + result = (result + Me._inventoryTableAdapter.Update(updatedRows)) + allChangedRows.AddRange(updatedRows) + End If + End If + Return result + End Function + + ''' + '''Insert rows in top-down order. + ''' + _ + Private Function UpdateInsertedRows(ByVal dataSet As InventoryDataSet, ByVal allAddedRows As Global.System.Collections.Generic.List(Of Global.System.Data.DataRow)) As Integer + Dim result As Integer = 0 + If (Not (Me._inventoryTableAdapter) Is Nothing) Then + Dim addedRows() As Global.System.Data.DataRow = dataSet.Inventory.Select(Nothing, Nothing, Global.System.Data.DataViewRowState.Added) + If ((Not (addedRows) Is Nothing) _ + AndAlso (0 < addedRows.Length)) Then + result = (result + Me._inventoryTableAdapter.Update(addedRows)) + allAddedRows.AddRange(addedRows) + End If + End If + Return result + End Function + + ''' + '''Delete rows in bottom-up order. + ''' + _ + Private Function UpdateDeletedRows(ByVal dataSet As InventoryDataSet, ByVal allChangedRows As Global.System.Collections.Generic.List(Of Global.System.Data.DataRow)) As Integer + Dim result As Integer = 0 + If (Not (Me._inventoryTableAdapter) Is Nothing) Then + Dim deletedRows() As Global.System.Data.DataRow = dataSet.Inventory.Select(Nothing, Nothing, Global.System.Data.DataViewRowState.Deleted) + If ((Not (deletedRows) Is Nothing) _ + AndAlso (0 < deletedRows.Length)) Then + result = (result + Me._inventoryTableAdapter.Update(deletedRows)) + allChangedRows.AddRange(deletedRows) + End If + End If + Return result + End Function + + ''' + '''Remove inserted rows that become updated rows after calling TableAdapter.Update(inserted rows) first + ''' + _ + Private Function GetRealUpdatedRows(ByVal updatedRows() As Global.System.Data.DataRow, ByVal allAddedRows As Global.System.Collections.Generic.List(Of Global.System.Data.DataRow)) As Global.System.Data.DataRow() + If ((updatedRows Is Nothing) _ + OrElse (updatedRows.Length < 1)) Then + Return updatedRows + End If + If ((allAddedRows Is Nothing) _ + OrElse (allAddedRows.Count < 1)) Then + Return updatedRows + End If + Dim realUpdatedRows As Global.System.Collections.Generic.List(Of Global.System.Data.DataRow) = New Global.System.Collections.Generic.List(Of Global.System.Data.DataRow) + Dim i As Integer = 0 + Do While (i < updatedRows.Length) + Dim row As Global.System.Data.DataRow = updatedRows(i) + If (allAddedRows.Contains(row) = false) Then + realUpdatedRows.Add(row) + End If + i = (i + 1) + Loop + Return realUpdatedRows.ToArray + End Function + + ''' + '''Update all changes to the dataset. + ''' + _ + Public Overridable Function UpdateAll(ByVal dataSet As InventoryDataSet) As Integer + If (dataSet Is Nothing) Then + Throw New Global.System.ArgumentNullException("dataSet") + End If + If (dataSet.HasChanges = false) Then + Return 0 + End If + Dim workConnection As Global.System.Data.IDbConnection = Me.Connection + If (workConnection Is Nothing) Then + Throw New Global.System.ApplicationException("TableAdapterManager contains no connection information. Set each TableAdapterMana"& _ + "ger TableAdapter property to a valid TableAdapter instance.") + End If + Dim workConnOpened As Boolean = false + If ((workConnection.State And Global.System.Data.ConnectionState.Closed) _ + = Global.System.Data.ConnectionState.Closed) Then + workConnection.Open + workConnOpened = true + End If + Dim workTransaction As Global.System.Data.IDbTransaction = workConnection.BeginTransaction + If (workTransaction Is Nothing) Then + Throw New Global.System.ApplicationException("The transaction cannot begin. The current data connection does not support transa"& _ + "ctions or the current state is not allowing the transaction to begin.") + End If + Dim allChangedRows As Global.System.Collections.Generic.List(Of Global.System.Data.DataRow) = New Global.System.Collections.Generic.List(Of Global.System.Data.DataRow) + Dim allAddedRows As Global.System.Collections.Generic.List(Of Global.System.Data.DataRow) = New Global.System.Collections.Generic.List(Of Global.System.Data.DataRow) + Dim adaptersWithAcceptChangesDuringUpdate As Global.System.Collections.Generic.List(Of Global.System.Data.Common.DataAdapter) = New Global.System.Collections.Generic.List(Of Global.System.Data.Common.DataAdapter) + Dim revertConnections As Global.System.Collections.Generic.Dictionary(Of Object, Global.System.Data.IDbConnection) = New Global.System.Collections.Generic.Dictionary(Of Object, Global.System.Data.IDbConnection) + Dim result As Integer = 0 + Dim backupDataSet As Global.System.Data.DataSet = Nothing + If Me.BackupDataSetBeforeUpdate Then + backupDataSet = New Global.System.Data.DataSet + backupDataSet.Merge(dataSet) + End If + Try + '---- Prepare for update ----------- + ' + If (Not (Me._inventoryTableAdapter) Is Nothing) Then + revertConnections.Add(Me._inventoryTableAdapter, Me._inventoryTableAdapter.Connection) + Me._inventoryTableAdapter.Connection = CType(workConnection,Global.System.Data.SqlClient.SqlConnection) + Me._inventoryTableAdapter.Transaction = CType(workTransaction,Global.System.Data.SqlClient.SqlTransaction) + If Me._inventoryTableAdapter.Adapter.AcceptChangesDuringUpdate Then + Me._inventoryTableAdapter.Adapter.AcceptChangesDuringUpdate = false + adaptersWithAcceptChangesDuringUpdate.Add(Me._inventoryTableAdapter.Adapter) + End If + End If + ' + '---- Perform updates ----------- + ' + If (Me.UpdateOrder = UpdateOrderOption.UpdateInsertDelete) Then + result = (result + Me.UpdateUpdatedRows(dataSet, allChangedRows, allAddedRows)) + result = (result + Me.UpdateInsertedRows(dataSet, allAddedRows)) + Else + result = (result + Me.UpdateInsertedRows(dataSet, allAddedRows)) + result = (result + Me.UpdateUpdatedRows(dataSet, allChangedRows, allAddedRows)) + End If + result = (result + Me.UpdateDeletedRows(dataSet, allChangedRows)) + ' + '---- Commit updates ----------- + ' + workTransaction.Commit + If (0 < allAddedRows.Count) Then + Dim rows((allAddedRows.Count) - 1) As Global.System.Data.DataRow + allAddedRows.CopyTo(rows) + Dim i As Integer = 0 + Do While (i < rows.Length) + Dim row As Global.System.Data.DataRow = rows(i) + row.AcceptChanges + i = (i + 1) + Loop + End If + If (0 < allChangedRows.Count) Then + Dim rows((allChangedRows.Count) - 1) As Global.System.Data.DataRow + allChangedRows.CopyTo(rows) + Dim i As Integer = 0 + Do While (i < rows.Length) + Dim row As Global.System.Data.DataRow = rows(i) + row.AcceptChanges + i = (i + 1) + Loop + End If + Catch ex As Global.System.Exception + workTransaction.Rollback + '---- Restore the dataset ----------- + If Me.BackupDataSetBeforeUpdate Then + Global.System.Diagnostics.Debug.Assert((Not (backupDataSet) Is Nothing)) + dataSet.Clear + dataSet.Merge(backupDataSet) + Else + If (0 < allAddedRows.Count) Then + Dim rows((allAddedRows.Count) - 1) As Global.System.Data.DataRow + allAddedRows.CopyTo(rows) + Dim i As Integer = 0 + Do While (i < rows.Length) + Dim row As Global.System.Data.DataRow = rows(i) + row.AcceptChanges + row.SetAdded + i = (i + 1) + Loop + End If + End If + Throw ex + Finally + If workConnOpened Then + workConnection.Close + End If + If (Not (Me._inventoryTableAdapter) Is Nothing) Then + Me._inventoryTableAdapter.Connection = CType(revertConnections(Me._inventoryTableAdapter),Global.System.Data.SqlClient.SqlConnection) + Me._inventoryTableAdapter.Transaction = Nothing + End If + If (0 < adaptersWithAcceptChangesDuringUpdate.Count) Then + Dim adapters((adaptersWithAcceptChangesDuringUpdate.Count) - 1) As Global.System.Data.Common.DataAdapter + adaptersWithAcceptChangesDuringUpdate.CopyTo(adapters) + Dim i As Integer = 0 + Do While (i < adapters.Length) + Dim adapter As Global.System.Data.Common.DataAdapter = adapters(i) + adapter.AcceptChangesDuringUpdate = true + i = (i + 1) + Loop + End If + End Try + Return result + End Function + + _ + Protected Overridable Sub SortSelfReferenceRows(ByVal rows() As Global.System.Data.DataRow, ByVal relation As Global.System.Data.DataRelation, ByVal childFirst As Boolean) + Global.System.Array.Sort(Of Global.System.Data.DataRow)(rows, New SelfReferenceComparer(relation, childFirst)) + End Sub + + _ + Protected Overridable Function MatchTableAdapterConnection(ByVal inputConnection As Global.System.Data.IDbConnection) As Boolean + If (Not (Me._connection) Is Nothing) Then + Return true + End If + If ((Me.Connection Is Nothing) _ + OrElse (inputConnection Is Nothing)) Then + Return true + End If + If String.Equals(Me.Connection.ConnectionString, inputConnection.ConnectionString, Global.System.StringComparison.Ordinal) Then + Return true + End If + Return false + End Function + + ''' + '''Update Order Option + ''' + _ + Public Enum UpdateOrderOption + + InsertUpdateDelete = 0 + + UpdateInsertDelete = 1 + End Enum + + ''' + '''Used to sort self-referenced table's rows + ''' + _ + Private Class SelfReferenceComparer + Inherits Object + Implements Global.System.Collections.Generic.IComparer(Of Global.System.Data.DataRow) + + Private _relation As Global.System.Data.DataRelation + + Private _childFirst As Integer + + _ + Friend Sub New(ByVal relation As Global.System.Data.DataRelation, ByVal childFirst As Boolean) + MyBase.New + Me._relation = relation + If childFirst Then + Me._childFirst = -1 + Else + Me._childFirst = 1 + End If + End Sub + + _ + Private Function IsChildAndParent(ByVal child As Global.System.Data.DataRow, ByVal parent As Global.System.Data.DataRow) As Boolean + Global.System.Diagnostics.Debug.Assert((Not (child) Is Nothing)) + Global.System.Diagnostics.Debug.Assert((Not (parent) Is Nothing)) + Dim newParent As Global.System.Data.DataRow = child.GetParentRow(Me._relation, Global.System.Data.DataRowVersion.[Default]) + + Do While ((Not (newParent) Is Nothing) _ + AndAlso ((Object.ReferenceEquals(newParent, child) = false) _ + AndAlso (Object.ReferenceEquals(newParent, parent) = false))) + newParent = newParent.GetParentRow(Me._relation, Global.System.Data.DataRowVersion.[Default]) + + Loop + If (newParent Is Nothing) Then + newParent = child.GetParentRow(Me._relation, Global.System.Data.DataRowVersion.Original) + Do While ((Not (newParent) Is Nothing) _ + AndAlso ((Object.ReferenceEquals(newParent, child) = false) _ + AndAlso (Object.ReferenceEquals(newParent, parent) = false))) + newParent = newParent.GetParentRow(Me._relation, Global.System.Data.DataRowVersion.Original) + + Loop + End If + If Object.ReferenceEquals(newParent, parent) Then + Return true + End If + Return false + End Function + + _ + Public Function Compare(ByVal row1 As Global.System.Data.DataRow, ByVal row2 As Global.System.Data.DataRow) As Integer Implements Global.System.Collections.Generic.IComparer(Of Global.System.Data.DataRow).Compare + If Object.ReferenceEquals(row1, row2) Then + Return 0 + End If + If (row1 Is Nothing) Then + Return -1 + End If + If (row2 Is Nothing) Then + Return 1 + End If + + 'Is row1 the child or grandchild of row2 + If Me.IsChildAndParent(row1, row2) Then + Return Me._childFirst + End If + + 'Is row2 the child or grandchild of row1 + If Me.IsChildAndParent(row2, row1) Then + Return (-1 * Me._childFirst) + End If + Return 0 + End Function + End Class + End Class +End Namespace diff --git a/Code/Chapter 23/VisualDataGridViewApp/InventoryDataSet.vb b/Code/Chapter 23/VisualDataGridViewApp/InventoryDataSet.vb new file mode 100644 index 0000000..5a8647e --- /dev/null +++ b/Code/Chapter 23/VisualDataGridViewApp/InventoryDataSet.vb @@ -0,0 +1,2 @@ +Partial Class InventoryDataSet +End Class diff --git a/Code/Chapter 23/VisualDataGridViewApp/InventoryDataSet.xsc b/Code/Chapter 23/VisualDataGridViewApp/InventoryDataSet.xsc new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Code/Chapter 23/VisualDataGridViewApp/InventoryDataSet.xsc @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Code/Chapter 23/VisualDataGridViewApp/InventoryDataSet.xsd b/Code/Chapter 23/VisualDataGridViewApp/InventoryDataSet.xsd new file mode 100644 index 0000000..7032eb4 --- /dev/null +++ b/Code/Chapter 23/VisualDataGridViewApp/InventoryDataSet.xsd @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + DELETE FROM [dbo].[Inventory] WHERE (([CarID] = @Original_CarID) AND ([Make] = @Original_Make) AND ([Color] = @Original_Color) AND ((@IsNull_PetName = 1 AND [PetName] IS NULL) OR ([PetName] = @Original_PetName))) + + + + + + + + + + + + INSERT INTO [dbo].[Inventory] ([CarID], [Make], [Color], [PetName]) VALUES (@CarID, @Make, @Color, @PetName); +SELECT CarID, Make, Color, PetName FROM Inventory WHERE (CarID = @CarID) + + + + + + + + + + + SELECT CarID, Make, Color, PetName FROM dbo.Inventory + + + + + + UPDATE [dbo].[Inventory] SET [CarID] = @CarID, [Make] = @Make, [Color] = @Color, [PetName] = @PetName WHERE (([CarID] = @Original_CarID) AND ([Make] = @Original_Make) AND ([Color] = @Original_Color) AND ((@IsNull_PetName = 1 AND [PetName] IS NULL) OR ([PetName] = @Original_PetName))); +SELECT CarID, Make, Color, PetName FROM Inventory WHERE (CarID = @CarID) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 23/VisualDataGridViewApp/InventoryDataSet.xss b/Code/Chapter 23/VisualDataGridViewApp/InventoryDataSet.xss new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Code/Chapter 23/VisualDataGridViewApp/InventoryDataSet.xss @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Code/Chapter 23/VisualDataGridViewApp/MainForm.Designer.vb b/Code/Chapter 23/VisualDataGridViewApp/MainForm.Designer.vb new file mode 100644 index 0000000..8de1db8 --- /dev/null +++ b/Code/Chapter 23/VisualDataGridViewApp/MainForm.Designer.vb @@ -0,0 +1,253 @@ + _ +Partial Class MainForm + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + 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.Label1 = New System.Windows.Forms.Label + Me.DataGridView1 = New System.Windows.Forms.DataGridView + Me.InventoryDataSet = New VisualDataGridViewApp.InventoryDataSet + Me.InventoryBindingSource = New System.Windows.Forms.BindingSource(Me.components) + Me.InventoryTableAdapter = New VisualDataGridViewApp.InventoryDataSetTableAdapters.InventoryTableAdapter + Me.CarIDDataGridViewTextBoxColumn = New System.Windows.Forms.DataGridViewTextBoxColumn + Me.MakeDataGridViewTextBoxColumn = New System.Windows.Forms.DataGridViewTextBoxColumn + Me.ColorDataGridViewTextBoxColumn = New System.Windows.Forms.DataGridViewTextBoxColumn + Me.PetNameDataGridViewTextBoxColumn = New System.Windows.Forms.DataGridViewTextBoxColumn + Me.btnUpdateInventory = New System.Windows.Forms.Button + Me.groupBox1 = New System.Windows.Forms.GroupBox + Me.btnAddRow = New System.Windows.Forms.Button + Me.txtMake = New System.Windows.Forms.TextBox + Me.txtPetName = New System.Windows.Forms.TextBox + Me.txtColor = New System.Windows.Forms.TextBox + Me.txtCarID = New System.Windows.Forms.TextBox + Me.label5 = New System.Windows.Forms.Label + Me.label4 = New System.Windows.Forms.Label + Me.label3 = New System.Windows.Forms.Label + Me.label2 = New System.Windows.Forms.Label + CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.InventoryDataSet, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.InventoryBindingSource, System.ComponentModel.ISupportInitialize).BeginInit() + Me.groupBox1.SuspendLayout() + Me.SuspendLayout() + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Label1.Location = New System.Drawing.Point(12, 9) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(218, 20) + Me.Label1.TabIndex = 0 + Me.Label1.Text = "The AutoLot Inventory Viewer" + ' + 'DataGridView1 + ' + Me.DataGridView1.AutoGenerateColumns = False + Me.DataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize + Me.DataGridView1.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.CarIDDataGridViewTextBoxColumn, Me.MakeDataGridViewTextBoxColumn, Me.ColorDataGridViewTextBoxColumn, Me.PetNameDataGridViewTextBoxColumn}) + Me.DataGridView1.DataSource = Me.InventoryBindingSource + Me.DataGridView1.Location = New System.Drawing.Point(16, 48) + Me.DataGridView1.Name = "DataGridView1" + Me.DataGridView1.Size = New System.Drawing.Size(476, 220) + Me.DataGridView1.TabIndex = 1 + ' + 'InventoryDataSet + ' + Me.InventoryDataSet.DataSetName = "InventoryDataSet" + Me.InventoryDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema + ' + 'InventoryBindingSource + ' + Me.InventoryBindingSource.DataMember = "Inventory" + Me.InventoryBindingSource.DataSource = Me.InventoryDataSet + ' + 'InventoryTableAdapter + ' + Me.InventoryTableAdapter.ClearBeforeFill = True + ' + 'CarIDDataGridViewTextBoxColumn + ' + Me.CarIDDataGridViewTextBoxColumn.DataPropertyName = "CarID" + Me.CarIDDataGridViewTextBoxColumn.HeaderText = "CarID" + Me.CarIDDataGridViewTextBoxColumn.Name = "CarIDDataGridViewTextBoxColumn" + ' + 'MakeDataGridViewTextBoxColumn + ' + Me.MakeDataGridViewTextBoxColumn.DataPropertyName = "Make" + Me.MakeDataGridViewTextBoxColumn.HeaderText = "Make" + Me.MakeDataGridViewTextBoxColumn.Name = "MakeDataGridViewTextBoxColumn" + ' + 'ColorDataGridViewTextBoxColumn + ' + Me.ColorDataGridViewTextBoxColumn.DataPropertyName = "Color" + Me.ColorDataGridViewTextBoxColumn.HeaderText = "Color" + Me.ColorDataGridViewTextBoxColumn.Name = "ColorDataGridViewTextBoxColumn" + ' + 'PetNameDataGridViewTextBoxColumn + ' + Me.PetNameDataGridViewTextBoxColumn.DataPropertyName = "PetName" + Me.PetNameDataGridViewTextBoxColumn.HeaderText = "PetName" + Me.PetNameDataGridViewTextBoxColumn.Name = "PetNameDataGridViewTextBoxColumn" + ' + 'btnUpdateInventory + ' + Me.btnUpdateInventory.Location = New System.Drawing.Point(417, 283) + Me.btnUpdateInventory.Name = "btnUpdateInventory" + Me.btnUpdateInventory.Size = New System.Drawing.Size(75, 23) + Me.btnUpdateInventory.TabIndex = 2 + Me.btnUpdateInventory.Text = "Update!" + Me.btnUpdateInventory.UseVisualStyleBackColor = True + ' + 'groupBox1 + ' + Me.groupBox1.Controls.Add(Me.btnAddRow) + Me.groupBox1.Controls.Add(Me.txtMake) + Me.groupBox1.Controls.Add(Me.txtPetName) + Me.groupBox1.Controls.Add(Me.txtColor) + Me.groupBox1.Controls.Add(Me.txtCarID) + Me.groupBox1.Controls.Add(Me.label5) + Me.groupBox1.Controls.Add(Me.label4) + Me.groupBox1.Controls.Add(Me.label3) + Me.groupBox1.Controls.Add(Me.label2) + Me.groupBox1.Location = New System.Drawing.Point(16, 283) + Me.groupBox1.Name = "groupBox1" + Me.groupBox1.Size = New System.Drawing.Size(321, 161) + Me.groupBox1.TabIndex = 4 + Me.groupBox1.TabStop = False + Me.groupBox1.Text = "Manually Adding New Row" + ' + 'btnAddRow + ' + Me.btnAddRow.Location = New System.Drawing.Point(222, 122) + Me.btnAddRow.Name = "btnAddRow" + Me.btnAddRow.Size = New System.Drawing.Size(88, 23) + Me.btnAddRow.TabIndex = 4 + Me.btnAddRow.Text = "Add Row" + Me.btnAddRow.UseVisualStyleBackColor = True + ' + 'txtMake + ' + Me.txtMake.Location = New System.Drawing.Point(82, 58) + Me.txtMake.Name = "txtMake" + Me.txtMake.Size = New System.Drawing.Size(118, 20) + Me.txtMake.TabIndex = 1 + ' + 'txtPetName + ' + Me.txtPetName.Location = New System.Drawing.Point(82, 124) + Me.txtPetName.Name = "txtPetName" + Me.txtPetName.Size = New System.Drawing.Size(118, 20) + Me.txtPetName.TabIndex = 3 + ' + 'txtColor + ' + Me.txtColor.Location = New System.Drawing.Point(82, 91) + Me.txtColor.Name = "txtColor" + Me.txtColor.Size = New System.Drawing.Size(118, 20) + Me.txtColor.TabIndex = 2 + ' + 'txtCarID + ' + Me.txtCarID.Location = New System.Drawing.Point(82, 25) + Me.txtCarID.Name = "txtCarID" + Me.txtCarID.Size = New System.Drawing.Size(118, 20) + Me.txtCarID.TabIndex = 0 + ' + 'label5 + ' + Me.label5.AutoSize = True + Me.label5.Location = New System.Drawing.Point(12, 94) + Me.label5.Name = "label5" + Me.label5.Size = New System.Drawing.Size(31, 13) + Me.label5.TabIndex = 3 + Me.label5.Text = "Color" + ' + 'label4 + ' + Me.label4.AutoSize = True + Me.label4.Location = New System.Drawing.Point(12, 127) + Me.label4.Name = "label4" + Me.label4.Size = New System.Drawing.Size(51, 13) + Me.label4.TabIndex = 2 + Me.label4.Text = "PetName" + ' + 'label3 + ' + Me.label3.AutoSize = True + Me.label3.Location = New System.Drawing.Point(12, 61) + Me.label3.Name = "label3" + Me.label3.Size = New System.Drawing.Size(34, 13) + Me.label3.TabIndex = 1 + Me.label3.Text = "Make" + ' + 'label2 + ' + Me.label2.AutoSize = True + Me.label2.Location = New System.Drawing.Point(12, 28) + Me.label2.Name = "label2" + Me.label2.Size = New System.Drawing.Size(37, 13) + Me.label2.TabIndex = 0 + Me.label2.Text = "Car ID" + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(504, 464) + Me.Controls.Add(Me.groupBox1) + Me.Controls.Add(Me.btnUpdateInventory) + Me.Controls.Add(Me.DataGridView1) + Me.Controls.Add(Me.Label1) + Me.Name = "MainForm" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Inventory Viewer Redux" + CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.InventoryDataSet, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.InventoryBindingSource, System.ComponentModel.ISupportInitialize).EndInit() + Me.groupBox1.ResumeLayout(False) + Me.groupBox1.PerformLayout() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents DataGridView1 As System.Windows.Forms.DataGridView + Friend WithEvents InventoryDataSet As VisualDataGridViewApp.InventoryDataSet + Friend WithEvents InventoryBindingSource As System.Windows.Forms.BindingSource + Friend WithEvents InventoryTableAdapter As VisualDataGridViewApp.InventoryDataSetTableAdapters.InventoryTableAdapter + Friend WithEvents CarIDDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn + Friend WithEvents MakeDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn + Friend WithEvents ColorDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn + Friend WithEvents PetNameDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn + Friend WithEvents btnUpdateInventory As System.Windows.Forms.Button + Private WithEvents groupBox1 As System.Windows.Forms.GroupBox + Private WithEvents btnAddRow As System.Windows.Forms.Button + Private WithEvents txtMake As System.Windows.Forms.TextBox + Private WithEvents txtPetName As System.Windows.Forms.TextBox + Private WithEvents txtColor As System.Windows.Forms.TextBox + Private WithEvents txtCarID As System.Windows.Forms.TextBox + Private WithEvents label5 As System.Windows.Forms.Label + Private WithEvents label4 As System.Windows.Forms.Label + Private WithEvents label3 As System.Windows.Forms.Label + Private WithEvents label2 As System.Windows.Forms.Label + +End Class diff --git a/Code/Chapter 23/VisualDataGridViewApp/MainForm.resx b/Code/Chapter 23/VisualDataGridViewApp/MainForm.resx new file mode 100644 index 0000000..3f39894 --- /dev/null +++ b/Code/Chapter 23/VisualDataGridViewApp/MainForm.resx @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 163, 17 + + + 17, 17 + + + 163, 17 + + + 17, 17 + + + 345, 17 + + \ No newline at end of file diff --git a/Code/Chapter 23/VisualDataGridViewApp/MainForm.vb b/Code/Chapter 23/VisualDataGridViewApp/MainForm.vb new file mode 100644 index 0000000..ea5cbb5 --- /dev/null +++ b/Code/Chapter 23/VisualDataGridViewApp/MainForm.vb @@ -0,0 +1,49 @@ +Public Class MainForm + Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load + 'TODO: This line of code loads data into the 'InventoryDataSet.Inventory' table. You can move, or remove it, as needed. + Me.InventoryTableAdapter.Fill(Me.InventoryDataSet.Inventory) + End Sub + + Private Sub btnUpdateInventory_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles btnUpdateInventory.Click + ' This will push any changes within the Inventory table back to + ' the database for processing. + Me.InventoryTableAdapter.Update(Me.InventoryDataSet.Inventory) + + ' Get fresh copy for grid. + Me.InventoryTableAdapter.Fill(Me.InventoryDataSet.Inventory) + End Sub + +#Region "Add new row" + Private Sub btnAddRow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddRow.Click + ' Get data from widgets + Dim id As Integer = Integer.Parse(txtCarID.Text) + Dim make As String = txtMake.Text + Dim color As String = txtColor.Text + Dim petName As String = txtPetName.Text + + ' Use custom adapter to add row. + InventoryTableAdapter.Insert(id, make, color, petName) + + ' Refill table data. + Me.InventoryTableAdapter.Fill(Me.InventoryDataSet.Inventory) + End Sub + + 'Private Sub btnAddRow_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnAddRow.Click + ' ' Get new Row. + ' Dim newRow As InventoryDataSet.InventoryRow = InventoryDataSet.Inventory.NewInventoryRow() + ' newRow.CarID = Integer.Parse(txtCarID.Text) + ' newRow.Make = txtMake.Text + ' newRow.Color = txtColor.Text + ' newRow.PetName = txtPetName.Text + ' InventoryDataSet.Inventory.AddInventoryRow(newRow) + + ' ' Use custom adapter to add row. + ' InventoryTableAdapter.Update(InventoryDataSet.Inventory) + + ' ' Refill table data. + ' Me.InventoryTableAdapter.Fill(Me.InventoryDataSet.Inventory) + 'End Sub +#End Region + +End Class diff --git a/Code/Chapter 23/VisualDataGridViewApp/My Project/Application.Designer.vb b/Code/Chapter 23/VisualDataGridViewApp/My Project/Application.Designer.vb new file mode 100644 index 0000000..9c9e3c1 --- /dev/null +++ b/Code/Chapter 23/VisualDataGridViewApp/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.VisualDataGridViewApp.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 23/VisualDataGridViewApp/My Project/Application.myapp b/Code/Chapter 23/VisualDataGridViewApp/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 23/VisualDataGridViewApp/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 23/VisualDataGridViewApp/My Project/AssemblyInfo.vb b/Code/Chapter 23/VisualDataGridViewApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..a858452 --- /dev/null +++ b/Code/Chapter 23/VisualDataGridViewApp/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/Code/Chapter 23/VisualDataGridViewApp/My Project/Resources.Designer.vb b/Code/Chapter 23/VisualDataGridViewApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..7b93c66 --- /dev/null +++ b/Code/Chapter 23/VisualDataGridViewApp/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("VisualDataGridViewApp.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/Code/Chapter 23/VisualDataGridViewApp/My Project/Resources.resx b/Code/Chapter 23/VisualDataGridViewApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 23/VisualDataGridViewApp/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/Code/Chapter 23/VisualDataGridViewApp/My Project/Settings.Designer.vb b/Code/Chapter 23/VisualDataGridViewApp/My Project/Settings.Designer.vb new file mode 100644 index 0000000..459976d --- /dev/null +++ b/Code/Chapter 23/VisualDataGridViewApp/My Project/Settings.Designer.vb @@ -0,0 +1,84 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings),MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + + _ + Public ReadOnly Property AutoLotConnectionString() As String + Get + Return CType(Me("AutoLotConnectionString"),String) + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.VisualDataGridViewApp.My.MySettings + Get + Return Global.VisualDataGridViewApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 23/VisualDataGridViewApp/My Project/Settings.settings b/Code/Chapter 23/VisualDataGridViewApp/My Project/Settings.settings new file mode 100644 index 0000000..03c3afc --- /dev/null +++ b/Code/Chapter 23/VisualDataGridViewApp/My Project/Settings.settings @@ -0,0 +1,14 @@ + + + + + + <?xml version="1.0" encoding="utf-16"?> +<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <ConnectionString>Data Source=INTERUBER\SQLEXPRESS;Initial Catalog=AutoLot;Integrated Security=True</ConnectionString> + <ProviderName>System.Data.SqlClient</ProviderName> +</SerializableConnectionString> + Data Source=INTERUBER\SQLEXPRESS;Initial Catalog=AutoLot;Integrated Security=True + + + \ No newline at end of file diff --git a/Code/Chapter 23/VisualDataGridViewApp/VisualDataGridViewApp.sln b/Code/Chapter 23/VisualDataGridViewApp/VisualDataGridViewApp.sln new file mode 100644 index 0000000..c5b3417 --- /dev/null +++ b/Code/Chapter 23/VisualDataGridViewApp/VisualDataGridViewApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VisualDataGridViewApp", "VisualDataGridViewApp.vbproj", "{F109F023-1057-4C0B-91C5-342EB870E983}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F109F023-1057-4C0B-91C5-342EB870E983}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F109F023-1057-4C0B-91C5-342EB870E983}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F109F023-1057-4C0B-91C5-342EB870E983}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F109F023-1057-4C0B-91C5-342EB870E983}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 23/VisualDataGridViewApp/VisualDataGridViewApp.suo b/Code/Chapter 23/VisualDataGridViewApp/VisualDataGridViewApp.suo new file mode 100644 index 0000000..9c8eb50 Binary files /dev/null and b/Code/Chapter 23/VisualDataGridViewApp/VisualDataGridViewApp.suo differ diff --git a/Code/Chapter 23/VisualDataGridViewApp/VisualDataGridViewApp.vbproj b/Code/Chapter 23/VisualDataGridViewApp/VisualDataGridViewApp.vbproj new file mode 100644 index 0000000..90025a1 --- /dev/null +++ b/Code/Chapter 23/VisualDataGridViewApp/VisualDataGridViewApp.vbproj @@ -0,0 +1,144 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {F109F023-1057-4C0B-91C5-342EB870E983} + WinExe + VisualDataGridViewApp.My.MyApplication + VisualDataGridViewApp + VisualDataGridViewApp + 512 + WindowsForms + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + VisualDataGridViewApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + VisualDataGridViewApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + True + True + InventoryDataSet.xsd + + + InventoryDataSet.xsd + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + MainForm.vb + Designer + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + + + InventoryDataSet.xsd + + + MSDataSetGenerator + InventoryDataSet.Designer.vb + Designer + + + InventoryDataSet.xsd + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + \ No newline at end of file diff --git a/Code/Chapter 23/VisualDataGridViewApp/VisualDataGridViewApp.vbproj.user b/Code/Chapter 23/VisualDataGridViewApp/VisualDataGridViewApp.vbproj.user new file mode 100644 index 0000000..6a34e7d --- /dev/null +++ b/Code/Chapter 23/VisualDataGridViewApp/VisualDataGridViewApp.vbproj.user @@ -0,0 +1,5 @@ + + + ShowAllFiles + + \ No newline at end of file diff --git a/Code/Chapter 23/VisualDataGridViewApp/Wizard Generated DB Objects.cd b/Code/Chapter 23/VisualDataGridViewApp/Wizard Generated DB Objects.cd new file mode 100644 index 0000000..52108b0 --- /dev/null +++ b/Code/Chapter 23/VisualDataGridViewApp/Wizard Generated DB Objects.cd @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + AAAAAAAAAwAAAAJABAACQAAAAAgCQBgAAAAAAgEAFBA= + InventoryDataSet.vb + + + + + + BCAAAEAgECoAABAQAACCEAAGAAgAIIGIACAAAAAAAAA= + MainForm.vb + + + + + + EASAAGAAEAAAAAcAIAAAAAAAACEICAAAAAAAAAAABBA= + + + + + + AQAAACAAAABABAEBAAAAMAAgAAACgACAAAQABAAABAQ= + + + + + + AAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAA= + + + + + + AAAAAAAAAAAAAAQAABAAIAAABAABAAAgAAAAAAAAAAA= + + + + + + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAA= + + + + + + AAAAAAAAAAAAAAAAAAABEAAAAQAAAAAAAAAAAAAAAIA= + + + + \ No newline at end of file diff --git a/Code/Chapter 23/VisualDataGridViewApp/app.config b/Code/Chapter 23/VisualDataGridViewApp/app.config new file mode 100644 index 0000000..f72ae3b --- /dev/null +++ b/Code/Chapter 23/VisualDataGridViewApp/app.config @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 23/WindowsFormsDataTableViewer/Car.vb b/Code/Chapter 23/WindowsFormsDataTableViewer/Car.vb new file mode 100644 index 0000000..399a7b8 --- /dev/null +++ b/Code/Chapter 23/WindowsFormsDataTableViewer/Car.vb @@ -0,0 +1,12 @@ +Class Car + ' Public for simplicity. + Public carPetName As String + Public carMake As String + Public carColor As String + + Public Sub New(ByVal petName As String, ByVal make As String, ByVal color As String) + carPetName = petName + carColor = color + carMake = make + End Sub +End Class \ No newline at end of file diff --git a/Code/Chapter 23/WindowsFormsDataTableViewer/MainForm.Designer.vb b/Code/Chapter 23/WindowsFormsDataTableViewer/MainForm.Designer.vb new file mode 100644 index 0000000..4f75b13 --- /dev/null +++ b/Code/Chapter 23/WindowsFormsDataTableViewer/MainForm.Designer.vb @@ -0,0 +1,176 @@ + _ +Partial Class MainForm + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + 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.label2 = New System.Windows.Forms.Label + Me.btnDisplayMakes = New System.Windows.Forms.Button + Me.dataGridColtsView = New System.Windows.Forms.DataGridView + Me.txtMakeToView = New System.Windows.Forms.TextBox + Me.groupBox2 = New System.Windows.Forms.GroupBox + Me.groupBox1 = New System.Windows.Forms.GroupBox + Me.txtRowToRemove = New System.Windows.Forms.TextBox + Me.btnRemoveRow = New System.Windows.Forms.Button + Me.label1 = New System.Windows.Forms.Label + Me.carInventoryGridView = New System.Windows.Forms.DataGridView + Me.btnChangeBeemersToYugos = New System.Windows.Forms.Button + CType(Me.dataGridColtsView, System.ComponentModel.ISupportInitialize).BeginInit() + Me.groupBox2.SuspendLayout() + Me.groupBox1.SuspendLayout() + CType(Me.carInventoryGridView, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'label2 + ' + Me.label2.AutoSize = True + Me.label2.Location = New System.Drawing.Point(26, 299) + Me.label2.Name = "label2" + Me.label2.Size = New System.Drawing.Size(95, 13) + Me.label2.TabIndex = 13 + Me.label2.Text = "Here are the Colts:" + ' + 'btnDisplayMakes + ' + Me.btnDisplayMakes.Location = New System.Drawing.Point(6, 48) + Me.btnDisplayMakes.Name = "btnDisplayMakes" + Me.btnDisplayMakes.Size = New System.Drawing.Size(135, 23) + Me.btnDisplayMakes.TabIndex = 0 + Me.btnDisplayMakes.Text = "Display Makes" + Me.btnDisplayMakes.UseVisualStyleBackColor = True + ' + 'dataGridColtsView + ' + Me.dataGridColtsView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize + Me.dataGridColtsView.Location = New System.Drawing.Point(26, 325) + Me.dataGridColtsView.Name = "dataGridColtsView" + Me.dataGridColtsView.Size = New System.Drawing.Size(402, 95) + Me.dataGridColtsView.TabIndex = 12 + ' + 'txtMakeToView + ' + Me.txtMakeToView.Location = New System.Drawing.Point(6, 22) + Me.txtMakeToView.Name = "txtMakeToView" + Me.txtMakeToView.Size = New System.Drawing.Size(135, 20) + Me.txtMakeToView.TabIndex = 1 + ' + 'groupBox2 + ' + Me.groupBox2.Controls.Add(Me.txtMakeToView) + Me.groupBox2.Controls.Add(Me.btnDisplayMakes) + Me.groupBox2.Location = New System.Drawing.Point(251, 206) + Me.groupBox2.Name = "groupBox2" + Me.groupBox2.Size = New System.Drawing.Size(177, 85) + Me.groupBox2.TabIndex = 10 + Me.groupBox2.TabStop = False + Me.groupBox2.Text = "Enter make To view" + ' + 'groupBox1 + ' + Me.groupBox1.Controls.Add(Me.txtRowToRemove) + Me.groupBox1.Controls.Add(Me.btnRemoveRow) + Me.groupBox1.Location = New System.Drawing.Point(26, 206) + Me.groupBox1.Name = "groupBox1" + Me.groupBox1.Size = New System.Drawing.Size(177, 85) + Me.groupBox1.TabIndex = 9 + Me.groupBox1.TabStop = False + Me.groupBox1.Text = "Enter row number to delete" + ' + 'txtRowToRemove + ' + Me.txtRowToRemove.Location = New System.Drawing.Point(6, 22) + Me.txtRowToRemove.Name = "txtRowToRemove" + Me.txtRowToRemove.Size = New System.Drawing.Size(135, 20) + Me.txtRowToRemove.TabIndex = 1 + ' + 'btnRemoveRow + ' + Me.btnRemoveRow.Location = New System.Drawing.Point(6, 48) + Me.btnRemoveRow.Name = "btnRemoveRow" + Me.btnRemoveRow.Size = New System.Drawing.Size(135, 23) + Me.btnRemoveRow.TabIndex = 0 + Me.btnRemoveRow.Text = "Remove" + Me.btnRemoveRow.UseVisualStyleBackColor = True + ' + 'label1 + ' + Me.label1.AutoSize = True + Me.label1.Location = New System.Drawing.Point(26, 14) + Me.label1.Name = "label1" + Me.label1.Size = New System.Drawing.Size(141, 13) + Me.label1.TabIndex = 8 + Me.label1.Text = "The Current List of Inventory" + ' + 'carInventoryGridView + ' + Me.carInventoryGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize + Me.carInventoryGridView.Location = New System.Drawing.Point(26, 50) + Me.carInventoryGridView.Name = "carInventoryGridView" + Me.carInventoryGridView.Size = New System.Drawing.Size(402, 135) + Me.carInventoryGridView.TabIndex = 7 + ' + 'btnChangeBeemersToYugos + ' + Me.btnChangeBeemersToYugos.Location = New System.Drawing.Point(251, 14) + Me.btnChangeBeemersToYugos.Name = "btnChangeBeemersToYugos" + Me.btnChangeBeemersToYugos.Size = New System.Drawing.Size(177, 23) + Me.btnChangeBeemersToYugos.TabIndex = 14 + Me.btnChangeBeemersToYugos.Text = "Change all BMWs to Yugos" + Me.btnChangeBeemersToYugos.UseVisualStyleBackColor = True + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(458, 443) + Me.Controls.Add(Me.btnChangeBeemersToYugos) + Me.Controls.Add(Me.label2) + Me.Controls.Add(Me.dataGridColtsView) + Me.Controls.Add(Me.groupBox2) + Me.Controls.Add(Me.groupBox1) + Me.Controls.Add(Me.label1) + Me.Controls.Add(Me.carInventoryGridView) + Me.Name = "MainForm" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "DataTable Viewer" + CType(Me.dataGridColtsView, System.ComponentModel.ISupportInitialize).EndInit() + Me.groupBox2.ResumeLayout(False) + Me.groupBox2.PerformLayout() + Me.groupBox1.ResumeLayout(False) + Me.groupBox1.PerformLayout() + CType(Me.carInventoryGridView, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Private WithEvents label2 As System.Windows.Forms.Label + Private WithEvents btnDisplayMakes As System.Windows.Forms.Button + Private WithEvents dataGridColtsView As System.Windows.Forms.DataGridView + Private WithEvents txtMakeToView As System.Windows.Forms.TextBox + Private WithEvents groupBox2 As System.Windows.Forms.GroupBox + Private WithEvents groupBox1 As System.Windows.Forms.GroupBox + Private WithEvents txtRowToRemove As System.Windows.Forms.TextBox + Private WithEvents btnRemoveRow As System.Windows.Forms.Button + Private WithEvents label1 As System.Windows.Forms.Label + Private WithEvents carInventoryGridView As System.Windows.Forms.DataGridView + Friend WithEvents btnChangeBeemersToYugos As System.Windows.Forms.Button + +End Class diff --git a/Code/Chapter 23/WindowsFormsDataTableViewer/MainForm.resx b/Code/Chapter 23/WindowsFormsDataTableViewer/MainForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 23/WindowsFormsDataTableViewer/MainForm.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/Code/Chapter 23/WindowsFormsDataTableViewer/MainForm.vb b/Code/Chapter 23/WindowsFormsDataTableViewer/MainForm.vb new file mode 100644 index 0000000..b9ddd1f --- /dev/null +++ b/Code/Chapter 23/WindowsFormsDataTableViewer/MainForm.vb @@ -0,0 +1,157 @@ +Option Strict On +Option Explicit On + +Public Class MainForm + ' A collection of Car objects. + Private listCars As New List(Of Car)() + + ' View of the DataTable. + Private coltsOnlyView As DataView + + ' Our DataTable. + Private inventoryTable As New DataTable("Inventory") + + Public Sub New() + InitializeComponent() + + ' Fill the list with some cars. + listCars.Add(New Car("Chucky", "BMW", "Green")) + listCars.Add(New Car("Tiny", "Yugo", "White")) + listCars.Add(New Car("Ami", "Jeep", "Tan")) + listCars.Add(New Car("Pain Inducer", "Caravan", "Pink")) + listCars.Add(New Car("Fred", "BMW", "Pea Soup Green")) + listCars.Add(New Car("Sidd", "BMW", "Black")) + listCars.Add(New Car("Mel", "Firebird", "Red")) + listCars.Add(New Car("Sarah", "Colt", "Black")) + + ' Make a data table. + CreateDataTable() + + ' Make a view. + CreateDataView() + End Sub + +#Region "Create the DataTable object and bind to grid." + Private Sub CreateDataTable() + ' Create table schema + Dim carMakeColumn As New DataColumn("Make", GetType(String)) + Dim carColorColumn As New DataColumn("Color", GetType(String)) + Dim carPetNameColumn As New DataColumn("PetName", GetType(String)) + carPetNameColumn.Caption = "Pet Name" + inventoryTable.Columns.AddRange(New DataColumn() {carMakeColumn, carColorColumn, carPetNameColumn}) + + ' Iterate over the array list to make rows. + For Each c As Car In listCars + Dim newRow As DataRow = inventoryTable.NewRow() + newRow("Make") = c.carMake + newRow("Color") = c.carColor + newRow("PetName") = c.carPetName + inventoryTable.Rows.Add(newRow) + Next + + ' Bind the DataTable to the carInventoryGridView. + carInventoryGridView.DataSource = inventoryTable + End Sub +#End Region + +#Region "Handler for Remove Button's Click event." + ' Remove this row from the DataRowCollection. + Private Sub btnRemoveRow_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnRemoveRow.Click + Try + inventoryTable.Rows((Integer.Parse(txtRowToRemove.Text))).Delete() + inventoryTable.AcceptChanges() + Catch ex As Exception + MessageBox.Show(ex.Message) + End Try + End Sub +#End Region + +#Region "Handler / helper function for filtering logic" + Private Sub btnDisplayMakes_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnDisplayMakes.Click + ' Build a filter based on user input. + Dim filterStr As String = String.Format("Make= '{0}'", txtMakeToView.Text) + + ' Find all rows matching the filter. + Dim makes As DataRow() = inventoryTable.Select(filterStr) + + ' Show what we got! + If makes.Length = 0 Then + MessageBox.Show("Sorry, no cars...", "Selection error!") + Else + Dim strMake As String = String.Empty + For i As Integer = 0 To makes.Length - 1 + Dim temp As DataRow = makes(i) + strMake &= temp("PetName").ToString() & Chr(10) + Next + MessageBox.Show(strMake, String.Format("{0} type(s):", txtMakeToView.Text)) + End If + End Sub +#End Region + +#Region "Change BMWs to Yugos (oh, the horror...)" + Private Sub btnChangeBeemersToYugos_Click(ByVal sender As Object, _ + ByVal e As EventArgs) Handles btnChangeBeemersToYugos.Click + ' Make sure user has not lost his or her mind. + If DialogResult.Yes = MessageBox.Show("Are you sure?? BMWs are much nicer than Yugos!", _ + "Please Confirm!", MessageBoxButtons.YesNo) Then + ' Build a filter. + Dim filterStr As String = "Make='BMW'" + + ' Find all rows matching the filter. + Dim makes As DataRow() = inventoryTable.Select(filterStr) + For i As Integer = 0 To makes.Length - 1 + + ' Change all Beemers to Yugos! + makes(i)("Make") = "Yugo" + Next + End If + End Sub +#End Region + +#Region "Create our view object." + Private Sub CreateDataView() + ' Set the table that is used to construct this view. + coltsOnlyView = New DataView(inventoryTable) + + ' Now configure the views using a filter. + coltsOnlyView.RowFilter = "Make = 'Colt'" + + ' Bind to the new grid. + dataGridColtsView.DataSource = coltsOnlyView + End Sub +#End Region + +#Region "car ID > 5 (not called, but here for example...)" + Private Sub ShowCarsWithIdGreaterThanFive() + ' Now show the pet names of all cars with ID greater than 5. + ' (Assuming you did have an ID column!) + Dim properIDs As DataRow() + Dim newFilterStr As String = "ID > 5" + properIDs = inventoryTable.Select(newFilterStr) + + Dim strIDs As String = String.Empty + For i As Integer = 0 To properIDs.Length - 1 + Dim temp As DataRow = properIDs(i) + strIDs &= temp("PetName").ToString() & " is ID " & temp("ID").ToString() & Chr(10) + Next + MessageBox.Show(strIDs, "Pet names of cars where ID > 5") + End Sub +#End Region + +#Region "This is just to see the row numbers" + Private Sub carInventoryGridView_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles carInventoryGridView.RowPostPaint + ' This extra code will simply make it easier to visualize the # of the rows. + Using b As New SolidBrush(Color.Black) + e.Graphics.DrawString((e.RowIndex).ToString(), e.InheritedRowStyle.Font, b, e.RowBounds.Location.X + 15, e.RowBounds.Location.Y + 4) + End Using + End Sub + + Private Sub dataGridColtsView_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles dataGridColtsView.RowPostPaint + ' A more funky font. + Using b As New SolidBrush(Color.Green) + e.Graphics.DrawString((e.RowIndex).ToString(), New Font("Times New Roman", 11, FontStyle.Italic Or FontStyle.Bold), b, e.RowBounds.Location.X + 15, e.RowBounds.Location.Y + 4) + End Using + End Sub +#End Region + +End Class diff --git a/Code/Chapter 23/WindowsFormsDataTableViewer/My Project/Application.Designer.vb b/Code/Chapter 23/WindowsFormsDataTableViewer/My Project/Application.Designer.vb new file mode 100644 index 0000000..7ce2ce5 --- /dev/null +++ b/Code/Chapter 23/WindowsFormsDataTableViewer/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.WindowsFormsDataTableViewer.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 23/WindowsFormsDataTableViewer/My Project/Application.myapp b/Code/Chapter 23/WindowsFormsDataTableViewer/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 23/WindowsFormsDataTableViewer/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 23/WindowsFormsDataTableViewer/My Project/AssemblyInfo.vb b/Code/Chapter 23/WindowsFormsDataTableViewer/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..4918e3b --- /dev/null +++ b/Code/Chapter 23/WindowsFormsDataTableViewer/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/Code/Chapter 23/WindowsFormsDataTableViewer/My Project/Resources.Designer.vb b/Code/Chapter 23/WindowsFormsDataTableViewer/My Project/Resources.Designer.vb new file mode 100644 index 0000000..9259d30 --- /dev/null +++ b/Code/Chapter 23/WindowsFormsDataTableViewer/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("WindowsFormsDataTableViewer.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/Code/Chapter 23/WindowsFormsDataTableViewer/My Project/Resources.resx b/Code/Chapter 23/WindowsFormsDataTableViewer/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 23/WindowsFormsDataTableViewer/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/Code/Chapter 23/WindowsFormsDataTableViewer/My Project/Settings.Designer.vb b/Code/Chapter 23/WindowsFormsDataTableViewer/My Project/Settings.Designer.vb new file mode 100644 index 0000000..510f393 --- /dev/null +++ b/Code/Chapter 23/WindowsFormsDataTableViewer/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.WindowsFormsDataTableViewer.My.MySettings + Get + Return Global.WindowsFormsDataTableViewer.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 23/WindowsFormsDataTableViewer/My Project/Settings.settings b/Code/Chapter 23/WindowsFormsDataTableViewer/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 23/WindowsFormsDataTableViewer/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 23/WindowsFormsDataTableViewer/WindowsFormsDataTableViewer.sln b/Code/Chapter 23/WindowsFormsDataTableViewer/WindowsFormsDataTableViewer.sln new file mode 100644 index 0000000..3fd195a --- /dev/null +++ b/Code/Chapter 23/WindowsFormsDataTableViewer/WindowsFormsDataTableViewer.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "WindowsFormsDataTableViewer", "WindowsFormsDataTableViewer.vbproj", "{DDF81A37-DFB5-4903-BB6D-C16F9C37472B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DDF81A37-DFB5-4903-BB6D-C16F9C37472B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DDF81A37-DFB5-4903-BB6D-C16F9C37472B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DDF81A37-DFB5-4903-BB6D-C16F9C37472B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DDF81A37-DFB5-4903-BB6D-C16F9C37472B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 23/WindowsFormsDataTableViewer/WindowsFormsDataTableViewer.suo b/Code/Chapter 23/WindowsFormsDataTableViewer/WindowsFormsDataTableViewer.suo new file mode 100644 index 0000000..0a43980 Binary files /dev/null and b/Code/Chapter 23/WindowsFormsDataTableViewer/WindowsFormsDataTableViewer.suo differ diff --git a/Code/Chapter 23/WindowsFormsDataTableViewer/WindowsFormsDataTableViewer.vbproj b/Code/Chapter 23/WindowsFormsDataTableViewer/WindowsFormsDataTableViewer.vbproj new file mode 100644 index 0000000..921130e --- /dev/null +++ b/Code/Chapter 23/WindowsFormsDataTableViewer/WindowsFormsDataTableViewer.vbproj @@ -0,0 +1,124 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {DDF81A37-DFB5-4903-BB6D-C16F9C37472B} + WinExe + WindowsFormsDataTableViewer.My.MyApplication + WindowsFormsDataTableViewer + WindowsFormsDataTableViewer + 512 + WindowsForms + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + WindowsFormsDataTableViewer.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + WindowsFormsDataTableViewer.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + MainForm.vb + Designer + + + 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/Code/Chapter 23/WindowsFormsInventoryUI/MainForm.Designer.vb b/Code/Chapter 23/WindowsFormsInventoryUI/MainForm.Designer.vb new file mode 100644 index 0000000..748153c --- /dev/null +++ b/Code/Chapter 23/WindowsFormsInventoryUI/MainForm.Designer.vb @@ -0,0 +1,76 @@ + _ +Partial Class MainForm + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + 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.btnUpdateInventory = New System.Windows.Forms.Button + Me.label1 = New System.Windows.Forms.Label + Me.inventoryGrid = New System.Windows.Forms.DataGridView + CType(Me.inventoryGrid, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'btnUpdateInventory + ' + Me.btnUpdateInventory.Location = New System.Drawing.Point(12, 363) + Me.btnUpdateInventory.Name = "btnUpdateInventory" + Me.btnUpdateInventory.Size = New System.Drawing.Size(93, 23) + Me.btnUpdateInventory.TabIndex = 5 + Me.btnUpdateInventory.Text = "Update!" + Me.btnUpdateInventory.UseVisualStyleBackColor = True + ' + 'label1 + ' + Me.label1.AutoSize = True + Me.label1.Location = New System.Drawing.Point(11, 19) + Me.label1.Name = "label1" + Me.label1.Size = New System.Drawing.Size(366, 13) + Me.label1.TabIndex = 4 + Me.label1.Text = "Make Changes to the Grid and Click the Update Button to Process Changes" + ' + 'inventoryGrid + ' + Me.inventoryGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize + Me.inventoryGrid.Location = New System.Drawing.Point(12, 47) + Me.inventoryGrid.Name = "inventoryGrid" + Me.inventoryGrid.Size = New System.Drawing.Size(414, 298) + Me.inventoryGrid.TabIndex = 3 + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(436, 405) + Me.Controls.Add(Me.btnUpdateInventory) + Me.Controls.Add(Me.label1) + Me.Controls.Add(Me.inventoryGrid) + Me.Name = "MainForm" + Me.Text = "Inventory GUI" + CType(Me.inventoryGrid, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Private WithEvents btnUpdateInventory As System.Windows.Forms.Button + Private WithEvents label1 As System.Windows.Forms.Label + Private WithEvents inventoryGrid As System.Windows.Forms.DataGridView + +End Class diff --git a/Code/Chapter 23/WindowsFormsInventoryUI/MainForm.resx b/Code/Chapter 23/WindowsFormsInventoryUI/MainForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 23/WindowsFormsInventoryUI/MainForm.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/Code/Chapter 23/WindowsFormsInventoryUI/MainForm.vb b/Code/Chapter 23/WindowsFormsInventoryUI/MainForm.vb new file mode 100644 index 0000000..e894424 --- /dev/null +++ b/Code/Chapter 23/WindowsFormsInventoryUI/MainForm.vb @@ -0,0 +1,29 @@ +Imports AutoLotDisconnectedLayer +Imports System.Configuration + +Public Class MainForm + Private dal As InventoryDALDisLayer = Nothing + + Sub New() + + ' This call is required by the Windows Form Designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call. + ' Assume we have an App.config file + ' storing the connection string. + Dim cnStr As String = ConfigurationManager.ConnectionStrings("AutoLotSqlProvider").ConnectionString + + ' Create our data access object. + dal = New InventoryDALDisLayer(cnStr) + + ' Fill up our grid! + inventoryGrid.DataSource = dal.GetAllInventory() + End Sub + + Private Sub btnUpdateInventory_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateInventory.Click + Dim changedDT As DataTable = DirectCast(inventoryGrid.DataSource, DataTable) + ' Commit our changes. + dal.UpdateInventory(changedDT) + End Sub +End Class diff --git a/Code/Chapter 23/WindowsFormsInventoryUI/My Project/Application.Designer.vb b/Code/Chapter 23/WindowsFormsInventoryUI/My Project/Application.Designer.vb new file mode 100644 index 0000000..c107a78 --- /dev/null +++ b/Code/Chapter 23/WindowsFormsInventoryUI/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.WindowsFormsInventoryUI.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 23/WindowsFormsInventoryUI/My Project/Application.myapp b/Code/Chapter 23/WindowsFormsInventoryUI/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 23/WindowsFormsInventoryUI/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 23/WindowsFormsInventoryUI/My Project/AssemblyInfo.vb b/Code/Chapter 23/WindowsFormsInventoryUI/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..5d3e480 --- /dev/null +++ b/Code/Chapter 23/WindowsFormsInventoryUI/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/Code/Chapter 23/WindowsFormsInventoryUI/My Project/Resources.Designer.vb b/Code/Chapter 23/WindowsFormsInventoryUI/My Project/Resources.Designer.vb new file mode 100644 index 0000000..877d4ca --- /dev/null +++ b/Code/Chapter 23/WindowsFormsInventoryUI/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("WindowsFormsInventoryUI.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/Code/Chapter 23/WindowsFormsInventoryUI/My Project/Resources.resx b/Code/Chapter 23/WindowsFormsInventoryUI/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 23/WindowsFormsInventoryUI/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/Code/Chapter 23/WindowsFormsInventoryUI/My Project/Settings.Designer.vb b/Code/Chapter 23/WindowsFormsInventoryUI/My Project/Settings.Designer.vb new file mode 100644 index 0000000..313178e --- /dev/null +++ b/Code/Chapter 23/WindowsFormsInventoryUI/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.WindowsFormsInventoryUI.My.MySettings + Get + Return Global.WindowsFormsInventoryUI.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 23/WindowsFormsInventoryUI/My Project/Settings.settings b/Code/Chapter 23/WindowsFormsInventoryUI/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 23/WindowsFormsInventoryUI/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 23/WindowsFormsInventoryUI/WindowsFormsInventoryUI.sln b/Code/Chapter 23/WindowsFormsInventoryUI/WindowsFormsInventoryUI.sln new file mode 100644 index 0000000..0a17c8d --- /dev/null +++ b/Code/Chapter 23/WindowsFormsInventoryUI/WindowsFormsInventoryUI.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "WindowsFormsInventoryUI", "WindowsFormsInventoryUI.vbproj", "{2F160F3F-920C-485A-85FA-078B3167BFC5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2F160F3F-920C-485A-85FA-078B3167BFC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2F160F3F-920C-485A-85FA-078B3167BFC5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F160F3F-920C-485A-85FA-078B3167BFC5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2F160F3F-920C-485A-85FA-078B3167BFC5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 23/WindowsFormsInventoryUI/WindowsFormsInventoryUI.suo b/Code/Chapter 23/WindowsFormsInventoryUI/WindowsFormsInventoryUI.suo new file mode 100644 index 0000000..6b822e5 Binary files /dev/null and b/Code/Chapter 23/WindowsFormsInventoryUI/WindowsFormsInventoryUI.suo differ diff --git a/Code/Chapter 23/WindowsFormsInventoryUI/WindowsFormsInventoryUI.vbproj b/Code/Chapter 23/WindowsFormsInventoryUI/WindowsFormsInventoryUI.vbproj new file mode 100644 index 0000000..b94f923 --- /dev/null +++ b/Code/Chapter 23/WindowsFormsInventoryUI/WindowsFormsInventoryUI.vbproj @@ -0,0 +1,129 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {2F160F3F-920C-485A-85FA-078B3167BFC5} + WinExe + WindowsFormsInventoryUI.My.MyApplication + WindowsFormsInventoryUI + WindowsFormsInventoryUI + 512 + WindowsForms + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + WindowsFormsInventoryUI.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + WindowsFormsInventoryUI.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + False + ..\AutoLotDAL (Part 2)\bin\Debug\AutoLotDAL.dll + + + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + MainForm.vb + Designer + + + 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/Code/Chapter 23/WindowsFormsInventoryUI/app.config b/Code/Chapter 23/WindowsFormsInventoryUI/app.config new file mode 100644 index 0000000..4e833eb --- /dev/null +++ b/Code/Chapter 23/WindowsFormsInventoryUI/app.config @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/Code/Chapter 24/FunWithLinqToXml/FunWithLinqToXml.sln b/Code/Chapter 24/FunWithLinqToXml/FunWithLinqToXml.sln new file mode 100644 index 0000000..99d7e16 --- /dev/null +++ b/Code/Chapter 24/FunWithLinqToXml/FunWithLinqToXml.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "FunWithLinqToXml", "FunWithLinqToXml.vbproj", "{864CD281-CCF0-4EB8-AA24-A79C0B0FEE2C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {864CD281-CCF0-4EB8-AA24-A79C0B0FEE2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {864CD281-CCF0-4EB8-AA24-A79C0B0FEE2C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {864CD281-CCF0-4EB8-AA24-A79C0B0FEE2C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {864CD281-CCF0-4EB8-AA24-A79C0B0FEE2C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 24/FunWithLinqToXml/FunWithLinqToXml.suo b/Code/Chapter 24/FunWithLinqToXml/FunWithLinqToXml.suo new file mode 100644 index 0000000..f394ff2 Binary files /dev/null and b/Code/Chapter 24/FunWithLinqToXml/FunWithLinqToXml.suo differ diff --git a/Code/Chapter 24/FunWithLinqToXml/FunWithLinqToXml.vbproj b/Code/Chapter 24/FunWithLinqToXml/FunWithLinqToXml.vbproj new file mode 100644 index 0000000..c8abdf9 --- /dev/null +++ b/Code/Chapter 24/FunWithLinqToXml/FunWithLinqToXml.vbproj @@ -0,0 +1,109 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {864CD281-CCF0-4EB8-AA24-A79C0B0FEE2C} + Exe + FunWithLinqToXml.Program + FunWithLinqToXml + FunWithLinqToXml + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + FunWithLinqToXml.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + FunWithLinqToXml.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 24/FunWithLinqToXml/FunWithLinqToXml.vbproj.user b/Code/Chapter 24/FunWithLinqToXml/FunWithLinqToXml.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 24/FunWithLinqToXml/FunWithLinqToXml.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 24/FunWithLinqToXml/My Project/Application.Designer.vb b/Code/Chapter 24/FunWithLinqToXml/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 24/FunWithLinqToXml/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 24/FunWithLinqToXml/My Project/Application.myapp b/Code/Chapter 24/FunWithLinqToXml/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 24/FunWithLinqToXml/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 24/FunWithLinqToXml/My Project/AssemblyInfo.vb b/Code/Chapter 24/FunWithLinqToXml/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..077531b --- /dev/null +++ b/Code/Chapter 24/FunWithLinqToXml/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/Code/Chapter 24/FunWithLinqToXml/My Project/Resources.Designer.vb b/Code/Chapter 24/FunWithLinqToXml/My Project/Resources.Designer.vb new file mode 100644 index 0000000..ace40d3 --- /dev/null +++ b/Code/Chapter 24/FunWithLinqToXml/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("FunWithLinqToXml.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/Code/Chapter 24/FunWithLinqToXml/My Project/Resources.resx b/Code/Chapter 24/FunWithLinqToXml/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 24/FunWithLinqToXml/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/Code/Chapter 24/FunWithLinqToXml/My Project/Settings.Designer.vb b/Code/Chapter 24/FunWithLinqToXml/My Project/Settings.Designer.vb new file mode 100644 index 0000000..5fc5e3a --- /dev/null +++ b/Code/Chapter 24/FunWithLinqToXml/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.FunWithLinqToXml.My.MySettings + Get + Return Global.FunWithLinqToXml.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 24/FunWithLinqToXml/My Project/Settings.settings b/Code/Chapter 24/FunWithLinqToXml/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 24/FunWithLinqToXml/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 24/FunWithLinqToXml/Program.vb b/Code/Chapter 24/FunWithLinqToXml/Program.vb new file mode 100644 index 0000000..f0a1871 --- /dev/null +++ b/Code/Chapter 24/FunWithLinqToXml/Program.vb @@ -0,0 +1,175 @@ +' Simple helper class to populate +' a List(Of T). +Class Car + Public PetName As String + Public ID As Integer +End Class + +' Comment / uncomment method calls to test. +Module Program + Sub Main() + Console.WriteLine("*****Fun with LINQ to XML*****") + 'Console.WriteLine() + 'CreateXmlElementWithObjectModel() + + 'Console.WriteLine() + 'CreateXmlElementWithXmlLiteral() + + 'Console.WriteLine() + 'CreateFunctionalXmlDoc() + + 'Console.WriteLine() + CreateFunctionalXmlDocWithLiteral() + + CreateXmlDocFromArray() + Console.WriteLine() + + LoadExistingXml() + Console.ReadLine() + End Sub + +#Region "Create a single XML element" + Sub CreateXmlElementWithXmlLiteral() + Dim inventory As XElement = _ + + + Green + BMW + Stan + + + + ' Call ToString() on our XElement. + Console.WriteLine(inventory) + End Sub + + Sub CreateXmlElementWithObjectModel() + ' A "functional" approach to build an + ' XML element in memory. + Dim inventory As XElement = _ + New XElement("Inventory", _ + New XElement("Car", New XAttribute("ID", "1"), _ + New XElement("Color", "Green"), _ + New XElement("Make", "BMW"), _ + New XElement("PetName", "Stan") _ + ) _ + ) + ' Call ToString() on our XElement. + Console.WriteLine(inventory) + End Sub +#End Region + +#Region "Create XML doc" + Sub CreateFunctionalXmlDoc() + ' Create an in-memory XML document. + Dim inventoryDoc As XDocument = _ + New XDocument( _ + New XDeclaration("1.0", "utf-8", "yes"), _ + New XComment("Current Inventory of AutoLot"), _ + New XElement("Inventory", _ + New XElement("Car", New XAttribute("ID", "1"), _ + New XElement("Color", "Green"), _ + New XElement("Make", "BMW"), _ + New XElement("PetName", "Stan") _ + ), _ + New XElement("Car", New XAttribute("ID", "2"), _ + New XElement("Color", "Pink"), _ + New XElement("Make", "Yugo"), _ + New XElement("PetName", "Melvin") _ + ) _ + ) _ + ) + ' Display the document and save to disk. + Console.WriteLine(inventoryDoc) + inventoryDoc.Save("SimpleInventory.xml") + End Sub + + Sub CreateFunctionalXmlDocWithLiteral() + ' Create an in-memory XML document. + Dim inventoryDoc As XDocument = _ + + + + + Green + BMW + Stan + + + Pink + Yugo + Melvin + + + + ' Display the document and save to disk. + Console.WriteLine(inventoryDoc) + inventoryDoc.Save("SimpleInventory.xml") + End Sub +#End Region + +#Region "Create XML doc from array" + Sub CreateXmlDocFromArray() + ' Create an List of Car types. + Dim data As New List(Of Car) + data.Add(New Car With {.PetName = "Melvin", .ID = 10}) + data.Add(New Car With {.PetName = "Pat", .ID = 11}) + data.Add(New Car With {.PetName = "Danny", .ID = 12}) + data.Add(New Car With {.PetName = "Clunker", .ID = 13}) + + ' Now enumerate over the array to build + ' an XElement. + Dim vehicles As XElement = _ + New XElement("Inventory", _ + From c In data _ + Select New XElement("Car", _ + New XAttribute("ID", c.ID), _ + New XElement("PetName", c.PetName) _ + ) _ + ) + Console.WriteLine(vehicles) + End Sub + + Sub CreateXmlDocFromArrayUsingLiteral() + ' Create an List of Car types. + Dim data As New List(Of Car) + data.Add(New Car With {.PetName = "Melvin", .ID = 10}) + data.Add(New Car With {.PetName = "Pat", .ID = 11}) + data.Add(New Car With {.PetName = "Danny", .ID = 12}) + data.Add(New Car With {.PetName = "Clunker", .ID = 13}) + + Dim vehicles As XElement = _ + + <%= From c In data _ + Select > + <%= c.PetName %> + %> + + + Console.WriteLine(vehicles) + End Sub + +#End Region + +#Region "XML from Strings and files" + Sub LoadExistingXml() + + ' Build an XElement from string. + Dim myElement As String = _ + "" & _ + "Yellow" & _ + "Yugo" & _ + "" + + Dim newElement As XElement = XElement.Parse(myElement) + Console.WriteLine(newElement) + Console.WriteLine() + + ' Load the SimpleInventory.xml file. + Dim myDoc As XDocument = XDocument.Load("SimpleInventory.xml") + Console.WriteLine(myDoc) + End Sub + +#End Region + +End Module diff --git a/Code/Chapter 24/LinqOverDataSet/LinqOverDataSet.sln b/Code/Chapter 24/LinqOverDataSet/LinqOverDataSet.sln new file mode 100644 index 0000000..c497a7c --- /dev/null +++ b/Code/Chapter 24/LinqOverDataSet/LinqOverDataSet.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "LinqOverDataSet", "LinqOverDataSet.vbproj", "{8E47E211-2697-45A8-963A-98CFA33CFDFC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8E47E211-2697-45A8-963A-98CFA33CFDFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E47E211-2697-45A8-963A-98CFA33CFDFC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E47E211-2697-45A8-963A-98CFA33CFDFC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E47E211-2697-45A8-963A-98CFA33CFDFC}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 24/LinqOverDataSet/LinqOverDataSet.suo b/Code/Chapter 24/LinqOverDataSet/LinqOverDataSet.suo new file mode 100644 index 0000000..37c3910 Binary files /dev/null and b/Code/Chapter 24/LinqOverDataSet/LinqOverDataSet.suo differ diff --git a/Code/Chapter 24/LinqOverDataSet/LinqOverDataSet.vbproj b/Code/Chapter 24/LinqOverDataSet/LinqOverDataSet.vbproj new file mode 100644 index 0000000..2edd0f7 --- /dev/null +++ b/Code/Chapter 24/LinqOverDataSet/LinqOverDataSet.vbproj @@ -0,0 +1,113 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {8E47E211-2697-45A8-963A-98CFA33CFDFC} + Exe + LinqOverDataSet.Program + LinqOverDataSet + LinqOverDataSet + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + LinqOverDataSet.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + LinqOverDataSet.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + False + ..\..\Chapter 23\AutoLotDAL (Part 3)\bin\Debug\AutoLotDAL.dll + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 24/LinqOverDataSet/My Project/Application.Designer.vb b/Code/Chapter 24/LinqOverDataSet/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 24/LinqOverDataSet/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 24/LinqOverDataSet/My Project/Application.myapp b/Code/Chapter 24/LinqOverDataSet/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 24/LinqOverDataSet/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 24/LinqOverDataSet/My Project/AssemblyInfo.vb b/Code/Chapter 24/LinqOverDataSet/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..89814bc --- /dev/null +++ b/Code/Chapter 24/LinqOverDataSet/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/Code/Chapter 24/LinqOverDataSet/My Project/Resources.Designer.vb b/Code/Chapter 24/LinqOverDataSet/My Project/Resources.Designer.vb new file mode 100644 index 0000000..322e4b1 --- /dev/null +++ b/Code/Chapter 24/LinqOverDataSet/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("LinqOverDataSet.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/Code/Chapter 24/LinqOverDataSet/My Project/Resources.resx b/Code/Chapter 24/LinqOverDataSet/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 24/LinqOverDataSet/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/Code/Chapter 24/LinqOverDataSet/My Project/Settings.Designer.vb b/Code/Chapter 24/LinqOverDataSet/My Project/Settings.Designer.vb new file mode 100644 index 0000000..85b1a6e --- /dev/null +++ b/Code/Chapter 24/LinqOverDataSet/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.LinqOverDataSet.My.MySettings + Get + Return Global.LinqOverDataSet.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 24/LinqOverDataSet/My Project/Settings.settings b/Code/Chapter 24/LinqOverDataSet/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 24/LinqOverDataSet/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 24/LinqOverDataSet/Program.vb b/Code/Chapter 24/LinqOverDataSet/Program.vb new file mode 100644 index 0000000..c81a7b1 --- /dev/null +++ b/Code/Chapter 24/LinqOverDataSet/Program.vb @@ -0,0 +1,81 @@ +Option Strict On +Option Explicit On + +Imports AutoLotDisconnectedLayer + +Module Program + Sub Main() + Console.WriteLine("***** LINQ over DataSet *****" & vbLf) + ' Get a DataTable containing the current Inventory + ' of the AutoLot database. + Dim dal As New InventoryDALDisLayer _ + ("Data Source=(local)\SQLEXPRESS;Initial Catalog=AutoLot;" & _ + "Integrated Security=True") + Dim data As DataTable = dal.GetAllInventory() + + ' Invoke the methods that follow here! + PrintAllCarIDs(data) + Console.WriteLine() + + ApplyLinqQuery(data) + Console.WriteLine() + + BuildDataTableFromQuery(data) + Console.WriteLine() + + Console.ReadLine() + End Sub + +#Region "Print all car IDs" + Sub PrintAllCarIDs(ByVal data As DataTable) + Console.WriteLine("All Car IDs:") + + ' Get enumerable version of DataTable. + Dim enumData As EnumerableRowCollection = data.AsEnumerable() + + ' Print the car ID values. + For Each r As DataRow In enumData + Console.WriteLine("Car ID = {0}", r("CarID")) + Next + End Sub +#End Region + +#Region "Apply LINQ query" + Sub ApplyLinqQuery(ByVal data As DataTable) + ' Project a new result set containing + ' the ID/color for rows with a CarID > 5 + Dim cars = From car In data Where _ + car.Field(Of Integer)("CarID") > 5 _ + Select New With _ + { _ + .ID = car.Field(Of Integer)("CarID"), _ + .Color = car.Field(Of String)("Color") _ + } + + Console.WriteLine("Cars with ID greater than 5:") + For Each item In cars + Console.WriteLine("-> CarID = {0} is {1}", item.ID, item.Color) + Next + End Sub +#End Region + +#Region "DataTable from Query" + Sub BuildDataTableFromQuery(ByVal data As DataTable) + Dim cars = From car In data _ + Where car.Field(Of Integer)("CarID") > 5 _ + Select car + + ' Use this result set to build a new DataTable. + Dim newTable As DataTable = cars.CopyToDataTable() + For curRow As Integer = 0 To newTable.Rows.Count - 1 + + ' Print the DataTable. + For curCol As Integer = 0 To newTable.Columns.Count - 1 + Console.Write(newTable.Rows(curRow)(curCol).ToString().Trim() & vbTab) + Next + Console.WriteLine() + Next + End Sub +#End Region + +End Module diff --git a/Code/Chapter 24/LinqToSqlCrud/AutoLotObjects.dbml b/Code/Chapter 24/LinqToSqlCrud/AutoLotObjects.dbml new file mode 100644 index 0000000..55dc052 --- /dev/null +++ b/Code/Chapter 24/LinqToSqlCrud/AutoLotObjects.dbml @@ -0,0 +1,42 @@ + + + + + + + + + +
+ + + + + + + +
+ + + + + + + + +
+ + + + + + + + +
+ + + + + +
\ No newline at end of file diff --git a/Code/Chapter 24/LinqToSqlCrud/AutoLotObjects.dbml.layout b/Code/Chapter 24/LinqToSqlCrud/AutoLotObjects.dbml.layout new file mode 100644 index 0000000..646185a --- /dev/null +++ b/Code/Chapter 24/LinqToSqlCrud/AutoLotObjects.dbml.layout @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 24/LinqToSqlCrud/AutoLotObjects.designer.vb b/Code/Chapter 24/LinqToSqlCrud/AutoLotObjects.designer.vb new file mode 100644 index 0000000..78225cc --- /dev/null +++ b/Code/Chapter 24/LinqToSqlCrud/AutoLotObjects.designer.vb @@ -0,0 +1,683 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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 +Imports System.Collections.Generic +Imports System.ComponentModel +Imports System.Data +Imports System.Data.Linq +Imports System.Data.Linq.Mapping +Imports System.Linq +Imports System.Linq.Expressions +Imports System.Reflection + + + _ +Partial Public Class AutoLotObjectsDataContext + Inherits System.Data.Linq.DataContext + + Private Shared mappingSource As System.Data.Linq.Mapping.MappingSource = New AttributeMappingSource + + #Region "Extensibility Method Definitions" + Partial Private Sub OnCreated() + End Sub + Partial Private Sub InsertCreditRisk(instance As CreditRisk) + End Sub + Partial Private Sub UpdateCreditRisk(instance As CreditRisk) + End Sub + Partial Private Sub DeleteCreditRisk(instance As CreditRisk) + End Sub + Partial Private Sub InsertCustomer(instance As Customer) + End Sub + Partial Private Sub UpdateCustomer(instance As Customer) + End Sub + Partial Private Sub DeleteCustomer(instance As Customer) + End Sub + Partial Private Sub InsertInventory(instance As Inventory) + End Sub + Partial Private Sub UpdateInventory(instance As Inventory) + End Sub + Partial Private Sub DeleteInventory(instance As Inventory) + End Sub + Partial Private Sub InsertOrder(instance As [Order]) + End Sub + Partial Private Sub UpdateOrder(instance As [Order]) + End Sub + Partial Private Sub DeleteOrder(instance As [Order]) + End Sub + #End Region + + Public Sub New() + MyBase.New(Global.LinqToSqlCrud.My.MySettings.Default.AutoLotConnectionString, mappingSource) + OnCreated + End Sub + + Public Sub New(ByVal connection As String) + MyBase.New(connection, mappingSource) + OnCreated + End Sub + + Public Sub New(ByVal connection As System.Data.IDbConnection) + MyBase.New(connection, mappingSource) + OnCreated + End Sub + + Public Sub New(ByVal connection As String, ByVal mappingSource As System.Data.Linq.Mapping.MappingSource) + MyBase.New(connection, mappingSource) + OnCreated + End Sub + + Public Sub New(ByVal connection As System.Data.IDbConnection, ByVal mappingSource As System.Data.Linq.Mapping.MappingSource) + MyBase.New(connection, mappingSource) + OnCreated + End Sub + + Public ReadOnly Property CreditRisks() As System.Data.Linq.Table(Of CreditRisk) + Get + Return Me.GetTable(Of CreditRisk) + End Get + End Property + + Public ReadOnly Property Customers() As System.Data.Linq.Table(Of Customer) + Get + Return Me.GetTable(Of Customer) + End Get + End Property + + Public ReadOnly Property Inventories() As System.Data.Linq.Table(Of Inventory) + Get + Return Me.GetTable(Of Inventory) + End Get + End Property + + Public ReadOnly Property Orders() As System.Data.Linq.Table(Of [Order]) + Get + Return Me.GetTable(Of [Order]) + End Get + End Property + + _ + Public Function GetPetName( _ + ByVal carID As System.Nullable(Of Integer), _ + ByRef petName As String) As Integer + + Dim result As IExecuteResult = _ + Me.ExecuteMethodCall(Me, _ + CType(MethodInfo.GetCurrentMethod, MethodInfo), carID, petName) + + petName = CType(result.GetParameterValue(1), String) + Return CType(result.ReturnValue, Integer) + End Function +End Class + + _ +Partial Public Class CreditRisk + Implements System.ComponentModel.INotifyPropertyChanging, System.ComponentModel.INotifyPropertyChanged + + Private Shared emptyChangingEventArgs As PropertyChangingEventArgs = New PropertyChangingEventArgs(String.Empty) + + Private _CustID As Integer + + Private _FirstName As String + + Private _LastName As String + + #Region "Extensibility Method Definitions" + Partial Private Sub OnLoaded() + End Sub + Partial Private Sub OnValidate(action As System.Data.Linq.ChangeAction) + End Sub + Partial Private Sub OnCreated() + End Sub + Partial Private Sub OnCustIDChanging(value As Integer) + End Sub + Partial Private Sub OnCustIDChanged() + End Sub + Partial Private Sub OnFirstNameChanging(value As String) + End Sub + Partial Private Sub OnFirstNameChanged() + End Sub + Partial Private Sub OnLastNameChanging(value As String) + End Sub + Partial Private Sub OnLastNameChanged() + End Sub + #End Region + + Public Sub New() + MyBase.New + OnCreated + End Sub + + _ + Public Property CustID() As Integer + Get + Return Me._CustID + End Get + Set + If ((Me._CustID = value) _ + = false) Then + Me.OnCustIDChanging(value) + Me.SendPropertyChanging + Me._CustID = value + Me.SendPropertyChanged("CustID") + Me.OnCustIDChanged + End If + End Set + End Property + + _ + Public Property FirstName() As String + Get + Return Me._FirstName + End Get + Set + If (String.Equals(Me._FirstName, value) = false) Then + Me.OnFirstNameChanging(value) + Me.SendPropertyChanging + Me._FirstName = value + Me.SendPropertyChanged("FirstName") + Me.OnFirstNameChanged + End If + End Set + End Property + + _ + Public Property LastName() As String + Get + Return Me._LastName + End Get + Set + If (String.Equals(Me._LastName, value) = false) Then + Me.OnLastNameChanging(value) + Me.SendPropertyChanging + Me._LastName = value + Me.SendPropertyChanged("LastName") + Me.OnLastNameChanged + End If + End Set + End Property + + Public Event PropertyChanging As PropertyChangingEventHandler Implements System.ComponentModel.INotifyPropertyChanging.PropertyChanging + + Public Event PropertyChanged As PropertyChangedEventHandler Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged + + Protected Overridable Sub SendPropertyChanging() + If ((Me.PropertyChangingEvent Is Nothing) _ + = false) Then + RaiseEvent PropertyChanging(Me, emptyChangingEventArgs) + End If + End Sub + + Protected Overridable Sub SendPropertyChanged(ByVal propertyName As [String]) + If ((Me.PropertyChangedEvent Is Nothing) _ + = false) Then + RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName)) + End If + End Sub +End Class + + _ +Partial Public Class Customer + Implements System.ComponentModel.INotifyPropertyChanging, System.ComponentModel.INotifyPropertyChanged + + Private Shared emptyChangingEventArgs As PropertyChangingEventArgs = New PropertyChangingEventArgs(String.Empty) + + Private _CustID As Integer + + Private _FirstName As String + + Private _LastName As String + + Private _Orders As EntitySet(Of [Order]) + + #Region "Extensibility Method Definitions" + Partial Private Sub OnLoaded() + End Sub + Partial Private Sub OnValidate(action As System.Data.Linq.ChangeAction) + End Sub + Partial Private Sub OnCreated() + End Sub + Partial Private Sub OnCustIDChanging(value As Integer) + End Sub + Partial Private Sub OnCustIDChanged() + End Sub + Partial Private Sub OnFirstNameChanging(value As String) + End Sub + Partial Private Sub OnFirstNameChanged() + End Sub + Partial Private Sub OnLastNameChanging(value As String) + End Sub + Partial Private Sub OnLastNameChanged() + End Sub + #End Region + + Public Sub New() + MyBase.New + Me._Orders = New EntitySet(Of [Order])(AddressOf Me.attach_Orders, AddressOf Me.detach_Orders) + OnCreated + End Sub + + _ + Public Property CustID() As Integer + Get + Return Me._CustID + End Get + Set + If ((Me._CustID = value) _ + = false) Then + Me.OnCustIDChanging(value) + Me.SendPropertyChanging + Me._CustID = value + Me.SendPropertyChanged("CustID") + Me.OnCustIDChanged + End If + End Set + End Property + + _ + Public Property FirstName() As String + Get + Return Me._FirstName + End Get + Set + If (String.Equals(Me._FirstName, value) = false) Then + Me.OnFirstNameChanging(value) + Me.SendPropertyChanging + Me._FirstName = value + Me.SendPropertyChanged("FirstName") + Me.OnFirstNameChanged + End If + End Set + End Property + + _ + Public Property LastName() As String + Get + Return Me._LastName + End Get + Set + If (String.Equals(Me._LastName, value) = false) Then + Me.OnLastNameChanging(value) + Me.SendPropertyChanging + Me._LastName = value + Me.SendPropertyChanged("LastName") + Me.OnLastNameChanged + End If + End Set + End Property + + _ + Public Property Orders() As EntitySet(Of [Order]) + Get + Return Me._Orders + End Get + Set + Me._Orders.Assign(value) + End Set + End Property + + Public Event PropertyChanging As PropertyChangingEventHandler Implements System.ComponentModel.INotifyPropertyChanging.PropertyChanging + + Public Event PropertyChanged As PropertyChangedEventHandler Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged + + Protected Overridable Sub SendPropertyChanging() + If ((Me.PropertyChangingEvent Is Nothing) _ + = false) Then + RaiseEvent PropertyChanging(Me, emptyChangingEventArgs) + End If + End Sub + + Protected Overridable Sub SendPropertyChanged(ByVal propertyName As [String]) + If ((Me.PropertyChangedEvent Is Nothing) _ + = false) Then + RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName)) + End If + End Sub + + Private Sub attach_Orders(ByVal entity As [Order]) + Me.SendPropertyChanging + entity.Customer = Me + End Sub + + Private Sub detach_Orders(ByVal entity As [Order]) + Me.SendPropertyChanging + entity.Customer = Nothing + End Sub +End Class + + _ +Partial Public Class Inventory + Implements System.ComponentModel.INotifyPropertyChanging, System.ComponentModel.INotifyPropertyChanged + + Private Shared emptyChangingEventArgs As PropertyChangingEventArgs = New PropertyChangingEventArgs(String.Empty) + + Private _CarID As Integer + + Private _Make As String + + Private _Color As String + + Private _PetName As String + + Private _Orders As EntitySet(Of [Order]) + + #Region "Extensibility Method Definitions" + Partial Private Sub OnLoaded() + End Sub + Partial Private Sub OnValidate(action As System.Data.Linq.ChangeAction) + End Sub + Partial Private Sub OnCreated() + End Sub + Partial Private Sub OnCarIDChanging(value As Integer) + End Sub + Partial Private Sub OnCarIDChanged() + End Sub + Partial Private Sub OnMakeChanging(value As String) + End Sub + Partial Private Sub OnMakeChanged() + End Sub + Partial Private Sub OnColorChanging(value As String) + End Sub + Partial Private Sub OnColorChanged() + End Sub + Partial Private Sub OnPetNameChanging(value As String) + End Sub + Partial Private Sub OnPetNameChanged() + End Sub + #End Region + + Public Sub New() + MyBase.New + Me._Orders = New EntitySet(Of [Order])(AddressOf Me.attach_Orders, AddressOf Me.detach_Orders) + OnCreated + End Sub + + _ + Public Property CarID() As Integer + Get + Return Me._CarID + End Get + Set + If ((Me._CarID = value) _ + = false) Then + Me.OnCarIDChanging(value) + Me.SendPropertyChanging + Me._CarID = value + Me.SendPropertyChanged("CarID") + Me.OnCarIDChanged + End If + End Set + End Property + + _ + Public Property Make() As String + Get + Return Me._Make + End Get + Set + If (String.Equals(Me._Make, value) = false) Then + Me.OnMakeChanging(value) + Me.SendPropertyChanging + Me._Make = value + Me.SendPropertyChanged("Make") + Me.OnMakeChanged + End If + End Set + End Property + + _ + Public Property Color() As String + Get + Return Me._Color + End Get + Set + If (String.Equals(Me._Color, value) = false) Then + Me.OnColorChanging(value) + Me.SendPropertyChanging + Me._Color = value + Me.SendPropertyChanged("Color") + Me.OnColorChanged + End If + End Set + End Property + + _ + Public Property PetName() As String + Get + Return Me._PetName + End Get + Set + If (String.Equals(Me._PetName, value) = false) Then + Me.OnPetNameChanging(value) + Me.SendPropertyChanging + Me._PetName = value + Me.SendPropertyChanged("PetName") + Me.OnPetNameChanged + End If + End Set + End Property + + _ + Public Property Orders() As EntitySet(Of [Order]) + Get + Return Me._Orders + End Get + Set + Me._Orders.Assign(value) + End Set + End Property + + Public Event PropertyChanging As PropertyChangingEventHandler Implements System.ComponentModel.INotifyPropertyChanging.PropertyChanging + + Public Event PropertyChanged As PropertyChangedEventHandler Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged + + Protected Overridable Sub SendPropertyChanging() + If ((Me.PropertyChangingEvent Is Nothing) _ + = false) Then + RaiseEvent PropertyChanging(Me, emptyChangingEventArgs) + End If + End Sub + + Protected Overridable Sub SendPropertyChanged(ByVal propertyName As [String]) + If ((Me.PropertyChangedEvent Is Nothing) _ + = false) Then + RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName)) + End If + End Sub + + Private Sub attach_Orders(ByVal entity As [Order]) + Me.SendPropertyChanging + entity.Inventory = Me + End Sub + + Private Sub detach_Orders(ByVal entity As [Order]) + Me.SendPropertyChanging + entity.Inventory = Nothing + End Sub +End Class + + _ +Partial Public Class [Order] + Implements System.ComponentModel.INotifyPropertyChanging, System.ComponentModel.INotifyPropertyChanged + + Private Shared emptyChangingEventArgs As PropertyChangingEventArgs = New PropertyChangingEventArgs(String.Empty) + + Private _OrderID As Integer + + Private _CustID As Integer + + Private _CarID As Integer + + Private _Customer As EntityRef(Of Customer) + + Private _Inventory As EntityRef(Of Inventory) + + #Region "Extensibility Method Definitions" + Partial Private Sub OnLoaded() + End Sub + Partial Private Sub OnValidate(action As System.Data.Linq.ChangeAction) + End Sub + Partial Private Sub OnCreated() + End Sub + Partial Private Sub OnOrderIDChanging(value As Integer) + End Sub + Partial Private Sub OnOrderIDChanged() + End Sub + Partial Private Sub OnCustIDChanging(value As Integer) + End Sub + Partial Private Sub OnCustIDChanged() + End Sub + Partial Private Sub OnCarIDChanging(value As Integer) + End Sub + Partial Private Sub OnCarIDChanged() + End Sub + #End Region + + Public Sub New() + MyBase.New + Me._Customer = CType(Nothing, EntityRef(Of Customer)) + Me._Inventory = CType(Nothing, EntityRef(Of Inventory)) + OnCreated + End Sub + + _ + Public Property OrderID() As Integer + Get + Return Me._OrderID + End Get + Set + If ((Me._OrderID = value) _ + = false) Then + Me.OnOrderIDChanging(value) + Me.SendPropertyChanging + Me._OrderID = value + Me.SendPropertyChanged("OrderID") + Me.OnOrderIDChanged + End If + End Set + End Property + + _ + Public Property CustID() As Integer + Get + Return Me._CustID + End Get + Set + If ((Me._CustID = value) _ + = false) Then + If Me._Customer.HasLoadedOrAssignedValue Then + Throw New System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException + End If + Me.OnCustIDChanging(value) + Me.SendPropertyChanging + Me._CustID = value + Me.SendPropertyChanged("CustID") + Me.OnCustIDChanged + End If + End Set + End Property + + _ + Public Property CarID() As Integer + Get + Return Me._CarID + End Get + Set + If ((Me._CarID = value) _ + = false) Then + If Me._Inventory.HasLoadedOrAssignedValue Then + Throw New System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException + End If + Me.OnCarIDChanging(value) + Me.SendPropertyChanging + Me._CarID = value + Me.SendPropertyChanged("CarID") + Me.OnCarIDChanged + End If + End Set + End Property + + _ + Public Property Customer() As Customer + Get + Return Me._Customer.Entity + End Get + Set + Dim previousValue As Customer = Me._Customer.Entity + If ((Object.Equals(previousValue, value) = false) _ + OrElse (Me._Customer.HasLoadedOrAssignedValue = false)) Then + Me.SendPropertyChanging + If ((previousValue Is Nothing) _ + = false) Then + Me._Customer.Entity = Nothing + previousValue.Orders.Remove(Me) + End If + Me._Customer.Entity = value + If ((value Is Nothing) _ + = false) Then + value.Orders.Add(Me) + Me._CustID = value.CustID + Else + Me._CustID = CType(Nothing, Integer) + End If + Me.SendPropertyChanged("Customer") + End If + End Set + End Property + + _ + Public Property Inventory() As Inventory + Get + Return Me._Inventory.Entity + End Get + Set + Dim previousValue As Inventory = Me._Inventory.Entity + If ((Object.Equals(previousValue, value) = false) _ + OrElse (Me._Inventory.HasLoadedOrAssignedValue = false)) Then + Me.SendPropertyChanging + If ((previousValue Is Nothing) _ + = false) Then + Me._Inventory.Entity = Nothing + previousValue.Orders.Remove(Me) + End If + Me._Inventory.Entity = value + If ((value Is Nothing) _ + = false) Then + value.Orders.Add(Me) + Me._CarID = value.CarID + Else + Me._CarID = CType(Nothing, Integer) + End If + Me.SendPropertyChanged("Inventory") + End If + End Set + End Property + + Public Event PropertyChanging As PropertyChangingEventHandler Implements System.ComponentModel.INotifyPropertyChanging.PropertyChanging + + Public Event PropertyChanged As PropertyChangedEventHandler Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged + + Protected Overridable Sub SendPropertyChanging() + If ((Me.PropertyChangingEvent Is Nothing) _ + = false) Then + RaiseEvent PropertyChanging(Me, emptyChangingEventArgs) + End If + End Sub + + Protected Overridable Sub SendPropertyChanged(ByVal propertyName As [String]) + If ((Me.PropertyChangedEvent Is Nothing) _ + = false) Then + RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName)) + End If + End Sub +End Class diff --git a/Code/Chapter 24/LinqToSqlCrud/AutoLotObjects.vb b/Code/Chapter 24/LinqToSqlCrud/AutoLotObjects.vb new file mode 100644 index 0000000..e096a77 --- /dev/null +++ b/Code/Chapter 24/LinqToSqlCrud/AutoLotObjects.vb @@ -0,0 +1,4 @@ +Partial Class AutoLotObjectsDataContext + +End Class + diff --git a/Code/Chapter 24/LinqToSqlCrud/LinqToSqlCrud.sln b/Code/Chapter 24/LinqToSqlCrud/LinqToSqlCrud.sln new file mode 100644 index 0000000..0417902 --- /dev/null +++ b/Code/Chapter 24/LinqToSqlCrud/LinqToSqlCrud.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "LinqToSqlCrud", "LinqToSqlCrud.vbproj", "{5A308FF9-F0F4-427A-8546-B7D617A9764C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5A308FF9-F0F4-427A-8546-B7D617A9764C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5A308FF9-F0F4-427A-8546-B7D617A9764C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5A308FF9-F0F4-427A-8546-B7D617A9764C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5A308FF9-F0F4-427A-8546-B7D617A9764C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 24/LinqToSqlCrud/LinqToSqlCrud.suo b/Code/Chapter 24/LinqToSqlCrud/LinqToSqlCrud.suo new file mode 100644 index 0000000..e61f7e9 Binary files /dev/null and b/Code/Chapter 24/LinqToSqlCrud/LinqToSqlCrud.suo differ diff --git a/Code/Chapter 24/LinqToSqlCrud/LinqToSqlCrud.vbproj b/Code/Chapter 24/LinqToSqlCrud/LinqToSqlCrud.vbproj new file mode 100644 index 0000000..2b9dea5 --- /dev/null +++ b/Code/Chapter 24/LinqToSqlCrud/LinqToSqlCrud.vbproj @@ -0,0 +1,132 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {5A308FF9-F0F4-427A-8546-B7D617A9764C} + Exe + LinqToSqlCrud.Program + LinqToSqlCrud + LinqToSqlCrud + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + LinqToSqlCrud.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + LinqToSqlCrud.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + 3.5 + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + True + True + AutoLotObjects.dbml + + + AutoLotObjects.dbml + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + AutoLotObjects.dbml + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + + MSLinqToSQLGenerator + AutoLotObjects.designer.vb + Designer + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 24/LinqToSqlCrud/LinqToSqlCrud.vbproj.user b/Code/Chapter 24/LinqToSqlCrud/LinqToSqlCrud.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 24/LinqToSqlCrud/LinqToSqlCrud.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 24/LinqToSqlCrud/My Project/Application.Designer.vb b/Code/Chapter 24/LinqToSqlCrud/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 24/LinqToSqlCrud/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 24/LinqToSqlCrud/My Project/Application.myapp b/Code/Chapter 24/LinqToSqlCrud/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 24/LinqToSqlCrud/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 24/LinqToSqlCrud/My Project/AssemblyInfo.vb b/Code/Chapter 24/LinqToSqlCrud/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..93bc1be --- /dev/null +++ b/Code/Chapter 24/LinqToSqlCrud/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/Code/Chapter 24/LinqToSqlCrud/My Project/Resources.Designer.vb b/Code/Chapter 24/LinqToSqlCrud/My Project/Resources.Designer.vb new file mode 100644 index 0000000..6fd5d74 --- /dev/null +++ b/Code/Chapter 24/LinqToSqlCrud/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("LinqToSqlCrud.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/Code/Chapter 24/LinqToSqlCrud/My Project/Resources.resx b/Code/Chapter 24/LinqToSqlCrud/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 24/LinqToSqlCrud/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/Code/Chapter 24/LinqToSqlCrud/My Project/Settings.Designer.vb b/Code/Chapter 24/LinqToSqlCrud/My Project/Settings.Designer.vb new file mode 100644 index 0000000..6f7eae6 --- /dev/null +++ b/Code/Chapter 24/LinqToSqlCrud/My Project/Settings.Designer.vb @@ -0,0 +1,84 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings),MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + + _ + Public ReadOnly Property AutoLotConnectionString() As String + Get + Return CType(Me("AutoLotConnectionString"),String) + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.LinqToSqlCrud.My.MySettings + Get + Return Global.LinqToSqlCrud.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 24/LinqToSqlCrud/My Project/Settings.settings b/Code/Chapter 24/LinqToSqlCrud/My Project/Settings.settings new file mode 100644 index 0000000..03c3afc --- /dev/null +++ b/Code/Chapter 24/LinqToSqlCrud/My Project/Settings.settings @@ -0,0 +1,14 @@ + + + + + + <?xml version="1.0" encoding="utf-16"?> +<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <ConnectionString>Data Source=INTERUBER\SQLEXPRESS;Initial Catalog=AutoLot;Integrated Security=True</ConnectionString> + <ProviderName>System.Data.SqlClient</ProviderName> +</SerializableConnectionString> + Data Source=INTERUBER\SQLEXPRESS;Initial Catalog=AutoLot;Integrated Security=True + + + \ No newline at end of file diff --git a/Code/Chapter 24/LinqToSqlCrud/Program.vb b/Code/Chapter 24/LinqToSqlCrud/Program.vb new file mode 100644 index 0000000..f2a944b --- /dev/null +++ b/Code/Chapter 24/LinqToSqlCrud/Program.vb @@ -0,0 +1,68 @@ +Module Program + + Sub Main() + Console.WriteLine("***** CRUD with LINQ to SQL *****") + + Dim ctx As New AutoLotObjectsDataContext() + InsertNewCars(ctx) + UpdateCar(ctx) + DeleteCar(ctx) + Console.ReadLine() + End Sub + +#Region "Insert car" + Sub InsertNewCars(ByVal ctx As AutoLotObjectsDataContext) + + Console.WriteLine("***** Adding 2 Cars *****") + Dim newCarID As Integer = 0 + Console.Write("Enter ID for Betty: ") + newCarID = Integer.Parse(Console.ReadLine()) + + ' Add a new row using "longhand" notation. + Dim newCar As New Inventory() + newCar.Make = "Yugo" + newCar.Color = "Pink" + newCar.PetName = "Betty" + newCar.CarID = newCarID + ctx.Inventories.InsertOnSubmit(newCar) + ctx.SubmitChanges() + + Console.Write("Enter ID for Henry: ") + newCarID = Integer.Parse(Console.ReadLine()) + + ' Add another row using "shorthand" object init syntax. + newCar = New Inventory With {.Make = "BMW", .Color = "Silver", _ + .PetName = "Henry", .CarID = newCarID} + + ctx.Inventories.InsertOnSubmit(newCar) + ctx.SubmitChanges() + End Sub +#End Region + +#Region "Update car" + Sub UpdateCar(ByVal ctx As AutoLotObjectsDataContext) + Console.WriteLine("***** Updating color of 'Betty' *****") + + ' Update Betty's color to light pink. + Dim betty = (From c In ctx.Inventories Where _ + (c.PetName = "Betty") Select c).First() + betty.Color = "Pink" + ctx.SubmitChanges() + End Sub +#End Region + +#Region "Delete car" + Sub DeleteCar(ByVal ctx As AutoLotObjectsDataContext) + Dim carToDelete As Integer = 0 + Console.Write("Enter ID of car to delete: ") + carToDelete = Integer.Parse(Console.ReadLine()) + + ' Remove specified car. + ctx.Inventories.DeleteOnSubmit((From c In ctx.Inventories _ + Where c.CarID = carToDelete _ + Select c).First()) + ctx.SubmitChanges() + End Sub +#End Region + +End Module diff --git a/Code/Chapter 24/LinqToSqlCrud/app.config b/Code/Chapter 24/LinqToSqlCrud/app.config new file mode 100644 index 0000000..54db57d --- /dev/null +++ b/Code/Chapter 24/LinqToSqlCrud/app.config @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 24/LinqWithSqlMetalGenedCode/LINQ to SQL types.cd b/Code/Chapter 24/LinqWithSqlMetalGenedCode/LINQ to SQL types.cd new file mode 100644 index 0000000..0d1a474 --- /dev/null +++ b/Code/Chapter 24/LinqWithSqlMetalGenedCode/LINQ to SQL types.cd @@ -0,0 +1,94 @@ + + + + + + AQGCABkAAwAAIAIABAAAQAAAACAgAAEAAEgCAgIAAgA= + autoLotDB.vb + + + + + + + + + AAAgAEARAAEAAAIAQBEAAAABiCAAAABACAQCAAAAAAo= + autoLotDB.vb + + + + + + + + + + AAkgAEARAAEAAAIAQBEAAAABiCEAAABAKAQCAAAAAAo= + autoLotDB.vb + + + + + + + + + + AAkiIAABAAEgAAAAQAEAAgAhiSGIAgoAIAAAgAIABAA= + autoLotDB.vb + + + + + + + + + + AAFiABABAQAggAKAQAEAAABBiCAAAgBAAAACAgAAAAI= + autoLotDB.vb + + + + + + + IAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAgAAA= + autoLotDB.vb + + + + + + AAAEAACAAEAAiAAAAAAAoAQAAAAAAAAAAAAQAAAEAAA= + autoLotDB.vb + + + + + + AAAAAAAAAAAAAAAAAAAAIAAAAAABAAAAAAAAAAAAAAA= + + + + + + AAAAAAAAAAAAAAAAAAABEAAAAQAAAAAAAAAAAAAAAIA= + + + + + + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAA= + + + + + + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAA= + Program.vb + + + + \ No newline at end of file diff --git a/Code/Chapter 24/LinqWithSqlMetalGenedCode/LinqWithSqlMetalGenedCode.sln b/Code/Chapter 24/LinqWithSqlMetalGenedCode/LinqWithSqlMetalGenedCode.sln new file mode 100644 index 0000000..5a31696 --- /dev/null +++ b/Code/Chapter 24/LinqWithSqlMetalGenedCode/LinqWithSqlMetalGenedCode.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "LinqWithSqlMetalGenedCode", "LinqWithSqlMetalGenedCode.vbproj", "{64B91391-F1D4-4BC8-9CCD-A21A3BCE9112}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {64B91391-F1D4-4BC8-9CCD-A21A3BCE9112}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {64B91391-F1D4-4BC8-9CCD-A21A3BCE9112}.Debug|Any CPU.Build.0 = Debug|Any CPU + {64B91391-F1D4-4BC8-9CCD-A21A3BCE9112}.Release|Any CPU.ActiveCfg = Release|Any CPU + {64B91391-F1D4-4BC8-9CCD-A21A3BCE9112}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 24/LinqWithSqlMetalGenedCode/LinqWithSqlMetalGenedCode.suo b/Code/Chapter 24/LinqWithSqlMetalGenedCode/LinqWithSqlMetalGenedCode.suo new file mode 100644 index 0000000..1222942 Binary files /dev/null and b/Code/Chapter 24/LinqWithSqlMetalGenedCode/LinqWithSqlMetalGenedCode.suo differ diff --git a/Code/Chapter 24/LinqWithSqlMetalGenedCode/LinqWithSqlMetalGenedCode.vbproj b/Code/Chapter 24/LinqWithSqlMetalGenedCode/LinqWithSqlMetalGenedCode.vbproj new file mode 100644 index 0000000..56dc79c --- /dev/null +++ b/Code/Chapter 24/LinqWithSqlMetalGenedCode/LinqWithSqlMetalGenedCode.vbproj @@ -0,0 +1,114 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {64B91391-F1D4-4BC8-9CCD-A21A3BCE9112} + Exe + LinqWithSqlMetalGenedCode.Program + LinqWithSqlMetalGenedCode + LinqWithSqlMetalGenedCode + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + LinqWithSqlMetalGenedCode.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + LinqWithSqlMetalGenedCode.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + 3.5 + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + + 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/Code/Chapter 24/LinqWithSqlMetalGenedCode/LinqWithSqlMetalGenedCode.vbproj.user b/Code/Chapter 24/LinqWithSqlMetalGenedCode/LinqWithSqlMetalGenedCode.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 24/LinqWithSqlMetalGenedCode/LinqWithSqlMetalGenedCode.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 24/LinqWithSqlMetalGenedCode/My Project/Application.Designer.vb b/Code/Chapter 24/LinqWithSqlMetalGenedCode/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 24/LinqWithSqlMetalGenedCode/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 24/LinqWithSqlMetalGenedCode/My Project/Application.myapp b/Code/Chapter 24/LinqWithSqlMetalGenedCode/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 24/LinqWithSqlMetalGenedCode/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 24/LinqWithSqlMetalGenedCode/My Project/AssemblyInfo.vb b/Code/Chapter 24/LinqWithSqlMetalGenedCode/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..4c33fee --- /dev/null +++ b/Code/Chapter 24/LinqWithSqlMetalGenedCode/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/Code/Chapter 24/LinqWithSqlMetalGenedCode/My Project/Resources.Designer.vb b/Code/Chapter 24/LinqWithSqlMetalGenedCode/My Project/Resources.Designer.vb new file mode 100644 index 0000000..b3aed02 --- /dev/null +++ b/Code/Chapter 24/LinqWithSqlMetalGenedCode/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("LinqWithSqlMetalGenedCode.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/Code/Chapter 24/LinqWithSqlMetalGenedCode/My Project/Resources.resx b/Code/Chapter 24/LinqWithSqlMetalGenedCode/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 24/LinqWithSqlMetalGenedCode/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/Code/Chapter 24/LinqWithSqlMetalGenedCode/My Project/Settings.Designer.vb b/Code/Chapter 24/LinqWithSqlMetalGenedCode/My Project/Settings.Designer.vb new file mode 100644 index 0000000..77b857c --- /dev/null +++ b/Code/Chapter 24/LinqWithSqlMetalGenedCode/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.LinqWithSqlMetalGenedCode.My.MySettings + Get + Return Global.LinqWithSqlMetalGenedCode.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 24/LinqWithSqlMetalGenedCode/My Project/Settings.settings b/Code/Chapter 24/LinqWithSqlMetalGenedCode/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 24/LinqWithSqlMetalGenedCode/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 24/LinqWithSqlMetalGenedCode/Program.vb b/Code/Chapter 24/LinqWithSqlMetalGenedCode/Program.vb new file mode 100644 index 0000000..42bd762 --- /dev/null +++ b/Code/Chapter 24/LinqWithSqlMetalGenedCode/Program.vb @@ -0,0 +1,56 @@ +Imports LinqWithSqlMetalGenedCode.AutoLotDatabase + +Module Program + Const cnStr As String = "Data Source=(local)\SQLEXPRESS;" & _ + "Initial Catalog=AutoLot;Integrated Security=True" + + Sub Main() + Console.WriteLine("***** More Fun with LINQ to SQL *****" & vbLf) + Dim carsDB As New AutoLot(cnStr) + + InvokeStoredProc(carsDB) + PrintOrderForCustomer(carsDB) + + Console.ReadLine() + End Sub + +#Region "Invoke stored proc" + Sub InvokeStoredProc(ByVal carsDB As AutoLot) + Dim carID As Integer = 0 + Dim petName As String = "" + Console.Write("Enter ID: ") + carID = Integer.Parse(Console.ReadLine()) + + ' Invoke stored proc and print out the petname. + carsDB.GetPetName(carID, petName) + Console.WriteLine("Car ID {0} has the petname: {1}", carID, petName) + End Sub +#End Region + +#Region "Printer order for customer" + Sub PrintOrderForCustomer(ByVal carsDB As AutoLot) + Dim custID As Integer = 0 + Console.Write("Enter customer ID: ") + custID = Integer.Parse(Console.ReadLine()) + + Dim customerOrders = _ + From cust In carsDB.Customers _ + From o In cust.Orders _ + Where cust.CustID = custID _ + Select New With {cust, o} + + Console.WriteLine("***** Order Info for Customer ID: {0}. *****", custID) + For Each q In customerOrders + + Console.WriteLine("{0} {1} is order ID # {2}.", _ + q.cust.FirstName.Trim(), _ + q.cust.LastName.Trim(), _ + q.o.OrderID) + Console.WriteLine("{0} bought Car ID # {1}.", _ + q.cust.FirstName.Trim(), q.o.CarID) + Next + Console.WriteLine("customerOrders as a string: {0}", customerOrders) + End Sub +#End Region + +End Module diff --git a/Code/Chapter 24/LinqWithSqlMetalGenedCode/autoLotDB.vb b/Code/Chapter 24/LinqWithSqlMetalGenedCode/autoLotDB.vb new file mode 100644 index 0000000..cf59658 --- /dev/null +++ b/Code/Chapter 24/LinqWithSqlMetalGenedCode/autoLotDB.vb @@ -0,0 +1,821 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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 +Imports System.Collections.Generic +Imports System.ComponentModel +Imports System.Data +Imports System.Data.Linq +Imports System.Data.Linq.Mapping +Imports System.Linq +Imports System.Linq.Expressions +Imports System.Reflection + +Namespace AutoLotDatabase + + Partial Public Class AutoLot + Inherits System.Data.Linq.DataContext + + Private Shared mappingSource As System.Data.Linq.Mapping.MappingSource = New AttributeMappingSource + + #Region "Extensibility Method Definitions" + Partial Private Sub OnCreated() + End Sub + Partial Private Sub InsertCreditRisks(instance As CreditRisks) + End Sub + Partial Private Sub UpdateCreditRisks(instance As CreditRisks) + End Sub + Partial Private Sub DeleteCreditRisks(instance As CreditRisks) + End Sub + Partial Private Sub InsertCustomers(instance As Customers) + End Sub + Partial Private Sub UpdateCustomers(instance As Customers) + End Sub + Partial Private Sub DeleteCustomers(instance As Customers) + End Sub + Partial Private Sub InsertInventory(instance As Inventory) + End Sub + Partial Private Sub UpdateInventory(instance As Inventory) + End Sub + Partial Private Sub DeleteInventory(instance As Inventory) + End Sub + Partial Private Sub InsertOrders(instance As Orders) + End Sub + Partial Private Sub UpdateOrders(instance As Orders) + End Sub + Partial Private Sub DeleteOrders(instance As Orders) + End Sub + #End Region + + Public Sub New(ByVal connection As String) + MyBase.New(connection, mappingSource) + OnCreated + End Sub + + Public Sub New(ByVal connection As System.Data.IDbConnection) + MyBase.New(connection, mappingSource) + OnCreated + End Sub + + Public Sub New(ByVal connection As String, ByVal mappingSource As System.Data.Linq.Mapping.MappingSource) + MyBase.New(connection, mappingSource) + OnCreated + End Sub + + Public Sub New(ByVal connection As System.Data.IDbConnection, ByVal mappingSource As System.Data.Linq.Mapping.MappingSource) + MyBase.New(connection, mappingSource) + OnCreated + End Sub + + Public ReadOnly Property CreditRisks() As System.Data.Linq.Table(Of CreditRisks) + Get + Return Me.GetTable(Of CreditRisks) + End Get + End Property + + Public ReadOnly Property Customers() As System.Data.Linq.Table(Of Customers) + Get + Return Me.GetTable(Of Customers) + End Get + End Property + + Public ReadOnly Property Inventory() As System.Data.Linq.Table(Of Inventory) + Get + Return Me.GetTable(Of Inventory) + End Get + End Property + + Public ReadOnly Property Orders() As System.Data.Linq.Table(Of Orders) + Get + Return Me.GetTable(Of Orders) + End Get + End Property + + _ + Public Function GetPetName( ByVal carID As System.Nullable(Of Integer), ByRef petName As String) As Integer + Dim result As IExecuteResult = Me.ExecuteMethodCall(Me, CType(MethodInfo.GetCurrentMethod,MethodInfo), carID, petName) + petName = CType(result.GetParameterValue(1),String) + Return CType(result.ReturnValue,Integer) + End Function + + _ + Public Function Sp_alterdiagram( ByVal diagramname As String, ByVal owner_id As System.Nullable(Of Integer), ByVal version As System.Nullable(Of Integer), ByVal definition As System.Data.Linq.Binary) As Integer + Dim result As IExecuteResult = Me.ExecuteMethodCall(Me, CType(MethodInfo.GetCurrentMethod,MethodInfo), diagramname, owner_id, version, definition) + Return CType(result.ReturnValue,Integer) + End Function + + _ + Public Function Sp_creatediagram( ByVal diagramname As String, ByVal owner_id As System.Nullable(Of Integer), ByVal version As System.Nullable(Of Integer), ByVal definition As System.Data.Linq.Binary) As Integer + Dim result As IExecuteResult = Me.ExecuteMethodCall(Me, CType(MethodInfo.GetCurrentMethod,MethodInfo), diagramname, owner_id, version, definition) + Return CType(result.ReturnValue,Integer) + End Function + + _ + Public Function Sp_dropdiagram( ByVal diagramname As String, ByVal owner_id As System.Nullable(Of Integer)) As Integer + Dim result As IExecuteResult = Me.ExecuteMethodCall(Me, CType(MethodInfo.GetCurrentMethod,MethodInfo), diagramname, owner_id) + Return CType(result.ReturnValue,Integer) + End Function + + _ + Public Function Sp_helpdiagramdefinition( ByVal diagramname As String, ByVal owner_id As System.Nullable(Of Integer)) As ISingleResult(Of Sp_helpdiagramdefinitionResult) + Dim result As IExecuteResult = Me.ExecuteMethodCall(Me, CType(MethodInfo.GetCurrentMethod,MethodInfo), diagramname, owner_id) + Return CType(result.ReturnValue,ISingleResult(Of Sp_helpdiagramdefinitionResult)) + End Function + + _ + Public Function Sp_helpdiagrams( ByVal diagramname As String, ByVal owner_id As System.Nullable(Of Integer)) As ISingleResult(Of Sp_helpdiagramsResult) + Dim result As IExecuteResult = Me.ExecuteMethodCall(Me, CType(MethodInfo.GetCurrentMethod,MethodInfo), diagramname, owner_id) + Return CType(result.ReturnValue,ISingleResult(Of Sp_helpdiagramsResult)) + End Function + + _ + Public Function Sp_renamediagram( ByVal diagramname As String, ByVal owner_id As System.Nullable(Of Integer), ByVal new_diagramname As String) As Integer + Dim result As IExecuteResult = Me.ExecuteMethodCall(Me, CType(MethodInfo.GetCurrentMethod,MethodInfo), diagramname, owner_id, new_diagramname) + Return CType(result.ReturnValue,Integer) + End Function + End Class + + _ + Partial Public Class CreditRisks + Implements System.ComponentModel.INotifyPropertyChanging, System.ComponentModel.INotifyPropertyChanged + + Private Shared emptyChangingEventArgs As PropertyChangingEventArgs = New PropertyChangingEventArgs(String.Empty) + + Private _CustID As Integer + + Private _FirstName As String + + Private _LastName As String + + #Region "Extensibility Method Definitions" + Partial Private Sub OnLoaded() + End Sub + Partial Private Sub OnValidate(action As System.Data.Linq.ChangeAction) + End Sub + Partial Private Sub OnCreated() + End Sub + Partial Private Sub OnCustIDChanging(value As Integer) + End Sub + Partial Private Sub OnCustIDChanged() + End Sub + Partial Private Sub OnFirstNameChanging(value As String) + End Sub + Partial Private Sub OnFirstNameChanged() + End Sub + Partial Private Sub OnLastNameChanging(value As String) + End Sub + Partial Private Sub OnLastNameChanged() + End Sub + #End Region + + Public Sub New() + MyBase.New + OnCreated + End Sub + + _ + Public Property CustID() As Integer + Get + Return Me._CustID + End Get + Set + If ((Me._CustID = value) _ + = false) Then + Me.OnCustIDChanging(value) + Me.SendPropertyChanging + Me._CustID = value + Me.SendPropertyChanged("CustID") + Me.OnCustIDChanged + End If + End Set + End Property + + _ + Public Property FirstName() As String + Get + Return Me._FirstName + End Get + Set + If (String.Equals(Me._FirstName, value) = false) Then + Me.OnFirstNameChanging(value) + Me.SendPropertyChanging + Me._FirstName = value + Me.SendPropertyChanged("FirstName") + Me.OnFirstNameChanged + End If + End Set + End Property + + _ + Public Property LastName() As String + Get + Return Me._LastName + End Get + Set + If (String.Equals(Me._LastName, value) = false) Then + Me.OnLastNameChanging(value) + Me.SendPropertyChanging + Me._LastName = value + Me.SendPropertyChanged("LastName") + Me.OnLastNameChanged + End If + End Set + End Property + + Public Event PropertyChanging As PropertyChangingEventHandler Implements System.ComponentModel.INotifyPropertyChanging.PropertyChanging + + Public Event PropertyChanged As PropertyChangedEventHandler Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged + + Protected Overridable Sub SendPropertyChanging() + If ((Me.PropertyChangingEvent Is Nothing) _ + = false) Then + RaiseEvent PropertyChanging(Me, emptyChangingEventArgs) + End If + End Sub + + Protected Overridable Sub SendPropertyChanged(ByVal propertyName As [String]) + If ((Me.PropertyChangedEvent Is Nothing) _ + = false) Then + RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName)) + End If + End Sub + End Class + + _ + Partial Public Class Customers + Implements System.ComponentModel.INotifyPropertyChanging, System.ComponentModel.INotifyPropertyChanged + + Private Shared emptyChangingEventArgs As PropertyChangingEventArgs = New PropertyChangingEventArgs(String.Empty) + + Private _CustID As Integer + + Private _FirstName As String + + Private _LastName As String + + Private _Orders As EntitySet(Of Orders) + + #Region "Extensibility Method Definitions" + Partial Private Sub OnLoaded() + End Sub + Partial Private Sub OnValidate(action As System.Data.Linq.ChangeAction) + End Sub + Partial Private Sub OnCreated() + End Sub + Partial Private Sub OnCustIDChanging(value As Integer) + End Sub + Partial Private Sub OnCustIDChanged() + End Sub + Partial Private Sub OnFirstNameChanging(value As String) + End Sub + Partial Private Sub OnFirstNameChanged() + End Sub + Partial Private Sub OnLastNameChanging(value As String) + End Sub + Partial Private Sub OnLastNameChanged() + End Sub + #End Region + + Public Sub New() + MyBase.New + Me._Orders = New EntitySet(Of Orders)(AddressOf Me.attach_Orders, AddressOf Me.detach_Orders) + OnCreated + End Sub + + _ + Public Property CustID() As Integer + Get + Return Me._CustID + End Get + Set + If ((Me._CustID = value) _ + = false) Then + Me.OnCustIDChanging(value) + Me.SendPropertyChanging + Me._CustID = value + Me.SendPropertyChanged("CustID") + Me.OnCustIDChanged + End If + End Set + End Property + + _ + Public Property FirstName() As String + Get + Return Me._FirstName + End Get + Set + If (String.Equals(Me._FirstName, value) = false) Then + Me.OnFirstNameChanging(value) + Me.SendPropertyChanging + Me._FirstName = value + Me.SendPropertyChanged("FirstName") + Me.OnFirstNameChanged + End If + End Set + End Property + + _ + Public Property LastName() As String + Get + Return Me._LastName + End Get + Set + If (String.Equals(Me._LastName, value) = false) Then + Me.OnLastNameChanging(value) + Me.SendPropertyChanging + Me._LastName = value + Me.SendPropertyChanged("LastName") + Me.OnLastNameChanged + End If + End Set + End Property + + _ + Public Property Orders() As EntitySet(Of Orders) + Get + Return Me._Orders + End Get + Set + Me._Orders.Assign(value) + End Set + End Property + + Public Event PropertyChanging As PropertyChangingEventHandler Implements System.ComponentModel.INotifyPropertyChanging.PropertyChanging + + Public Event PropertyChanged As PropertyChangedEventHandler Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged + + Protected Overridable Sub SendPropertyChanging() + If ((Me.PropertyChangingEvent Is Nothing) _ + = false) Then + RaiseEvent PropertyChanging(Me, emptyChangingEventArgs) + End If + End Sub + + Protected Overridable Sub SendPropertyChanged(ByVal propertyName As [String]) + If ((Me.PropertyChangedEvent Is Nothing) _ + = false) Then + RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName)) + End If + End Sub + + Private Sub attach_Orders(ByVal entity As Orders) + Me.SendPropertyChanging + entity.Customers = Me + End Sub + + Private Sub detach_Orders(ByVal entity As Orders) + Me.SendPropertyChanging + entity.Customers = Nothing + End Sub + End Class + + _ + Partial Public Class Inventory + Implements System.ComponentModel.INotifyPropertyChanging, System.ComponentModel.INotifyPropertyChanged + + Private Shared emptyChangingEventArgs As PropertyChangingEventArgs = New PropertyChangingEventArgs(String.Empty) + + Private _CarID As Integer + + Private _Make As String + + Private _Color As String + + Private _PetName As String + + Private _Orders As EntitySet(Of Orders) + + #Region "Extensibility Method Definitions" + Partial Private Sub OnLoaded() + End Sub + Partial Private Sub OnValidate(action As System.Data.Linq.ChangeAction) + End Sub + Partial Private Sub OnCreated() + End Sub + Partial Private Sub OnCarIDChanging(value As Integer) + End Sub + Partial Private Sub OnCarIDChanged() + End Sub + Partial Private Sub OnMakeChanging(value As String) + End Sub + Partial Private Sub OnMakeChanged() + End Sub + Partial Private Sub OnColorChanging(value As String) + End Sub + Partial Private Sub OnColorChanged() + End Sub + Partial Private Sub OnPetNameChanging(value As String) + End Sub + Partial Private Sub OnPetNameChanged() + End Sub + #End Region + + Public Sub New() + MyBase.New + Me._Orders = New EntitySet(Of Orders)(AddressOf Me.attach_Orders, AddressOf Me.detach_Orders) + OnCreated + End Sub + + _ + Public Property CarID() As Integer + Get + Return Me._CarID + End Get + Set + If ((Me._CarID = value) _ + = false) Then + Me.OnCarIDChanging(value) + Me.SendPropertyChanging + Me._CarID = value + Me.SendPropertyChanged("CarID") + Me.OnCarIDChanged + End If + End Set + End Property + + _ + Public Property Make() As String + Get + Return Me._Make + End Get + Set + If (String.Equals(Me._Make, value) = false) Then + Me.OnMakeChanging(value) + Me.SendPropertyChanging + Me._Make = value + Me.SendPropertyChanged("Make") + Me.OnMakeChanged + End If + End Set + End Property + + _ + Public Property Color() As String + Get + Return Me._Color + End Get + Set + If (String.Equals(Me._Color, value) = false) Then + Me.OnColorChanging(value) + Me.SendPropertyChanging + Me._Color = value + Me.SendPropertyChanged("Color") + Me.OnColorChanged + End If + End Set + End Property + + _ + Public Property PetName() As String + Get + Return Me._PetName + End Get + Set + If (String.Equals(Me._PetName, value) = false) Then + Me.OnPetNameChanging(value) + Me.SendPropertyChanging + Me._PetName = value + Me.SendPropertyChanged("PetName") + Me.OnPetNameChanged + End If + End Set + End Property + + _ + Public Property Orders() As EntitySet(Of Orders) + Get + Return Me._Orders + End Get + Set + Me._Orders.Assign(value) + End Set + End Property + + Public Event PropertyChanging As PropertyChangingEventHandler Implements System.ComponentModel.INotifyPropertyChanging.PropertyChanging + + Public Event PropertyChanged As PropertyChangedEventHandler Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged + + Protected Overridable Sub SendPropertyChanging() + If ((Me.PropertyChangingEvent Is Nothing) _ + = false) Then + RaiseEvent PropertyChanging(Me, emptyChangingEventArgs) + End If + End Sub + + Protected Overridable Sub SendPropertyChanged(ByVal propertyName As [String]) + If ((Me.PropertyChangedEvent Is Nothing) _ + = false) Then + RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName)) + End If + End Sub + + Private Sub attach_Orders(ByVal entity As Orders) + Me.SendPropertyChanging + entity.Inventory = Me + End Sub + + Private Sub detach_Orders(ByVal entity As Orders) + Me.SendPropertyChanging + entity.Inventory = Nothing + End Sub + End Class + + _ + Partial Public Class Orders + Implements System.ComponentModel.INotifyPropertyChanging, System.ComponentModel.INotifyPropertyChanged + + Private Shared emptyChangingEventArgs As PropertyChangingEventArgs = New PropertyChangingEventArgs(String.Empty) + + Private _OrderID As Integer + + Private _CustID As Integer + + Private _CarID As Integer + + Private _Customers As EntityRef(Of Customers) + + Private _Inventory As EntityRef(Of Inventory) + + #Region "Extensibility Method Definitions" + Partial Private Sub OnLoaded() + End Sub + Partial Private Sub OnValidate(action As System.Data.Linq.ChangeAction) + End Sub + Partial Private Sub OnCreated() + End Sub + Partial Private Sub OnOrderIDChanging(value As Integer) + End Sub + Partial Private Sub OnOrderIDChanged() + End Sub + Partial Private Sub OnCustIDChanging(value As Integer) + End Sub + Partial Private Sub OnCustIDChanged() + End Sub + Partial Private Sub OnCarIDChanging(value As Integer) + End Sub + Partial Private Sub OnCarIDChanged() + End Sub + #End Region + + Public Sub New() + MyBase.New + Me._Customers = CType(Nothing, EntityRef(Of Customers)) + Me._Inventory = CType(Nothing, EntityRef(Of Inventory)) + OnCreated + End Sub + + _ + Public Property OrderID() As Integer + Get + Return Me._OrderID + End Get + Set + If ((Me._OrderID = value) _ + = false) Then + Me.OnOrderIDChanging(value) + Me.SendPropertyChanging + Me._OrderID = value + Me.SendPropertyChanged("OrderID") + Me.OnOrderIDChanged + End If + End Set + End Property + + _ + Public Property CustID() As Integer + Get + Return Me._CustID + End Get + Set + If ((Me._CustID = value) _ + = false) Then + If Me._Customers.HasLoadedOrAssignedValue Then + Throw New System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException + End If + Me.OnCustIDChanging(value) + Me.SendPropertyChanging + Me._CustID = value + Me.SendPropertyChanged("CustID") + Me.OnCustIDChanged + End If + End Set + End Property + + _ + Public Property CarID() As Integer + Get + Return Me._CarID + End Get + Set + If ((Me._CarID = value) _ + = false) Then + If Me._Inventory.HasLoadedOrAssignedValue Then + Throw New System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException + End If + Me.OnCarIDChanging(value) + Me.SendPropertyChanging + Me._CarID = value + Me.SendPropertyChanged("CarID") + Me.OnCarIDChanged + End If + End Set + End Property + + _ + Public Property Customers() As Customers + Get + Return Me._Customers.Entity + End Get + Set + Dim previousValue As Customers = Me._Customers.Entity + If ((Object.Equals(previousValue, value) = false) _ + OrElse (Me._Customers.HasLoadedOrAssignedValue = false)) Then + Me.SendPropertyChanging + If ((previousValue Is Nothing) _ + = false) Then + Me._Customers.Entity = Nothing + previousValue.Orders.Remove(Me) + End If + Me._Customers.Entity = value + If ((value Is Nothing) _ + = false) Then + value.Orders.Add(Me) + Me._CustID = value.CustID + Else + Me._CustID = CType(Nothing, Integer) + End If + Me.SendPropertyChanged("Customers") + End If + End Set + End Property + + _ + Public Property Inventory() As Inventory + Get + Return Me._Inventory.Entity + End Get + Set + Dim previousValue As Inventory = Me._Inventory.Entity + If ((Object.Equals(previousValue, value) = false) _ + OrElse (Me._Inventory.HasLoadedOrAssignedValue = false)) Then + Me.SendPropertyChanging + If ((previousValue Is Nothing) _ + = false) Then + Me._Inventory.Entity = Nothing + previousValue.Orders.Remove(Me) + End If + Me._Inventory.Entity = value + If ((value Is Nothing) _ + = false) Then + value.Orders.Add(Me) + Me._CarID = value.CarID + Else + Me._CarID = CType(Nothing, Integer) + End If + Me.SendPropertyChanged("Inventory") + End If + End Set + End Property + + Public Event PropertyChanging As PropertyChangingEventHandler Implements System.ComponentModel.INotifyPropertyChanging.PropertyChanging + + Public Event PropertyChanged As PropertyChangedEventHandler Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged + + Protected Overridable Sub SendPropertyChanging() + If ((Me.PropertyChangingEvent Is Nothing) _ + = false) Then + RaiseEvent PropertyChanging(Me, emptyChangingEventArgs) + End If + End Sub + + Protected Overridable Sub SendPropertyChanged(ByVal propertyName As [String]) + If ((Me.PropertyChangedEvent Is Nothing) _ + = false) Then + RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName)) + End If + End Sub + End Class + + Partial Public Class Sp_helpdiagramdefinitionResult + + Private _Version As System.Nullable(Of Integer) + + Private _Definition As System.Data.Linq.Binary + + Public Sub New() + MyBase.New + End Sub + + _ + Public Property Version() As System.Nullable(Of Integer) + Get + Return Me._Version + End Get + Set + If (Me._Version.Equals(value) = false) Then + Me._Version = value + End If + End Set + End Property + + _ + Public Property Definition() As System.Data.Linq.Binary + Get + Return Me._Definition + End Get + Set + If (Object.Equals(Me._Definition, value) = false) Then + Me._Definition = value + End If + End Set + End Property + End Class + + Partial Public Class Sp_helpdiagramsResult + + Private _Database As String + + Private _Name As String + + Private _ID As System.Nullable(Of Integer) + + Private _Owner As String + + Private _OwnerID As System.Nullable(Of Integer) + + Public Sub New() + MyBase.New + End Sub + + _ + Public Property Database() As String + Get + Return Me._Database + End Get + Set + If (String.Equals(Me._Database, value) = false) Then + Me._Database = value + End If + End Set + End Property + + _ + Public Property Name() As String + Get + Return Me._Name + End Get + Set + If (String.Equals(Me._Name, value) = false) Then + Me._Name = value + End If + End Set + End Property + + _ + Public Property ID() As System.Nullable(Of Integer) + Get + Return Me._ID + End Get + Set + If (Me._ID.Equals(value) = false) Then + Me._ID = value + End If + End Set + End Property + + _ + Public Property Owner() As String + Get + Return Me._Owner + End Get + Set + If (String.Equals(Me._Owner, value) = false) Then + Me._Owner = value + End If + End Set + End Property + + _ + Public Property OwnerID() As System.Nullable(Of Integer) + Get + Return Me._OwnerID + End Get + Set + If (Me._OwnerID.Equals(value) = false) Then + Me._OwnerID = value + End If + End Set + End Property + End Class +End Namespace diff --git a/Code/Chapter 24/NavigationWithAxisProperties/Inventory.xml b/Code/Chapter 24/NavigationWithAxisProperties/Inventory.xml new file mode 100644 index 0000000..a338452 --- /dev/null +++ b/Code/Chapter 24/NavigationWithAxisProperties/Inventory.xml @@ -0,0 +1,28 @@ + + + + Ford + Blue + Chuck + + + VW + Silver + Mary + + + Yugo + Pink + Gipper + + + Ford + Yellow + Max + + + BMW + Black + Zippy + + diff --git a/Code/Chapter 24/NavigationWithAxisProperties/My Project/Application.Designer.vb b/Code/Chapter 24/NavigationWithAxisProperties/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 24/NavigationWithAxisProperties/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 24/NavigationWithAxisProperties/My Project/Application.myapp b/Code/Chapter 24/NavigationWithAxisProperties/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 24/NavigationWithAxisProperties/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 24/NavigationWithAxisProperties/My Project/AssemblyInfo.vb b/Code/Chapter 24/NavigationWithAxisProperties/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..7c2d8ac --- /dev/null +++ b/Code/Chapter 24/NavigationWithAxisProperties/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/Code/Chapter 24/NavigationWithAxisProperties/My Project/Resources.Designer.vb b/Code/Chapter 24/NavigationWithAxisProperties/My Project/Resources.Designer.vb new file mode 100644 index 0000000..0518ae7 --- /dev/null +++ b/Code/Chapter 24/NavigationWithAxisProperties/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("NavigationWithAxisProperties.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/Code/Chapter 24/NavigationWithAxisProperties/My Project/Resources.resx b/Code/Chapter 24/NavigationWithAxisProperties/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 24/NavigationWithAxisProperties/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/Code/Chapter 24/NavigationWithAxisProperties/My Project/Settings.Designer.vb b/Code/Chapter 24/NavigationWithAxisProperties/My Project/Settings.Designer.vb new file mode 100644 index 0000000..a7c4a6c --- /dev/null +++ b/Code/Chapter 24/NavigationWithAxisProperties/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.NavigationWithAxisProperties.My.MySettings + Get + Return Global.NavigationWithAxisProperties.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 24/NavigationWithAxisProperties/My Project/Settings.settings b/Code/Chapter 24/NavigationWithAxisProperties/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 24/NavigationWithAxisProperties/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 24/NavigationWithAxisProperties/NavigationWithAxisProperties.sln b/Code/Chapter 24/NavigationWithAxisProperties/NavigationWithAxisProperties.sln new file mode 100644 index 0000000..62d3e23 --- /dev/null +++ b/Code/Chapter 24/NavigationWithAxisProperties/NavigationWithAxisProperties.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "NavigationWithAxisProperties", "NavigationWithAxisProperties.vbproj", "{27B768CA-F75F-4D0A-9DAE-5A92F35C723E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {27B768CA-F75F-4D0A-9DAE-5A92F35C723E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {27B768CA-F75F-4D0A-9DAE-5A92F35C723E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {27B768CA-F75F-4D0A-9DAE-5A92F35C723E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {27B768CA-F75F-4D0A-9DAE-5A92F35C723E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 24/NavigationWithAxisProperties/NavigationWithAxisProperties.suo b/Code/Chapter 24/NavigationWithAxisProperties/NavigationWithAxisProperties.suo new file mode 100644 index 0000000..00ea0cf Binary files /dev/null and b/Code/Chapter 24/NavigationWithAxisProperties/NavigationWithAxisProperties.suo differ diff --git a/Code/Chapter 24/NavigationWithAxisProperties/NavigationWithAxisProperties.vbproj b/Code/Chapter 24/NavigationWithAxisProperties/NavigationWithAxisProperties.vbproj new file mode 100644 index 0000000..f812398 --- /dev/null +++ b/Code/Chapter 24/NavigationWithAxisProperties/NavigationWithAxisProperties.vbproj @@ -0,0 +1,114 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {27B768CA-F75F-4D0A-9DAE-5A92F35C723E} + Exe + NavigationWithAxisProperties.Program + NavigationWithAxisProperties + NavigationWithAxisProperties + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + NavigationWithAxisProperties.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + NavigationWithAxisProperties.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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 + + + + + Always + + + + + \ No newline at end of file diff --git a/Code/Chapter 24/NavigationWithAxisProperties/Program.vb b/Code/Chapter 24/NavigationWithAxisProperties/Program.vb new file mode 100644 index 0000000..a80ee77 --- /dev/null +++ b/Code/Chapter 24/NavigationWithAxisProperties/Program.vb @@ -0,0 +1,66 @@ +Module Program + + Sub Main() + Console.WriteLine("***** Fun with XML Axis Properties *****") + + ' Load the Inventory.xml document into memory. + Dim doc As XElement = XElement.Load("Inventory.xml") + + ' We will author each of these next... + PrintAllPetNames(doc) + Console.WriteLine() + GetAllFords(doc) + + Console.WriteLine() + GetAllIds(doc) + + Console.WriteLine() + PrintAllColors(doc) + + Console.ReadLine() + End Sub + +#Region "Helper methods" + Sub PrintAllPetNames(ByVal doc As XElement) + ' Use XML descendant axis property to + ' navigate to sub-element. + Dim petNames = From pn In doc... _ + Select pn.Value + + For Each name In petNames + Console.WriteLine("Name: {0}", name) + Next + End Sub + + Sub GetAllFords(ByVal doc As XElement) + Dim fords = From c In doc... _ + Where c.Value = "Ford" _ + Select c + + For Each f In fords + Console.WriteLine("Make: {0}", f) + Next + End Sub + + Sub GetAllIds(ByVal doc As XElement) + ' Navigate to element and + ' get carID attribute. + Dim ids = From c In doc. _ + Select c.@carID + + For Each id In ids + Console.WriteLine(id) + Next + End Sub + + Sub PrintAllColors(ByVal doc As XElement) + ' Get value of each color using indexer. + For i As Integer = 0 To doc.Nodes.Count - 1 + Console.WriteLine(doc.(i)..Value) + Next + End Sub + + +#End Region + +End Module diff --git a/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/Inventory.xml b/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/Inventory.xml new file mode 100644 index 0000000..a338452 --- /dev/null +++ b/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/Inventory.xml @@ -0,0 +1,28 @@ + + + + Ford + Blue + Chuck + + + VW + Silver + Mary + + + Yugo + Pink + Gipper + + + Ford + Yellow + Max + + + BMW + Black + Zippy + + diff --git a/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/My Project/Application.Designer.vb b/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/My Project/Application.myapp b/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/My Project/AssemblyInfo.vb b/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..f3c2c06 --- /dev/null +++ b/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/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/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/My Project/Resources.Designer.vb b/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/My Project/Resources.Designer.vb new file mode 100644 index 0000000..f8ee011 --- /dev/null +++ b/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("NavigationWithLinqToXmlObjectModel.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/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/My Project/Resources.resx b/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/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/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/My Project/Settings.Designer.vb b/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/My Project/Settings.Designer.vb new file mode 100644 index 0000000..36ae2f4 --- /dev/null +++ b/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.NavigationWithLinqToXmlObjectModel.My.MySettings + Get + Return Global.NavigationWithLinqToXmlObjectModel.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/My Project/Settings.settings b/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/NavigationWithLinqToXmlObjectModel.sln b/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/NavigationWithLinqToXmlObjectModel.sln new file mode 100644 index 0000000..c1e5337 --- /dev/null +++ b/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/NavigationWithLinqToXmlObjectModel.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "NavigationWithLinqToXmlObjectModel", "NavigationWithLinqToXmlObjectModel.vbproj", "{83FC8A79-8A85-449D-A9A2-69A32158648D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {83FC8A79-8A85-449D-A9A2-69A32158648D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {83FC8A79-8A85-449D-A9A2-69A32158648D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {83FC8A79-8A85-449D-A9A2-69A32158648D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {83FC8A79-8A85-449D-A9A2-69A32158648D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/NavigationWithLinqToXmlObjectModel.suo b/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/NavigationWithLinqToXmlObjectModel.suo new file mode 100644 index 0000000..553c894 Binary files /dev/null and b/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/NavigationWithLinqToXmlObjectModel.suo differ diff --git a/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/NavigationWithLinqToXmlObjectModel.vbproj b/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/NavigationWithLinqToXmlObjectModel.vbproj new file mode 100644 index 0000000..f5b0402 --- /dev/null +++ b/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/NavigationWithLinqToXmlObjectModel.vbproj @@ -0,0 +1,114 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {83FC8A79-8A85-449D-A9A2-69A32158648D} + Exe + NavigationWithLinqToXmlObjectModel.Program + NavigationWithLinqToXmlObjectModel + NavigationWithLinqToXmlObjectModel + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + NavigationWithLinqToXmlObjectModel.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + NavigationWithLinqToXmlObjectModel.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + 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 + + + + + Always + + + + + \ No newline at end of file diff --git a/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/Program.vb b/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/Program.vb new file mode 100644 index 0000000..c9a4e28 --- /dev/null +++ b/Code/Chapter 24/NavigationWithLinqToXmlObjectModel/Program.vb @@ -0,0 +1,57 @@ +Module Program + + Sub Main() + Console.WriteLine("***** Fun with LINQ to XML *****") + + ' Load the Inventory.xml document into memory. + Dim doc As XElement = XElement.Load("Inventory.xml") + + ' We will author each of these next... + PrintAllPetNames(doc) + Console.WriteLine() + GetAllFords(doc) + + Console.WriteLine() + AddNewElements(doc) + + Console.ReadLine() + End Sub + +#Region "Helper methods" + Sub PrintAllPetNames(ByVal doc As XElement) + Dim petNames = From pn In doc.Descendants("PetName") _ + Select pn.Value + + For Each name In petNames + Console.WriteLine("Name: {0}", name) + Next + End Sub + + Sub GetAllFords(ByVal doc As XElement) + Dim fords = From c In doc.Descendants("Make") _ + Where c.Value = "Ford" _ + Select c + + For Each f In fords + Console.WriteLine(f) + Next + End Sub + + Sub AddNewElements(ByVal doc As XElement) + For i As Integer = 0 To 4 + ' Add 5 new green Fords to the incoming document. + ' Create a new XElement + Dim newCar As New XElement("Car", _ + New XAttribute("ID", i + 1000), _ + New XElement("Color", "Green"), _ + New XElement("Make", "Ford"), _ + New XElement("PetName", "")) + ' Add to doc. + doc.Add(newCar) + Next + ' Show the updates. + Console.WriteLine(doc) + End Sub +#End Region + +End Module diff --git a/Code/Chapter 24/SimpleLinqToSqlApp/AutoLotDataContext.vb b/Code/Chapter 24/SimpleLinqToSqlApp/AutoLotDataContext.vb new file mode 100644 index 0000000..b823871 --- /dev/null +++ b/Code/Chapter 24/SimpleLinqToSqlApp/AutoLotDataContext.vb @@ -0,0 +1,14 @@ +Imports System.Data.Linq + +Class AutoLotDatabase + Inherits DataContext + + ' Define a member variable representing + ' the table in the database. + Public Inventory As Table(Of Inventory) + + ' Pass connection string to base class. + Public Sub New(ByVal connectionString As String) + MyBase.New(connectionString) + End Sub +End Class diff --git a/Code/Chapter 24/SimpleLinqToSqlApp/Inventory.vb b/Code/Chapter 24/SimpleLinqToSqlApp/Inventory.vb new file mode 100644 index 0000000..7820d4f --- /dev/null +++ b/Code/Chapter 24/SimpleLinqToSqlApp/Inventory.vb @@ -0,0 +1,21 @@ +Imports System.Data.Linq.Mapping + + _ +Public Class Inventory + _ + Public Make As String + _ + Public Color As String + _ + Public PetName As String + + ' Identify the primary key. + _ + Public CarID As Integer + + Public Overrides Function ToString() As String + Return String.Format("ID = {0}; Make = {1}; Color = {2}; PetName = {3}", _ + CarID, Make.Trim(), Color.Trim(), PetName.Trim()) + End Function +End Class + diff --git a/Code/Chapter 24/SimpleLinqToSqlApp/My Project/Application.Designer.vb b/Code/Chapter 24/SimpleLinqToSqlApp/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 24/SimpleLinqToSqlApp/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 24/SimpleLinqToSqlApp/My Project/Application.myapp b/Code/Chapter 24/SimpleLinqToSqlApp/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 24/SimpleLinqToSqlApp/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 24/SimpleLinqToSqlApp/My Project/AssemblyInfo.vb b/Code/Chapter 24/SimpleLinqToSqlApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..e0a2f04 --- /dev/null +++ b/Code/Chapter 24/SimpleLinqToSqlApp/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/Code/Chapter 24/SimpleLinqToSqlApp/My Project/Resources.Designer.vb b/Code/Chapter 24/SimpleLinqToSqlApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..06926ce --- /dev/null +++ b/Code/Chapter 24/SimpleLinqToSqlApp/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("SimpleLinqToSqlApp.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/Code/Chapter 24/SimpleLinqToSqlApp/My Project/Resources.resx b/Code/Chapter 24/SimpleLinqToSqlApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 24/SimpleLinqToSqlApp/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/Code/Chapter 24/SimpleLinqToSqlApp/My Project/Settings.Designer.vb b/Code/Chapter 24/SimpleLinqToSqlApp/My Project/Settings.Designer.vb new file mode 100644 index 0000000..a2e50a0 --- /dev/null +++ b/Code/Chapter 24/SimpleLinqToSqlApp/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SimpleLinqToSqlApp.My.MySettings + Get + Return Global.SimpleLinqToSqlApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 24/SimpleLinqToSqlApp/My Project/Settings.settings b/Code/Chapter 24/SimpleLinqToSqlApp/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 24/SimpleLinqToSqlApp/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 24/SimpleLinqToSqlApp/Program.vb b/Code/Chapter 24/SimpleLinqToSqlApp/Program.vb new file mode 100644 index 0000000..8b72864 --- /dev/null +++ b/Code/Chapter 24/SimpleLinqToSqlApp/Program.vb @@ -0,0 +1,42 @@ +Imports System.Data.Linq + +Module Program + Const cnStr As String = _ + "Data Source=(local)\SQLEXPRESS;Initial Catalog=AutoLot;" & _ + "Integrated Security=True" + + Sub Main() + Console.WriteLine("***** LINQ to SQL Sample App *****") + Console.WriteLine() + + ' Create a AutoLotDatabase object. + Dim db As New AutoLotDatabase(cnStr) + + ' Note we can now use the Inventory field of AutoLotDatabase. + Console.WriteLine("-> Contents of Inventory Table from AutoLot database:") + For Each car In From c In db.Inventory Select c + Console.WriteLine(car.ToString()) + Next + + Console.WriteLine() + ShowOnlyBimmers(db) + Console.ReadLine() + End Sub + +#Region "Show only BMWs" + Sub ShowOnlyBimmers(ByVal db As AutoLotDatabase) + Console.WriteLine("***** Only BMWs *****") + + ' Get the BMWs. + Dim bimmers = From s In db.Inventory _ + Where (s.Make = "BMW") _ + Order By s.CarID Select s + + For Each c In bimmers + Console.WriteLine(c.ToString()) + Next + End Sub +#End Region + +End Module + diff --git a/Code/Chapter 24/SimpleLinqToSqlApp/SimpleLinqToSqlApp.sln b/Code/Chapter 24/SimpleLinqToSqlApp/SimpleLinqToSqlApp.sln new file mode 100644 index 0000000..fb41877 --- /dev/null +++ b/Code/Chapter 24/SimpleLinqToSqlApp/SimpleLinqToSqlApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SimpleLinqToSqlApp", "SimpleLinqToSqlApp.vbproj", "{02E5820F-4DB7-4A5E-9F72-AB31362B3834}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {02E5820F-4DB7-4A5E-9F72-AB31362B3834}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {02E5820F-4DB7-4A5E-9F72-AB31362B3834}.Debug|Any CPU.Build.0 = Debug|Any CPU + {02E5820F-4DB7-4A5E-9F72-AB31362B3834}.Release|Any CPU.ActiveCfg = Release|Any CPU + {02E5820F-4DB7-4A5E-9F72-AB31362B3834}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 24/SimpleLinqToSqlApp/SimpleLinqToSqlApp.suo b/Code/Chapter 24/SimpleLinqToSqlApp/SimpleLinqToSqlApp.suo new file mode 100644 index 0000000..8159d58 Binary files /dev/null and b/Code/Chapter 24/SimpleLinqToSqlApp/SimpleLinqToSqlApp.suo differ diff --git a/Code/Chapter 24/SimpleLinqToSqlApp/SimpleLinqToSqlApp.vbproj b/Code/Chapter 24/SimpleLinqToSqlApp/SimpleLinqToSqlApp.vbproj new file mode 100644 index 0000000..cf4afde --- /dev/null +++ b/Code/Chapter 24/SimpleLinqToSqlApp/SimpleLinqToSqlApp.vbproj @@ -0,0 +1,114 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {02E5820F-4DB7-4A5E-9F72-AB31362B3834} + Exe + SimpleLinqToSqlApp.Program + SimpleLinqToSqlApp + SimpleLinqToSqlApp + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + SimpleLinqToSqlApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SimpleLinqToSqlApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + 3.5 + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + + + 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/Code/Chapter 24/SimpleXmlLiteral/My Project/Application.Designer.vb b/Code/Chapter 24/SimpleXmlLiteral/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 24/SimpleXmlLiteral/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 24/SimpleXmlLiteral/My Project/Application.myapp b/Code/Chapter 24/SimpleXmlLiteral/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 24/SimpleXmlLiteral/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 24/SimpleXmlLiteral/My Project/AssemblyInfo.vb b/Code/Chapter 24/SimpleXmlLiteral/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..71d988b --- /dev/null +++ b/Code/Chapter 24/SimpleXmlLiteral/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/Code/Chapter 24/SimpleXmlLiteral/My Project/Resources.Designer.vb b/Code/Chapter 24/SimpleXmlLiteral/My Project/Resources.Designer.vb new file mode 100644 index 0000000..35c36ec --- /dev/null +++ b/Code/Chapter 24/SimpleXmlLiteral/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("SimpleXmlLiteral.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/Code/Chapter 24/SimpleXmlLiteral/My Project/Resources.resx b/Code/Chapter 24/SimpleXmlLiteral/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 24/SimpleXmlLiteral/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/Code/Chapter 24/SimpleXmlLiteral/My Project/Settings.Designer.vb b/Code/Chapter 24/SimpleXmlLiteral/My Project/Settings.Designer.vb new file mode 100644 index 0000000..3b9caf1 --- /dev/null +++ b/Code/Chapter 24/SimpleXmlLiteral/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SimpleXmlLiteral.My.MySettings + Get + Return Global.SimpleXmlLiteral.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 24/SimpleXmlLiteral/My Project/Settings.settings b/Code/Chapter 24/SimpleXmlLiteral/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 24/SimpleXmlLiteral/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 24/SimpleXmlLiteral/Program.vb b/Code/Chapter 24/SimpleXmlLiteral/Program.vb new file mode 100644 index 0000000..4e9b83b --- /dev/null +++ b/Code/Chapter 24/SimpleXmlLiteral/Program.vb @@ -0,0 +1,21 @@ +Module Program + Sub Main() + + Dim interiorColor As String = "White" + Dim exteriorColor As String = "Blue" + + ' Note the 'inlined' code blocks. + Dim car1 As XElement = _ + + <%= GetPetName() %> + <%= interiorColor %> + <%= exteriorColor %> + + + Console.WriteLine(car1) + End Sub + + Function GetPetName() As String + Return "Sidd" + End Function +End Module diff --git a/Code/Chapter 24/SimpleXmlLiteral/SimpleXmlLiteral.sln b/Code/Chapter 24/SimpleXmlLiteral/SimpleXmlLiteral.sln new file mode 100644 index 0000000..28b6ce2 --- /dev/null +++ b/Code/Chapter 24/SimpleXmlLiteral/SimpleXmlLiteral.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SimpleXmlLiteral", "SimpleXmlLiteral.vbproj", "{0D7ABE92-840D-4B00-9CF2-BD743F6AC486}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0D7ABE92-840D-4B00-9CF2-BD743F6AC486}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0D7ABE92-840D-4B00-9CF2-BD743F6AC486}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0D7ABE92-840D-4B00-9CF2-BD743F6AC486}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0D7ABE92-840D-4B00-9CF2-BD743F6AC486}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 24/SimpleXmlLiteral/SimpleXmlLiteral.suo b/Code/Chapter 24/SimpleXmlLiteral/SimpleXmlLiteral.suo new file mode 100644 index 0000000..bb5ef94 Binary files /dev/null and b/Code/Chapter 24/SimpleXmlLiteral/SimpleXmlLiteral.suo differ diff --git a/Code/Chapter 24/SimpleXmlLiteral/SimpleXmlLiteral.vbproj b/Code/Chapter 24/SimpleXmlLiteral/SimpleXmlLiteral.vbproj new file mode 100644 index 0000000..6bcc923 --- /dev/null +++ b/Code/Chapter 24/SimpleXmlLiteral/SimpleXmlLiteral.vbproj @@ -0,0 +1,109 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {0D7ABE92-840D-4B00-9CF2-BD743F6AC486} + Exe + SimpleXmlLiteral.Program + SimpleXmlLiteral + SimpleXmlLiteral + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + SimpleXmlLiteral.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SimpleXmlLiteral.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 25/HelloWebService/HelloWebService.asmx b/Code/Chapter 25/HelloWebService/HelloWebService.asmx new file mode 100644 index 0000000..4cf3756 --- /dev/null +++ b/Code/Chapter 25/HelloWebService/HelloWebService.asmx @@ -0,0 +1,10 @@ +<%@ WebService Language="VB" Class="HelloWebService" %> +Imports System +Imports System.Web.Services + +Public Class HelloWebService + _ + Public Function HelloWorld() As String + Return "Hello World" + End Function +End Class diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/MagicEightBallServiceClient.sln b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/MagicEightBallServiceClient.sln new file mode 100644 index 0000000..ba94b58 --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/MagicEightBallServiceClient.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MagicEightBallServiceClient", "MagicEightBallServiceClient.vbproj", "{3C6B276C-B1B2-4CEB-BF6E-28012E90C887}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3C6B276C-B1B2-4CEB-BF6E-28012E90C887}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3C6B276C-B1B2-4CEB-BF6E-28012E90C887}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3C6B276C-B1B2-4CEB-BF6E-28012E90C887}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3C6B276C-B1B2-4CEB-BF6E-28012E90C887}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/MagicEightBallServiceClient.suo b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/MagicEightBallServiceClient.suo new file mode 100644 index 0000000..0ea041b Binary files /dev/null and b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/MagicEightBallServiceClient.suo differ diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/MagicEightBallServiceClient.vbproj b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/MagicEightBallServiceClient.vbproj new file mode 100644 index 0000000..a3704ed --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/MagicEightBallServiceClient.vbproj @@ -0,0 +1,143 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {3C6B276C-B1B2-4CEB-BF6E-28012E90C887} + Exe + MagicEightBallServiceClient.Program + MagicEightBallServiceClient + MagicEightBallServiceClient + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + MagicEightBallServiceClient.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + MagicEightBallServiceClient.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + 3.0 + + + 3.0 + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + True + True + Reference.svcmap + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + + + + + + + + + + + + + + + + + WCF Proxy Generator + Reference.vb + + + + + \ No newline at end of file diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/MagicEightBallServiceClient.vbproj.user b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/MagicEightBallServiceClient.vbproj.user new file mode 100644 index 0000000..6a34e7d --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/MagicEightBallServiceClient.vbproj.user @@ -0,0 +1,5 @@ + + + ShowAllFiles + + \ No newline at end of file diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/My Project/Application.Designer.vb b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/My Project/Application.myapp b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/My Project/AssemblyInfo.vb b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..6cc851a --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/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/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/My Project/Resources.Designer.vb b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/My Project/Resources.Designer.vb new file mode 100644 index 0000000..a993fcb --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("MagicEightBallServiceClient.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/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/My Project/Resources.resx b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/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/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/My Project/Settings.Designer.vb b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/My Project/Settings.Designer.vb new file mode 100644 index 0000000..92dbc18 --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.MagicEightBallServiceClient.My.MySettings + Get + Return Global.MagicEightBallServiceClient.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/My Project/Settings.settings b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Program.vb b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Program.vb new file mode 100644 index 0000000..96134ea --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Program.vb @@ -0,0 +1,15 @@ +Imports MagicEightBallServiceClient.ServiceReference1 + +Module Program + Sub Main() + Console.WriteLine("***** Ask the Magic 8 Ball *****" & Chr(10) & "") + + Using ball As New EightBallClient() + Console.Write("Your question: ") + Dim question As String = Console.ReadLine() + Dim answer As String = ball.ObtainAnswerToQuestion(question) + Console.WriteLine("8-Ball says: {0}", answer) + End Using + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Service References/ServiceReference1/MagicEightBallService.disco b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Service References/ServiceReference1/MagicEightBallService.disco new file mode 100644 index 0000000..1f46fc9 --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Service References/ServiceReference1/MagicEightBallService.disco @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Service References/ServiceReference1/MagicEightBallService.wsdl b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Service References/ServiceReference1/MagicEightBallService.wsdl new file mode 100644 index 0000000..eeaf6f2 --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Service References/ServiceReference1/MagicEightBallService.wsdl @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Service References/ServiceReference1/MagicEightBallService.xsd b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Service References/ServiceReference1/MagicEightBallService.xsd new file mode 100644 index 0000000..d00d787 --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Service References/ServiceReference1/MagicEightBallService.xsd @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Service References/ServiceReference1/MagicEightBallService1.wsdl b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Service References/ServiceReference1/MagicEightBallService1.wsdl new file mode 100644 index 0000000..857d7c1 --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Service References/ServiceReference1/MagicEightBallService1.wsdl @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Service References/ServiceReference1/MagicEightBallService1.xsd b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Service References/ServiceReference1/MagicEightBallService1.xsd new file mode 100644 index 0000000..27297d6 --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Service References/ServiceReference1/MagicEightBallService1.xsd @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Service References/ServiceReference1/Reference.svcmap b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Service References/ServiceReference1/Reference.svcmap new file mode 100644 index 0000000..53857e6 --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Service References/ServiceReference1/Reference.svcmap @@ -0,0 +1,32 @@ + + + + false + true + + false + false + false + + + true + Auto + true + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Service References/ServiceReference1/Reference.vb b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Service References/ServiceReference1/Reference.vb new file mode 100644 index 0000000..aa64bd1 --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Service References/ServiceReference1/Reference.vb @@ -0,0 +1,60 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace ServiceReference1 + + _ + Public Interface IEightBall + + _ + Function ObtainAnswerToQuestion(ByVal userQuestion As String) As String + End Interface + + _ + Public Interface IEightBallChannel + Inherits ServiceReference1.IEightBall, System.ServiceModel.IClientChannel + End Interface + + _ + Partial Public Class EightBallClient + Inherits System.ServiceModel.ClientBase(Of ServiceReference1.IEightBall) + Implements ServiceReference1.IEightBall + + Public Sub New() + MyBase.New + End Sub + + Public Sub New(ByVal endpointConfigurationName As String) + MyBase.New(endpointConfigurationName) + End Sub + + Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As String) + MyBase.New(endpointConfigurationName, remoteAddress) + End Sub + + Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As System.ServiceModel.EndpointAddress) + MyBase.New(endpointConfigurationName, remoteAddress) + End Sub + + Public Sub New(ByVal binding As System.ServiceModel.Channels.Binding, ByVal remoteAddress As System.ServiceModel.EndpointAddress) + MyBase.New(binding, remoteAddress) + End Sub + + Public Function ObtainAnswerToQuestion(ByVal userQuestion As String) As String Implements ServiceReference1.IEightBall.ObtainAnswerToQuestion + Return MyBase.Channel.ObtainAnswerToQuestion(userQuestion) + End Function + End Class +End Namespace diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Service References/ServiceReference1/configuration.svcinfo b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Service References/ServiceReference1/configuration.svcinfo new file mode 100644 index 0000000..d4f1649 --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/Service References/ServiceReference1/configuration.svcinfo @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/app.config b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/app.config new file mode 100644 index 0000000..1687693 --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceClient/app.config @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/MagicEightBallServiceHost.sln b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/MagicEightBallServiceHost.sln new file mode 100644 index 0000000..7bfe88e --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/MagicEightBallServiceHost.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MagicEightBallServiceHost", "MagicEightBallServiceHost.vbproj", "{F1F6E441-8225-442E-9FFD-961A0A93FC2E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F1F6E441-8225-442E-9FFD-961A0A93FC2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F1F6E441-8225-442E-9FFD-961A0A93FC2E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F1F6E441-8225-442E-9FFD-961A0A93FC2E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F1F6E441-8225-442E-9FFD-961A0A93FC2E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/MagicEightBallServiceHost.suo b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/MagicEightBallServiceHost.suo new file mode 100644 index 0000000..c25d1b8 Binary files /dev/null and b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/MagicEightBallServiceHost.suo differ diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/MagicEightBallServiceHost.vbproj b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/MagicEightBallServiceHost.vbproj new file mode 100644 index 0000000..a8bf68c --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/MagicEightBallServiceHost.vbproj @@ -0,0 +1,117 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {F1F6E441-8225-442E-9FFD-961A0A93FC2E} + Exe + MagicEightBallServiceHost.Program + MagicEightBallServiceHost + MagicEightBallServiceHost + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + MagicEightBallServiceHost.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + MagicEightBallServiceHost.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + False + ..\MagicEightBallServiceLib\bin\Debug\MagicEightBallServiceLib.dll + + + + + + 3.0 + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/My Project/Application.Designer.vb b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/My Project/Application.myapp b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/My Project/AssemblyInfo.vb b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..67124ba --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/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/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/My Project/Resources.Designer.vb b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/My Project/Resources.Designer.vb new file mode 100644 index 0000000..5537c86 --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("MagicEightBallServiceHost.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/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/My Project/Resources.resx b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/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/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/My Project/Settings.Designer.vb b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/My Project/Settings.Designer.vb new file mode 100644 index 0000000..daddff2 --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.MagicEightBallServiceHost.My.MySettings + Get + Return Global.MagicEightBallServiceHost.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/My Project/Settings.settings b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/Program.vb b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/Program.vb new file mode 100644 index 0000000..afe12f8 --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/Program.vb @@ -0,0 +1,32 @@ +Imports System.ServiceModel +Imports MagicEightBallServiceLib + +Module Program + + Sub Main() + Console.WriteLine("***** Console Based WCF Host *****") + + Using svcHost As New ServiceHost(GetType(MagicEightBallService)) + ' Open the host and start listening for incoming messages. + svcHost.Open() + DisplayHostInfo(svcHost) + ' Keep the service running until the Enter key is pressed. + Console.WriteLine("The service is ready.") + Console.WriteLine("Press the Enter key to terminate service.") + Console.ReadLine() + End Using + End Sub + + Private Sub DisplayHostInfo(ByVal host As ServiceHost) + Console.WriteLine() + Console.WriteLine("***** Host Info *****") + + Console.WriteLine("Name: {0}", host.Description.ConfigurationName) + Console.WriteLine("Port: {0}", host.BaseAddresses(0).Port) + Console.WriteLine("LocalPath: {0}", host.BaseAddresses(0).LocalPath) + Console.WriteLine("Uri: {0}", host.BaseAddresses(0).AbsoluteUri) + Console.WriteLine("Scheme: {0}", host.BaseAddresses(0).Scheme) + Console.WriteLine("**********************") + Console.WriteLine() + End Sub +End Module diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/app.config b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/app.config new file mode 100644 index 0000000..97424a7 --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceHost/app.config @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/MagicEightBallService.vb b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/MagicEightBallService.vb new file mode 100644 index 0000000..fa5bccd --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/MagicEightBallService.vb @@ -0,0 +1,28 @@ +' The key WCF namespace. +Imports System.ServiceModel + + _ +Public Interface IEightBall + ' Ask a question, receive an answer! + _ + Function ObtainAnswerToQuestion(ByVal userQuestion As String) As String +End Interface + + +Public Class MagicEightBallService + Implements IEightBall + ' Just for display purposes on the host. + Public Sub New() + Console.WriteLine("The 8-Ball awaits your question...") + End Sub + + Public Function ObtainAnswerToQuestion(ByVal userQuestion As String) As String _ + Implements IEightBall.ObtainAnswerToQuestion + Dim answers As String() = {"Future Uncertain", "Yes", "No", _ + "Hazy", "Ask again later", "Definitely"} + + ' Return a random response. + Dim r As New Random() + Return String.Format("{0}? {1}.", userQuestion, answers(r.Next(answers.Length))) + End Function +End Class diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/MagicEightBallServiceLib.sln b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/MagicEightBallServiceLib.sln new file mode 100644 index 0000000..978e6e6 --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/MagicEightBallServiceLib.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MagicEightBallServiceLib", "MagicEightBallServiceLib.vbproj", "{3DD68424-70DC-4A3F-8EB0-8AAC70C52B82}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3DD68424-70DC-4A3F-8EB0-8AAC70C52B82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3DD68424-70DC-4A3F-8EB0-8AAC70C52B82}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3DD68424-70DC-4A3F-8EB0-8AAC70C52B82}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3DD68424-70DC-4A3F-8EB0-8AAC70C52B82}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/MagicEightBallServiceLib.suo b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/MagicEightBallServiceLib.suo new file mode 100644 index 0000000..11a203c Binary files /dev/null and b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/MagicEightBallServiceLib.suo differ diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/MagicEightBallServiceLib.vbproj b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/MagicEightBallServiceLib.vbproj new file mode 100644 index 0000000..2da1f79 --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/MagicEightBallServiceLib.vbproj @@ -0,0 +1,110 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {3DD68424-70DC-4A3F-8EB0-8AAC70C52B82} + Library + MagicEightBallServiceLib + MagicEightBallServiceLib + 512 + Windows + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + MagicEightBallServiceLib.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + MagicEightBallServiceLib.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + 3.0 + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/My Project/Application.Designer.vb b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/My Project/Application.myapp b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/My Project/Application.myapp new file mode 100644 index 0000000..758895d --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/My Project/AssemblyInfo.vb b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..3985ff2 --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/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/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/My Project/Resources.Designer.vb b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/My Project/Resources.Designer.vb new file mode 100644 index 0000000..a894f76 --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("MagicEightBallServiceLib.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/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/My Project/Resources.resx b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/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/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/My Project/Settings.Designer.vb b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/My Project/Settings.Designer.vb new file mode 100644 index 0000000..4a2e20c --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.MagicEightBallServiceLib.My.MySettings + Get + Return Global.MagicEightBallServiceLib.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/My Project/Settings.settings b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 25/MagicEightBall/MagicEightBallServiceLib/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 25/MathService/MathClient/MathClient.sln b/Code/Chapter 25/MathService/MathClient/MathClient.sln new file mode 100644 index 0000000..5c0768a --- /dev/null +++ b/Code/Chapter 25/MathService/MathClient/MathClient.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MathClient", "MathClient.vbproj", "{CA708D29-7C87-401B-960B-CA6070106832}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CA708D29-7C87-401B-960B-CA6070106832}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CA708D29-7C87-401B-960B-CA6070106832}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CA708D29-7C87-401B-960B-CA6070106832}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CA708D29-7C87-401B-960B-CA6070106832}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 25/MathService/MathClient/MathClient.suo b/Code/Chapter 25/MathService/MathClient/MathClient.suo new file mode 100644 index 0000000..199805e Binary files /dev/null and b/Code/Chapter 25/MathService/MathClient/MathClient.suo differ diff --git a/Code/Chapter 25/MathService/MathClient/MathClient.vbproj b/Code/Chapter 25/MathService/MathClient/MathClient.vbproj new file mode 100644 index 0000000..cbf832b --- /dev/null +++ b/Code/Chapter 25/MathService/MathClient/MathClient.vbproj @@ -0,0 +1,143 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {CA708D29-7C87-401B-960B-CA6070106832} + Exe + MathClient.Program + MathClient + MathClient + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + MathClient.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + MathClient.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + 3.0 + + + 3.0 + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + True + True + Reference.svcmap + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + + + + + + + + + + + + + + + + + WCF Proxy Generator + Reference.vb + + + + + \ No newline at end of file diff --git a/Code/Chapter 25/MathService/MathClient/My Project/Application.Designer.vb b/Code/Chapter 25/MathService/MathClient/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 25/MathService/MathClient/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 25/MathService/MathClient/My Project/Application.myapp b/Code/Chapter 25/MathService/MathClient/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 25/MathService/MathClient/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 25/MathService/MathClient/My Project/AssemblyInfo.vb b/Code/Chapter 25/MathService/MathClient/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..05941a2 --- /dev/null +++ b/Code/Chapter 25/MathService/MathClient/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/Code/Chapter 25/MathService/MathClient/My Project/Resources.Designer.vb b/Code/Chapter 25/MathService/MathClient/My Project/Resources.Designer.vb new file mode 100644 index 0000000..a4d0a06 --- /dev/null +++ b/Code/Chapter 25/MathService/MathClient/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("MathClient.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/Code/Chapter 25/MathService/MathClient/My Project/Resources.resx b/Code/Chapter 25/MathService/MathClient/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 25/MathService/MathClient/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/Code/Chapter 25/MathService/MathClient/My Project/Settings.Designer.vb b/Code/Chapter 25/MathService/MathClient/My Project/Settings.Designer.vb new file mode 100644 index 0000000..d299a5a --- /dev/null +++ b/Code/Chapter 25/MathService/MathClient/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.MathClient.My.MySettings + Get + Return Global.MathClient.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 25/MathService/MathClient/My Project/Settings.settings b/Code/Chapter 25/MathService/MathClient/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 25/MathService/MathClient/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 25/MathService/MathClient/Program.vb b/Code/Chapter 25/MathService/MathClient/Program.vb new file mode 100644 index 0000000..b25b4da --- /dev/null +++ b/Code/Chapter 25/MathService/MathClient/Program.vb @@ -0,0 +1,26 @@ +Imports MathClient.ServiceReference1 +Imports System.Threading + +Module Program + Private proxy As New BasicMathClient + + Sub Main() + Console.WriteLine("***** The Async Math Client *****") + + proxy.Open() + + Dim result As IAsyncResult = proxy.BeginAdd(10, 10, _ + New AsyncCallback(AddressOf AddCallback), Nothing) + + While Not result.IsCompleted + Thread.Sleep(200) + End While + + proxy.Close() + Console.ReadLine() + End Sub + + Sub AddCallback(ByVal i As IAsyncResult) + Console.WriteLine("10 + 10 = {0}", proxy.EndAdd(i)) + End Sub +End Module diff --git a/Code/Chapter 25/MathService/MathClient/Service References/ServiceReference1/MathService.disco b/Code/Chapter 25/MathService/MathClient/Service References/ServiceReference1/MathService.disco new file mode 100644 index 0000000..e7bdddb --- /dev/null +++ b/Code/Chapter 25/MathService/MathClient/Service References/ServiceReference1/MathService.disco @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Code/Chapter 25/MathService/MathClient/Service References/ServiceReference1/MathService.wsdl b/Code/Chapter 25/MathService/MathClient/Service References/ServiceReference1/MathService.wsdl new file mode 100644 index 0000000..42e5af2 --- /dev/null +++ b/Code/Chapter 25/MathService/MathClient/Service References/ServiceReference1/MathService.wsdl @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 25/MathService/MathClient/Service References/ServiceReference1/MathService.xsd b/Code/Chapter 25/MathService/MathClient/Service References/ServiceReference1/MathService.xsd new file mode 100644 index 0000000..095d9f6 --- /dev/null +++ b/Code/Chapter 25/MathService/MathClient/Service References/ServiceReference1/MathService.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 25/MathService/MathClient/Service References/ServiceReference1/MathService1.wsdl b/Code/Chapter 25/MathService/MathClient/Service References/ServiceReference1/MathService1.wsdl new file mode 100644 index 0000000..9385f0d --- /dev/null +++ b/Code/Chapter 25/MathService/MathClient/Service References/ServiceReference1/MathService1.wsdl @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://localhost:8080/MathServiceLibrary + + host/InterUber.intertech-inc.com + + + + + \ No newline at end of file diff --git a/Code/Chapter 25/MathService/MathClient/Service References/ServiceReference1/MathService1.xsd b/Code/Chapter 25/MathService/MathClient/Service References/ServiceReference1/MathService1.xsd new file mode 100644 index 0000000..d00d787 --- /dev/null +++ b/Code/Chapter 25/MathService/MathClient/Service References/ServiceReference1/MathService1.xsd @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 25/MathService/MathClient/Service References/ServiceReference1/Reference.svcmap b/Code/Chapter 25/MathService/MathClient/Service References/ServiceReference1/Reference.svcmap new file mode 100644 index 0000000..3e42740 --- /dev/null +++ b/Code/Chapter 25/MathService/MathClient/Service References/ServiceReference1/Reference.svcmap @@ -0,0 +1,32 @@ + + + + true + true + + false + false + false + + + true + Auto + true + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 25/MathService/MathClient/Service References/ServiceReference1/Reference.vb b/Code/Chapter 25/MathService/MathClient/Service References/ServiceReference1/Reference.vb new file mode 100644 index 0000000..81173a7 --- /dev/null +++ b/Code/Chapter 25/MathService/MathClient/Service References/ServiceReference1/Reference.vb @@ -0,0 +1,138 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace ServiceReference1 + + _ + Public Interface IBasicMath + + _ + Function Add(ByVal x As Integer, ByVal y As Integer) As Integer + + _ + Function BeginAdd(ByVal x As Integer, ByVal y As Integer, ByVal callback As System.AsyncCallback, ByVal asyncState As Object) As System.IAsyncResult + + Function EndAdd(ByVal result As System.IAsyncResult) As Integer + End Interface + + _ + Public Interface IBasicMathChannel + Inherits ServiceReference1.IBasicMath, System.ServiceModel.IClientChannel + End Interface + + _ + Partial Public Class AddCompletedEventArgs + Inherits System.ComponentModel.AsyncCompletedEventArgs + + Private results() As Object + + Public Sub New(ByVal results() As Object, ByVal exception As System.Exception, ByVal cancelled As Boolean, ByVal userState As Object) + MyBase.New(exception, cancelled, userState) + Me.results = results + End Sub + + Public ReadOnly Property Result() As Integer + Get + MyBase.RaiseExceptionIfNecessary + Return CType(Me.results(0),Integer) + End Get + End Property + End Class + + _ + Partial Public Class BasicMathClient + Inherits System.ServiceModel.ClientBase(Of ServiceReference1.IBasicMath) + Implements ServiceReference1.IBasicMath + + Private onBeginAddDelegate As BeginOperationDelegate + + Private onEndAddDelegate As EndOperationDelegate + + Private onAddCompletedDelegate As System.Threading.SendOrPostCallback + + Public Sub New() + MyBase.New + End Sub + + Public Sub New(ByVal endpointConfigurationName As String) + MyBase.New(endpointConfigurationName) + End Sub + + Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As String) + MyBase.New(endpointConfigurationName, remoteAddress) + End Sub + + Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As System.ServiceModel.EndpointAddress) + MyBase.New(endpointConfigurationName, remoteAddress) + End Sub + + Public Sub New(ByVal binding As System.ServiceModel.Channels.Binding, ByVal remoteAddress As System.ServiceModel.EndpointAddress) + MyBase.New(binding, remoteAddress) + End Sub + + Public Event AddCompleted As System.EventHandler(Of AddCompletedEventArgs) + + Public Function Add(ByVal x As Integer, ByVal y As Integer) As Integer Implements ServiceReference1.IBasicMath.Add + Return MyBase.Channel.Add(x, y) + End Function + + _ + Public Function BeginAdd(ByVal x As Integer, ByVal y As Integer, ByVal callback As System.AsyncCallback, ByVal asyncState As Object) As System.IAsyncResult Implements ServiceReference1.IBasicMath.BeginAdd + Return MyBase.Channel.BeginAdd(x, y, callback, asyncState) + End Function + + _ + Public Function EndAdd(ByVal result As System.IAsyncResult) As Integer Implements ServiceReference1.IBasicMath.EndAdd + Return MyBase.Channel.EndAdd(result) + End Function + + Private Function OnBeginAdd(ByVal inValues() As Object, ByVal callback As System.AsyncCallback, ByVal asyncState As Object) As System.IAsyncResult + Dim x As Integer = CType(inValues(0),Integer) + Dim y As Integer = CType(inValues(1),Integer) + Return Me.BeginAdd(x, y, callback, asyncState) + End Function + + Private Function OnEndAdd(ByVal result As System.IAsyncResult) As Object() + Dim retVal As Integer = Me.EndAdd(result) + Return New Object() {retVal} + End Function + + Private Sub OnAddCompleted(ByVal state As Object) + If (Not (Me.AddCompletedEvent) Is Nothing) Then + Dim e As InvokeAsyncCompletedEventArgs = CType(state,InvokeAsyncCompletedEventArgs) + RaiseEvent AddCompleted(Me, New AddCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState)) + End If + End Sub + + Public Overloads Sub AddAsync(ByVal x As Integer, ByVal y As Integer) + Me.AddAsync(x, y, Nothing) + End Sub + + Public Overloads Sub AddAsync(ByVal x As Integer, ByVal y As Integer, ByVal userState As Object) + If (Me.onBeginAddDelegate Is Nothing) Then + Me.onBeginAddDelegate = AddressOf Me.OnBeginAdd + End If + If (Me.onEndAddDelegate Is Nothing) Then + Me.onEndAddDelegate = AddressOf Me.OnEndAdd + End If + If (Me.onAddCompletedDelegate Is Nothing) Then + Me.onAddCompletedDelegate = AddressOf Me.OnAddCompleted + End If + MyBase.InvokeAsync(Me.onBeginAddDelegate, New Object() {x, y}, Me.onEndAddDelegate, Me.onAddCompletedDelegate, userState) + End Sub + End Class +End Namespace diff --git a/Code/Chapter 25/MathService/MathClient/Service References/ServiceReference1/configuration.svcinfo b/Code/Chapter 25/MathService/MathClient/Service References/ServiceReference1/configuration.svcinfo new file mode 100644 index 0000000..f60c728 --- /dev/null +++ b/Code/Chapter 25/MathService/MathClient/Service References/ServiceReference1/configuration.svcinfo @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 25/MathService/MathClient/app.config b/Code/Chapter 25/MathService/MathClient/app.config new file mode 100644 index 0000000..29ebcb0 --- /dev/null +++ b/Code/Chapter 25/MathService/MathClient/app.config @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 25/MathService/MathServiceLibrary/App.config b/Code/Chapter 25/MathService/MathServiceLibrary/App.config new file mode 100644 index 0000000..22937be --- /dev/null +++ b/Code/Chapter 25/MathService/MathServiceLibrary/App.config @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 25/MathService/MathServiceLibrary/IBasicMath.vb b/Code/Chapter 25/MathService/MathServiceLibrary/IBasicMath.vb new file mode 100644 index 0000000..a5ead2e --- /dev/null +++ b/Code/Chapter 25/MathService/MathServiceLibrary/IBasicMath.vb @@ -0,0 +1,5 @@ + _ +Public Interface IBasicMath + _ + Function Add(ByVal x As Integer, ByVal y As Integer) As Integer +End Interface diff --git a/Code/Chapter 25/MathService/MathServiceLibrary/MathService.vb b/Code/Chapter 25/MathService/MathServiceLibrary/MathService.vb new file mode 100644 index 0000000..92761d8 --- /dev/null +++ b/Code/Chapter 25/MathService/MathServiceLibrary/MathService.vb @@ -0,0 +1,7 @@ +Public Class MathService + Implements IBasicMath + + Public Function Add(ByVal x As Integer, ByVal y As Integer) As Integer Implements IBasicMath.Add + Return x + y + End Function +End Class diff --git a/Code/Chapter 25/MathService/MathServiceLibrary/MathServiceLibrary.sln b/Code/Chapter 25/MathService/MathServiceLibrary/MathServiceLibrary.sln new file mode 100644 index 0000000..6404ab4 --- /dev/null +++ b/Code/Chapter 25/MathService/MathServiceLibrary/MathServiceLibrary.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MathServiceLibrary", "MathServiceLibrary.vbproj", "{B0856391-C33E-4223-A2A4-A567C0962F28}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0856391-C33E-4223-A2A4-A567C0962F28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0856391-C33E-4223-A2A4-A567C0962F28}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0856391-C33E-4223-A2A4-A567C0962F28}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0856391-C33E-4223-A2A4-A567C0962F28}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 25/MathService/MathServiceLibrary/MathServiceLibrary.suo b/Code/Chapter 25/MathService/MathServiceLibrary/MathServiceLibrary.suo new file mode 100644 index 0000000..3b9037d Binary files /dev/null and b/Code/Chapter 25/MathService/MathServiceLibrary/MathServiceLibrary.suo differ diff --git a/Code/Chapter 25/MathService/MathServiceLibrary/MathServiceLibrary.vbproj b/Code/Chapter 25/MathService/MathServiceLibrary/MathServiceLibrary.vbproj new file mode 100644 index 0000000..76381eb --- /dev/null +++ b/Code/Chapter 25/MathService/MathServiceLibrary/MathServiceLibrary.vbproj @@ -0,0 +1,108 @@ + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {B0856391-C33E-4223-A2A4-A567C0962F28} + Library + MathServiceLibrary + MathServiceLibrary + {3D9AD99F-2412-4246-B90B-4EAA41C64699};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + /client:"WcfTestClient.exe" + v3.5 + On + Binary + Off + On + + + true + full + true + true + false + bin\Debug\ + MathServiceLibrary.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + MathServiceLibrary.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + 3.0 + + + 3.0 + + + + 3.5 + + + + + + + + + + + + + + + + + + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + \ No newline at end of file diff --git a/Code/Chapter 25/MathService/MathServiceLibrary/My Project/AssemblyInfo.vb b/Code/Chapter 25/MathService/MathServiceLibrary/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..ab3f284 --- /dev/null +++ b/Code/Chapter 25/MathService/MathServiceLibrary/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/Code/Chapter 25/MathService/MathServiceLibrary/My Project/Resources.Designer.vb b/Code/Chapter 25/MathService/MathServiceLibrary/My Project/Resources.Designer.vb new file mode 100644 index 0000000..bec35e9 --- /dev/null +++ b/Code/Chapter 25/MathService/MathServiceLibrary/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("MathServiceLibrary.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/Code/Chapter 25/MathService/MathServiceLibrary/My Project/Resources.resx b/Code/Chapter 25/MathService/MathServiceLibrary/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 25/MathService/MathServiceLibrary/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/Code/Chapter 25/MathService/MathServiceLibrary/My Project/Settings.Designer.vb b/Code/Chapter 25/MathService/MathServiceLibrary/My Project/Settings.Designer.vb new file mode 100644 index 0000000..1f55685 --- /dev/null +++ b/Code/Chapter 25/MathService/MathServiceLibrary/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.MathServiceLibrary.My.MySettings + Get + Return Global.MathServiceLibrary.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 25/MathService/MathServiceLibrary/My Project/Settings.settings b/Code/Chapter 25/MathService/MathServiceLibrary/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 25/MathService/MathServiceLibrary/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 25/MathService/MathWindowsServiceHost/MathWinService.Designer.vb b/Code/Chapter 25/MathService/MathWindowsServiceHost/MathWinService.Designer.vb new file mode 100644 index 0000000..6d9786d --- /dev/null +++ b/Code/Chapter 25/MathService/MathWindowsServiceHost/MathWinService.Designer.vb @@ -0,0 +1,48 @@ +Imports System.ServiceProcess + + _ +Partial Class MathWinService + Inherits System.ServiceProcess.ServiceBase + + 'UserService overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + ' The main entry point for the process + _ + _ + Shared Sub Main() + Dim ServicesToRun() As System.ServiceProcess.ServiceBase + + ' More than one NT Service may run within the same process. To add + ' another service to this process, change the following line to + ' create a second service object. For example, + ' + ' ServicesToRun = New System.ServiceProcess.ServiceBase () {New Service1, New MySecondUserService} + ' + ServicesToRun = New System.ServiceProcess.ServiceBase() {New MathWinService} + + System.ServiceProcess.ServiceBase.Run(ServicesToRun) + End Sub + + 'Required by the Component Designer + Private components As System.ComponentModel.IContainer + + ' NOTE: The following procedure is required by the Component Designer + ' It can be modified using the Component Designer. + ' Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + components = New System.ComponentModel.Container() + Me.ServiceName = "Service1" + End Sub + +End Class diff --git a/Code/Chapter 25/MathService/MathWindowsServiceHost/MathWinService.vb b/Code/Chapter 25/MathService/MathWindowsServiceHost/MathWinService.vb new file mode 100644 index 0000000..08f2a63 --- /dev/null +++ b/Code/Chapter 25/MathService/MathWindowsServiceHost/MathWinService.vb @@ -0,0 +1,41 @@ +' Be sure to import these namespaces: +Imports MathServiceLibrary +Imports System.ServiceModel + +Partial Public Class MathWinService + ' A member variable of type ServiceHost. + Private myHost As ServiceHost + + Public Sub New() + InitializeComponent() + End Sub + + Protected Overloads Overrides Sub OnStart(ByVal args As String()) + ' Just to be really safe. + If myHost IsNot Nothing Then + myHost.Close() + myHost = Nothing + End If + + ' Create the host. + myHost = New ServiceHost(GetType(MathService)) + + ' The ABCs in code! + Dim address As New Uri("http://localhost:8080/MathServiceLibrary") + Dim binding As New WSHttpBinding() + Dim contract As Type = GetType(IBasicMath) + + ' Add this endpoint. + myHost.AddServiceEndpoint(contract, binding, address) + + ' Open the host. + myHost.Open() + End Sub + + Protected Overloads Overrides Sub OnStop() + ' Shut down the host. + If myHost IsNot Nothing Then + myHost.Close() + End If + End Sub +End Class diff --git a/Code/Chapter 25/MathService/MathWindowsServiceHost/MathWindowsServiceHost.sln b/Code/Chapter 25/MathService/MathWindowsServiceHost/MathWindowsServiceHost.sln new file mode 100644 index 0000000..0f5a856 --- /dev/null +++ b/Code/Chapter 25/MathService/MathWindowsServiceHost/MathWindowsServiceHost.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MathWindowsServiceHost", "MathWindowsServiceHost.vbproj", "{46C0E086-7664-46C8-BE64-7E6B9B6FB0F0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {46C0E086-7664-46C8-BE64-7E6B9B6FB0F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {46C0E086-7664-46C8-BE64-7E6B9B6FB0F0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {46C0E086-7664-46C8-BE64-7E6B9B6FB0F0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {46C0E086-7664-46C8-BE64-7E6B9B6FB0F0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 25/MathService/MathWindowsServiceHost/MathWindowsServiceHost.suo b/Code/Chapter 25/MathService/MathWindowsServiceHost/MathWindowsServiceHost.suo new file mode 100644 index 0000000..670d44d Binary files /dev/null and b/Code/Chapter 25/MathService/MathWindowsServiceHost/MathWindowsServiceHost.suo differ diff --git a/Code/Chapter 25/MathService/MathWindowsServiceHost/MathWindowsServiceHost.vbproj b/Code/Chapter 25/MathService/MathWindowsServiceHost/MathWindowsServiceHost.vbproj new file mode 100644 index 0000000..b8cfb84 --- /dev/null +++ b/Code/Chapter 25/MathService/MathWindowsServiceHost/MathWindowsServiceHost.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {46C0E086-7664-46C8-BE64-7E6B9B6FB0F0} + WinExe + MathWindowsServiceHost.MathWinService + MathWindowsServiceHost + MathWindowsServiceHost + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + MathWindowsServiceHost.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + MathWindowsServiceHost.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + False + ..\MathServiceLibrary\bin\Debug\MathServiceLibrary.dll + + + + + + + 3.0 + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + True + Application.myapp + + + Component + + + MathWinService.vb + + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ProjectInstaller.vb + + + Component + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + ProjectInstaller.vb + Designer + + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + \ No newline at end of file diff --git a/Code/Chapter 25/MathService/MathWindowsServiceHost/My Project/Application.Designer.vb b/Code/Chapter 25/MathService/MathWindowsServiceHost/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 25/MathService/MathWindowsServiceHost/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 25/MathService/MathWindowsServiceHost/My Project/Application.myapp b/Code/Chapter 25/MathService/MathWindowsServiceHost/My Project/Application.myapp new file mode 100644 index 0000000..602de37 --- /dev/null +++ b/Code/Chapter 25/MathService/MathWindowsServiceHost/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 3 + true + diff --git a/Code/Chapter 25/MathService/MathWindowsServiceHost/My Project/AssemblyInfo.vb b/Code/Chapter 25/MathService/MathWindowsServiceHost/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..4d7c3bb --- /dev/null +++ b/Code/Chapter 25/MathService/MathWindowsServiceHost/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/Code/Chapter 25/MathService/MathWindowsServiceHost/My Project/Resources.Designer.vb b/Code/Chapter 25/MathService/MathWindowsServiceHost/My Project/Resources.Designer.vb new file mode 100644 index 0000000..5ba3ebc --- /dev/null +++ b/Code/Chapter 25/MathService/MathWindowsServiceHost/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("MathWindowsServiceHost.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/Code/Chapter 25/MathService/MathWindowsServiceHost/My Project/Resources.resx b/Code/Chapter 25/MathService/MathWindowsServiceHost/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 25/MathService/MathWindowsServiceHost/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/Code/Chapter 25/MathService/MathWindowsServiceHost/My Project/Settings.Designer.vb b/Code/Chapter 25/MathService/MathWindowsServiceHost/My Project/Settings.Designer.vb new file mode 100644 index 0000000..3ff61de --- /dev/null +++ b/Code/Chapter 25/MathService/MathWindowsServiceHost/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.MathWindowsServiceHost.My.MySettings + Get + Return Global.MathWindowsServiceHost.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 25/MathService/MathWindowsServiceHost/My Project/Settings.settings b/Code/Chapter 25/MathService/MathWindowsServiceHost/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 25/MathService/MathWindowsServiceHost/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 25/MathService/MathWindowsServiceHost/ProjectInstaller.Designer.vb b/Code/Chapter 25/MathService/MathWindowsServiceHost/ProjectInstaller.Designer.vb new file mode 100644 index 0000000..d40bd30 --- /dev/null +++ b/Code/Chapter 25/MathService/MathWindowsServiceHost/ProjectInstaller.Designer.vb @@ -0,0 +1,46 @@ + Partial Class ProjectInstaller + Inherits System.Configuration.Install.Installer + + 'Installer overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Required by the Component Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Component Designer + 'It can be modified using the Component Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.ServiceProcessInstaller1 = New System.ServiceProcess.ServiceProcessInstaller + Me.ServiceInstaller1 = New System.ServiceProcess.ServiceInstaller + ' + 'ServiceProcessInstaller1 + ' + Me.ServiceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem + Me.ServiceProcessInstaller1.Password = Nothing + Me.ServiceProcessInstaller1.Username = Nothing + ' + 'ServiceInstaller1 + ' + Me.ServiceInstaller1.ServiceName = "Math Service" + Me.ServiceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic + ' + 'ProjectInstaller + ' + Me.Installers.AddRange(New System.Configuration.Install.Installer() {Me.ServiceProcessInstaller1, Me.ServiceInstaller1}) + + End Sub + Friend WithEvents ServiceProcessInstaller1 As System.ServiceProcess.ServiceProcessInstaller + Friend WithEvents ServiceInstaller1 As System.ServiceProcess.ServiceInstaller + +End Class diff --git a/Code/Chapter 25/MathService/MathWindowsServiceHost/ProjectInstaller.resx b/Code/Chapter 25/MathService/MathWindowsServiceHost/ProjectInstaller.resx new file mode 100644 index 0000000..544fb94 --- /dev/null +++ b/Code/Chapter 25/MathService/MathWindowsServiceHost/ProjectInstaller.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 + + + 197, 17 + + + False + + \ No newline at end of file diff --git a/Code/Chapter 25/MathService/MathWindowsServiceHost/ProjectInstaller.vb b/Code/Chapter 25/MathService/MathWindowsServiceHost/ProjectInstaller.vb new file mode 100644 index 0000000..f64fbad --- /dev/null +++ b/Code/Chapter 25/MathService/MathWindowsServiceHost/ProjectInstaller.vb @@ -0,0 +1,16 @@ +Imports System.ComponentModel +Imports System.Configuration.Install + +Public Class ProjectInstaller + + Public Sub New() + MyBase.New() + + 'This call is required by the Component Designer. + InitializeComponent() + + 'Add initialization code after the call to InitializeComponent + + End Sub + +End Class diff --git a/Code/Chapter 25/MathService/MathWindowsServiceHost/app.config b/Code/Chapter 25/MathService/MathWindowsServiceHost/app.config new file mode 100644 index 0000000..efc5cc4 --- /dev/null +++ b/Code/Chapter 25/MathService/MathWindowsServiceHost/app.config @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 25/VbAutoLotWCFService/VbAutoLotWCFService/App_Code/IAutoLotService.vb b/Code/Chapter 25/VbAutoLotWCFService/VbAutoLotWCFService/App_Code/IAutoLotService.vb new file mode 100644 index 0000000..e18d79b --- /dev/null +++ b/Code/Chapter 25/VbAutoLotWCFService/VbAutoLotWCFService/App_Code/IAutoLotService.vb @@ -0,0 +1,23 @@ + _ +Public Interface IAutoLotService + _ + Sub InsertCar(ByVal id As Integer, ByVal make As String, ByVal color As String, ByVal petname As String) + + _ + Sub InsertCar(ByVal car As InventoryRecord) + + _ + Function GetInventory() As InventoryRecord() +End Interface + + _ +Public Class InventoryRecord + _ + Public ID As Integer + _ + Public Make As String + _ + Public Color As String + _ + Public PetName As String +End Class diff --git a/Code/Chapter 25/VbAutoLotWCFService/VbAutoLotWCFService/App_Code/VbAutoLotWCFService.vb b/Code/Chapter 25/VbAutoLotWCFService/VbAutoLotWCFService/App_Code/VbAutoLotWCFService.vb new file mode 100644 index 0000000..6cb599f --- /dev/null +++ b/Code/Chapter 25/VbAutoLotWCFService/VbAutoLotWCFService/App_Code/VbAutoLotWCFService.vb @@ -0,0 +1,50 @@ +Imports AutoLotConnectedLayer +Imports System.Data +Imports System.Collections.Generic + +Public Class VbAutoLotWCFService + Implements IAutoLotService + Private Const ConnString As String = "Data Source=(local)\SQLEXPRESS;Initial Catalog" & _ + "=AutoLot;Integrated Security=True" + + Public Sub InsertCar(ByVal id As Integer, ByVal make As String, _ + ByVal color As String, ByVal petname As String) _ + Implements IAutoLotService.InsertCar + Dim d As New InventoryDAL() + d.OpenConnection(ConnString) + d.InsertAuto(id, color, make, petname) + d.CloseConnection() + End Sub + + Public Sub InsertCarWithDetails(ByVal car As InventoryRecord) Implements IAutoLotService.InsertCar + Dim d As New InventoryDAL() + d.OpenConnection(ConnString) + d.InsertAuto(car.ID, car.Color, car.Make, car.PetName) + d.CloseConnection() + End Sub + + Public Function GetInventory() As InventoryRecord() Implements IAutoLotService.GetInventory + ' First, get the DataTable from the database. + Dim d As New InventoryDAL() + d.OpenConnection(ConnString) + Dim dt As DataTable = d.GetAllInventory() + d.CloseConnection() + + ' Now make a List to contain the records. + Dim records As New List(Of InventoryRecord)() + + ' Copy the data table into List<> of custom contracts. + Dim reader As DataTableReader = dt.CreateDataReader() + While reader.Read() + Dim r As New InventoryRecord() + r.ID = CInt(reader("CarID")) + r.Color = DirectCast(reader("Color"), String).Trim() + r.Make = DirectCast(reader("Make"), String).Trim() + r.PetName = DirectCast(reader("PetName"), String).Trim() + records.Add(r) + End While + + ' Transform List to array of InventoryRecord types. + Return DirectCast(records.ToArray(), InventoryRecord()) + End Function +End Class diff --git a/Code/Chapter 25/VbAutoLotWCFService/VbAutoLotWCFService/Bin/AutoLotDAL.dll b/Code/Chapter 25/VbAutoLotWCFService/VbAutoLotWCFService/Bin/AutoLotDAL.dll new file mode 100644 index 0000000..2b301c5 Binary files /dev/null and b/Code/Chapter 25/VbAutoLotWCFService/VbAutoLotWCFService/Bin/AutoLotDAL.dll differ diff --git a/Code/Chapter 25/VbAutoLotWCFService/VbAutoLotWCFService/Bin/AutoLotDAL.dll.refresh b/Code/Chapter 25/VbAutoLotWCFService/VbAutoLotWCFService/Bin/AutoLotDAL.dll.refresh new file mode 100644 index 0000000..6f29ca6 Binary files /dev/null and b/Code/Chapter 25/VbAutoLotWCFService/VbAutoLotWCFService/Bin/AutoLotDAL.dll.refresh differ diff --git a/Code/Chapter 25/VbAutoLotWCFService/VbAutoLotWCFService/Bin/AutoLotDAL.pdb b/Code/Chapter 25/VbAutoLotWCFService/VbAutoLotWCFService/Bin/AutoLotDAL.pdb new file mode 100644 index 0000000..ae0af7f Binary files /dev/null and b/Code/Chapter 25/VbAutoLotWCFService/VbAutoLotWCFService/Bin/AutoLotDAL.pdb differ diff --git a/Code/Chapter 25/VbAutoLotWCFService/VbAutoLotWCFService/Bin/AutoLotDAL.xml b/Code/Chapter 25/VbAutoLotWCFService/VbAutoLotWCFService/Bin/AutoLotDAL.xml new file mode 100644 index 0000000..b8e562a --- /dev/null +++ b/Code/Chapter 25/VbAutoLotWCFService/VbAutoLotWCFService/Bin/AutoLotDAL.xml @@ -0,0 +1,24 @@ + + + + +AutoLotDAL + + + + + + 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/Code/Chapter 25/VbAutoLotWCFService/VbAutoLotWCFService/Service.svc b/Code/Chapter 25/VbAutoLotWCFService/VbAutoLotWCFService/Service.svc new file mode 100644 index 0000000..7c2c83b --- /dev/null +++ b/Code/Chapter 25/VbAutoLotWCFService/VbAutoLotWCFService/Service.svc @@ -0,0 +1 @@ +<%@ ServiceHost Language="VB" Debug="true" Service="VbAutoLotWCFService" CodeBehind="~/App_Code/VbAutoLotWCFService.vb" %> \ No newline at end of file diff --git a/Code/Chapter 25/VbAutoLotWCFService/VbAutoLotWCFService/Web.config b/Code/Chapter 25/VbAutoLotWCFService/VbAutoLotWCFService/Web.config new file mode 100644 index 0000000..7eb8b40 --- /dev/null +++ b/Code/Chapter 25/VbAutoLotWCFService/VbAutoLotWCFService/Web.config @@ -0,0 +1,198 @@ + + + + + + + + +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 26/CreditCheckApp/CreditCheckApp.sln b/Code/Chapter 26/CreditCheckApp/CreditCheckApp.sln new file mode 100644 index 0000000..fcbd361 --- /dev/null +++ b/Code/Chapter 26/CreditCheckApp/CreditCheckApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CreditCheckApp", "CreditCheckApp.vbproj", "{30B1728C-65A5-4FAC-B1D8-73A67090D2BE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {30B1728C-65A5-4FAC-B1D8-73A67090D2BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {30B1728C-65A5-4FAC-B1D8-73A67090D2BE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {30B1728C-65A5-4FAC-B1D8-73A67090D2BE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {30B1728C-65A5-4FAC-B1D8-73A67090D2BE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 26/CreditCheckApp/CreditCheckApp.suo b/Code/Chapter 26/CreditCheckApp/CreditCheckApp.suo new file mode 100644 index 0000000..f3d6ad7 Binary files /dev/null and b/Code/Chapter 26/CreditCheckApp/CreditCheckApp.suo differ diff --git a/Code/Chapter 26/CreditCheckApp/CreditCheckApp.vbproj b/Code/Chapter 26/CreditCheckApp/CreditCheckApp.vbproj new file mode 100644 index 0000000..dae7247 --- /dev/null +++ b/Code/Chapter 26/CreditCheckApp/CreditCheckApp.vbproj @@ -0,0 +1,136 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {30B1728C-65A5-4FAC-B1D8-73A67090D2BE} + WinExe + CreditCheckApp.My.MyApplication + CreditCheckApp + CreditCheckApp + 512 + WindowsForms + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + CreditCheckApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + CreditCheckApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + False + ..\CreditCheckWFLib\bin\CreditCheckWFLib.dll + + + + + + + + 3.0 + + + 3.0 + + + 3.0 + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + MainForm.vb + Designer + + + 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/Code/Chapter 26/CreditCheckApp/CreditCheckApp.vbproj.user b/Code/Chapter 26/CreditCheckApp/CreditCheckApp.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 26/CreditCheckApp/CreditCheckApp.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 26/CreditCheckApp/MainForm.Designer.vb b/Code/Chapter 26/CreditCheckApp/MainForm.Designer.vb new file mode 100644 index 0000000..b7fd890 --- /dev/null +++ b/Code/Chapter 26/CreditCheckApp/MainForm.Designer.vb @@ -0,0 +1,73 @@ + _ +Partial Class MainForm + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + 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.txtCustomerID = New System.Windows.Forms.TextBox + Me.label1 = New System.Windows.Forms.Label + Me.btnCheckCustomerCredit = New System.Windows.Forms.Button + Me.SuspendLayout() + ' + 'txtCustomerID + ' + Me.txtCustomerID.Location = New System.Drawing.Point(120, 23) + Me.txtCustomerID.Name = "txtCustomerID" + Me.txtCustomerID.Size = New System.Drawing.Size(100, 20) + Me.txtCustomerID.TabIndex = 5 + ' + 'label1 + ' + Me.label1.AutoSize = True + Me.label1.Location = New System.Drawing.Point(20, 23) + Me.label1.Name = "label1" + Me.label1.Size = New System.Drawing.Size(84, 13) + Me.label1.TabIndex = 4 + Me.label1.Text = "Check my Credit" + ' + 'btnCheckCustomerCredit + ' + Me.btnCheckCustomerCredit.Location = New System.Drawing.Point(23, 64) + Me.btnCheckCustomerCredit.Name = "btnCheckCustomerCredit" + Me.btnCheckCustomerCredit.Size = New System.Drawing.Size(197, 23) + Me.btnCheckCustomerCredit.TabIndex = 3 + Me.btnCheckCustomerCredit.Text = "Check Credit" + Me.btnCheckCustomerCredit.UseVisualStyleBackColor = True + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(248, 106) + Me.Controls.Add(Me.txtCustomerID) + Me.Controls.Add(Me.label1) + Me.Controls.Add(Me.btnCheckCustomerCredit) + Me.Name = "MainForm" + Me.Text = "Credit Checker" + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Private WithEvents txtCustomerID As System.Windows.Forms.TextBox + Private WithEvents label1 As System.Windows.Forms.Label + Private WithEvents btnCheckCustomerCredit As System.Windows.Forms.Button + +End Class diff --git a/Code/Chapter 26/CreditCheckApp/MainForm.resx b/Code/Chapter 26/CreditCheckApp/MainForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 26/CreditCheckApp/MainForm.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/Code/Chapter 26/CreditCheckApp/MainForm.vb b/Code/Chapter 26/CreditCheckApp/MainForm.vb new file mode 100644 index 0000000..a553c27 --- /dev/null +++ b/Code/Chapter 26/CreditCheckApp/MainForm.vb @@ -0,0 +1,24 @@ +' Need the WF runtime! +Imports System.Workflow.Runtime + +' Be sure to reference our custom WF library. +Imports CreditCheckWFLib + +Public Class MainForm + + Private Sub btnCheckCustomerCredit_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles btnCheckCustomerCredit.Click + ' Create the WF runtime. + Dim wfRuntime As New WorkflowRuntime() + + ' Get ID in the TextBox to pass to the workflow. + Dim args As New Dictionary(Of String, Object)() + args.Add("ID", Integer.Parse(txtCustomerID.Text)) + + ' Get an instance of our WF. + Dim myWorkflow As WorkflowInstance = wfRuntime.CreateWorkflow(GetType(CreditCheckWF), args) + + ' Start it up! + myWorkflow.Start() + End Sub +End Class diff --git a/Code/Chapter 26/CreditCheckApp/My Project/Application.Designer.vb b/Code/Chapter 26/CreditCheckApp/My Project/Application.Designer.vb new file mode 100644 index 0000000..09c38a3 --- /dev/null +++ b/Code/Chapter 26/CreditCheckApp/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CreditCheckApp.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 26/CreditCheckApp/My Project/Application.myapp b/Code/Chapter 26/CreditCheckApp/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 26/CreditCheckApp/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 26/CreditCheckApp/My Project/AssemblyInfo.vb b/Code/Chapter 26/CreditCheckApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..ca51cff --- /dev/null +++ b/Code/Chapter 26/CreditCheckApp/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/Code/Chapter 26/CreditCheckApp/My Project/Resources.Designer.vb b/Code/Chapter 26/CreditCheckApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..c7daac1 --- /dev/null +++ b/Code/Chapter 26/CreditCheckApp/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("CreditCheckApp.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/Code/Chapter 26/CreditCheckApp/My Project/Resources.resx b/Code/Chapter 26/CreditCheckApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 26/CreditCheckApp/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/Code/Chapter 26/CreditCheckApp/My Project/Settings.Designer.vb b/Code/Chapter 26/CreditCheckApp/My Project/Settings.Designer.vb new file mode 100644 index 0000000..0d3bc66 --- /dev/null +++ b/Code/Chapter 26/CreditCheckApp/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CreditCheckApp.My.MySettings + Get + Return Global.CreditCheckApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 26/CreditCheckApp/My Project/Settings.settings b/Code/Chapter 26/CreditCheckApp/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 26/CreditCheckApp/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 26/CreditCheckWFLib/CreditCheckWF.designer.vb b/Code/Chapter 26/CreditCheckWFLib/CreditCheckWF.designer.vb new file mode 100644 index 0000000..87a1849 --- /dev/null +++ b/Code/Chapter 26/CreditCheckWFLib/CreditCheckWF.designer.vb @@ -0,0 +1,74 @@ + _ +Partial Class CreditCheckWF + + 'NOTE: The following procedure is required by the Workflow Designer + 'It can be modified using the Workflow Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.CanModifyActivities = True + Dim ruleconditionreference1 As System.Workflow.Activities.Rules.RuleConditionReference = New System.Workflow.Activities.Rules.RuleConditionReference + Me.ShowDenyMessageActivity = New System.Workflow.Activities.CodeActivity + Me.ProcessCreditRiskActivity = New System.Workflow.Activities.CodeActivity + Me.PurchaseCarActivity = New System.Workflow.Activities.CodeActivity + Me.CreditCheckFailed = New System.Workflow.Activities.IfElseBranchActivity + Me.CreditCheckOK = New System.Workflow.Activities.IfElseBranchActivity + Me.CreditCheckPassedActivity = New System.Workflow.Activities.IfElseActivity + Me.ValidateCreditActivity = New System.Workflow.Activities.CodeActivity + ' + 'ShowDenyMessageActivity + ' + Me.ShowDenyMessageActivity.Name = "ShowDenyMessageActivity" + AddHandler Me.ShowDenyMessageActivity.ExecuteCode, AddressOf Me.CreditDenied + ' + 'ProcessCreditRiskActivity + ' + Me.ProcessCreditRiskActivity.Name = "ProcessCreditRiskActivity" + AddHandler Me.ProcessCreditRiskActivity.ExecuteCode, AddressOf Me.ProcessCreditRisk + ' + 'PurchaseCarActivity + ' + Me.PurchaseCarActivity.Name = "PurchaseCarActivity" + AddHandler Me.PurchaseCarActivity.ExecuteCode, AddressOf Me.PurchaseCar + ' + 'CreditCheckFailed + ' + Me.CreditCheckFailed.Activities.Add(Me.ProcessCreditRiskActivity) + Me.CreditCheckFailed.Activities.Add(Me.ShowDenyMessageActivity) + Me.CreditCheckFailed.Name = "CreditCheckFailed" + ' + 'CreditCheckOK + ' + Me.CreditCheckOK.Activities.Add(Me.PurchaseCarActivity) + ruleconditionreference1.ConditionName = "Condition1" + Me.CreditCheckOK.Condition = ruleconditionreference1 + Me.CreditCheckOK.Name = "CreditCheckOK" + ' + 'CreditCheckPassedActivity + ' + Me.CreditCheckPassedActivity.Activities.Add(Me.CreditCheckOK) + Me.CreditCheckPassedActivity.Activities.Add(Me.CreditCheckFailed) + Me.CreditCheckPassedActivity.Name = "CreditCheckPassedActivity" + ' + 'ValidateCreditActivity + ' + Me.ValidateCreditActivity.Name = "ValidateCreditActivity" + AddHandler Me.ValidateCreditActivity.ExecuteCode, AddressOf Me.ValidateCredit + ' + 'CreditCheckWF + ' + Me.Activities.Add(Me.ValidateCreditActivity) + Me.Activities.Add(Me.CreditCheckPassedActivity) + Me.Name = "CreditCheckWF" + Me.CanModifyActivities = False + + End Sub + Private ShowDenyMessageActivity As System.Workflow.Activities.CodeActivity + Private PurchaseCarActivity As System.Workflow.Activities.CodeActivity + Private CreditCheckFailed As System.Workflow.Activities.IfElseBranchActivity + Private CreditCheckOK As System.Workflow.Activities.IfElseBranchActivity + Private CreditCheckPassedActivity As System.Workflow.Activities.IfElseActivity + Private ProcessCreditRiskActivity As System.Workflow.Activities.CodeActivity + Private ValidateCreditActivity As System.Workflow.Activities.CodeActivity + +End Class diff --git a/Code/Chapter 26/CreditCheckWFLib/CreditCheckWF.rules b/Code/Chapter 26/CreditCheckWFLib/CreditCheckWF.rules new file mode 100644 index 0000000..c9e045a --- /dev/null +++ b/Code/Chapter 26/CreditCheckWFLib/CreditCheckWF.rules @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + true + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 26/CreditCheckWFLib/CreditCheckWF.vb b/Code/Chapter 26/CreditCheckWFLib/CreditCheckWF.vb new file mode 100644 index 0000000..5fb42b2 --- /dev/null +++ b/Code/Chapter 26/CreditCheckWFLib/CreditCheckWF.vb @@ -0,0 +1,65 @@ +' Add the following import. +Imports AutoLotConnectedLayer +Imports System.Windows.Forms + +Public Class CreditCheckWF + Inherits SequentialWorkflowActivity + + ' ID of customer to check. + Private custID As Integer + Public Property ID() As Integer + Get + Return custID + End Get + Set(ByVal value As Integer) + custID = value + End Set + End Property + + Private checkOK As Boolean + Public Property CreditOK() As Boolean + Get + Return checkOK + End Get + Set(ByVal value As Boolean) + checkOK = value + End Set + End Property + + Private Sub ValidateCredit(ByVal sender As System.Object, ByVal e As System.EventArgs) + ' Pretend that we have preformed some exotic + ' credit validation here... + Dim r As New Random() + Dim value As Integer = r.Next(500) + If value > 300 Then + CreditOK = True + Else + CreditOK = False + End If + End Sub + + Private Sub ProcessCreditRisk(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) + ' Ideally we would store the connection string externally. + Dim dal As New InventoryDAL() + dal.OpenConnection( _ + "Data Source=(local)\SQLEXPRESS;Integrated Security=SSPI;" & _ + "Initial Catalog=AutoLot") + Try + dal.ProcessCreditRisk(False, ID) + Finally + dal.CloseConnection() + End Try + End Sub + + Private Sub PurchaseCar(ByVal sender As System.Object, ByVal e As System.EventArgs) + ' Here, we will opt for simplicity. However, we could easily update + ' AutoLotDAL.dll with a new method to place a new order within the Orders table. + MessageBox.Show("Your credit has been approved!") + End Sub + + Private Sub CreditDenied(ByVal sender As System.Object, ByVal e As System.EventArgs) + MessageBox.Show("You are a CREDIT RISK!", _ + "Order Denied!") + End Sub +End Class diff --git a/Code/Chapter 26/CreditCheckWFLib/CreditCheckWFLib.sln b/Code/Chapter 26/CreditCheckWFLib/CreditCheckWFLib.sln new file mode 100644 index 0000000..730a9a0 --- /dev/null +++ b/Code/Chapter 26/CreditCheckWFLib/CreditCheckWFLib.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CreditCheckWFLib", "CreditCheckWFLib.vbproj", "{D1683A8D-4707-4BBE-8F35-861DABFA44FC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D1683A8D-4707-4BBE-8F35-861DABFA44FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D1683A8D-4707-4BBE-8F35-861DABFA44FC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D1683A8D-4707-4BBE-8F35-861DABFA44FC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D1683A8D-4707-4BBE-8F35-861DABFA44FC}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 26/CreditCheckWFLib/CreditCheckWFLib.suo b/Code/Chapter 26/CreditCheckWFLib/CreditCheckWFLib.suo new file mode 100644 index 0000000..262125d Binary files /dev/null and b/Code/Chapter 26/CreditCheckWFLib/CreditCheckWFLib.suo differ diff --git a/Code/Chapter 26/CreditCheckWFLib/CreditCheckWFLib.vbproj b/Code/Chapter 26/CreditCheckWFLib/CreditCheckWFLib.vbproj new file mode 100644 index 0000000..152d294 --- /dev/null +++ b/Code/Chapter 26/CreditCheckWFLib/CreditCheckWFLib.vbproj @@ -0,0 +1,181 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {D1683A8D-4707-4BBE-8F35-861DABFA44FC} + {D59BE175-2ED0-4C54-BE3D-CDAA9F3214C8};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + Library + + + CreditCheckWFLib + CreditCheckWFLib + v3.5 + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + On + Binary + Off + On + + + true + full + true + true + true + bin\ + _MyType="Windows" + CreditCheckWFLib.xml + false + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + false + false + true + false + true + bin\ + _MyType="Windows" + CreditCheckWFLib.xml + false + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + False + ..\..\Chapter 22\AutoLotDAL\bin\Debug\AutoLotDAL.dll + + + System + True + + + System.Data + True + + + System.Transactions + True + + + System.Xml + True + + + System.Workflow.Activities + 3.0 + True + + + System.Workflow.ComponentModel + 3.0 + True + + + System.Workflow.Runtime + 3.0 + True + + + System.Design + True + + + System.Drawing + True + + + System.Drawing.Design + True + + + System.Windows.Forms + + + mscorlib + + + System.Web + True + + + System.Web.Services + True + + + 3.5 + + + 3.5 + + + 3.5 + + + 3.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Component + + + CreditCheckWF.vb + + + + True + MySettings.settings + Code + + + + + SettingsSingleFileGenerator + MySettings.vb + + + + + + + + CreditCheckWF.vb + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 26/CreditCheckWFLib/My Project/AssemblyInfo.vb b/Code/Chapter 26/CreditCheckWFLib/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..d1f6d05 --- /dev/null +++ b/Code/Chapter 26/CreditCheckWFLib/My Project/AssemblyInfo.vb @@ -0,0 +1,38 @@ +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 '*'. + + + + +'NOTE: When updating the namespaces in the project please add new or update existing the XmlnsDefinitionAttribute +'You can add additional attributes in order to map any additional namespaces you have in the project +' diff --git a/Code/Chapter 26/CreditCheckWFLib/My Project/MySettings.settings b/Code/Chapter 26/CreditCheckWFLib/My Project/MySettings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 26/CreditCheckWFLib/My Project/MySettings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 26/CreditCheckWFLib/My Project/MySettings.vb b/Code/Chapter 26/CreditCheckWFLib/My Project/MySettings.vb new file mode 100644 index 0000000..120b484 --- /dev/null +++ b/Code/Chapter 26/CreditCheckWFLib/My Project/MySettings.vb @@ -0,0 +1,28 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + + + _ +Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + + Public Shared ReadOnly Property [Default]() As MySettings + Get + Return defaultInstance + End Get + End Property +End Class diff --git a/Code/Chapter 26/MathWebService/App_Code/Service.vb b/Code/Chapter 26/MathWebService/App_Code/Service.vb new file mode 100644 index 0000000..652e24a --- /dev/null +++ b/Code/Chapter 26/MathWebService/App_Code/Service.vb @@ -0,0 +1,30 @@ +Imports System.Web +Imports System.Web.Services +Imports System.Web.Services.Protocols + + _ + _ +Public Class MathService + Inherits System.Web.Services.WebService + _ + Public Function Add(ByVal x As Integer, ByVal y As Integer) As Integer + Return x + y + End Function + _ + Public Function Subtract(ByVal x As Integer, ByVal y As Integer) As Integer + Return x - y + End Function + _ + Public Function Multiply(ByVal x As Integer, ByVal y As Integer) As Integer + Return x * y + End Function + _ + Public Function Divide(ByVal x As Integer, ByVal y As Integer) As Integer + If y = 0 Then + Return 0 + Else + Return x / y + End If + End Function +End Class + diff --git a/Code/Chapter 26/MathWebService/Service.asmx b/Code/Chapter 26/MathWebService/Service.asmx new file mode 100644 index 0000000..f1b113a --- /dev/null +++ b/Code/Chapter 26/MathWebService/Service.asmx @@ -0,0 +1 @@ +<%@ WebService Language="vb" CodeBehind="~/App_Code/Service.vb" Class="MathService" %> diff --git a/Code/Chapter 26/MathWebService/web.config b/Code/Chapter 26/MathWebService/web.config new file mode 100644 index 0000000..3cd8a42 --- /dev/null +++ b/Code/Chapter 26/MathWebService/web.config @@ -0,0 +1,166 @@ + + + + + + + + +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 26/UserDataWFApp/Module1.vb b/Code/Chapter 26/UserDataWFApp/Module1.vb new file mode 100644 index 0000000..8a0a24e --- /dev/null +++ b/Code/Chapter 26/UserDataWFApp/Module1.vb @@ -0,0 +1,41 @@ +Module Module1 + Class Program + + Shared WaitHandle As New AutoResetEvent(False) + + Shared Sub Main() + ' Ensure the runtime shuts down when we are finished. + Using workflowRuntime As New WorkflowRuntime() + + ' Handle events that capture when the engine completes + ' the workflow process and if the engine shuts down with an error. + AddHandler workflowRuntime.WorkflowCompleted, AddressOf OnWorkflowCompleted + AddHandler workflowRuntime.WorkflowTerminated, AddressOf OnWorkflowTerminated + + ' Define two parameters for use by our workflow. + ' Remember! These must be mapped to identically named + ' properties in our workflow class type. + Dim parameters As New Dictionary(Of String, Object)() + parameters.Add("ErrorMessage", "Ack! Your name is too long!") + parameters.Add("NameLength", 5) + + ' Now, create a WF instance that represents our type. + Dim workflowInstance As WorkflowInstance + workflowInstance = workflowRuntime.CreateWorkflow(GetType(ProcessUsernameWorkflow), parameters) + workflowInstance.Start() + WaitHandle.WaitOne() + End Using + End Sub + + Shared Sub OnWorkflowCompleted(ByVal sender As Object, ByVal e As WorkflowCompletedEventArgs) + WaitHandle.Set() + End Sub + + Shared Sub OnWorkflowTerminated(ByVal sender As Object, ByVal e As WorkflowTerminatedEventArgs) + Console.WriteLine(e.Exception.Message) + WaitHandle.Set() + End Sub + + End Class +End Module + diff --git a/Code/Chapter 26/UserDataWFApp/My Project/AssemblyInfo.vb b/Code/Chapter 26/UserDataWFApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..375e724 --- /dev/null +++ b/Code/Chapter 26/UserDataWFApp/My Project/AssemblyInfo.vb @@ -0,0 +1,38 @@ +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 '*'. + + + + +'NOTE: When updating the namespaces in the project please add new or update existing the XmlnsDefinitionAttribute +'You can add additional attributes in order to map any additional namespaces you have in the project +' diff --git a/Code/Chapter 26/UserDataWFApp/My Project/MySettings.settings b/Code/Chapter 26/UserDataWFApp/My Project/MySettings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 26/UserDataWFApp/My Project/MySettings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 26/UserDataWFApp/My Project/MySettings.vb b/Code/Chapter 26/UserDataWFApp/My Project/MySettings.vb new file mode 100644 index 0000000..120b484 --- /dev/null +++ b/Code/Chapter 26/UserDataWFApp/My Project/MySettings.vb @@ -0,0 +1,28 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + + + _ +Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + + Public Shared ReadOnly Property [Default]() As MySettings + Get + Return defaultInstance + End Get + End Property +End Class diff --git a/Code/Chapter 26/UserDataWFApp/ProcessUsernameWorkflow.designer.vb b/Code/Chapter 26/UserDataWFApp/ProcessUsernameWorkflow.designer.vb new file mode 100644 index 0000000..f5f629c --- /dev/null +++ b/Code/Chapter 26/UserDataWFApp/ProcessUsernameWorkflow.designer.vb @@ -0,0 +1,44 @@ + _ +Partial Class ProcessUsernameWorkflow + + 'NOTE: The following procedure is required by the Workflow Designer + 'It can be modified using the Workflow Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.CanModifyActivities = True + Dim codecondition1 As System.Workflow.Activities.CodeCondition = New System.Workflow.Activities.CodeCondition + Me.NameNotValidActivity = New System.Workflow.Activities.CodeActivity + Me.AskForNameLoopActivity = New System.Workflow.Activities.WhileActivity + Me.ShowInstructionsActivity = New System.Workflow.Activities.CodeActivity + ' + 'NameNotValidActivity + ' + Me.NameNotValidActivity.Name = "NameNotValidActivity" + AddHandler Me.NameNotValidActivity.ExecuteCode, AddressOf Me.NameNotValid + ' + 'AskForNameLoopActivity + ' + Me.AskForNameLoopActivity.Activities.Add(Me.NameNotValidActivity) + AddHandler codecondition1.Condition, AddressOf Me.GetAndValidateUserName + Me.AskForNameLoopActivity.Condition = codecondition1 + Me.AskForNameLoopActivity.Name = "AskForNameLoopActivity" + ' + 'ShowInstructionsActivity + ' + Me.ShowInstructionsActivity.Name = "ShowInstructionsActivity" + AddHandler Me.ShowInstructionsActivity.ExecuteCode, AddressOf Me.ShowInstructions + ' + 'ProcessUsernameWorkflow + ' + Me.Activities.Add(Me.ShowInstructionsActivity) + Me.Activities.Add(Me.AskForNameLoopActivity) + Me.Name = "ProcessUsernameWorkflow" + Me.CanModifyActivities = False + + End Sub + Private AskForNameLoopActivity As System.Workflow.Activities.WhileActivity + Private NameNotValidActivity As System.Workflow.Activities.CodeActivity + Private ShowInstructionsActivity As System.Workflow.Activities.CodeActivity + +End Class diff --git a/Code/Chapter 26/UserDataWFApp/ProcessUsernameWorkflow.vb b/Code/Chapter 26/UserDataWFApp/ProcessUsernameWorkflow.vb new file mode 100644 index 0000000..884957d --- /dev/null +++ b/Code/Chapter 26/UserDataWFApp/ProcessUsernameWorkflow.vb @@ -0,0 +1,58 @@ +Public Class ProcessUsernameWorkflow + Inherits SequentialWorkflowActivity + +#Region "Properties / backing fields" + ' To hold the name of the user. + Private usrName As String + Public Property UserName() As String + Get + Return usrName + End Get + Set(ByVal value As String) + usrName = value + End Set + End Property + + Private errMsg As String + Public Property ErrorMessage() As String + Get + Return errMsg + End Get + Set(ByVal value As String) + errMsg = value + End Set + End Property + + Private nameLen As Integer + Public Property NameLength() As Integer + Get + Return nameLen + End Get + Set(ByVal value As Integer) + nameLen = value + End Set + End Property +#End Region + + Private Sub GetAndValidateUserName(ByVal sender As System.Object, ByVal e As System.Workflow.Activities.ConditionalEventArgs) + Console.Write("Please enter name, which must be less than {0} chars: ", NameLength) + UserName = Console.ReadLine() + + ' See if name is correct length, and set the result. + e.Result = (UserName.Length >= NameLength) + End Sub + + Private Sub NameNotValid(ByVal sender As System.Object, ByVal e As System.EventArgs) + Console.WriteLine(ErrorMessage) + End Sub + + Private Sub ShowInstructions(ByVal sender As System.Object, ByVal e As System.EventArgs) + Dim previousColor As ConsoleColor = Console.ForegroundColor + Console.ForegroundColor = ConsoleColor.Yellow + Console.WriteLine("*******************************************") + Console.WriteLine("***** Welcome to the first WF Example *****") + Console.WriteLine("*******************************************" & vbLf) + Console.WriteLine("I will now ask for your name and validate the data..." & vbLf) + Console.ForegroundColor = previousColor + End Sub +End Class diff --git a/Code/Chapter 26/UserDataWFApp/UserDataWFApp.sln b/Code/Chapter 26/UserDataWFApp/UserDataWFApp.sln new file mode 100644 index 0000000..2ae9449 --- /dev/null +++ b/Code/Chapter 26/UserDataWFApp/UserDataWFApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "UserDataWFApp", "UserDataWFApp.vbproj", "{2827EEB1-DA7C-441E-851F-230353A6C916}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2827EEB1-DA7C-441E-851F-230353A6C916}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2827EEB1-DA7C-441E-851F-230353A6C916}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2827EEB1-DA7C-441E-851F-230353A6C916}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2827EEB1-DA7C-441E-851F-230353A6C916}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 26/UserDataWFApp/UserDataWFApp.suo b/Code/Chapter 26/UserDataWFApp/UserDataWFApp.suo new file mode 100644 index 0000000..d2c49a9 Binary files /dev/null and b/Code/Chapter 26/UserDataWFApp/UserDataWFApp.suo differ diff --git a/Code/Chapter 26/UserDataWFApp/UserDataWFApp.vbproj b/Code/Chapter 26/UserDataWFApp/UserDataWFApp.vbproj new file mode 100644 index 0000000..df6fd95 --- /dev/null +++ b/Code/Chapter 26/UserDataWFApp/UserDataWFApp.vbproj @@ -0,0 +1,173 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {2827EEB1-DA7C-441E-851F-230353A6C916} + {D59BE175-2ED0-4C54-BE3D-CDAA9F3214C8};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + Exe + + + UserDataWFApp + UserDataWFApp + v3.5 + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + On + Binary + Off + On + + + true + full + true + true + true + bin\ + _MyType="Windows" + UserDataWFApp.xml + false + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + false + false + true + false + true + bin\ + _MyType="Windows" + UserDataWFApp.xml + false + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + System + True + + + System.Data + True + + + System.Transactions + True + + + System.Xml + True + + + System.Workflow.Activities + 3.0 + True + + + System.Workflow.ComponentModel + 3.0 + True + + + System.Workflow.Runtime + 3.0 + True + + + System.Design + True + + + System.Drawing + True + + + System.Drawing.Design + True + + + System.Windows.Forms + + + mscorlib + + + System.Web + True + + + System.Web.Services + True + + + 3.5 + + + 3.5 + + + 3.5 + + + 3.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Component + + + ProcessUsernameWorkflow.vb + + + + True + MySettings.settings + Code + + + + + SettingsSingleFileGenerator + MySettings.vb + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 26/UserDataWFApp/UserDataWFApp.vbproj.user b/Code/Chapter 26/UserDataWFApp/UserDataWFApp.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 26/UserDataWFApp/UserDataWFApp.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 26/WFMathClient/MathWF.designer.vb b/Code/Chapter 26/WFMathClient/MathWF.designer.vb new file mode 100644 index 0000000..7fabaec --- /dev/null +++ b/Code/Chapter 26/WFMathClient/MathWF.designer.vb @@ -0,0 +1,254 @@ + _ +Partial Class MathWF + + 'NOTE: The following procedure is required by the Workflow Designer + 'It can be modified using the Workflow Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.CanModifyActivities = True + Dim activitybind1 As System.Workflow.ComponentModel.ActivityBind = New System.Workflow.ComponentModel.ActivityBind + Dim workflowparameterbinding1 As System.Workflow.ComponentModel.WorkflowParameterBinding = New System.Workflow.ComponentModel.WorkflowParameterBinding + Dim activitybind2 As System.Workflow.ComponentModel.ActivityBind = New System.Workflow.ComponentModel.ActivityBind + Dim workflowparameterbinding2 As System.Workflow.ComponentModel.WorkflowParameterBinding = New System.Workflow.ComponentModel.WorkflowParameterBinding + Dim activitybind3 As System.Workflow.ComponentModel.ActivityBind = New System.Workflow.ComponentModel.ActivityBind + Dim workflowparameterbinding3 As System.Workflow.ComponentModel.WorkflowParameterBinding = New System.Workflow.ComponentModel.WorkflowParameterBinding + Dim activitybind4 As System.Workflow.ComponentModel.ActivityBind = New System.Workflow.ComponentModel.ActivityBind + Dim workflowparameterbinding4 As System.Workflow.ComponentModel.WorkflowParameterBinding = New System.Workflow.ComponentModel.WorkflowParameterBinding + Dim activitybind5 As System.Workflow.ComponentModel.ActivityBind = New System.Workflow.ComponentModel.ActivityBind + Dim workflowparameterbinding5 As System.Workflow.ComponentModel.WorkflowParameterBinding = New System.Workflow.ComponentModel.WorkflowParameterBinding + Dim activitybind6 As System.Workflow.ComponentModel.ActivityBind = New System.Workflow.ComponentModel.ActivityBind + Dim workflowparameterbinding6 As System.Workflow.ComponentModel.WorkflowParameterBinding = New System.Workflow.ComponentModel.WorkflowParameterBinding + Dim activitybind7 As System.Workflow.ComponentModel.ActivityBind = New System.Workflow.ComponentModel.ActivityBind + Dim workflowparameterbinding7 As System.Workflow.ComponentModel.WorkflowParameterBinding = New System.Workflow.ComponentModel.WorkflowParameterBinding + Dim activitybind8 As System.Workflow.ComponentModel.ActivityBind = New System.Workflow.ComponentModel.ActivityBind + Dim workflowparameterbinding8 As System.Workflow.ComponentModel.WorkflowParameterBinding = New System.Workflow.ComponentModel.WorkflowParameterBinding + Dim activitybind9 As System.Workflow.ComponentModel.ActivityBind = New System.Workflow.ComponentModel.ActivityBind + Dim workflowparameterbinding9 As System.Workflow.ComponentModel.WorkflowParameterBinding = New System.Workflow.ComponentModel.WorkflowParameterBinding + Dim activitybind10 As System.Workflow.ComponentModel.ActivityBind = New System.Workflow.ComponentModel.ActivityBind + Dim workflowparameterbinding10 As System.Workflow.ComponentModel.WorkflowParameterBinding = New System.Workflow.ComponentModel.WorkflowParameterBinding + Dim activitybind11 As System.Workflow.ComponentModel.ActivityBind = New System.Workflow.ComponentModel.ActivityBind + Dim workflowparameterbinding11 As System.Workflow.ComponentModel.WorkflowParameterBinding = New System.Workflow.ComponentModel.WorkflowParameterBinding + Dim activitybind12 As System.Workflow.ComponentModel.ActivityBind = New System.Workflow.ComponentModel.ActivityBind + Dim workflowparameterbinding12 As System.Workflow.ComponentModel.WorkflowParameterBinding = New System.Workflow.ComponentModel.WorkflowParameterBinding + Dim ruleconditionreference1 As System.Workflow.Activities.Rules.RuleConditionReference = New System.Workflow.Activities.Rules.RuleConditionReference + Dim ruleconditionreference2 As System.Workflow.Activities.Rules.RuleConditionReference = New System.Workflow.Activities.Rules.RuleConditionReference + Dim ruleconditionreference3 As System.Workflow.Activities.Rules.RuleConditionReference = New System.Workflow.Activities.Rules.RuleConditionReference + Dim ruleconditionreference4 As System.Workflow.Activities.Rules.RuleConditionReference = New System.Workflow.Activities.Rules.RuleConditionReference + Dim channeltoken1 As System.Workflow.Activities.ChannelToken = New System.Workflow.Activities.ChannelToken + Dim activitybind13 As System.Workflow.ComponentModel.ActivityBind = New System.Workflow.ComponentModel.ActivityBind + Dim workflowparameterbinding13 As System.Workflow.ComponentModel.WorkflowParameterBinding = New System.Workflow.ComponentModel.WorkflowParameterBinding + Dim activitybind14 As System.Workflow.ComponentModel.ActivityBind = New System.Workflow.ComponentModel.ActivityBind + Dim workflowparameterbinding14 As System.Workflow.ComponentModel.WorkflowParameterBinding = New System.Workflow.ComponentModel.WorkflowParameterBinding + Dim activitybind15 As System.Workflow.ComponentModel.ActivityBind = New System.Workflow.ComponentModel.ActivityBind + Dim workflowparameterbinding15 As System.Workflow.ComponentModel.WorkflowParameterBinding = New System.Workflow.ComponentModel.WorkflowParameterBinding + Dim typedoperationinfo1 As System.Workflow.Activities.TypedOperationInfo = New System.Workflow.Activities.TypedOperationInfo + Me.invokeWebServiceActivity4 = New System.Workflow.Activities.InvokeWebServiceActivity + Me.invokeWebServiceActivity3 = New System.Workflow.Activities.InvokeWebServiceActivity + Me.invokeWebServiceActivity2 = New System.Workflow.Activities.InvokeWebServiceActivity + Me.invokeWebServiceActivity1 = New System.Workflow.Activities.InvokeWebServiceActivity + Me.IfDivideOp = New System.Workflow.Activities.IfElseBranchActivity + Me.IfMultiplyOp = New System.Workflow.Activities.IfElseBranchActivity + Me.IfSubOp = New System.Workflow.Activities.IfElseBranchActivity + Me.IfAddOp = New System.Workflow.Activities.IfElseBranchActivity + Me.codeActivity1 = New System.Workflow.Activities.CodeActivity + Me.WCFSendAddActivity = New System.Workflow.Activities.SendActivity + Me.DisplayResult = New System.Workflow.Activities.CodeActivity + Me.ifElseActivity1 = New System.Workflow.Activities.IfElseActivity + Me.GetMathOpInput = New System.Workflow.Activities.CodeActivity + Me.GetNumericalInput = New System.Workflow.Activities.CodeActivity + ' + 'invokeWebServiceActivity4 + ' + Me.invokeWebServiceActivity4.MethodName = "Divide" + Me.invokeWebServiceActivity4.Name = "invokeWebServiceActivity4" + activitybind1.Name = "MathWF" + activitybind1.Path = "Result" + workflowparameterbinding1.ParameterName = "(ReturnValue)" + workflowparameterbinding1.SetBinding(System.Workflow.ComponentModel.WorkflowParameterBinding.ValueProperty, CType(activitybind1, System.Workflow.ComponentModel.ActivityBind)) + activitybind2.Name = "MathWF" + activitybind2.Path = "FirstNumber" + workflowparameterbinding2.ParameterName = "x" + workflowparameterbinding2.SetBinding(System.Workflow.ComponentModel.WorkflowParameterBinding.ValueProperty, CType(activitybind2, System.Workflow.ComponentModel.ActivityBind)) + activitybind3.Name = "MathWF" + activitybind3.Path = "SecondNumber" + workflowparameterbinding3.ParameterName = "y" + workflowparameterbinding3.SetBinding(System.Workflow.ComponentModel.WorkflowParameterBinding.ValueProperty, CType(activitybind3, System.Workflow.ComponentModel.ActivityBind)) + Me.invokeWebServiceActivity4.ParameterBindings.Add(workflowparameterbinding1) + Me.invokeWebServiceActivity4.ParameterBindings.Add(workflowparameterbinding2) + Me.invokeWebServiceActivity4.ParameterBindings.Add(workflowparameterbinding3) + Me.invokeWebServiceActivity4.ProxyClass = GetType(WFMathClient.localhost.MathService) + ' + 'invokeWebServiceActivity3 + ' + Me.invokeWebServiceActivity3.MethodName = "Multiply" + Me.invokeWebServiceActivity3.Name = "invokeWebServiceActivity3" + activitybind4.Name = "MathWF" + activitybind4.Path = "FirstNumber" + workflowparameterbinding4.ParameterName = "x" + workflowparameterbinding4.SetBinding(System.Workflow.ComponentModel.WorkflowParameterBinding.ValueProperty, CType(activitybind4, System.Workflow.ComponentModel.ActivityBind)) + activitybind5.Name = "MathWF" + activitybind5.Path = "SecondNumber" + workflowparameterbinding5.ParameterName = "y" + workflowparameterbinding5.SetBinding(System.Workflow.ComponentModel.WorkflowParameterBinding.ValueProperty, CType(activitybind5, System.Workflow.ComponentModel.ActivityBind)) + activitybind6.Name = "MathWF" + activitybind6.Path = "Result" + workflowparameterbinding6.ParameterName = "(ReturnValue)" + workflowparameterbinding6.SetBinding(System.Workflow.ComponentModel.WorkflowParameterBinding.ValueProperty, CType(activitybind6, System.Workflow.ComponentModel.ActivityBind)) + Me.invokeWebServiceActivity3.ParameterBindings.Add(workflowparameterbinding4) + Me.invokeWebServiceActivity3.ParameterBindings.Add(workflowparameterbinding5) + Me.invokeWebServiceActivity3.ParameterBindings.Add(workflowparameterbinding6) + Me.invokeWebServiceActivity3.ProxyClass = GetType(WFMathClient.localhost.MathService) + ' + 'invokeWebServiceActivity2 + ' + Me.invokeWebServiceActivity2.MethodName = "Subtract" + Me.invokeWebServiceActivity2.Name = "invokeWebServiceActivity2" + activitybind7.Name = "MathWF" + activitybind7.Path = "FirstNumber" + workflowparameterbinding7.ParameterName = "x" + workflowparameterbinding7.SetBinding(System.Workflow.ComponentModel.WorkflowParameterBinding.ValueProperty, CType(activitybind7, System.Workflow.ComponentModel.ActivityBind)) + activitybind8.Name = "MathWF" + activitybind8.Path = "SecondNumber" + workflowparameterbinding8.ParameterName = "y" + workflowparameterbinding8.SetBinding(System.Workflow.ComponentModel.WorkflowParameterBinding.ValueProperty, CType(activitybind8, System.Workflow.ComponentModel.ActivityBind)) + activitybind9.Name = "MathWF" + activitybind9.Path = "Result" + workflowparameterbinding9.ParameterName = "(ReturnValue)" + workflowparameterbinding9.SetBinding(System.Workflow.ComponentModel.WorkflowParameterBinding.ValueProperty, CType(activitybind9, System.Workflow.ComponentModel.ActivityBind)) + Me.invokeWebServiceActivity2.ParameterBindings.Add(workflowparameterbinding7) + Me.invokeWebServiceActivity2.ParameterBindings.Add(workflowparameterbinding8) + Me.invokeWebServiceActivity2.ParameterBindings.Add(workflowparameterbinding9) + Me.invokeWebServiceActivity2.ProxyClass = GetType(WFMathClient.localhost.MathService) + ' + 'invokeWebServiceActivity1 + ' + Me.invokeWebServiceActivity1.MethodName = "Add" + Me.invokeWebServiceActivity1.Name = "invokeWebServiceActivity1" + activitybind10.Name = "MathWF" + activitybind10.Path = "FirstNumber" + workflowparameterbinding10.ParameterName = "x" + workflowparameterbinding10.SetBinding(System.Workflow.ComponentModel.WorkflowParameterBinding.ValueProperty, CType(activitybind10, System.Workflow.ComponentModel.ActivityBind)) + activitybind11.Name = "MathWF" + activitybind11.Path = "SecondNumber" + workflowparameterbinding11.ParameterName = "y" + workflowparameterbinding11.SetBinding(System.Workflow.ComponentModel.WorkflowParameterBinding.ValueProperty, CType(activitybind11, System.Workflow.ComponentModel.ActivityBind)) + activitybind12.Name = "MathWF" + activitybind12.Path = "Result" + workflowparameterbinding12.ParameterName = "(ReturnValue)" + workflowparameterbinding12.SetBinding(System.Workflow.ComponentModel.WorkflowParameterBinding.ValueProperty, CType(activitybind12, System.Workflow.ComponentModel.ActivityBind)) + Me.invokeWebServiceActivity1.ParameterBindings.Add(workflowparameterbinding10) + Me.invokeWebServiceActivity1.ParameterBindings.Add(workflowparameterbinding11) + Me.invokeWebServiceActivity1.ParameterBindings.Add(workflowparameterbinding12) + Me.invokeWebServiceActivity1.ProxyClass = GetType(WFMathClient.localhost.MathService) + ' + 'IfDivideOp + ' + Me.IfDivideOp.Activities.Add(Me.invokeWebServiceActivity4) + ruleconditionreference1.ConditionName = "Condition4" + Me.IfDivideOp.Condition = ruleconditionreference1 + Me.IfDivideOp.Name = "IfDivideOp" + ' + 'IfMultiplyOp + ' + Me.IfMultiplyOp.Activities.Add(Me.invokeWebServiceActivity3) + ruleconditionreference2.ConditionName = "Condition3" + Me.IfMultiplyOp.Condition = ruleconditionreference2 + Me.IfMultiplyOp.Name = "IfMultiplyOp" + ' + 'IfSubOp + ' + Me.IfSubOp.Activities.Add(Me.invokeWebServiceActivity2) + ruleconditionreference3.ConditionName = "Condition2" + Me.IfSubOp.Condition = ruleconditionreference3 + Me.IfSubOp.Name = "IfSubOp" + ' + 'IfAddOp + ' + Me.IfAddOp.Activities.Add(Me.invokeWebServiceActivity1) + ruleconditionreference4.ConditionName = "Condition1" + Me.IfAddOp.Condition = ruleconditionreference4 + Me.IfAddOp.Name = "IfAddOp" + ' + 'codeActivity1 + ' + Me.codeActivity1.Name = "codeActivity1" + AddHandler Me.codeActivity1.ExecuteCode, AddressOf Me.WCFResult + ' + 'WCFSendAddActivity + ' + channeltoken1.EndpointName = "WSHttpBinding_IBasicMath" + channeltoken1.Name = "WSHttpBinding_IBasicMath" + channeltoken1.OwnerActivityName = "WCFSendAddActivity" + Me.WCFSendAddActivity.ChannelToken = channeltoken1 + Me.WCFSendAddActivity.Name = "WCFSendAddActivity" + activitybind13.Name = "MathWF" + activitybind13.Path = "Result" + workflowparameterbinding13.ParameterName = "(ReturnValue)" + workflowparameterbinding13.SetBinding(System.Workflow.ComponentModel.WorkflowParameterBinding.ValueProperty, CType(activitybind13, System.Workflow.ComponentModel.ActivityBind)) + activitybind14.Name = "MathWF" + activitybind14.Path = "FirstNumber" + workflowparameterbinding14.ParameterName = "x" + workflowparameterbinding14.SetBinding(System.Workflow.ComponentModel.WorkflowParameterBinding.ValueProperty, CType(activitybind14, System.Workflow.ComponentModel.ActivityBind)) + activitybind15.Name = "MathWF" + activitybind15.Path = "SecondNumber" + workflowparameterbinding15.ParameterName = "y" + workflowparameterbinding15.SetBinding(System.Workflow.ComponentModel.WorkflowParameterBinding.ValueProperty, CType(activitybind15, System.Workflow.ComponentModel.ActivityBind)) + Me.WCFSendAddActivity.ParameterBindings.Add(workflowparameterbinding13) + Me.WCFSendAddActivity.ParameterBindings.Add(workflowparameterbinding14) + Me.WCFSendAddActivity.ParameterBindings.Add(workflowparameterbinding15) + typedoperationinfo1.ContractType = GetType(WFMathClient.ServiceReference1.IBasicMath) + typedoperationinfo1.Name = "Add" + Me.WCFSendAddActivity.ServiceOperationInfo = typedoperationinfo1 + ' + 'DisplayResult + ' + Me.DisplayResult.Name = "DisplayResult" + AddHandler Me.DisplayResult.ExecuteCode, AddressOf Me.ShowResult + ' + 'ifElseActivity1 + ' + Me.ifElseActivity1.Activities.Add(Me.IfAddOp) + Me.ifElseActivity1.Activities.Add(Me.IfSubOp) + Me.ifElseActivity1.Activities.Add(Me.IfMultiplyOp) + Me.ifElseActivity1.Activities.Add(Me.IfDivideOp) + Me.ifElseActivity1.Name = "ifElseActivity1" + ' + 'GetMathOpInput + ' + Me.GetMathOpInput.Name = "GetMathOpInput" + AddHandler Me.GetMathOpInput.ExecuteCode, AddressOf Me.GetOpInput + ' + 'GetNumericalInput + ' + Me.GetNumericalInput.Name = "GetNumericalInput" + AddHandler Me.GetNumericalInput.ExecuteCode, AddressOf Me.GetNumbInput + ' + 'MathWF + ' + Me.Activities.Add(Me.GetNumericalInput) + Me.Activities.Add(Me.GetMathOpInput) + Me.Activities.Add(Me.ifElseActivity1) + Me.Activities.Add(Me.DisplayResult) + Me.Activities.Add(Me.WCFSendAddActivity) + Me.Activities.Add(Me.codeActivity1) + Me.Name = "MathWF" + Me.CanModifyActivities = False + + End Sub + Private WCFSendAddActivity As System.Workflow.Activities.SendActivity + Private codeActivity1 As System.Workflow.Activities.CodeActivity + Private IfDivideOp As System.Workflow.Activities.IfElseBranchActivity + Private IfMultiplyOp As System.Workflow.Activities.IfElseBranchActivity + Private IfSubOp As System.Workflow.Activities.IfElseBranchActivity + Private IfAddOp As System.Workflow.Activities.IfElseBranchActivity + Private ifElseActivity1 As System.Workflow.Activities.IfElseActivity + Private invokeWebServiceActivity1 As System.Workflow.Activities.InvokeWebServiceActivity + Private invokeWebServiceActivity2 As System.Workflow.Activities.InvokeWebServiceActivity + Private invokeWebServiceActivity3 As System.Workflow.Activities.InvokeWebServiceActivity + Private invokeWebServiceActivity4 As System.Workflow.Activities.InvokeWebServiceActivity + Private DisplayResult As System.Workflow.Activities.CodeActivity + Private GetMathOpInput As System.Workflow.Activities.CodeActivity + Private GetNumericalInput As System.Workflow.Activities.CodeActivity + +End Class diff --git a/Code/Chapter 26/WFMathClient/MathWF.resx b/Code/Chapter 26/WFMathClient/MathWF.resx new file mode 100644 index 0000000..00a8661 --- /dev/null +++ b/Code/Chapter 26/WFMathClient/MathWF.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + http://localhost/VbMathWebService/Service.asmx + + + http://localhost/VbMathWebService/Service.asmx + + + http://localhost/VbMathWebService/Service.asmx + + + http://localhost/VbMathWebService/Service.asmx + + \ No newline at end of file diff --git a/Code/Chapter 26/WFMathClient/MathWF.rules b/Code/Chapter 26/WFMathClient/MathWF.rules new file mode 100644 index 0000000..1462ea4 --- /dev/null +++ b/Code/Chapter 26/WFMathClient/MathWF.rules @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 26/WFMathClient/MathWF.vb b/Code/Chapter 26/WFMathClient/MathWF.vb new file mode 100644 index 0000000..6c65957 --- /dev/null +++ b/Code/Chapter 26/WFMathClient/MathWF.vb @@ -0,0 +1,106 @@ +Public Enum MathOperation + Add + Subtract + Multiply + Divide +End Enum + +Public Class MathWF + Inherits SequentialWorkflowActivity + +#Region "Properties / backing fields" + Private numb1 As Integer + Public Property FirstNumber() As Integer + Get + Return numb1 + End Get + Set(ByVal value As Integer) + numb1 = value + End Set + End Property + + Private numb2 As Integer + Public Property SecondNumber() As Integer + Get + Return numb2 + End Get + Set(ByVal value As Integer) + numb2 = value + End Set + End Property + + Private res As Integer + Public Property Result() As Integer + Get + Return res + End Get + Set(ByVal value As Integer) + res = value + End Set + End Property + + Private mathOp As MathOperation + Public Property Operation() As MathOperation + Get + Return mathOp + End Get + Set(ByVal value As MathOperation) + mathOp = value + End Set + End Property +#End Region + + Sub New() + + ' This call is required by the Windows Form Designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call. + Operation = MathOperation.Add + End Sub + + Private Sub GetNumbInput(ByVal sender As System.Object, ByVal e As System.EventArgs) + ' For simplicity, we are not bothering to verify that + ' the input values are indeed numerical. + Console.Write("Enter first number: ") + FirstNumber = Integer.Parse(Console.ReadLine()) + + Console.Write("Enter second number: ") + SecondNumber = Integer.Parse(Console.ReadLine()) + End Sub + + Private Sub GetOpInput(ByVal sender As System.Object, ByVal e As System.EventArgs) + Console.WriteLine("Do you wish to A[dd], S[ubtract],") + Console.Write("Do you wish to M[ultiply] or D[ivide]: ") + Dim op As String = Console.ReadLine() + + Select Case op.ToUpper() + Case "A" + Operation = MathOperation.Add + Exit Select + Case "S" + Operation = MathOperation.Subtract + Exit Select + Case "M" + Operation = MathOperation.Multiply + Exit Select + Case "D" + Operation = MathOperation.Divide + Exit Select + Case Else + Operation = MathOperation.Add + Exit Select + End Select + End Sub + + Private Sub ShowResult(ByVal sender As System.Object, ByVal e As System.EventArgs) + Console.WriteLine("{0} {1} {2} = {3}", _ + FirstNumber, Operation.ToString().ToUpper(), SecondNumber, Result) + End Sub + + Private Sub WCFResult(ByVal sender As System.Object, ByVal e As System.EventArgs) + Console.WriteLine("***** WCF Service Addition *****") + Console.WriteLine("{0} + {1} = {2}", _ + FirstNumber, SecondNumber, Result) + End Sub +End Class diff --git a/Code/Chapter 26/WFMathClient/Module1.vb b/Code/Chapter 26/WFMathClient/Module1.vb new file mode 100644 index 0000000..b5023d5 --- /dev/null +++ b/Code/Chapter 26/WFMathClient/Module1.vb @@ -0,0 +1,29 @@ +Module Module1 + Class Program + + Shared WaitHandle As New AutoResetEvent(False) + + Shared Sub Main() + Using workflowRuntime As New WorkflowRuntime() + AddHandler workflowRuntime.WorkflowCompleted, AddressOf OnWorkflowCompleted + AddHandler workflowRuntime.WorkflowTerminated, AddressOf OnWorkflowTerminated + + Dim workflowInstance As WorkflowInstance + workflowInstance = workflowRuntime.CreateWorkflow(GetType(MathWF)) + workflowInstance.Start() + WaitHandle.WaitOne() + End Using + End Sub + + Shared Sub OnWorkflowCompleted(ByVal sender As Object, ByVal e As WorkflowCompletedEventArgs) + WaitHandle.Set() + End Sub + + Shared Sub OnWorkflowTerminated(ByVal sender As Object, ByVal e As WorkflowTerminatedEventArgs) + Console.WriteLine(e.Exception.Message) + WaitHandle.Set() + End Sub + + End Class +End Module + diff --git a/Code/Chapter 26/WFMathClient/My Project/AssemblyInfo.vb b/Code/Chapter 26/WFMathClient/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..a40d50a --- /dev/null +++ b/Code/Chapter 26/WFMathClient/My Project/AssemblyInfo.vb @@ -0,0 +1,38 @@ +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 '*'. + + + + +'NOTE: When updating the namespaces in the project please add new or update existing the XmlnsDefinitionAttribute +'You can add additional attributes in order to map any additional namespaces you have in the project +' diff --git a/Code/Chapter 26/WFMathClient/My Project/MySettings.settings b/Code/Chapter 26/WFMathClient/My Project/MySettings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 26/WFMathClient/My Project/MySettings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 26/WFMathClient/My Project/MySettings.vb b/Code/Chapter 26/WFMathClient/My Project/MySettings.vb new file mode 100644 index 0000000..120b484 --- /dev/null +++ b/Code/Chapter 26/WFMathClient/My Project/MySettings.vb @@ -0,0 +1,28 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + + + _ +Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + + Public Shared ReadOnly Property [Default]() As MySettings + Get + Return defaultInstance + End Get + End Property +End Class diff --git a/Code/Chapter 26/WFMathClient/My Project/Settings.Designer.vb b/Code/Chapter 26/WFMathClient/My Project/Settings.Designer.vb new file mode 100644 index 0000000..d300636 --- /dev/null +++ b/Code/Chapter 26/WFMathClient/My Project/Settings.Designer.vb @@ -0,0 +1,83 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings),MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + + _ + Public ReadOnly Property WFMathClient_localhost_MathService() As String + Get + Return CType(Me("WFMathClient_localhost_MathService"),String) + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.WFMathClient.My.MySettings + Get + Return Global.WFMathClient.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 26/WFMathClient/My Project/Settings.settings b/Code/Chapter 26/WFMathClient/My Project/Settings.settings new file mode 100644 index 0000000..0047f5b --- /dev/null +++ b/Code/Chapter 26/WFMathClient/My Project/Settings.settings @@ -0,0 +1,9 @@ + + + + + + http://localhost/VbMathWebService/Service.asmx + + + \ No newline at end of file diff --git a/Code/Chapter 26/WFMathClient/Service References/ServiceReference1/MathService.disco b/Code/Chapter 26/WFMathClient/Service References/ServiceReference1/MathService.disco new file mode 100644 index 0000000..e7bdddb --- /dev/null +++ b/Code/Chapter 26/WFMathClient/Service References/ServiceReference1/MathService.disco @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Code/Chapter 26/WFMathClient/Service References/ServiceReference1/MathService.wsdl b/Code/Chapter 26/WFMathClient/Service References/ServiceReference1/MathService.wsdl new file mode 100644 index 0000000..42e5af2 --- /dev/null +++ b/Code/Chapter 26/WFMathClient/Service References/ServiceReference1/MathService.wsdl @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 26/WFMathClient/Service References/ServiceReference1/MathService.xsd b/Code/Chapter 26/WFMathClient/Service References/ServiceReference1/MathService.xsd new file mode 100644 index 0000000..095d9f6 --- /dev/null +++ b/Code/Chapter 26/WFMathClient/Service References/ServiceReference1/MathService.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 26/WFMathClient/Service References/ServiceReference1/MathService1.wsdl b/Code/Chapter 26/WFMathClient/Service References/ServiceReference1/MathService1.wsdl new file mode 100644 index 0000000..9385f0d --- /dev/null +++ b/Code/Chapter 26/WFMathClient/Service References/ServiceReference1/MathService1.wsdl @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://localhost:8080/MathServiceLibrary + + host/InterUber.intertech-inc.com + + + + + \ No newline at end of file diff --git a/Code/Chapter 26/WFMathClient/Service References/ServiceReference1/MathService1.xsd b/Code/Chapter 26/WFMathClient/Service References/ServiceReference1/MathService1.xsd new file mode 100644 index 0000000..d00d787 --- /dev/null +++ b/Code/Chapter 26/WFMathClient/Service References/ServiceReference1/MathService1.xsd @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 26/WFMathClient/Service References/ServiceReference1/Reference.svcmap b/Code/Chapter 26/WFMathClient/Service References/ServiceReference1/Reference.svcmap new file mode 100644 index 0000000..a6afa11 --- /dev/null +++ b/Code/Chapter 26/WFMathClient/Service References/ServiceReference1/Reference.svcmap @@ -0,0 +1,32 @@ + + + + false + true + + false + false + false + + + true + Auto + true + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 26/WFMathClient/Service References/ServiceReference1/Reference.vb b/Code/Chapter 26/WFMathClient/Service References/ServiceReference1/Reference.vb new file mode 100644 index 0000000..fa379ae --- /dev/null +++ b/Code/Chapter 26/WFMathClient/Service References/ServiceReference1/Reference.vb @@ -0,0 +1,60 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace ServiceReference1 + + _ + Public Interface IBasicMath + + _ + Function Add(ByVal x As Integer, ByVal y As Integer) As Integer + End Interface + + _ + Public Interface IBasicMathChannel + Inherits ServiceReference1.IBasicMath, System.ServiceModel.IClientChannel + End Interface + + _ + Partial Public Class BasicMathClient + Inherits System.ServiceModel.ClientBase(Of ServiceReference1.IBasicMath) + Implements ServiceReference1.IBasicMath + + Public Sub New() + MyBase.New + End Sub + + Public Sub New(ByVal endpointConfigurationName As String) + MyBase.New(endpointConfigurationName) + End Sub + + Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As String) + MyBase.New(endpointConfigurationName, remoteAddress) + End Sub + + Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As System.ServiceModel.EndpointAddress) + MyBase.New(endpointConfigurationName, remoteAddress) + End Sub + + Public Sub New(ByVal binding As System.ServiceModel.Channels.Binding, ByVal remoteAddress As System.ServiceModel.EndpointAddress) + MyBase.New(binding, remoteAddress) + End Sub + + Public Function Add(ByVal x As Integer, ByVal y As Integer) As Integer Implements ServiceReference1.IBasicMath.Add + Return MyBase.Channel.Add(x, y) + End Function + End Class +End Namespace diff --git a/Code/Chapter 26/WFMathClient/Service References/ServiceReference1/configuration.svcinfo b/Code/Chapter 26/WFMathClient/Service References/ServiceReference1/configuration.svcinfo new file mode 100644 index 0000000..f60c728 --- /dev/null +++ b/Code/Chapter 26/WFMathClient/Service References/ServiceReference1/configuration.svcinfo @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 26/WFMathClient/WFMathClient.sln b/Code/Chapter 26/WFMathClient/WFMathClient.sln new file mode 100644 index 0000000..ca2f694 --- /dev/null +++ b/Code/Chapter 26/WFMathClient/WFMathClient.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "WFMathClient", "WFMathClient.vbproj", "{9F0221AF-0115-48A7-A818-EDBFBE0D4472}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9F0221AF-0115-48A7-A818-EDBFBE0D4472}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9F0221AF-0115-48A7-A818-EDBFBE0D4472}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9F0221AF-0115-48A7-A818-EDBFBE0D4472}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9F0221AF-0115-48A7-A818-EDBFBE0D4472}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 26/WFMathClient/WFMathClient.suo b/Code/Chapter 26/WFMathClient/WFMathClient.suo new file mode 100644 index 0000000..f9f1da0 Binary files /dev/null and b/Code/Chapter 26/WFMathClient/WFMathClient.suo differ diff --git a/Code/Chapter 26/WFMathClient/WFMathClient.vbproj b/Code/Chapter 26/WFMathClient/WFMathClient.vbproj new file mode 100644 index 0000000..a7f3dc8 --- /dev/null +++ b/Code/Chapter 26/WFMathClient/WFMathClient.vbproj @@ -0,0 +1,253 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {9F0221AF-0115-48A7-A818-EDBFBE0D4472} + {D59BE175-2ED0-4C54-BE3D-CDAA9F3214C8};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + Exe + + + WFMathClient + WFMathClient + v3.5 + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + On + Binary + Off + On + + + true + full + true + true + true + bin\ + _MyType="Windows" + WFMathClient.xml + false + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + false + false + true + false + true + bin\ + _MyType="Windows" + WFMathClient.xml + false + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + System + True + + + System.Data + True + + + + 3.0 + + + System.Transactions + True + + + System.Xml + True + + + System.Workflow.Activities + 3.0 + True + + + System.Workflow.ComponentModel + 3.0 + True + + + System.Workflow.Runtime + 3.0 + True + + + System.Design + True + + + System.Drawing + True + + + System.Drawing.Design + True + + + System.Windows.Forms + + + mscorlib + + + System.Web + True + + + System.Web.Services + True + + + 3.5 + + + 3.5 + + + 3.5 + + + 3.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Component + + + True + True + Settings.settings + + + True + True + Reference.svcmap + + + True + True + Reference.map + + + MathWF.vb + + + + True + MySettings.settings + Code + + + + + SettingsSingleFileGenerator + MySettings.vb + + + + + + + + + MathWF.vb + Designer + + + MathWF.vb + + + + + + + + Dynamic + Web References\localhost\ + http://localhost/VbMathWebService/Service.asmx + + + + + MySettings + WFMathClient_localhost_MathService + + + + + + My + SettingsSingleFileGenerator + Settings.Designer.vb + + + + + + MSDiscoCodeGenerator + Reference.vb + + + + + + + + + + + + + + + + + + + WCF Proxy Generator + Reference.vb + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 26/WFMathClient/WFMathClient.vbproj.user b/Code/Chapter 26/WFMathClient/WFMathClient.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 26/WFMathClient/WFMathClient.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 26/WFMathClient/Web References/localhost/Reference.map b/Code/Chapter 26/WFMathClient/Web References/localhost/Reference.map new file mode 100644 index 0000000..b66b1cf --- /dev/null +++ b/Code/Chapter 26/WFMathClient/Web References/localhost/Reference.map @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 26/WFMathClient/Web References/localhost/Reference.vb b/Code/Chapter 26/WFMathClient/Web References/localhost/Reference.vb new file mode 100644 index 0000000..65a5d43 --- /dev/null +++ b/Code/Chapter 26/WFMathClient/Web References/localhost/Reference.vb @@ -0,0 +1,326 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.ComponentModel +Imports System.Diagnostics +Imports System.Web.Services +Imports System.Web.Services.Protocols +Imports System.Xml.Serialization + +' +'This source code was auto-generated by Microsoft.VSDesigner, Version 2.0.50727.1433. +' +Namespace localhost + + ''' + _ + Partial Public Class MathService + Inherits System.Web.Services.Protocols.SoapHttpClientProtocol + + Private AddOperationCompleted As System.Threading.SendOrPostCallback + + Private SubtractOperationCompleted As System.Threading.SendOrPostCallback + + Private MultiplyOperationCompleted As System.Threading.SendOrPostCallback + + Private DivideOperationCompleted As System.Threading.SendOrPostCallback + + Private useDefaultCredentialsSetExplicitly As Boolean + + ''' + Public Sub New() + MyBase.New + Me.Url = Global.WFMathClient.My.MySettings.Default.WFMathClient_localhost_MathService + If (Me.IsLocalFileSystemWebService(Me.Url) = true) Then + Me.UseDefaultCredentials = true + Me.useDefaultCredentialsSetExplicitly = false + Else + Me.useDefaultCredentialsSetExplicitly = true + End If + End Sub + + Public Shadows Property Url() As String + Get + Return MyBase.Url + End Get + Set + If (((Me.IsLocalFileSystemWebService(MyBase.Url) = true) _ + AndAlso (Me.useDefaultCredentialsSetExplicitly = false)) _ + AndAlso (Me.IsLocalFileSystemWebService(value) = false)) Then + MyBase.UseDefaultCredentials = false + End If + MyBase.Url = value + End Set + End Property + + Public Shadows Property UseDefaultCredentials() As Boolean + Get + Return MyBase.UseDefaultCredentials + End Get + Set + MyBase.UseDefaultCredentials = value + Me.useDefaultCredentialsSetExplicitly = true + End Set + End Property + + ''' + Public Event AddCompleted As AddCompletedEventHandler + + ''' + Public Event SubtractCompleted As SubtractCompletedEventHandler + + ''' + Public Event MultiplyCompleted As MultiplyCompletedEventHandler + + ''' + Public Event DivideCompleted As DivideCompletedEventHandler + + ''' + _ + Public Function Add(ByVal x As Integer, ByVal y As Integer) As Integer + Dim results() As Object = Me.Invoke("Add", New Object() {x, y}) + Return CType(results(0),Integer) + End Function + + ''' + Public Overloads Sub AddAsync(ByVal x As Integer, ByVal y As Integer) + Me.AddAsync(x, y, Nothing) + End Sub + + ''' + Public Overloads Sub AddAsync(ByVal x As Integer, ByVal y As Integer, ByVal userState As Object) + If (Me.AddOperationCompleted Is Nothing) Then + Me.AddOperationCompleted = AddressOf Me.OnAddOperationCompleted + End If + Me.InvokeAsync("Add", New Object() {x, y}, Me.AddOperationCompleted, userState) + End Sub + + Private Sub OnAddOperationCompleted(ByVal arg As Object) + If (Not (Me.AddCompletedEvent) Is Nothing) Then + Dim invokeArgs As System.Web.Services.Protocols.InvokeCompletedEventArgs = CType(arg,System.Web.Services.Protocols.InvokeCompletedEventArgs) + RaiseEvent AddCompleted(Me, New AddCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)) + End If + End Sub + + ''' + _ + Public Function Subtract(ByVal x As Integer, ByVal y As Integer) As Integer + Dim results() As Object = Me.Invoke("Subtract", New Object() {x, y}) + Return CType(results(0),Integer) + End Function + + ''' + Public Overloads Sub SubtractAsync(ByVal x As Integer, ByVal y As Integer) + Me.SubtractAsync(x, y, Nothing) + End Sub + + ''' + Public Overloads Sub SubtractAsync(ByVal x As Integer, ByVal y As Integer, ByVal userState As Object) + If (Me.SubtractOperationCompleted Is Nothing) Then + Me.SubtractOperationCompleted = AddressOf Me.OnSubtractOperationCompleted + End If + Me.InvokeAsync("Subtract", New Object() {x, y}, Me.SubtractOperationCompleted, userState) + End Sub + + Private Sub OnSubtractOperationCompleted(ByVal arg As Object) + If (Not (Me.SubtractCompletedEvent) Is Nothing) Then + Dim invokeArgs As System.Web.Services.Protocols.InvokeCompletedEventArgs = CType(arg,System.Web.Services.Protocols.InvokeCompletedEventArgs) + RaiseEvent SubtractCompleted(Me, New SubtractCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)) + End If + End Sub + + ''' + _ + Public Function Multiply(ByVal x As Integer, ByVal y As Integer) As Integer + Dim results() As Object = Me.Invoke("Multiply", New Object() {x, y}) + Return CType(results(0),Integer) + End Function + + ''' + Public Overloads Sub MultiplyAsync(ByVal x As Integer, ByVal y As Integer) + Me.MultiplyAsync(x, y, Nothing) + End Sub + + ''' + Public Overloads Sub MultiplyAsync(ByVal x As Integer, ByVal y As Integer, ByVal userState As Object) + If (Me.MultiplyOperationCompleted Is Nothing) Then + Me.MultiplyOperationCompleted = AddressOf Me.OnMultiplyOperationCompleted + End If + Me.InvokeAsync("Multiply", New Object() {x, y}, Me.MultiplyOperationCompleted, userState) + End Sub + + Private Sub OnMultiplyOperationCompleted(ByVal arg As Object) + If (Not (Me.MultiplyCompletedEvent) Is Nothing) Then + Dim invokeArgs As System.Web.Services.Protocols.InvokeCompletedEventArgs = CType(arg,System.Web.Services.Protocols.InvokeCompletedEventArgs) + RaiseEvent MultiplyCompleted(Me, New MultiplyCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)) + End If + End Sub + + ''' + _ + Public Function Divide(ByVal x As Integer, ByVal y As Integer) As Integer + Dim results() As Object = Me.Invoke("Divide", New Object() {x, y}) + Return CType(results(0),Integer) + End Function + + ''' + Public Overloads Sub DivideAsync(ByVal x As Integer, ByVal y As Integer) + Me.DivideAsync(x, y, Nothing) + End Sub + + ''' + Public Overloads Sub DivideAsync(ByVal x As Integer, ByVal y As Integer, ByVal userState As Object) + If (Me.DivideOperationCompleted Is Nothing) Then + Me.DivideOperationCompleted = AddressOf Me.OnDivideOperationCompleted + End If + Me.InvokeAsync("Divide", New Object() {x, y}, Me.DivideOperationCompleted, userState) + End Sub + + Private Sub OnDivideOperationCompleted(ByVal arg As Object) + If (Not (Me.DivideCompletedEvent) Is Nothing) Then + Dim invokeArgs As System.Web.Services.Protocols.InvokeCompletedEventArgs = CType(arg,System.Web.Services.Protocols.InvokeCompletedEventArgs) + RaiseEvent DivideCompleted(Me, New DivideCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)) + End If + End Sub + + ''' + Public Shadows Sub CancelAsync(ByVal userState As Object) + MyBase.CancelAsync(userState) + End Sub + + Private Function IsLocalFileSystemWebService(ByVal url As String) As Boolean + If ((url Is Nothing) _ + OrElse (url Is String.Empty)) Then + Return false + End If + Dim wsUri As System.Uri = New System.Uri(url) + If ((wsUri.Port >= 1024) _ + AndAlso (String.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) = 0)) Then + Return true + End If + Return false + End Function + End Class + + ''' + _ + Public Delegate Sub AddCompletedEventHandler(ByVal sender As Object, ByVal e As AddCompletedEventArgs) + + ''' + _ + Partial Public Class AddCompletedEventArgs + Inherits System.ComponentModel.AsyncCompletedEventArgs + + Private results() As Object + + Friend Sub New(ByVal results() As Object, ByVal exception As System.Exception, ByVal cancelled As Boolean, ByVal userState As Object) + MyBase.New(exception, cancelled, userState) + Me.results = results + End Sub + + ''' + Public ReadOnly Property Result() As Integer + Get + Me.RaiseExceptionIfNecessary + Return CType(Me.results(0),Integer) + End Get + End Property + End Class + + ''' + _ + Public Delegate Sub SubtractCompletedEventHandler(ByVal sender As Object, ByVal e As SubtractCompletedEventArgs) + + ''' + _ + Partial Public Class SubtractCompletedEventArgs + Inherits System.ComponentModel.AsyncCompletedEventArgs + + Private results() As Object + + Friend Sub New(ByVal results() As Object, ByVal exception As System.Exception, ByVal cancelled As Boolean, ByVal userState As Object) + MyBase.New(exception, cancelled, userState) + Me.results = results + End Sub + + ''' + Public ReadOnly Property Result() As Integer + Get + Me.RaiseExceptionIfNecessary + Return CType(Me.results(0),Integer) + End Get + End Property + End Class + + ''' + _ + Public Delegate Sub MultiplyCompletedEventHandler(ByVal sender As Object, ByVal e As MultiplyCompletedEventArgs) + + ''' + _ + Partial Public Class MultiplyCompletedEventArgs + Inherits System.ComponentModel.AsyncCompletedEventArgs + + Private results() As Object + + Friend Sub New(ByVal results() As Object, ByVal exception As System.Exception, ByVal cancelled As Boolean, ByVal userState As Object) + MyBase.New(exception, cancelled, userState) + Me.results = results + End Sub + + ''' + Public ReadOnly Property Result() As Integer + Get + Me.RaiseExceptionIfNecessary + Return CType(Me.results(0),Integer) + End Get + End Property + End Class + + ''' + _ + Public Delegate Sub DivideCompletedEventHandler(ByVal sender As Object, ByVal e As DivideCompletedEventArgs) + + ''' + _ + Partial Public Class DivideCompletedEventArgs + Inherits System.ComponentModel.AsyncCompletedEventArgs + + Private results() As Object + + Friend Sub New(ByVal results() As Object, ByVal exception As System.Exception, ByVal cancelled As Boolean, ByVal userState As Object) + MyBase.New(exception, cancelled, userState) + Me.results = results + End Sub + + ''' + Public ReadOnly Property Result() As Integer + Get + Me.RaiseExceptionIfNecessary + Return CType(Me.results(0),Integer) + End Get + End Property + End Class +End Namespace diff --git a/Code/Chapter 26/WFMathClient/Web References/localhost/Service.disco b/Code/Chapter 26/WFMathClient/Web References/localhost/Service.disco new file mode 100644 index 0000000..26ad003 --- /dev/null +++ b/Code/Chapter 26/WFMathClient/Web References/localhost/Service.disco @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Code/Chapter 26/WFMathClient/Web References/localhost/Service.wsdl b/Code/Chapter 26/WFMathClient/Web References/localhost/Service.wsdl new file mode 100644 index 0000000..8c3d1d3 --- /dev/null +++ b/Code/Chapter 26/WFMathClient/Web References/localhost/Service.wsdl @@ -0,0 +1,195 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 26/WFMathClient/app.config b/Code/Chapter 26/WFMathClient/app.config new file mode 100644 index 0000000..890256b --- /dev/null +++ b/Code/Chapter 26/WFMathClient/app.config @@ -0,0 +1,69 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + http://localhost/VbMathWebService/Service.asmx + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 27/AppClassExample/MainWindow.vb b/Code/Chapter 27/AppClassExample/MainWindow.vb new file mode 100644 index 0000000..52daf8d --- /dev/null +++ b/Code/Chapter 27/AppClassExample/MainWindow.vb @@ -0,0 +1,34 @@ +Imports System.Windows.Forms +Imports System.Reflection + +' Assembly-level attributes. + + + + +Namespace MyWindowsApp + Public Class MainWindow + Inherits Form + ' Reflect over attributes using Application type. + Public Sub New + MessageBox.Show(String.Format("This app brought to you by {0}", _ + Application.CompanyName), _ + Application.ProductName) + + ' Handle Application.Exit event. + AddHandler Application.ApplicationExit, AddressOf MainWindow_OnExit + End Sub + + Public Sub MainWindow_OnExit(ByVal sender As Object, ByVal args As EventArgs) + MessageBox.Show(string.Format("Form version {0} has terminated.", _ + Application.ProductVersion)) + End Sub + End Class + + Public Module Program + ' Run this application and identify the main window. + Sub Main() + Application.Run(New MainWindow()) + End Sub + End Module +End Namespace diff --git a/Code/Chapter 27/ControlBehaviors/MainWindow.vb b/Code/Chapter 27/ControlBehaviors/MainWindow.vb new file mode 100644 index 0000000..3383826 --- /dev/null +++ b/Code/Chapter 27/ControlBehaviors/MainWindow.vb @@ -0,0 +1,48 @@ +Imports System.Windows.Forms +Imports System.Drawing + +Namespace MyWindowsApp + Public Class MainWindow + Inherits Form + + Public Sub New() + ' Use inherited properties to set basic UI. + Text = "My Fantastic Form" + Height = 300 + Width = 500 + BackColor = Color.LemonChiffon + Cursor = Cursors.Hand + End Sub + + Public Sub MainWindow_MouseMove(ByVal sender As Object, _ + ByVal e As MouseEventArgs) Handles Me.MouseMove + Text = String.Format("Current Pos: ({0} , {1})", e.X, e.Y) + End Sub + + Public Sub MainWindow_MouseUp(ByVal sender As Object, _ + ByVal e As MouseEventArgs) Handles Me.MouseUp + If e.Button = System.Windows.Forms.MouseButtons.Left Then + MessageBox.Show("Left click!") + End If + If e.Button = System.Windows.Forms.MouseButtons.Right Then + MessageBox.Show("Right click!") + End If + If e.Button = System.Windows.Forms.MouseButtons.Middle Then + MessageBox.Show("Middle click!") + End If + End Sub + + Public Sub MainWindow_KeyUp(ByVal sender As Object, _ + ByVal e As KeyEventArgs) Handles Me.KeyUp + MessageBox.Show(e.KeyCode.ToString(), "Key Pressed!") + End Sub + + End Class + + Public Module Program + ' Run this application and identify the main window. + Sub Main() + Application.Run(New MainWindow()) + End Sub + End Module +End Namespace diff --git a/Code/Chapter 27/FormLifeTime/MainWindow.vb b/Code/Chapter 27/FormLifeTime/MainWindow.vb new file mode 100644 index 0000000..26170c1 --- /dev/null +++ b/Code/Chapter 27/FormLifeTime/MainWindow.vb @@ -0,0 +1,51 @@ +Imports System.Windows.Forms +Imports System.ComponentModel + +Public Class MainWindow + Inherits Form + + Private lifeTimeInfo As String + + ' Handle the Load, Activated, Deactivate, and Closed events. + Public Sub MainWindow_Load(ByVal sender As Object, _ + ByVal e as EventArgs) Handles Me.Load + lifeTimeInfo = lifeTimeInfo & "Load event" & VbLf + End Sub + + Public Sub MainWindow_Activated(ByVal sender As Object, _ + ByVal e as EventArgs) Handles Me.Activated + lifeTimeInfo = lifeTimeInfo & "Activated event" & VbLf + End Sub + + Public Sub MainWindow_Deactivate(ByVal sender As Object, _ + ByVal e as EventArgs) Handles Me.Deactivate + lifeTimeInfo = lifeTimeInfo & "Deactivate event" & VbLf + End Sub + + Public Sub MainWindow_Closed(ByVal sender As Object, _ + ByVal e as EventArgs) Handles Me.Closed + lifeTimeInfo = lifeTimeInfo & "Closed event" & VbLf + MessageBox.Show(lifeTimeInfo) + End Sub + + Private Sub MainWindow_Closing(ByVal sender As Object, _ + ByVal e As CancelEventArgs) Handles Me.Closing + Dim dr As System.Windows.Forms.DialogResult = _ + MessageBox.Show("Do you REALLY want to close this app?", _ + "Closing event!", MessageBoxButtons.YesNo) + If dr = System.Windows.Forms.DialogResult.No Then + e.Cancel = True + Else + e.Cancel = False + End If + End Sub + +End Class + +Public Module Program + ' Run this application and identify the main window. + Sub Main() + Application.Run(New MainWindow()) + End Sub +End Module + diff --git a/Code/Chapter 27/MenuStripApp/MainWindow.Designer.vb b/Code/Chapter 27/MenuStripApp/MainWindow.Designer.vb new file mode 100644 index 0000000..1980194 --- /dev/null +++ b/Code/Chapter 27/MenuStripApp/MainWindow.Designer.vb @@ -0,0 +1,115 @@ + _ +Partial Class MainWindow + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + 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.mainFormMenuStrip = New System.Windows.Forms.MenuStrip + Me.FileToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.ExitToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.toolStripTextBoxColor = New System.Windows.Forms.ToolStripTextBox + Me.ContextMenuStrip1 = New System.Windows.Forms.ContextMenuStrip(Me.components) + Me.HugeToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.NormalToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.TinyToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.mainFormMenuStrip.SuspendLayout() + Me.ContextMenuStrip1.SuspendLayout() + Me.SuspendLayout() + ' + 'mainFormMenuStrip + ' + Me.mainFormMenuStrip.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.FileToolStripMenuItem, Me.toolStripTextBoxColor}) + Me.mainFormMenuStrip.Location = New System.Drawing.Point(0, 0) + Me.mainFormMenuStrip.Name = "mainFormMenuStrip" + Me.mainFormMenuStrip.Size = New System.Drawing.Size(284, 27) + Me.mainFormMenuStrip.TabIndex = 0 + Me.mainFormMenuStrip.Text = "MenuStrip1" + ' + 'FileToolStripMenuItem + ' + Me.FileToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ExitToolStripMenuItem}) + Me.FileToolStripMenuItem.Name = "FileToolStripMenuItem" + Me.FileToolStripMenuItem.Size = New System.Drawing.Size(37, 23) + Me.FileToolStripMenuItem.Text = "&File" + ' + 'ExitToolStripMenuItem + ' + Me.ExitToolStripMenuItem.Name = "ExitToolStripMenuItem" + Me.ExitToolStripMenuItem.Size = New System.Drawing.Size(92, 22) + Me.ExitToolStripMenuItem.Text = "E&xit" + ' + 'toolStripTextBoxColor + ' + Me.toolStripTextBoxColor.Name = "toolStripTextBoxColor" + Me.toolStripTextBoxColor.Size = New System.Drawing.Size(100, 23) + ' + 'ContextMenuStrip1 + ' + Me.ContextMenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.HugeToolStripMenuItem, Me.NormalToolStripMenuItem, Me.TinyToolStripMenuItem}) + Me.ContextMenuStrip1.Name = "ContextMenuStrip1" + Me.ContextMenuStrip1.Size = New System.Drawing.Size(115, 70) + ' + 'HugeToolStripMenuItem + ' + Me.HugeToolStripMenuItem.Name = "HugeToolStripMenuItem" + Me.HugeToolStripMenuItem.Size = New System.Drawing.Size(152, 22) + Me.HugeToolStripMenuItem.Text = "Huge" + ' + 'NormalToolStripMenuItem + ' + Me.NormalToolStripMenuItem.Name = "NormalToolStripMenuItem" + Me.NormalToolStripMenuItem.Size = New System.Drawing.Size(152, 22) + Me.NormalToolStripMenuItem.Text = "Normal" + ' + 'TinyToolStripMenuItem + ' + Me.TinyToolStripMenuItem.Name = "TinyToolStripMenuItem" + Me.TinyToolStripMenuItem.Size = New System.Drawing.Size(152, 22) + Me.TinyToolStripMenuItem.Text = "Tiny" + ' + 'MainWindow + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(284, 264) + Me.ContextMenuStrip = Me.ContextMenuStrip1 + Me.Controls.Add(Me.mainFormMenuStrip) + Me.MainMenuStrip = Me.mainFormMenuStrip + Me.Name = "MainWindow" + Me.Text = "My Menu App" + Me.mainFormMenuStrip.ResumeLayout(False) + Me.mainFormMenuStrip.PerformLayout() + Me.ContextMenuStrip1.ResumeLayout(False) + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents mainFormMenuStrip As System.Windows.Forms.MenuStrip + Friend WithEvents FileToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Friend WithEvents ExitToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Friend WithEvents toolStripTextBoxColor As System.Windows.Forms.ToolStripTextBox + Friend WithEvents ContextMenuStrip1 As System.Windows.Forms.ContextMenuStrip + Friend WithEvents HugeToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Friend WithEvents NormalToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Friend WithEvents TinyToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + +End Class diff --git a/Code/Chapter 27/MenuStripApp/MainWindow.resx b/Code/Chapter 27/MenuStripApp/MainWindow.resx new file mode 100644 index 0000000..f9e2771 --- /dev/null +++ b/Code/Chapter 27/MenuStripApp/MainWindow.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 181, 17 + + \ No newline at end of file diff --git a/Code/Chapter 27/MenuStripApp/MainWindow.vb b/Code/Chapter 27/MenuStripApp/MainWindow.vb new file mode 100644 index 0000000..0c76c62 --- /dev/null +++ b/Code/Chapter 27/MenuStripApp/MainWindow.vb @@ -0,0 +1,88 @@ +' Helper enum for font size. +Public Enum TextFontSize + FontSizeHuge = 30 + FontSizeNormal = 20 + FontSizeTiny = 8 +End Enum + +Public Class MainWindow + Private currFontSize As TextFontSize = TextFontSize.FontSizeNormal + + ' Marks the item checked. + Private WithEvents currentCheckedItem As ToolStripMenuItem + + Public Sub New() + ' Call InitializeComponent() when defining your own constructor! + InitializeComponent() + + ' Inherited method to center the Form. + CenterToScreen() + + ' Now check the 'Normal' menu item. + currentCheckedItem = normalToolStripMenuItem + currentCheckedItem.Checked = True + End Sub + + Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click + Application.Exit() + End Sub + + Private Sub toolStripTextBoxColor_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles toolStripTextBoxColor.Leave + Try + BackColor = Color.FromName(toolStripTextBoxColor.Text) + Catch ' Just do nothing if the user provides bad data + End Try + End Sub + + Private Sub MainWindow_Paint(ByVal sender As System.Object, _ + ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint + Dim g As Graphics = e.Graphics + g.DrawString("Right click on me...", _ + New Font("Times New Roman", currFontSize), _ + New SolidBrush(Color.Black), 50, 50) + End Sub + + ' This one event handler handles the Click event from each context menu item. + Private Sub ContextMenuItemSelection_Clicked(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles HugeToolStripMenuItem.Click, _ + TinyToolStripMenuItem.Click, NormalToolStripMenuItem.Click + + ' Obtain the currently clicked ToolStripMenuItem. + Dim miClicked As ToolStripMenuItem = CType(sender, ToolStripMenuItem) + + ' Uncheck the currently checked item. + currentCheckedItem.Checked = False + + ' Figure out which item was clicked using its Name. + If miClicked.Name = "HugeToolStripMenuItem" Then + currFontSize = TextFontSize.FontSizeHuge + End If + If miClicked.Name = "NormalToolStripMenuItem" Then + currFontSize = TextFontSize.FontSizeNormal + End If + If miClicked.Name = "TinyToolStripMenuItem" Then + currFontSize = TextFontSize.FontSizeTiny + End If + + ' Tell the Form to repaint itself. + Invalidate() + + ' Establish which item to check. + If miClicked.Name = "HugeToolStripMenuItem" Then + currFontSize = TextFontSize.FontSizeHuge + currentCheckedItem = HugeToolStripMenuItem + End If + If miClicked.Name = "NormalToolStripMenuItem" Then + currFontSize = TextFontSize.FontSizeNormal + currentCheckedItem = NormalToolStripMenuItem + End If + If miClicked.Name = "TinyToolStripMenuItem" Then + currFontSize = TextFontSize.FontSizeTiny + currentCheckedItem = TinyToolStripMenuItem + End If + + ' Check new item. + currentCheckedItem.Checked = True + End Sub + +End Class diff --git a/Code/Chapter 27/MenuStripApp/MenuStripApp.sln b/Code/Chapter 27/MenuStripApp/MenuStripApp.sln new file mode 100644 index 0000000..b48ed00 --- /dev/null +++ b/Code/Chapter 27/MenuStripApp/MenuStripApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MenuStripApp", "MenuStripApp.vbproj", "{1926E57C-88F9-4156-A202-EF7996DD8165}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1926E57C-88F9-4156-A202-EF7996DD8165}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1926E57C-88F9-4156-A202-EF7996DD8165}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1926E57C-88F9-4156-A202-EF7996DD8165}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1926E57C-88F9-4156-A202-EF7996DD8165}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 27/MenuStripApp/MenuStripApp.suo b/Code/Chapter 27/MenuStripApp/MenuStripApp.suo new file mode 100644 index 0000000..afb7594 Binary files /dev/null and b/Code/Chapter 27/MenuStripApp/MenuStripApp.suo differ diff --git a/Code/Chapter 27/MenuStripApp/MenuStripApp.vbproj b/Code/Chapter 27/MenuStripApp/MenuStripApp.vbproj new file mode 100644 index 0000000..333b153 --- /dev/null +++ b/Code/Chapter 27/MenuStripApp/MenuStripApp.vbproj @@ -0,0 +1,123 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {1926E57C-88F9-4156-A202-EF7996DD8165} + WinExe + MenuStripApp.My.MyApplication + MenuStripApp + MenuStripApp + 512 + WindowsForms + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + MenuStripApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + MenuStripApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + Form + + + MainWindow.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + MainWindow.vb + Designer + + + 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/Code/Chapter 27/MenuStripApp/My Project/Application.Designer.vb b/Code/Chapter 27/MenuStripApp/My Project/Application.Designer.vb new file mode 100644 index 0000000..c6adfd8 --- /dev/null +++ b/Code/Chapter 27/MenuStripApp/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.MenuStripApp.MainWindow + End Sub + End Class +End Namespace diff --git a/Code/Chapter 27/MenuStripApp/My Project/Application.myapp b/Code/Chapter 27/MenuStripApp/My Project/Application.myapp new file mode 100644 index 0000000..dbf9822 --- /dev/null +++ b/Code/Chapter 27/MenuStripApp/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainWindow + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 27/MenuStripApp/My Project/AssemblyInfo.vb b/Code/Chapter 27/MenuStripApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..d17d3ea --- /dev/null +++ b/Code/Chapter 27/MenuStripApp/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/Code/Chapter 27/MenuStripApp/My Project/Resources.Designer.vb b/Code/Chapter 27/MenuStripApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..3e1ccfe --- /dev/null +++ b/Code/Chapter 27/MenuStripApp/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("MenuStripApp.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/Code/Chapter 27/MenuStripApp/My Project/Resources.resx b/Code/Chapter 27/MenuStripApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 27/MenuStripApp/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/Code/Chapter 27/MenuStripApp/My Project/Settings.Designer.vb b/Code/Chapter 27/MenuStripApp/My Project/Settings.Designer.vb new file mode 100644 index 0000000..e2a8517 --- /dev/null +++ b/Code/Chapter 27/MenuStripApp/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.MenuStripApp.My.MySettings + Get + Return Global.MenuStripApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 27/MenuStripApp/My Project/Settings.settings b/Code/Chapter 27/MenuStripApp/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 27/MenuStripApp/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 27/MyFirstWindow/MainWindow.vb b/Code/Chapter 27/MyFirstWindow/MainWindow.vb new file mode 100644 index 0000000..2532eb3 --- /dev/null +++ b/Code/Chapter 27/MyFirstWindow/MainWindow.vb @@ -0,0 +1,14 @@ +Imports System.Windows.Forms + +Namespace MyWindowsApp + Public Class MainWindow + Inherits Form + End Class + + Public Module Program + ' Run this application and identify the main window. + Sub Main() + Application.Run(New MainWindow()) + End Sub + End Module +End Namespace diff --git a/Code/Chapter 27/SimpleMdiApp/ChildPrototypeForm.Designer.vb b/Code/Chapter 27/SimpleMdiApp/ChildPrototypeForm.Designer.vb new file mode 100644 index 0000000..c450f7c --- /dev/null +++ b/Code/Chapter 27/SimpleMdiApp/ChildPrototypeForm.Designer.vb @@ -0,0 +1,34 @@ + _ +Partial Class ChildPrototypeForm + 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.SuspendLayout() + ' + 'ChildPrototypeForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(292, 266) + Me.Name = "ChildPrototypeForm" + Me.Text = "ChildPrototypeForm" + Me.ResumeLayout(False) + + End Sub +End Class diff --git a/Code/Chapter 27/SimpleMdiApp/ChildPrototypeForm.resx b/Code/Chapter 27/SimpleMdiApp/ChildPrototypeForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 27/SimpleMdiApp/ChildPrototypeForm.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/Code/Chapter 27/SimpleMdiApp/ChildPrototypeForm.vb b/Code/Chapter 27/SimpleMdiApp/ChildPrototypeForm.vb new file mode 100644 index 0000000..8913160 --- /dev/null +++ b/Code/Chapter 27/SimpleMdiApp/ChildPrototypeForm.vb @@ -0,0 +1,19 @@ +Option Explicit On +Option Strict On + +Public Class ChildPrototypeForm + Private Sub ChildPrototypeForm_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles MyBase.Click + ' Get three random numbers + Dim r, g, b As Integer + Dim ran As New Random() + r = ran.Next(0, 255) + g = ran.Next(0, 255) + b = ran.Next(0, 255) + + ' Now create a color for the background. + Dim currColor As Color = Color.FromArgb(r, g, b) + Me.BackColor = currColor + Me.Text = currColor.ToString() + End Sub +End Class \ No newline at end of file diff --git a/Code/Chapter 27/SimpleMdiApp/Form1.resx b/Code/Chapter 27/SimpleMdiApp/Form1.resx new file mode 100644 index 0000000..541af56 --- /dev/null +++ b/Code/Chapter 27/SimpleMdiApp/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/Code/Chapter 27/SimpleMdiApp/MainWindow.Designer.vb b/Code/Chapter 27/SimpleMdiApp/MainWindow.Designer.vb new file mode 100644 index 0000000..b4068ce --- /dev/null +++ b/Code/Chapter 27/SimpleMdiApp/MainWindow.Designer.vb @@ -0,0 +1,119 @@ + _ +Partial Class MainWindow + 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.menuStrip1 = New System.Windows.Forms.MenuStrip + Me.fileToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem + Me.newToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.exitToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.windowToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.arrangeWindowsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.cascadeToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.verticalToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.horizontalToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.menuStrip1.SuspendLayout() + Me.SuspendLayout() + ' + 'menuStrip1 + ' + Me.menuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.fileToolStripMenuItem1, Me.windowToolStripMenuItem, Me.arrangeWindowsToolStripMenuItem}) + Me.menuStrip1.Location = New System.Drawing.Point(0, 0) + Me.menuStrip1.MdiWindowListItem = Me.windowToolStripMenuItem + Me.menuStrip1.Name = "menuStrip1" + Me.menuStrip1.Size = New System.Drawing.Size(292, 24) + Me.menuStrip1.TabIndex = 3 + Me.menuStrip1.Text = "menuStrip1" + ' + 'fileToolStripMenuItem1 + ' + Me.fileToolStripMenuItem1.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.newToolStripMenuItem, Me.exitToolStripMenuItem}) + Me.fileToolStripMenuItem1.Name = "fileToolStripMenuItem1" + Me.fileToolStripMenuItem1.Size = New System.Drawing.Size(35, 20) + Me.fileToolStripMenuItem1.Text = "&File" + ' + 'newToolStripMenuItem + ' + Me.newToolStripMenuItem.Name = "newToolStripMenuItem" + Me.newToolStripMenuItem.Size = New System.Drawing.Size(152, 22) + Me.newToolStripMenuItem.Text = "&New" + ' + 'exitToolStripMenuItem + ' + Me.exitToolStripMenuItem.Name = "exitToolStripMenuItem" + Me.exitToolStripMenuItem.Size = New System.Drawing.Size(152, 22) + Me.exitToolStripMenuItem.Text = "E&xit" + ' + 'windowToolStripMenuItem + ' + Me.windowToolStripMenuItem.Name = "windowToolStripMenuItem" + Me.windowToolStripMenuItem.Size = New System.Drawing.Size(57, 20) + Me.windowToolStripMenuItem.Text = "&Window" + ' + 'arrangeWindowsToolStripMenuItem + ' + Me.arrangeWindowsToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.cascadeToolStripMenuItem, Me.verticalToolStripMenuItem, Me.horizontalToolStripMenuItem}) + Me.arrangeWindowsToolStripMenuItem.Name = "arrangeWindowsToolStripMenuItem" + Me.arrangeWindowsToolStripMenuItem.Size = New System.Drawing.Size(104, 20) + Me.arrangeWindowsToolStripMenuItem.Text = "&Arrange Windows" + ' + 'cascadeToolStripMenuItem + ' + Me.cascadeToolStripMenuItem.Name = "cascadeToolStripMenuItem" + Me.cascadeToolStripMenuItem.Size = New System.Drawing.Size(152, 22) + Me.cascadeToolStripMenuItem.Text = "&Cascade" + ' + 'verticalToolStripMenuItem + ' + Me.verticalToolStripMenuItem.Name = "verticalToolStripMenuItem" + Me.verticalToolStripMenuItem.Size = New System.Drawing.Size(152, 22) + Me.verticalToolStripMenuItem.Text = "&Vertical" + ' + 'horizontalToolStripMenuItem + ' + Me.horizontalToolStripMenuItem.Name = "horizontalToolStripMenuItem" + Me.horizontalToolStripMenuItem.Size = New System.Drawing.Size(152, 22) + Me.horizontalToolStripMenuItem.Text = "&Horizontal" + ' + 'MainWindow + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(292, 266) + Me.Controls.Add(Me.menuStrip1) + Me.IsMdiContainer = True + Me.Name = "MainWindow" + Me.Text = "Simple MDI App" + Me.menuStrip1.ResumeLayout(False) + Me.menuStrip1.PerformLayout() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Private WithEvents menuStrip1 As System.Windows.Forms.MenuStrip + Private WithEvents fileToolStripMenuItem1 As System.Windows.Forms.ToolStripMenuItem + Private WithEvents newToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Private WithEvents exitToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Private WithEvents windowToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Private WithEvents arrangeWindowsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Private WithEvents cascadeToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Private WithEvents verticalToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Private WithEvents horizontalToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + +End Class diff --git a/Code/Chapter 27/SimpleMdiApp/MainWindow.vb b/Code/Chapter 27/SimpleMdiApp/MainWindow.vb new file mode 100644 index 0000000..41481a6 --- /dev/null +++ b/Code/Chapter 27/SimpleMdiApp/MainWindow.vb @@ -0,0 +1,35 @@ +Option Explicit On +Option Strict On + +Public Class MainWindow + +#Region "Menu Handlers" + Private Sub newToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles newToolStripMenuItem.Click + ' Make a new child window. + Dim newChild As New ChildPrototypeForm() + + ' Set the Parent Form of the Child window. + newChild.MdiParent = Me + + ' Display the new form. + newChild.Show() + End Sub + + Private Sub exitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitToolStripMenuItem.Click + Application.Exit() + End Sub + + Private Sub cascadeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cascadeToolStripMenuItem.Click + LayoutMdi(MdiLayout.Cascade) + End Sub + + Private Sub verticalToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles verticalToolStripMenuItem.Click + LayoutMdi(MdiLayout.TileVertical) + End Sub + + Private Sub horizontalToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles horizontalToolStripMenuItem.Click + LayoutMdi(MdiLayout.TileHorizontal) + End Sub +#End Region + +End Class diff --git a/Code/Chapter 27/SimpleMdiApp/My Project/Application.Designer.vb b/Code/Chapter 27/SimpleMdiApp/My Project/Application.Designer.vb new file mode 100644 index 0000000..f47ecd7 --- /dev/null +++ b/Code/Chapter 27/SimpleMdiApp/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SimpleMdiApp.MainWindow + End Sub + End Class +End Namespace diff --git a/Code/Chapter 27/SimpleMdiApp/My Project/Application.myapp b/Code/Chapter 27/SimpleMdiApp/My Project/Application.myapp new file mode 100644 index 0000000..dbf9822 --- /dev/null +++ b/Code/Chapter 27/SimpleMdiApp/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainWindow + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 27/SimpleMdiApp/My Project/AssemblyInfo.vb b/Code/Chapter 27/SimpleMdiApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..37e88b7 --- /dev/null +++ b/Code/Chapter 27/SimpleMdiApp/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/Code/Chapter 27/SimpleMdiApp/My Project/Resources.Designer.vb b/Code/Chapter 27/SimpleMdiApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..b879c80 --- /dev/null +++ b/Code/Chapter 27/SimpleMdiApp/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("SimpleMdiApp.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/Code/Chapter 27/SimpleMdiApp/My Project/Resources.resx b/Code/Chapter 27/SimpleMdiApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 27/SimpleMdiApp/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/Code/Chapter 27/SimpleMdiApp/My Project/Settings.Designer.vb b/Code/Chapter 27/SimpleMdiApp/My Project/Settings.Designer.vb new file mode 100644 index 0000000..6255844 --- /dev/null +++ b/Code/Chapter 27/SimpleMdiApp/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SimpleMdiApp.My.MySettings + Get + Return Global.SimpleMdiApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 27/SimpleMdiApp/My Project/Settings.settings b/Code/Chapter 27/SimpleMdiApp/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 27/SimpleMdiApp/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 27/SimpleMdiApp/SimpleMdiApp.sln b/Code/Chapter 27/SimpleMdiApp/SimpleMdiApp.sln new file mode 100644 index 0000000..a7685b4 --- /dev/null +++ b/Code/Chapter 27/SimpleMdiApp/SimpleMdiApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SimpleMdiApp", "SimpleMdiApp.vbproj", "{ECAA54F3-68CE-44DE-B6A9-D64F793785AF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {ECAA54F3-68CE-44DE-B6A9-D64F793785AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ECAA54F3-68CE-44DE-B6A9-D64F793785AF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ECAA54F3-68CE-44DE-B6A9-D64F793785AF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ECAA54F3-68CE-44DE-B6A9-D64F793785AF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 27/SimpleMdiApp/SimpleMdiApp.suo b/Code/Chapter 27/SimpleMdiApp/SimpleMdiApp.suo new file mode 100644 index 0000000..b317e9c Binary files /dev/null and b/Code/Chapter 27/SimpleMdiApp/SimpleMdiApp.suo differ diff --git a/Code/Chapter 27/SimpleMdiApp/SimpleMdiApp.vbproj b/Code/Chapter 27/SimpleMdiApp/SimpleMdiApp.vbproj new file mode 100644 index 0000000..2a484c6 --- /dev/null +++ b/Code/Chapter 27/SimpleMdiApp/SimpleMdiApp.vbproj @@ -0,0 +1,158 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {ECAA54F3-68CE-44DE-B6A9-D64F793785AF} + WinExe + SimpleMdiApp.My.MyApplication + SimpleMdiApp + SimpleMdiApp + WindowsForms + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + SimpleMdiApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SimpleMdiApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + ChildPrototypeForm.vb + + + Form + + + Form + + + MainWindow.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + ChildPrototypeForm.vb + + + Designer + MainWindow.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 27/SimpleMdiApp/SimpleMdiApp.vbproj.user b/Code/Chapter 27/SimpleMdiApp/SimpleMdiApp.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 27/SimpleMdiApp/SimpleMdiApp.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 27/StatusStripApp/HappyDude.jpg b/Code/Chapter 27/StatusStripApp/HappyDude.jpg new file mode 100644 index 0000000..1c9aada Binary files /dev/null and b/Code/Chapter 27/StatusStripApp/HappyDude.jpg differ diff --git a/Code/Chapter 27/StatusStripApp/MainWindow.Designer.vb b/Code/Chapter 27/StatusStripApp/MainWindow.Designer.vb new file mode 100644 index 0000000..7127797 --- /dev/null +++ b/Code/Chapter 27/StatusStripApp/MainWindow.Designer.vb @@ -0,0 +1,160 @@ + _ +Partial Class MainWindow + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + 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(MainWindow)) + Me.MenuStrip1 = New System.Windows.Forms.MenuStrip + Me.FileToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.ExitToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.HelpToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.AboutToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.mainStatusStrip = New System.Windows.Forms.StatusStrip + Me.toolStripStatusLabelMenuState = New System.Windows.Forms.ToolStripStatusLabel + Me.toolStripStatusLabelClock = New System.Windows.Forms.ToolStripStatusLabel + Me.toolStripDropDownButtonDateTime = New System.Windows.Forms.ToolStripDropDownButton + Me.DayOfTheWeekToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.CurrentTimeToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.timerDateTimeUpdate = New System.Windows.Forms.Timer(Me.components) + Me.MenuStrip1.SuspendLayout() + Me.mainStatusStrip.SuspendLayout() + Me.SuspendLayout() + ' + 'MenuStrip1 + ' + Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.FileToolStripMenuItem, Me.HelpToolStripMenuItem}) + Me.MenuStrip1.Location = New System.Drawing.Point(0, 0) + Me.MenuStrip1.Name = "MenuStrip1" + Me.MenuStrip1.Size = New System.Drawing.Size(440, 24) + Me.MenuStrip1.TabIndex = 0 + Me.MenuStrip1.Text = "MenuStrip1" + ' + 'FileToolStripMenuItem + ' + Me.FileToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ExitToolStripMenuItem}) + Me.FileToolStripMenuItem.Name = "FileToolStripMenuItem" + Me.FileToolStripMenuItem.Size = New System.Drawing.Size(37, 20) + Me.FileToolStripMenuItem.Text = "&File" + ' + 'ExitToolStripMenuItem + ' + Me.ExitToolStripMenuItem.Name = "ExitToolStripMenuItem" + Me.ExitToolStripMenuItem.Size = New System.Drawing.Size(92, 22) + Me.ExitToolStripMenuItem.Text = "E&xit" + ' + 'HelpToolStripMenuItem + ' + Me.HelpToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.AboutToolStripMenuItem}) + Me.HelpToolStripMenuItem.Name = "HelpToolStripMenuItem" + Me.HelpToolStripMenuItem.Size = New System.Drawing.Size(44, 20) + Me.HelpToolStripMenuItem.Text = "&Help" + ' + 'AboutToolStripMenuItem + ' + Me.AboutToolStripMenuItem.Name = "AboutToolStripMenuItem" + Me.AboutToolStripMenuItem.Size = New System.Drawing.Size(152, 22) + Me.AboutToolStripMenuItem.Text = "&About..." + ' + 'mainStatusStrip + ' + Me.mainStatusStrip.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.toolStripStatusLabelMenuState, Me.toolStripStatusLabelClock, Me.toolStripDropDownButtonDateTime}) + Me.mainStatusStrip.Location = New System.Drawing.Point(0, 242) + Me.mainStatusStrip.Name = "mainStatusStrip" + Me.mainStatusStrip.Size = New System.Drawing.Size(440, 22) + Me.mainStatusStrip.TabIndex = 1 + Me.mainStatusStrip.Text = "StatusStrip1" + ' + 'toolStripStatusLabelMenuState + ' + Me.toolStripStatusLabelMenuState.Name = "toolStripStatusLabelMenuState" + Me.toolStripStatusLabelMenuState.Size = New System.Drawing.Size(392, 17) + Me.toolStripStatusLabelMenuState.Spring = True + Me.toolStripStatusLabelMenuState.TextAlign = System.Drawing.ContentAlignment.TopLeft + ' + 'toolStripStatusLabelClock + ' + Me.toolStripStatusLabelClock.BorderSides = CType((((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left Or System.Windows.Forms.ToolStripStatusLabelBorderSides.Top) _ + Or System.Windows.Forms.ToolStripStatusLabelBorderSides.Right) _ + Or System.Windows.Forms.ToolStripStatusLabelBorderSides.Bottom), System.Windows.Forms.ToolStripStatusLabelBorderSides) + Me.toolStripStatusLabelClock.Name = "toolStripStatusLabelClock" + Me.toolStripStatusLabelClock.Size = New System.Drawing.Size(4, 17) + ' + 'toolStripDropDownButtonDateTime + ' + Me.toolStripDropDownButtonDateTime.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.toolStripDropDownButtonDateTime.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.DayOfTheWeekToolStripMenuItem, Me.CurrentTimeToolStripMenuItem}) + Me.toolStripDropDownButtonDateTime.Image = CType(resources.GetObject("toolStripDropDownButtonDateTime.Image"), System.Drawing.Image) + Me.toolStripDropDownButtonDateTime.ImageTransparentColor = System.Drawing.Color.Magenta + Me.toolStripDropDownButtonDateTime.Name = "toolStripDropDownButtonDateTime" + Me.toolStripDropDownButtonDateTime.Size = New System.Drawing.Size(29, 20) + Me.toolStripDropDownButtonDateTime.Text = "ToolStripDropDownButton1" + ' + 'DayOfTheWeekToolStripMenuItem + ' + Me.DayOfTheWeekToolStripMenuItem.Name = "DayOfTheWeekToolStripMenuItem" + Me.DayOfTheWeekToolStripMenuItem.Size = New System.Drawing.Size(160, 22) + Me.DayOfTheWeekToolStripMenuItem.Text = "Day of the Week" + ' + 'CurrentTimeToolStripMenuItem + ' + Me.CurrentTimeToolStripMenuItem.Name = "CurrentTimeToolStripMenuItem" + Me.CurrentTimeToolStripMenuItem.Size = New System.Drawing.Size(160, 22) + Me.CurrentTimeToolStripMenuItem.Text = "Current Time" + ' + 'timerDateTimeUpdate + ' + Me.timerDateTimeUpdate.Enabled = True + Me.timerDateTimeUpdate.Interval = 1000 + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(440, 264) + Me.Controls.Add(Me.mainStatusStrip) + Me.Controls.Add(Me.MenuStrip1) + Me.MainMenuStrip = Me.MenuStrip1 + Me.Name = "MainForm" + Me.Text = "Status Strip App" + Me.MenuStrip1.ResumeLayout(False) + Me.MenuStrip1.PerformLayout() + Me.mainStatusStrip.ResumeLayout(False) + Me.mainStatusStrip.PerformLayout() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents MenuStrip1 As System.Windows.Forms.MenuStrip + Friend WithEvents FileToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Friend WithEvents ExitToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Friend WithEvents HelpToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Friend WithEvents AboutToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Friend WithEvents mainStatusStrip As System.Windows.Forms.StatusStrip + Friend WithEvents toolStripStatusLabelMenuState As System.Windows.Forms.ToolStripStatusLabel + Friend WithEvents toolStripStatusLabelClock As System.Windows.Forms.ToolStripStatusLabel + Friend WithEvents toolStripDropDownButtonDateTime As System.Windows.Forms.ToolStripDropDownButton + Friend WithEvents CurrentTimeToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Friend WithEvents DayOfTheWeekToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Friend WithEvents timerDateTimeUpdate As System.Windows.Forms.Timer + +End Class diff --git a/Code/Chapter 27/StatusStripApp/MainWindow.resx b/Code/Chapter 27/StatusStripApp/MainWindow.resx new file mode 100644 index 0000000..c00f847 --- /dev/null +++ b/Code/Chapter 27/StatusStripApp/MainWindow.resx @@ -0,0 +1,484 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 132, 17 + + + + + iVBORw0KGgoAAAANSUhEUgAAAHQAAAB0CAYAAABUmhYnAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAUVlJREFUeF7tvQeY + ZVWV930r38qxQ3VuoIlN6m5C0+QmZwFBQKIggqCIjogjIqgoiKIIBkT5FNEZdT51nBnDjCO84zg6JkbH + jAINHSuHm+vWen//tc+5dSs0QldjeB94ns2tvvGcvfbK/7VWRSKRMNYO/lfD5+pZlawxVi5RkSgk+F+i + Ut/KY0X07ebvqWLV+uM4/w7P6Q18xj+XC1/F5/RYm0wkinytVqJYdqV6j75rvJqPN7P0Ab6x1hLjY/oO + PlDJ9xXH/b4q6xKJ6qpavscSxRzPG5/jRyqra3h/OtoB/9LoGnm1ojpRVVWVqOBGCnm+s4Lv5Ccr+ei4 + rkc/yaUna6p4fTwxHn4qYcaTeo3/ksmKRDYXNiDeh4ndDr8XXo0+HF3BbB/0nTu4qvlcY7TqeKzU1vri + 3stWJX/XsOp8Vfiq4f08V8Xnq5KWqK6z6mSdNTYnLdnI94reVROrsaXGGlv4nJ6r0PVWW21do1XX1Pvv + VobzEVZ1whpbWR38XcOqDc/p76q6hHXMq7ImXtd7q3i+mpXktTpeq62psEq+H3L7b2jV1TZaa1uX/45+ + u6ml3prb+F39ll9LWJWVlVZfX8f3cG96Xiu6pgr/znhpn8I+REd/B/d/RrrtKDGnfC66gYmL1sXXsBpZ + TdHSTUQ3GhGrOhnddLwBTmjdaJ11tM+1tpZW3+TyA1LjB6Pen0tCjPa2hO27T8KOPbbFzjm7225800H2 + iQdfYf/w1avtG996gz363bfYo4/9rX39W39j//ZtHr/5VrvnnnPsootW2OmnLLV1h86x3ZZWWFsTBOU6 + qrX4buSPdc+Z64exwn+vmdc6uLYWVpvVVrdbMtlgjY31PHIoyxmD76jRQYoPWYnwMRO0Rd+j+91JNIgY + fnZfWHYKdSInCBoTUzff4oT1E6/3i5gRx+jved2N1r2gy7lCG9eUnGeN1drIJja2xhDS1gQHIcGsgcd9 + 9qi2V19xuH30/gutv+cDNjx4q9n4XUi7O2109C2WztzE32/3tXHzpdY/+BobHH6t9fZfY6n0m3j+3aw7 + eN87rFi4j78fYj1io8MP2U9+dJvd84HT7dST2m3xArgWgtRzrUhtrqWa1WjJxDxrqFjEtXaW7qsWCSMO + LXFmfEBLhBTHi3iSKNoL7Uu0J38xBBUBuWFfETGDCBGHxReux+gUlotRERRilouiKj5bk0iyeS1sWhur + mVVvS7s67MKzDrH/7+NX2BO/vsXyY7fZmF1n6eKZNpJebSOp3W1sfD+Isr+lsrvy3FIbzSyzvqH5/ty4 + 7WXZsV15bbkNjiyyvsFuG04ts1xxpW0Z2MM29+9n2wYPttHcibz3Ej7zRtbtNj7+AXvs0VfbfR86zU4/ + eYF1NgfC1vkh02HrsJbaJVZX1RVxMVzJgWtoCGLcpZHfe5NzdFgiYplI3rnEFHPOgt3LCer6QeJEBNQN + lF34FH04oXvQOdUN0cmvtLaGJmuqrICIiFE25shVC+x7377PNvz2QbPcp9nkuy2Xv8T6htfYQG6JFWwe + hG2xdDphuVyFFcerrDBWwftqWfU2VqywbC5hA4MJGxmVvdLAavX36d/DrHFrsow12lAuaX2pJtZc6x3d + 1XoGD7QtvUdZ0V7NAbrJCvkP2LMb3m8fv+9cW3dQFYTEHGPVcgiruWeJ6HK1IGI2JJtd1SQgfAJuDgSF + mJGed/2uv2dDg+mfnd0XisN0I0FfxhevC4+MhtgokT4p3YCI3s37F7IRLdZZ32WtEFanf49FtXbnbWfZ + M394P5t/n/UPnGe9A4fDbfvYaHYFRFzGmmuj+VqeE5Hm21iq1cbSLTaebbH8aNIs34gIbrGxTB2vL2A1 + W2602lcxy+uFJrNiO8+3W56DkC8kIFy1HwLjgIzreZtjWeu2VHGZjRT2tt6R1dafOp7Xr2PdbN//0Xq7 + +a1dNqc9cK3UggjcXCMCa0+k56VqYs6UiC0jpvYj1rF/KQSdsGal+2T86OKnnMRygkrM+sXrRpdwwwut + Hq4WR67eu9m++Nkb2Oy/Z8PuseHhV9pQ6nC4Zxc2txUi1hgegGXZ/HxRhKxkQZjxDrM0xBmbw7/nQswW + vqMZgkHQVK2lBnjvmDiT90FoPWc5CF5oNcvyfAGiFyHmeA2rCq6G28fCb+j3cvzOyHi1pcZbIfAiGyos + s57Urpa2g/nOKy2Vudvues9xtnwhOh5ua0SNtCcbrSHRCmHbIqJOsR/iPflL41AZMTqJ9VXtzp01FW3W + 1DDfubOiBqsP6zR2PfDfsAareL8+Uw8h50HIGlu5vMI+99AFbOYD6ME326a+dZZC75ntY4PZZghaD0HZ + aDa3yMLfgwDRYuNtDEKUVhV/R6sIwbe34veImPyGZSBujsMxBvdCVP1Gkd8o8KjfFVFzXIOuJS0RP96J + /u62kbG90L+Hu87NZu+yez9wvC3ugrAc0A4s4KBnxanBVigZgxC9qR0ilyz72UnJKSJ7x79MOrMKzuxq + Xow5L3ErA0BGEataih8jBx+uHl0iK1CiaGFXi4uoORgYn/vU9VbI3AdXvBGuON8GUgdaX7rThsfq4Iak + c2WeDdWmlgg5BqFEkAKE1IJoem1Hln/PVIIWeU4HhsMiohKb4Pcr/VDlx+sgbCPGVBur0zJj3Vzncgh7 + oD3xJEbV6I1Igc/ZO28+yRqlQ92A4l7bGqwK4s2ZExHR96ieAz6HR9kdO06DGT67418WCNrkS9xaycmr + wTlXEKAd/y0YRnN4bZ7ryuXz5mLuJ+zGa1da3xYMnPQb4LoTrG90gfUOd0DARZz2pZbOt2GwNLCZzWxq + TRkx2WgRUToy0wlXtdk4r2vTd2T5ISlwQLREXCcmRlUZQcd5rliss+JYEy5Op43lF9pYbpmNYU3n80sg + 9jwbzEmk7w+xD7Zf/06i+B32zO/fbeec3on7FYg6t1VumNRSizU3LHa1U1cjY+kviKC6mOa6zij6g1iJ + IzulCIpuoBMR1GULWjutGWI++o3Xc8MfsUL2YhvF5dg22GCj6LBxLNACpz8DsTK5VoiIzkPviWAuOsWZ + TkwMlxx6MoPOzPE63CwO3v6qjF6LHyfe64cgIp4TcRxispzQEYeKoPqNcQyp8Ty/l+vG+FrEWmbFfLcN + DUuf12M0JWyb/70W92edPfnUifz9gP3dw5e7/9zowQod/g72pMM6W5dATLl3f1EEleNdi+6stGRd1aRQ + l/RDbW2t648OIjBHr0VXZT/PTb7XNm440J7ZAFGwWA2RFR7bLZ3F4szL2OG9bFI2gyh1YkrEQkhxpnSd + CKrFv52DJnFoJf8uX3pd/44fJ78+xvdr6T3jiFWtmNAitovy+BpcV6N3dS3RKo5Vu2sUXCXcnwwuUUHS + Zl/rHVxvQ0M320DPZ233pZUugtvqZSjV4W9XR37qjkvI7Yjq2X2hLF3FPpNJIuOIXcVX2zuIe0ZGQNfc + hN31vpO52YdtoPdi6+tdBResCBapjIzhBhvsS1pqGKK52yBiojvZpHRKnCIjR/oyIqiIKi7Na2MRx06M + sPETjxAnJlLpMRC09P7o+QKPOZ7PoycLIqYbYCJyhS+93wnqK3Cur/hvQ+zn8X85iDoYqWzCUvjCGSxw + +cpm51k692Yb7P+o3fSmo6y5Ht2KuxL7rSH4sFPXLL5MgYVoBdEhvRD0gwi6+9419t0f3cxN3WVbho62 + 4ezubKr8wnkQBG5ETJmhC0VIuQ4QsgghR3A18mkFCLqCWyFR64SNRG/pMWxsbDA992MwnsrfrwOQRVyn + 3ZLlN63CiSoDqMD1jI3VBnErrvQVXYfr3KB/e5+RqG51vzaXlt+r++ngO/F7cbd+v7XCdWtv6hQbLbzV + /u07N2AgwgCop8YaeQcvhsj1eKO+WFaqHj35NTku6acosmDj15StiJzjqkoCA9XdxFoXIVKq7cADG3H8 + H8S8fyPRlyPcQR9KVyNSWUR2zMUUHCanPo9e49/624qIriKiNIfIHRERtZF6LHNXYrdllo9yg9y3LREU + VwWiTiZoPQTlwMVEnXq4cGPyIxA/xXvQ+8U8rlZWxBSX6vuJVvGeoeJS2zS4Fglwqz3+47fb/JZgLAUO + nSDq5IzMRPYqPB9ngCLazBhlKvlCccA4uB/+BXyAlKGnpkLgvA5d2cq/o/SWAgVYtU1zELW1bW7BJbm4 + PZfBZYN3whGXcXP7ETqbg5VIBGYMQhXaQqQGIk1zNSTe2LzwPowQPcrKjcTdTBy4I+5K+WfG5JZIXMs1 + 8qUQYqRXkQTh9yfWVJ83iGTuRe+B6MVivVvFLrb9+yot7ZGoDoIlS9iXYzjI77Qfffs86yLTJBtDLkyy + ocaaW4LNUc1edzR24seSIoyiUHouzvoEt7A88lYuZd0iFeWnELQsTqs8YbJW4bqQ1tIX1qELkhg7zXMJ + HkD0pqYGa22stJvfcIo99ZvbuOhrbMNT7U7IYNTAaXkIKUux0BKMlMi/LG2wW5QQVMR0gvK3nttBP/P5 + fM59zVhscz0GQV0fowe1JggmopUvEbncIEOXy4WKCOqGmKxvvmvYVYvE8Vwb2LoQ6YQFnH+V/fz7l9iJ + xy+xud1E2KIER0dzu2eYmiob4WBysdMIyv6LCUVQrelcKgKFZPNM4tYjHDJ84Mrq6mD4VPB3RVWUKuJz + 7R3kCdEJb3jDasTOvTaaugjL70C3YMVlLq4UksNv1KOei294gpgRN5Rz53MRNDJWfMNnQfDJBJXejgha + RujYMJr8KOIGgyys2F/l3kTUiKCyfPNSFx6qbLfUUKcNbMFYSq1nr25grz5m+x5I3nVulRtKCvTPbVGM + m8RFVY0/Bu4M4ndaem66QaWgMdw3Ja8ZLC9l66OgMl/Y2t5itckQAQqcGpLX87saiYLooh+0zb0noiv3 + 5O+FVoArXf+4hQp3lrhOwYDI6oyJEft7Imhp8fmZONRFczBW/iQELT8w8QGKHsWFwc2JuFMBCD+wgXtH + sRfSsnxxwZQEcKOpsNgyQ7vaUO9hRJ+us1T+Pk/Ud7c1ImKVuVHIkL2vkmsTVsmmKfn4cYpymlGlYHoU + kooTzyWYx4QYrq4hgVuHeI0hFVhonR27cAF1tgRiZlIftE09JxIk2BOjQj4lNyDDx/22CQsxFmEefWFN + nPqggyYTM+jPSRxY7ui7jp2dSH5eHPocEiAQVOJW0SQIiYrxqJJHsCojcSsLPqTyxrF+x8cbiDgp27MH + UbHV1jNwrv3q8Vutmb1VHLjF86t1IDXKgvpxCrJEUCVCFGmahnhQPJEPlufolAVwURvSYbUgCJwro/dU + 1YfMu07Obt0YAENfxme8CiNgLRc8z7biduhGJW4mguUTLoNO7xg3PjYWQnclPRVznXPeDMR0J1+El57l + s+hi//eLLXKfN0EVHmwLRHWxK9+aPSDoIIML/JgTNgXXBr3axsFvtYGBffj7PfaT797iMWAl0NubF0aM + xl7HBlApOyPxK7SEaCdOLTOKlPIS7GMaQV3ZyhBqsxonaMjlNXeCrcEg0t8LF1bZ07/5kA1vuY5NPhGx + Mt8GPUc5D5+szAkvczlCJoNDoJgoy4kTRWMmGx3b0Y0lw2knETQ2fuSjstkz6tA/StBI5IpDRVAnqnRp + jXNlHwdcKxxyGUeyokMEqn+bngM5sWElkuxm+/IjV3uoMEB24EB5FCIkhqk/+mvCNynkqjDiFA7Viy6j + y9M7ETwkUREATVV1fHEFAK+aaqsnS6IT046Y/eRDl5FEBr9TOMWD1WP5VstlQrA7NagLJR01hZiBoKAJ + iKJolQha0qV/xMiJ9ae4Uzp5tiJ3ZxG0ZBTBnU5QiV1Sf643ZRAl3SUaIfoFktSfK/hjsw1vVZBiqQ31 + H8G/77e33nSsuy/1jQsmE1Q+vxtH0ARiVjkzTiNo5NyWG0XlutSBTxESj/dUckoqWNe8fjUXeJ9l0ofj + TM+JRKDcEsVY4yWRG4XM4rhozKEF4COsQg4UQfRarM88F8nNZjAkJKbGOBT6tx6di0g4jxH6y6YjN+JF + FLn6/fi6YpGpx1jMuw6NDSMRtaRHY10qv3TCCHQDKvpMSAggjj2o32qp0cXW03sSf3/G5s8PxKuuR+2J + HnFSXEH+CpCGDqITUGAqQZ2FYxkc6clYn0ac2tLR7spXMdsOIBdrDiJwkPu49Q9f7CmkENeMAuhyTciC + +HLLNs6WhM0PBkSN60+d5FF0SSCU9E0gXDi5MiSkf6I4bclXlFgMYcLt6tkXQOA/ZhSVDpFfH74p16Hn + 4kNWIuiMxlFEVBe/UwkbxYcJLxpcO6a4NXCabf1LbNvAy21o9BGwv5GfiaRs78bbEGEV7KkUUECZm5kI + Gjm0Iawnl6QsCqRTAVHriWJIBAj1JvP66afuAEVHUrp4AlyGGe4Ba4nayN8kn+nRoFJWQgF16bxYtwQL + NxgNCsiLyGGTYj06ViAE5+HBQOgJ518ElQgTUWUx7lhyu8Rh2wssRM+ntNF+nbJiCdj7YeOQ+nVHudip + XFpu8ZZ06lTiRpY/odBcf6xblVftsic2Kt79Xvv4J19mVdBn/rxFJbeyGl1ajeiV2K2tkFE0A4cGi7aM + oLE+jU6EoInCyzSw7r9nveWzt2DRnuVwSA8cOIdOpLniYIIHtSGqW6O5eb5cv0SOd7ypWflpIPByPIbP + NofgQ0GQEESSHPiI4JOjOrMjZgw1mTFSJIJCQM/4OAGTAVDGciwTS3+Xi9BJovd5EDXkejkUjkisBbkY + dGo/YLffPbMvf3/Yzn/5bqXMjCSkuJQSEbdua4D+TM+nxrHc+DHyM+OIhHKaimB0wZ2r9tIP3k9+7xSg + k7sBqQyhuYDxCWmmyWmrEMpzIuYWskgMK/TnEaAo++GcBuEE4hJCb7zb8iliv1ml1xDnY/hrRYHBAjfG + 4k6PpXzlLLj0uUN/HFIOlIv+YgMGXzU6X4cMKChpvGEMvzgiNFn0Rs+XR4/igEMcGiyLUYuIQ3BpjiRF + WgA1gvkZUox9w6fbYO+HPDOz22JZtUE9ChlS3zAR8JmSfotwQLHjGlu4USQoWQPkX84uXPqDx15nvRvP + 5wZPt41KGxH1mHA14sTxhNIvRVB0M3m4k+X+o6JHccCdR21MH+Z7ZkRQTKzf1HLLDi223AiHIAuRHdGn + hLg2N+ixnUHM7XKoJAISR8lrD7gjKYoFxCFIwpAeI/2HvtMhDAZP2T3H4rfcUPIoUqRmphhIwhSHA43o + haBCG2Yk7TjcvYN78Hibvff2Qz3g0EwdkGAsASIbBXmi0GwZUcvwotKZWhK1HlQIvs5cAu/nnCyO+YSN + 9B5nW59t5e+lbHYQkbHPFZABM8BB/KTCqR7Si9JhceoL/Ksc7LEsG5VfBrSESNPQ3oghRM74QZbuXwzW + ls0rEXUikFBube6oLp2RQ8sIKms6l6n1tJhxrcVcO/laEvJDyhh1ld37cxE15tjy2G8IGaaVyHdR2wX8 + JhA3j6jf6P4pyI5nFRP/iEfj2onOtVTvBV0IOkCjarmQU4PzARwdRfBj89jxsyosarGWyvkOndj69Aes + MHoVKD0C8JyenCIdXEAgqHwuGTkTBPVMwyRjYSLNFKeg9NkREAvjxT3YqKPtf/57N3vn2xJ29ikJu/xC + kA7vTNimp46z3q2Hosv2ABW/AIe8KUBGytygHSVmjB0q+cpRcMFFuxALgnXCjXkOWiF7oOXACW94Yj/7 + r0fn238+Nt9+9b97EPI8mhThKnzLJXAX0a8pWaQ4UhYs8ig7E+2N9kfGllJto+6iJYGs6LGdBHslhieq + yfbkMF1qX3nkVU6H6gS+KSD1mlaM15mA2nWVyciXgZVVmidiEglq6giYl1bSOBeeujc/cgvFPPsiemSB + NbK5wScs5QJLqaUInxOJoaDoZUjIqMDd8QsmKZyhBIGyg/6RFbaxZ72dfSYZfCy4tkb0g8r6uI4GlL9S + dze8scme3rLehvP74MMttRF0WbByZ2cUSffn5AO6FQvsBfHnSXZEuzC5RYXmCqD1x8+0b3x9rZ1wdMIW + 4LapDKJBwRXSh/thVzz86SNI5p9rI/n9bABu1v0NExly/ZuFk7NY/dngxmm/RMgSPDXetzjAj9dQBJNU + ygNzDb1bJHofsmWd7BG/W1XXEIg5E0GTBA6UOFWIr6oWM1hcyhsrKbhJCpIJUX/xg3ssM3waP9LtJQa6 + +RCLDKmm6aG7iWiPNl1EdSNGdSfj8i3RQQUwramV9ocNJ9ocnOg6LnT5YkEyQpYnxJdV/4nuwB9bd2zC + +tOnWqqwFxvdFQGzZk/QgM3lXgRIcy4JtTHDirdm58Mlx9vb3s61LQmWvuyJxqoW3zNlQ2QwtiH6zkOi + bNh2FMTanc8Q8nPrmHsVQTMQUyhFCBujFGOClse6HZIKMQUX9aSGAiy6NiSY5W+0j77vGK+GS5J3dmK2 + RC5meSw3gJXIu1VBzIrmiUCwTgLEfflpChx/FZDTWoiik8MpgztCzLYsTFfK3Ic8YUzo2BxXsCAgD8g0 + gNgTHHJw2+F2/lkQE8WujaqrDJVqycY2q29SFihUsAmknOQGPnTvQnvy6d0RT7KIuY5ZWLcB/SDjAwON + TXPXQXodguYKlD5k56DbDoUz97Jli0MZo1aNrpWKgPr6RirNSETXg9ZgnzrRcfd8GEu4cCQwVA4+kZ+M + uB8AmWX1G3Cpgi6FEOONEQ0l8FkU241tjRh6k/dDtsJGe0/lOz5saw5MerROtk4FBdDlBcduGCl5WluR + DASVPmXjGrtCCYNK4n77i/sBRd8AZ60FgyqOlF6pQW88F0EnUlohCKD3Eq5TsCBbh0GhHOli+93PV3kt + yLLu5V4eIeLVNyoRwIVKcki0cE3K4jcjfud2JKy35xiqyWSgdVta1WOzSHD7ZmrDhWNyUSu9KSMlyYav + pFDqVCrNgphrQQ0tmIcair2BEg6L13mtjn2bOy9hTzxxNLaEwNYLUSt8p75XoDKHoEJQAiyyOaRrXYfG + xmEc/owiaaU8MqoqSyFW37aQkXnwgUudNpXiTqnHqVauEqmhTL7VOaKmCTGCHtOHVq+SPnjEHn/8AB5X + gokJSlwElQ7VmlnkTnBpCOMFvSScrSxat1gJGT78qejUVwf0Q019gzW0dPM3xG3gUEmsVCjMxYZC0GZU + wLMbj/Va0OEBxGEqAK13lFPdd3a3AZdEFqaMIXE9Ij2VWWPf/PoB1iyEnmyJhqj6PLIxEtVxJbaSG3Ct + Ai9c7+c/s5JDe6r190q1yKKPCRpBcHK4evjicXBlgqATEFOvFvDkg9RbK7ZLBWUWVNyhcvr7HrBGdHcd + +CPPxMSAvljsNuNnBu6gnIGNrGlkI7noWjbvEw9cjui53rL5NS5uHWXuIS/AxUpgg0WdnHwuB1UFopZS + Uvw9JENB/tvYPOvb3GiXXMDpRleLmPWt4XcTQFta5oHr1aESQK06EFSb2gYn3H23zP01tm2T/MFdpmdr + XoAY9s10SVPv4tF1vBtbC21r7z522zu4FnFnZRulgirCgqgcrFokBZ04SPgvsIbGZc4IMujmtGKhn47N + kHk5OU4lsCOCOlFjsDiHsERQSYcIEupwlshLoBLOAzAsG9d+12J1N9rAECk2+5CddebSqL/DDD0aGqsC + QVV7ImPEex5wE3vu3mzbtnzSnnxmDV+ylxfVBuKo9K4KQydALiaJPNej5Sg5WY9weWRFBgt3no0OkDLq + 7bCrruDkKwCtyIcelfMTV+qRVccGSae2kr6TyT4P4+M23Jp0ah+sZTidwzGb9JkTNPL9QrqPWhpixzmk + yEhmP7v//tYo4azf3yUklONkc4X2S0lolTR0unGkOPdRhxMYyJ7Ld+3jenJSpZwXWIWMVIiWleGNFSyJ + PIOxMoKOUU3grg1uVL64O7bLVfatb4HtZX8qK+VyToGgCJSUrGyxxqTigqHYSFbn6acK3f5pwMGrQYJH + gXOJTw/ECycrR1uIgzIISEzQEuIgIOBDQLvZU15yzodAyputsX/4AjALES8KNza0RclciNqxIGR+FBmp + Fwdwbe28t3fz6WRj9uGA4fuq9G9WOhS14WqAwqiMROQC8FD8hluoh9rPfrnOuiTeBAfxelblJ7neBlmZ + FGNViDt3oQp9IfuHq4dU+eCHOojwrENsL7EBuD4YX9HyeHeIb5fgoDGQXASN/VP5so7IYAFIlyuVcfdv + iW3tEwz0YVvQDUFpXzBN5KoJhHMohlGc5K5C1P3s8Y+iB/4WzMte05S3Y2qjLMJ2CRoRVTFYr7ksYYHI + OpBaK+ISpIdPBvUgLtRqw+9cTJsZdBJitwqRputqrep2cSvuPAR03PCQbmilbfVICkGJFyBip763VM5A + xsNyyunOBWhdC0AaRx+XYyC7znbfJcb5dGKFi4hRNM0DMhhwEFqgrlaurwHi/+oPa23r8FIIOscyEZEm + 17OWl1XAGDKWRGCJ3FLAQWHHAJYLEi6EOsdgoP7hvXjubXbXHReETi24TvRTivbQr60JgwPcEPWbtaq5 + YC1ZlrDBgYfwNa+xTGGXAJ3wjMoEh75wgk7ANIsgG4q5LqzUI+wLXzrRTX7BFFuTC/xROrOruYuKLaSH + /D42sRVda3a5/fZ3lBzgqymm6j0SZkHQUqSooKpuxZnnQ9Cko+lTrOHC7vaZh3cLaUO5VXLx5Lao11Fn + i9XgZs1vW+rPJ9HvN9/CvhUOYuMX2bN9AWTt9TTlXFpm1bqkU/GV8sb8HRNUdTYOoPMwKZa39LxHsahN + HV/M977Sfvrfd1mTPBF+u6LC21qFJZFbXy04ZqhTke95GnWNheIHbUvPCRTikiKLL2iHCBoSw6Xgg4Ld + nEoRNZvdjTKBl9td+JdL4FT5o1pyZbSB0psreF4buq13vfUOAVK2XZ2QpUjVTiZoUREtiKl6l9EiInj0 + TLvgfCQEhtACIjWyZBUEke8py1b4H1XXXXRxwjYCyxzIh6B9H2K76ImEAHgr9zcnODYiqFePTyFoVFhl + QvG7WgjqRU1CevsV3/28V4sH5H3ZUuuYphplv0PITYDpT37qQj5wiw1nDiVQDDfE3FmmQx39rvKG7enQ + ksgtI6g2X/FMOELZC3HaH7agW8mtfutf19sZxHB3XRq4sYVrWU0zqWtfxcYOX+qZfAWwi4ig0ShHuTPi + uS51XOQKL9vFwcOihJhexFTEZSCGOzR0jt1/72LbhQCDqscWIFGa0JmybPdAmt34uoT9/Jfa5EOtN03p + g3NTcO1KxU5Rdqnc7/QcslfTKT03IXJ1oErtB2Qpew62zqNGYxilm7ct5t8fswvORtyX+aHeJ6keay34 + osGFUDDhmWfvs8HM2Yge+v9gLk/4UkIlSOwiRrDWXM5PImhUHFsCQQdiTo25hjIDcose/F7kzShGMmzc + 8OFgVA+1wdGjMHpOwO8FEZE/C6PqGN67i0enQtuaDgtIgp0gcmPH3+ttMPTQ+dpMxXJzBBzyY6oqXwdU + Zj3uyPm2edMZdu89lXb9tQn79KcW2s/+Z51t3HgI71/NfilC1OyB9oK7eCEhMbnvQ7mRJHcmbi0wYRSV + CKrPShxnhGRAcjin1mMUEgqkCOybX7uaar8J7nSChh47QW9VI0LmIlaKBBP+sGV/xE5wgP1Hczop+vGI + oEpcl7stcehvErZ2OwSVsSDdgCneiyU4ynfmiBGPY2Xmi/NJHdUh7hXU2I21v42MdANGk5MdGQnyhaX3 + 2LzZuC3uJ3sUBw712OlE0wxldAoQNE2wfXi02a8hn9/bBvpwHQZW8dvnklw4lkc1zTiYhlYkG1S36n46 + WClHIcTEi9Ac5c093P/U78s/FdEDkGxy4F4V64oBy+dGouk78UvHcV82bTiGNN7d1oprF+tQJ6g6dzVU + Jz27oRXclc+gC1ahS/DLVGykOGRGjyppCJsQKq3KShFeKEFFVAWf/SRjjHBT2yKMqiEZ+glCjLM5mzbr + dRGzIcIYkd3H4LDxXSDA7AILzj3qj6ClzZa/rKXNJf8ZcqAq6aiKCATiYpwMDH2RdNAGejttw9Ph+lTq + oP0YIaojqeP6Tq6GG0GxuxKwVbEfGoB12k8RLqgwb84RWbvBKFoGiEwZrhYrKCGCJEkNL7QNT9I5rXiH + LcDFrPaoVcSp8vMaa5udQ6XkX3/9Kuvt+xvE4EobUgJb4SelfkoEDSIkNKuYUoYwLbAQR4omi8ZyuKZO + cTjNei9QxpFGrF9hdhAtTuyuUB/igQ3Chy5qCczrJjNsXAzU3hHx6yJNYT84U5vuPRZ0f5JGEJM15AGH + Nkci5j0IAeZYabYiup9Auze1Ul7YVUsd1w5BssIgkYLzTElMUEk3ETRAXEPNqX5LEk/XEQgax3hdh/p1 + zLfcoA4Qr2f0G7hDI8Syxw7i75tsGTq8ti6q5w1EbeN/BBZqWj01878/ex064GzevJx+ePqxyBHOR7Le + C5ACYi8ugZ8e/ovwRS90k3Ugnk8RUoyen225YQmZEOObIuS8P48uFQRlpsDFdjJLk0oPp9576TNxJC0w + Q2wkxVCeOFoUvAIRWmB1YaoCSnAMsS4PwVBNxcJZdtvtR9PuNfS3aKbtK+2ECIZ7o0QWT/7qVxejMw4J + YkOnrtSkKdIDOMFxYDnuHzRbX/DP+fk/hsv9c16bY56kZxWcgfslFcdgrICGFFLkaLvvI6eW+vaq9y8c + qphkM1n4Tvf31J40W5Cinx9g/C7/I1kfgalfIujsrevne1BEUOdUh7OKmHL51LaANkD5I+37/32rB4O8 + N29wYQKKrKmmmSbA0hHvJh94MFn39oAKiK2xWNa/xKGzjk49X2JORoIEUS1iBrWktj/rwEY/bLX4xs3C + GDlB1R6c2hWFkFbuqSDwm3Di9ySGG9rLTA35ecY9qsB+SeT+CTg10r1Bn8c1tIKW0pgS1aiSCSEYxKWh + bS0VZVVRS9BXnLsbevMtOPb7EMMN2KGXCPonINpzGY9uoCkQEww1+cqOS0KXjgwfRGj2i7ZgcRIaRgT1 + FJVgJ6y73iPrlo7Rthq0G5xYDpEoidy45Dzq8vFCLdm/sPf/pRtFcqNCTU0gqiMJWWp0NTSkcONX7Yhj + 9qSGN+JSJZSZaOEi98MfvADOvIZedTQbpk/QRKRD7kvkL0Uhvziq8YL0wV8YMd2KjAIc7kLsQMHvi33/ + z0XQwcH9UI2P2ImnHhBwRh4GhJhOXQh67wfPJ375WssW9yfRq9DalIy7W7kTTSFe0qEvojh23TmxSlEs + 1fgI2wvHpmhHW7C/s7VHLgsNwLzigf+pgFcEve/eC4glvg5xuy8AaLVHm3B8X+LQF5F4M0mu50lQg6BH + rF9utcJmxQT1mkOJ3A+9Ar35etqsrLQR9WZ/Th0aAskvtsh5sb//zy5ypxBu5p5I0p1RnDmC3QjWk0of + AI0+B0GXlrBgGknlfowIeucdZ2I1XW+DKcZiEKssWbkltMJLInenH7BZEXQ/RO6nbe1RDGSQyPVIEQSN + jaJ33XYG6asbELcU4agAaQboyUs6dCdLpedL0Mhgi9EfAoSn0itxMz9Dmch8q4rQmhq85p2o66sr7D3v + PAeufLulcgdA+baANJuCJZog6Etuy07h1lkSVAjAo09caEnCtrKFsHJphgGYWbUlb38r9RO0/0zllMCd + B8B6JoK+FCnaKYSMDaFJmZsIljoDkWOXaiqH5uzjtvboLrqlRCK3uiFgO9Xj9upXHUEfndeB/dwdViYP + V07QuNG+x3JDLajXf8qXKy2h3JRWm7iwEv40wtTE8cnQG2873cL+hP7qbI2iiXYEUaw1Qr/HexITf3vv + c9RE3EFG+VJPagdQWSmWG/nIyn7FLdSFVxoFDN4zeJ/tuxpMtVcdiENVbkB7cdW2dAN+EocOpNXjdhHR + CBpEOY6FBDfJ2oyQ7/y4E9pLBsjk++tNtLlJMEdMf1NK7o98RodAveFpAuFFQQpOuCMPABvwmVY89WGn + nvoXcCBmQ9AJ8NxEglqIg9AdOxQ8T1QcUAlOIl+AbiWyB7yKACCZkuBqbSNM8DAJkYFoaJAS5yTSQ/mJ + AOok92XZCq9EIl6Nmn0sysDnJsZeenBe1pE6bCZoxkgx67jdTl3kGvTnAs/KC5xU4EJyfgEBSeAgKogz + 4iiCGocsFhxxsMh6RvXji+z3T4ZMf4CvCPGg5v86faFPUa7Y4euvnqBKMeqwqqoM8HkY2BO3PNceUKUO + 6mHI4TWKvi32Rl0p4DxZcaP6KyDxUn0iqqAmu1sahti2Ue+nkltlmC4B6Y0v1ATcW9AEDUagDI4cbRs3 + fYHhecyPA4YSoCheq0GZXEWjNYMvHU5jFBXWI3pVsieIRb2NCsMjbCkE1akJHKqL4WLVKMoH1dB/XVw6 + rNpHod+WhGo1YU41YyUFei6tQl+Ja92wRl+FjpV/Lu6cbejPObSEGgy2haYwlRO0R4T0fvoCenXSyqAe + cFe7l9qnMguApApIp31uBH6jxiHiWCEn9LzUUoC+aM+FGR4X5wI3zWaYwjh8of3rv945GWidAEqvsjQ1 + OE5i+v7il6/DdTkX1yUgzdwX9doUahph95SXFIZCJZ0gQf6z6Nv+LCcPuGPeTrJ//mal/fo3rTjDuwZQ + lERuGpB0RFBtZP7/JYJ6nDvYBBK3EwSV1BLwmj0AWbgZQFma/vRmq6ipOZwWOUINrnHmGYAR/H0+jKjV + pyeORFXy3spHA4JgLrVmTY9yMIYPoFvMG+zuOy+ZDLROgJoXQVXIqlKIRx45HcIwPHVYHCou1EWRJUfW + O4wQIko/DvQjRiD61j5BVc60Z5+9xD70/r1sXhuNfBHdy0GjPf3bNVRqQ0iH/Ks+Mohc5fXyY52+HDn4 + AnTezn7vTtGhkW0Q5qRNEFRVZCLQwBbFxZlwIXwQXPrNb1Buwv6sWEJx090arHAhe36YPf4LJCR96VWx + PQLYLOx1aBAS08GNITUaGT0Mhrndrnn1ET4fR+I21LhQThi3Tq2DQ1/7muV8+J00PRKhQu8cR7P5aRGB + 28GjAqBSHwA7inW53fP+JbYCVHk3GFFViTVjbS3lgjc/Q3EuLVQDQdWiPBoeIGwMn/9/iaA6aDFBS0aR + ZqWN0EVlSLqRLi4kPNSQ8v//cjj0iyivWEQ5g5D4H/mYiH4pgG6aTfUL07WPG07a/9BvUDDTQI9sWohE + 7f277NCDVNdbUSZ2vaKKwlEFFwjwrj5AH/6YR4vyEDQYPrQJjaxZtXAb6NVze9oP/mOOzceh7aaMLh7e + tnBuwq64osG+892V3OAhbsn6JIhRilVH6KaiTiC6eU6v1l+9Do3mycQElXUbE9SxVxnKFvK7Q4C5lh4K + DTm29MynfU+d7QUTaN+akI6qTldjjgc+tNJ6n70YDwPcLepMuK7g2qgcM7RrVWMNS62zTN+N1qLC6En1 + LfQhcoJiHKkcToU3Zl+CoAcxa6Uh6mqF8eMc2uBdvxR00NyvfVZAzBYuBnN5DtxdzxfPAXk/kGIWNkPq + emnDnZNVHBN0FIKqx61bbQT3Vdg6E0zyTyiCZydyI5B0NOEpRr2LoO6jy85Qt1JGRbsVi7jVoJ9Ujp78 + uXvsq4/cyqiPBi/MmoOq0mpH7b1ahU/P4Db63FPpXAHBu2i70wqh1dGMgX+0AnrqF9fQiUWFv8QRELcR + gr6T0nI6O0JIwQDVg2fzUw/CmafbMCV2BQC+HjHyBoahPbhmlfVsqmVeJpVhiI0bXl9jr7lyN69gbiBi + 8dWvn2qbMispyaPBoT6jz9JONQxqDfk8EbnAUNbZthifrU6dFUFLAYHQ83A6QenpO0RTaAdKz/XC536X + eGtsy8a32cH70lAa7hQe+vbbV9pSQHrtSMl/+hKTD7PUr6haQMW+Xpy1jP1bhv6UqjvSsj3X2GNfu9bB + 8ZM5VB0daalaCcvLylWt4x23noppfK0nujXnOqMqKo2RgrBeVj8eGiv29rbZb/7QwSjj0+3Hj1/qNZKt + cOy59OwZtCNsKyc3izk+FhtXEbA4oNc4rd7I8a/XKHJ4pbeQDQODwpzRiaBCaB+Lq6aoG0RR1VxWwZjC + /vbYdy70ngyqZrv44jlEfF5Pfc+r6DhzHpx4mjflkr4MTUfERPNtdLCTEkzcwYEjEbn32pnHdHnIdnLP + +RrNKaPttfrwRARdtafY/G5M6aPwSRf6cDbVOrrZjMjMjArGLwtMlcp0I7ED6Ab2cpuHIdQGp89B0Q/k + LrQRJvSlx5eSKOdUORZGPllUUkg2pwDH/jVzaCh2UmVBqLYewwiSPz7RJUwegsSm6lHkR4qL21nH2A03 + NHljLzHAt/59vW1BxQ1SxzI0utx6esTRcmH4Ti/FB0NEfc2Iz1bblRogCJr7ijWrwGwqQdUPSBmX6los + JV5MEteV9dW/5YO2redskt27MH+a6Iebzrq4bm8cNYjborCW5mYOE7baNrTebrut3Yt1G1h//yXmaOb5 + PJkbFQ3LPZmA/YcKZW3AX7MODcaK/PTQE1h9CKeNl4bL8l5SEnx5dSfrGTnBdtuNw4/ObIKgG7edZMPF + xcz6Vn+/UATmLVdlfPq+hwaPRZ7LIBlH0+cwQeJOL4ieVvAr67YqiVJVbwPNNiNIPw9R8IXPXMlm34q4 + Ja5LhCIF62sWS+hri0+lZk3e7lQnaQWEP9J+9cvzrRGZLsvttONqrGfrjfz4EcQgmWRPvLK8QDcE9/+8 + UaLZRoocWOYSRyqEjqLYCdMIKnXjYhM1NIjbkjvcPvJAh6u3JqTZXXfBfcXjOPzaV/xz3usl+FGT5RAx + IuzHgcjy3DO96l76Jrv6sr29VcF0giqH5lF6jV1Wb1yGu0KQc05cygcfoknDPliqcBJLscR0SpwWxIFP + OiByMURt5Gh2BRx9ph27Fr3A5xdyKL736BU4yLRK85tV8U+EL/U6yIlszWwNm9l8fjZG0WSCdngvJxmB + cRbKucszJSF7Mqo2scyEO3D/YDyKqD/9yUHW17eYKoXQM1fEL0rXEm4tDiMBshLbVG/DPAOZNntqqxpp + 3mlLaVWgut7p80eVR3OCYu0m5vubZBh141/+5ue32GB6jQ25uJC4VbxRlcQK0mPBufWlimJZwPM8j/rV + Lx/qUaIWOPW1V9URGz6A7swAzoQtBRysUSB+mjXqw1Ntf14u3XkEZT63giUlggoxiT718kcOr6r3wDt/ + 79HjvJRf7Q9OOhnCZTUFQoZTM11heK97FDKCZM3yfJp9ShOMxw4Zye7Nfl5uX/uXS73HQxgiMLVPUVTk + ov7l1aTQvA2bLF7BOu8W8Po1ti3VaYNkFMY5JSmFpLyzs0JZ0g0yljQdt4Lh6G1kEc7xE6gOXEsIMgyO + HEsAn2Ay7k4eXVOg3lFLpf4hsDBB1JkHo4dinfIVGlAEiOlsuNPbqTsiPcAldxiXKzfMR2RF/XLlR8dN + pZQiUwx8lILd3HH28tOjdnhw54/+53o/8GoWKaMx674+Ex0hbAEbxWtUcXdGBokRY4eM2Xr26z128klq + FqahsqocnDJEoIaB5z69XVAUr40IYySS1R3WTBRiJH+vbcucRHk+k5AiGe9iQNYd86bN45Wk2CDoIGIj + NbbK/usHh9BKjc4hiN2rr5bvdQwKfYU9uVUXzLyvjE5k4HIfyoNxFCfMpw1HF9FV+h+NoAxugmLCyq/O + kqgihHdkCb0iyvtBTGuDHqMIpgQ9pBuVVRpTWT1E0XBbz654ETFl9K4P24mY7W+P//RgZxaNSjn1bJpK + py63EarQlXWSQaWmjgEQEAcsovQa3JqX28KBePLJW91vVX9GNbyaNiqrLrHY28Kp/06c9a5kzGFNdRd+ + ZYV949/fggX2Ri5qnf0BgoRJQczO9lL51igBXufttbPqA4AD/NSmw+x0xEkj+rkJR/n/fO9I6yW7nsdC + y5IPTNN4KjSOCrWmEr/lBA1mP2LKo0mB6PGA2BJBSx24ZiGyZcxEpffOUWUNPiYR1Ik5uVA3lgwhzqol + 44fUGXovNwpHeSNk5Y6rKJzuoEfEWXbskRCT/VCTqi//2wFE05BeGJkZleGrU3c0NLf80MoPHR5hIlN2 + F77varv9lrXWippUU65klRpfTeHQWnrK1yQagrUkDtWSfMbqVZu49SdJvD5gz/StgfvorRfNK8kLlaAS + 8ZxOdr2XqY9BUL1nkGlLX/zCwR6fbIaoig+P2yV8B0lzsg9bPFlO5xNl8KMBNSEcGBK5LopLvexDtXgQ + uZGodVdBc2FmOZ3QI1a0hWMFkRuIM8n6jTuglUZghh59sbvliAMPz7EX4kqN/8oGtIdUVK9nqA6yT3x4 + N7qDE1lDcp24Xs+db88i0dKSejrAUV9+b9joLXZCsEL7Kt9zw4ZVXOddHsxvUGalbDjvpMBCHU0zahIa + 5RG1FxOnRoRVrYQg9t/89quJBl1IJGOVtx4NmRdEnyt89djBUPJOJtX09qHJfv4A27T1bDvjVEJZ6Arp + 0/vuVdL7bHvKOVMWMsNRfUxW6MUexoREvRsijgxtc2YaOSmRFM0ZLW+r80JjwK5Do9J7t0anEFQTfhXJ + cnEf9d5T29OoFUCp5xAE1Z7ofUaQpZgndouhKP99INdqWwgELIcQS8Sd7O0vfna5bWVWXF8UyI978/tv + EW61bJiHI39Ufuk4+VMbu8k+8J71oZuZj9SOpnlMDSzUQkB1aa6GS0PxbzQuS5YvhJDzuxd1o+LSJ58+ + GL9ybtQeXCJFtf/ohxGJKyAVNBqUdZb29mXH22P/52Brg0sX8x0aIv7TH55OfHcFYrnaNsKlaiJV4jrv + 1xOF0dTjTs561IFrquHjvR3KkXEvlJBl73dXKjKuJhE06qVUImZefW5ZTliNk5b7Jq4ODTJGHNUhH3EX + 6+mvR00hasfpu5s/3s45C68BMdnO5t9yow72tbapXwYPYlZB/Ph6nKAQkxWrIqmppzYonfYVDyS01tLC + ryp04axtiAb5lhO1hhOjblSVlOWHBhphrGQ841kpNZnIP/z+zXzp39KijVQQQDAVywQHuAPMkXwoWr15 + mKoJjBEtvovKvJ9j73v3Cmvl++dC2H2JjgyOnoTV3OGT49V+zcHcbgQoMyEwGSJHj/GGRfU1cUOKuKfs + pOYSsyHopOozXX+Yu+3WL70MvBGx964NjYv935HkcILqntHzYQ8WEThosy2DMmb2AsVxiN1zT6cnPFrZ + 9HUrsTOGrrNnnlHOGXsiwgsFdF8YWqTfUXpMakeYq5G0iHmXve/tF8GduJSVSFMv0sZdEdpkagNkzdYK + E3vEnSKo2oNPGEiyfps4XYcfqm4cn6Db15ko8L0dpKReQmHifQCT+aAANmQb3DfiYKZ98b+usTPQGd2I + Xt3UlZcCgKL1dx4w1EiUZorbuhh93i3DCdajW7I69WGVT6H3XOpOCkxM80MjfR23r4s7S5cI6S3vYn3O + /bqOZFAPvqIC6MPqV4/hVwDF8ZnPcpjZuyWkFFsh6u9+eR5tclYjyfBZiZw5nMeB7Aryo0LUbs+t/gBl + SSu2O3gFALPPWgt7t8vcvUMgQdG4NppEK+051Q8VQcPgdMlkWJlRhgnclngSnnrgiOBqqvjgR8/nFN3m + w2EKXLSc4dA4WDpmwjjQdCD11elP1dPzaH8aHr/e2vn8QukQHr/w+SM5vUeRL20N6TVv3yJEgwgKZ2cF + JlMCYIKg3txQ8V/N5PQguBo0hQ7Qs/FFJxHUC4JC6Xs8TSmMkIZzoobFkwYkxMSQdBpWAL2daA5JBzyC + X/32AjtwvxDXnou6+eQnFxJJO4gDvwzICarGpZlcm4ig0bA/GUcCmqWxM4Zzay07+mG76qKjyTWrDW4L + oPjAbM0dABOcCacEFtz3LOXU9KKormkDIWiv5U2pdEIWSLx8yX71m1O4mONsM8QMYGzpkpBRUOtyRZWE + 15WRlC/OpdL4EPvFj6+wdn5nMb6tokgPP7InXHYKeN7W0A+JzI2GC2QG2gJhydYXZOGVETWO/wbsqwgb + xiLvFILqHpQRikreS91GuBcfaOepMH5T6LsYK6uginxYb57cQqaEFnK4Z7954kRbf0SY7aLK+PfdPQ/L + /zB32Qp5GlAC4Rx3zlbTSN2j7BH55gxGQJWNY4f0phehfy+z//3xR60jWYeNw6KHsBitAT9WIreuQZMz + pg5Vj4gWGi6IU+Pp64GotYyxUMyxJlHhFtaVl6jv+aftt88iTjltY9xkGC4gomqFDLtyfxKLmxyucpD1 + bDnG7nvfLi52D1hOL3e+81MPLeW1U+3pZ4kyDWrDFOsUGoKkML5cmO8iTg1ZmbifrE6wCOpoiJ1BUFmz + boCFYEAYwEeQAD0a/EwCJtxPuE+GECGNenr0t1RNN9DWTtqSz4UQh9iWzWfaEYfCQSImXsJllyXsuz/c + Fa7dk4gZkiUrPBAHIMI0e2CG50eHMKxGFLMly0JUKGsvQzTfY4etWeTEbG+lQXRjkJw+Mttpo5ZEk7qI + 8e9ygjqnSvRGA9M4BV4ZzHuSVfXWwJdI9P7zP76WG7kJ40bEBVvqeCMZAlxQJHpDO/JQktiDrs1wkXJb + bryWHvL8ThdGkrpUf+rjMhBodsXQujxc7kNsiEQJiJYaUDRKIlhmfMDzTgCxdg6uNyQMZiBolEwI7eB0 + 2Gi7qoyHSyDdG8EV7jsDd2Zzy72BxcanzrCTCB60CvkhH/5YBgA+vgTxqS7U6sxGRE0QEhIaPrxAlQUc + iM0b9J1d3Bt2CQGJNG1ax4rvtjveeVpocAwXNrBXbqiyd3X1tcQImArhDDhtRf1tYtHrc7fLxG70vFJr + 8zq6XfTuvQcndPBOrFnwu6PLHAWuC1LmZUSnWEoe63csI8sPoLZOt2CguDPZ9Hl2x9sXuZJXVkYW4Le+ + cYT1DKkT9DJcnhjHBIaGGPJ4egUija7aZX3wZDAELt1JOnQaQTX8dQI+GYioe9GstqgHHzHWoSEiZMBC + +jF0cumr7UD2RWplGSi+/fdNMDXqYPxQwTLp5InqGaWPYZgshcQRh2rktBB8MEUqLYm00IbyK+ixeKH9 + 13dvDVMhm1qRkFi1yoqxVClYWcV0ipgRpxNULBv5nv4m6c5If0bEbG4NA+9EVPmsGjxzwomNuCB34HMd + b4PDu7p/WqRhcMypRoAh1Vcd6mG4oSF0Rg9/F4jl5vLn2jWXN9niDgwG4r1CSnz+i8uIBdMRWhYum6XT + LNN+HIS4lkZVhoB+qB2J104ziqJuXa5DZRRF/mkcsNeQOXUe0TVpqsWWDbJqj2Lm2WH26ydOtjUQsJXN + FkF3I7U1nDrBBpEsI6AcVTydy3JAVRIisQ5njtEoWWO08iOBoIK09gwssk09J/Pvh1wStmsokUZy1YfB + ddUYlfWNKi4Lc+mmp87Erc620XRfH9lcFlhQcIGxULUN8lE124UEuDu2oZX5bbcdz4/fxbrQtvYsxGcS + pwaLd1zcKSwuzXuLWSl9iakmal9osOxJ2rfaVVc2+CSFdpR8kmTvxeibvsET8XUFkKJXUgp9qlCahsmS + mvLJhG7SB+7caRzqbpGMopD1KCdo4E4RmC6cw7KCFVNlmj0J/f7Nx9hX/nFvR0tKZ8rY2x8kZGb0Gnt6 + IxKK+y1oeKxQj8yqMRVnYQQJEjuuLjOkxDQ1SZyZYVjupm2r+ftBO5DD0UyH1ITGirDvtY3QJa7Q9phB + BSpQhhJIv2kc6saQxKy4UG5LiOXGLO4EdmISDK5r9nncPkmIWG8TP/K1L14H9vQWFPghnFbGYbExqn8x + jxpxsSl0zJDESWhePOxGxnzbPMTw8NSZ9jfvYHAAHC8ckqzCVXvT7vtHIMnzRJVGl4Thbj5MNeB4A0FJ + tquh/s4yikqRIrVXjVCJEYdqEF+YBQ4wDnzVyDZ0fuFEe+Z/V9vNr4UrIeY8RKzGWR95iEZ5XYoKWsv7 + UUUOBgB3pVloENbnrwhK4oXU+JwQOo+BVBxfYJu3KhBzk930+v3c+Kwgxq6xkrXJLqoD4cpY9fHYzNSp + ZqJFal49LR8ajCIRbQaCSgnzWhj4wiQhToWPtGKIWyXvr6WlnJT/j7//Ji7mWhvKMJlXtSyRgTQmcTvK + jdAK1EWvm/419pRbvstsoLgbM1IutO/94DJbPC/ge2UFL4Vj33u7mhPSNTpLgpzSxhwoieCqYCn6avQV + N+mflA0p5U8nt4aZqSGF53O1yjhU36lu1loec6ZX8NYtsgkg1Pgl9p2vrrTTDuMQotPmYKxosMDNbwSY + nrkd1QMAGvUwilHnSWoKkvKDCrhLRMstCggEQXdS5I/T2T1tS68482/s4x9b6RMQFVtvqtOAH3zNSo0w + Y+RJbaMbQxrXrM7jaiuv5tXTCSqWdbHrpWjBatK/Yzem9Fqka0ssHt4r5aw+c09uepP9/tkjUf4HcHFA + /xUoILBgg+gI6cUiCXHMc80/05xpzUbJadb0qKzfM+2pn51uV51HeikiqlAPK3ZJ2Gc/v4q603OIvhxm + G/rwCd04UTvzMIwgJzFPzLSAJNAGZr0YSL+nfyP+lZj3BdHiomXlK9V/Vktt2Enaj5JQLnrnF66Tz49w + /b2pFqrpIA7Nhkfpff/oY4fYZa8gLo0uU1y2K0rif+ufKcoqnmf9PXvDcVInuDbulpDjBOFhRfmYKofQ + d5ORQu1k/PX9KTm50n791C32hS9f7J1M1PO/pTl4GTWV8jPlmoihJCWDAeu56+3q0OlW0kym8MzP6Yu5 + AJWDS2Gbfcp6es9CXK4DNShO5SbEocOEBxXrVKdnL60D3YYLIiSbCqAKg0KDH2FjQxfYA/fsGsZpRLlU + DYS97FUqrQCJPywExUk+HqRnK2MrHVgF+kEjQzLS39o4Mv5Ek4T0z3lqLxA2wDoUaQIWojpLDBwdiOyQ + 9KIgqTpYHRgz1fwOfvS4+t0fx7rCfvfU2Xbz2+pt6RLptqAvlyJmTztOE4iP5T3rWLt5N24/TExwHJUU + UtKbKFKawH16QNEwwOXyQ31M9SLGdazGVWPPRh710WCNbbgk7KOIVlmBWxLNpAtEFZGjWWexhTuz2zKj + L/P8iBoRVC1VhLo/7hht3JcgHAnx/NGWHtSJZJN90q0MgeB7ecrMxY44Qs186dWOYz1E621VYT357FH2 + xpvCcJt6vlfjqlr4rf13TdjH3r/Ohra8ns9dyjrMccHDfO8I/qKGEeh7s5qX4ohEMkCaB6oDhGU8imQY + 4r1aGsUh4JV0YzbdiOtB4gDpURRXQ5xNfYxm/uFaO+XEECAQPFWodo293A+IzQMPUffDwRUCQ7pwAIt+ + dFDxbhDyRIxCBkowHdkS/O26WZUDSyD8CvBDCrrfgIV8j1XxvQuWRX4mv1Nbp8E6kogioAgZxQXKU2bb + d1tmQVBxd6Ssmxqxxvj3Yasa7fuPXs/FvokJffvDDWBhBOGUr6dNZOMFy5DPKj0ywEaGFBRchXEywKlO + 4YRv6DkMrlzvyeAONtGr2lgL0Vmd/PvM4xP29X88gCT5GUAzsDoBL2/uh0sYgdGbVqSFavIsfiO6dxB3 + aojA9yBWZmqc8BphxjxpvDx99Xt6pPsO5fNH4TocYv/903Z7+7sSdrCiPVjgmojYjXulGaIaz/zQp0mP + jYCjlfsFR28iYhTGaEpaQMwU3E7kyOTCoYNDz3r+5v629RN/zh8McS+1p379SvuXr7zCdiED5QYo35/k + 9+o8CqTSzlrGhclFiWIC/jglu7LTOTQ6RV1dy3wAe0N1ixM1ySn76Q9lKN3GNKTVXiOjGSilJhsKqWVC + w32JQ3GLcw1clFLvAIg6PE5PdUJpZufZvz+2yi5Ed3VATIk7GU8irlY3p/uwfSvs9pvW2j98/mX25BPX + 2B+ePpuAx2nWwxD04bG1EPJgHtfx/Scj6s+jsdaFtuHZc+wXv3iZ/fB7Z9h9dy+380jG74fO7kT0yf1Q + SaTgIipV2H33hN3/AEGTwhmAoQ+2TdTO6nAMOpJPK+hiZZ6yw6EGVEQcdGI2eMuCEYItQ9mllI+cBdd+ + zP7xkZsDUJrfao8G8Da3Bv+/QW6KXgMKNGHbxMScastMY8jZcGjAHiUwsVublkPUJsZINTJ6guInTt2P + fvJWNvDN3NQ5EGdfCMuQGh+fKEOG0RjouSFOd+jPACKQOLDEpqYhavXz2tahJAH8FQS3j7T//P5qe/Ob + k3YAfpoCEqpHXdZaUyKuCN0OATSNd9UBjK+6KEAlT4ZYp4G2O/NMwFn8+7CDSTQshvuU0uM6FapTFmge + /25jgxWa3BsRePpJFF59bT+vABAHbxhock53MY1hlvPYL/4phEuzFCzIU2LvfW0VKuS+dH/yqVMkvoey + J/D3vfaxD15qbRqtQrpSkSCfn9oQDB7vG8+jZqtND+vFxNTjDLnQYA/NjqAhhyqfqZ6LYT60ThUbooFv + igM/9Nkr7ee/USHOlRDmEIpYMVp86p70bWiO38dN93n2IURNBNzKEhbzoTM+IprMC7q4bxQ/sHgYG4Wr + 8/jh9sabMU4gzAJ8WOm3OdK1cJb0rUKLWrJGtTqix7bo+fj1hXxGceU2rlVjr64gX/vFLy2zDRuPpvxj + vRNyKyOie9GLRQgpMFeAhRDL9SyRODRkYuLYtUKd6gqjwIKqCn6/iaJnu4zDfKtdf90+nphorFiA27HE + mUAGUOBGJAIWbkNjiNPK5y/F2kt0iokZc+/U4PysCEoKhwnBbo0xWlnTeRMav6wS/1pMbZpaKUhx45vW + 063jTm7qZsZFHkU8lICBcqH0Hci4gaRTz4lnclNK1mBK9ZCCt0iUUT4AsWM0xCiibAuThgY49Wk2e1Pf + OnoUnGvf/Y/V9v47m+zilyfsNRe32DGrIBQHa67ykTx2RgSdD/EOgHAvW19t114y1669tNm++PDR9vTv + L7OebWcTHDkcQqxmUTRExifNOK+ig8w12jJ0k87jcmgFpF8g6riMMq5T9sI44jc3vpC1nz2zBZ3JeMgf + /uQqO+XUep/VrXRkpY/I7rRkjfKaIQrX2iJpFwg0dx5MUm7NlvRlOUFnxBXNhkOj5Hj8w24gRdAItVgR + gWsgNM8fumae/ce3b+XmHgQV90rr37oEX0yGxHK4bw7x3ZBE9pOu/KCwvxJXnpVQ3pEJt7gaqrMpSD9x + +p/F50zx2XRxoWf30wWsxxxNgTOHUEiFlZ06HrF+EuvkaOnvE/ADj2UdQyQHvar3UlCVztPfsLAEQDNV + 00RxBB91JB7GnEJ1oeAodoO4xhzgcoHlaGYhLG48zjpfmIehxzgtZqPm82/hfr5sH7nvIp++KH0pP9MN + H4lWReTc2JGfGbslZbGAqQQtEVXvETF3NkHltoiIurDI2i1xqS5YK9nIWOY5fioF6bzjbccwFekD3Ohb + wCQdRWncAm4ejFEGjK+iKfJV5T+CCAxTA4OrI4Jm4YBhNlGtdHKOoRUOWDDIeAnFEP3t0SRypui5nADP + 8VLrGf0dPSrqpN5CQj9I5wXIqMDOgsAoVymRGrJGSrbnh/htN3YkPciiOKfqIDLvjC4vw6MHklK7wIb7 + 32Eb/vBRO+f0fW3XRXMjpB6eANar71ccm3VdWO5nPh+Cxlw6ox6dBYfGEaUSMSMixsTUI+Eqj25A0FZ0 + RwN/r19ba//0xcuIAd+KeJJjTok6ocBsqg1HH/2qZlVka8K8aojqXBpvosRflVvGIzyvWO84jZwCgCug + 8WLMTwB7hXznxIrLH4g7K+fprdyiEKGI6G14BIXBf87MseIgiAT5lLoGj0PLgBMeOfQUygEnSZE42Na/ + 2Pr65ZfewnrIPvPgZbbn8hq3+gWKlohtSM7Bt6ZKgX1RgXU90JQgYmM/cwpGaLscGn9umv6crVEULLJy + gHZJlJRxbWMbfQRA4Qudr7SQ6maWdFbYm69XafoVIAEop6NKbXSILqA5VVetcEhkSvUdMiwQaQqlBdwS + leRsrMZBKgoklJym8zo4OUYLSjRG4LLtP0KYsv4OpYFzoPZEyJigatkW2ssE0FoRySFJMsahS6cZO51j + RhzukdmVrNvs6/9yoZ20Xqj2UIzbiC2RxM6oqgjxcCegIkGe1xRh4vxzuYsyA6GeOzpUbhHPgkP9dEVs + H4vemJAu3+usaw4FNdFrQuJLRNczVqQ92e2wROF233LDCtv0tGCi76Jw50wKYBdZn4fRWqxnOFiMIS+J + K4DOUr+7UJKBVewD4kR0YXm16RDTh5dLvz3Hil6f2lwxVGQLH6xHjB3pcjjcD5GHLQWOO5DfX0eYk5zn + IK0LsnfZf373WrvgvE5r4H7U90DVZZWx5CqLi0tSybWrwzuQhTsBmC53Sab+HdHoOTm2RMfZEjQ6WTGn + Roq7wlM7UXpHz+nEcpMdcwTo1iGgJU7HSmuuDF1AJI5fdfk8JuVexYbdynqlPUmqKkc0J4/hlCGMphmj + gVsoa0f3Kelc6vYZz2jzAiYRQUvEjVf8/GQix2j9SYNbncODGPbBsx4oWMzE46X2LHNVt/adBUF1AD8J + suAWu/C83b0biUDr7c1gsOqiKoToICvoriiQDCJxrYbwNlC6qTIUz5ZMivjExIyTJTNEh6bs9RTXczYE + jUSuX5AIKwLq1AlyiF/qk4NDUWpDA+m2Ork3XGBN0urbySTwt1AQdaD2G2tDfY1SQ4esbbBH/u5yNuzz + lPy/gYDERQTMybZsnmdb+5VpCagGLziOxGZcWhiXVIQyedW/tAbcsNwgDwREdSgS2ZrmqzJA5VyjQqGg + g0ObN59uTPJ5YGSZbe5ZhSH1Kv79ABbyZ7FcX2XrDlkAqiA0GnFCwXkq/CrpxCrsBwxBHWQNyvHMFO+r + ZV/q2KNa36/yPYxpUW7FTvE3p9otkw7DrAML5RcTzG+FAKt4VP2FiFlfA6BJNxajCZks70SNzPa6unb/ + jIITVfLLauWLhVZ1LW2UI167h33zO5eykR90zk0XzgfVcBQBikNZVJfjauRxNeLOZOGRf9PBLJ9fBLGA + TrKKdLosgOspYmw5igCguP6dye2FVbqavOuqaOHCZBlEhDuTwvUZzRCqo2Jg3N5rX/2ni+zsl3V7OWAA + p+vAAhGpaI4qD3QfbfiacwFxKfUV8sfxEkEbaqso4gJw55OVA5Rkkr/pcYGpvmYZl05yEWdkxlly6AwR + DN1oRcSZExCJ8nBVhFkq4+zYuS75VpFLpIIp6d7FBAMuvHh3+3sQEhu3PMIGf5ON/jTogEt9ZrdK/wdH + 1wFf2R9uPoAyg0MJ2a2hoFYhx319uNAQDZ8G00qqg19K70Jf4DWektvcfyV4p+vxQ28niPBhDskDjGX+ + JEntR+zO955l5718L5tPflawGx20pmakSl3wAcN9xuIx9g3LuGoKB8V5zPC5Ga3UyMDZjh6N9zsm7PTA + 0M4i6I58z9Qw1gx+VUTYOMYpAytJmG/FHgvsmPVL7DEyOz//+VXoundC4PtZ72eJMESlMtegd6/j32/A + x7wO4+pyIlPS0Tf4Gsq+jnYBH4Co99oTG+4mVnybfewTV9orX3mwLV8mtQER1fInMvCClAGCQ33J9JDc + jtz/i/KZF+VLy83o5/j7jxO0hnY7ClwLZFytNFNkOYpr2zuowIrcIA2zbRIkhID9YQc122uvPsze9Y6z + 7Lpr1tjb37be3v3OU3g8xm695Vh/vOSVu9qaNSD0AHXN7VaGI3QjdcOF35CLJTCcuKgSSEhDfavVJ+lp + IGJGrsd2cLHP895ftH1/0b74edzYHyfoJB0kccd4Ys3KFD5V4qu+oo1c6RzSXgvJk8pylDMPqtyND7hZ + eksWaPRvPbYJDqkEgl4jDCdCKjukofI1WrymlWRShsBwobi2zE+sJAEduyTTRd7zuO8Xb8//Lz/5zreB + Ssb1AAAAAElFTkSuQmCC + + + + 269, 17 + + \ No newline at end of file diff --git a/Code/Chapter 27/StatusStripApp/MainWindow.vb b/Code/Chapter 27/StatusStripApp/MainWindow.vb new file mode 100644 index 0000000..e03affc --- /dev/null +++ b/Code/Chapter 27/StatusStripApp/MainWindow.vb @@ -0,0 +1,105 @@ +Public Class MainWindow + + ' Which format to display? + Private dtFormat As DateTimeFormat = DateTimeFormat.ShowClock + + ' Marks the item checked. + Private currentCheckedItem As ToolStripMenuItem + + Public Sub New() + ' This call is required by the Windows Forms designer. + InitializeComponent() + + ' These properties can also be set + ' with the Properties window. + Text = "Status Strip Example" + CenterToScreen() + currentCheckedItem = currentTimeToolStripMenuItem + currentCheckedItem.Checked = True + End Sub + + Private Sub exitToolStripMenuItem_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click + Application.Exit() + End Sub + + Private Sub aboutToolStripMenuItem_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click + MessageBox.Show("My StatusStripApp!") + End Sub + +#Region "Mouse Hover event handlers" + Private Sub exitToolStripMenuItem_MouseHover(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.MouseHover + toolStripStatusLabelMenuState.Text = "Exits the app." + End Sub + + Private Sub aboutToolStripMenuItem_MouseHover(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.MouseHover + toolStripStatusLabelMenuState.Text = "Shows about box." + End Sub + + Private Sub dayoftheWeekToolStripMenuItem_MouseHover(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles DayOfTheWeekToolStripMenuItem.MouseHover + toolStripStatusLabelMenuState.Text = "Shows the day of the week." + End Sub + + Private Sub currentTimeToolStripMenuItem_MouseHover(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles CurrentTimeToolStripMenuItem.MouseHover + toolStripStatusLabelMenuState.Text = "Shows the current time." + End Sub +#End Region + +#Region "Pop up button Click event handlers" + Private Sub currentTimeToolStripMenuItem_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles CurrentTimeToolStripMenuItem.Click + ' Toggle check mark and set pane format to time. + currentCheckedItem.Checked = False + dtFormat = DateTimeFormat.ShowClock + currentCheckedItem = CurrentTimeToolStripMenuItem + currentCheckedItem.Checked = True + End Sub + + Private Sub dayoftheWeekToolStripMenuItem_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles DayOfTheWeekToolStripMenuItem.Click + ' Toggle check mark and set pane format to date. + currentCheckedItem.Checked = False + dtFormat = DateTimeFormat.ShowDay + currentCheckedItem = DayOfTheWeekToolStripMenuItem + currentCheckedItem.Checked = True + End Sub +#End Region + +#Region "Timer Tick Event Handler" + Private Sub timerDateTimeUpdate_Tick(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles timerDateTimeUpdate.Tick + Dim panelInfo As String = "" + + ' Create current format. + If dtFormat = DateTimeFormat.ShowClock Then + panelInfo = DateTime.Now.ToLongTimeString + Else + panelInfo = DateTime.Now.ToLongDateString + End If + + ' Set text on pane. + toolStripStatusLabelClock.Text = panelInfo + End Sub +#End Region + +#Region "Mouse Leave event for menu items" + Private Sub Handle_MouseLeave(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles CurrentTimeToolStripMenuItem.MouseLeave, _ + ExitToolStripMenuItem.MouseLeave, _ + DayOfTheWeekToolStripMenuItem.MouseLeave, _ + AboutToolStripMenuItem.MouseLeave + toolStripStatusLabelMenuState.Text = "Ready." + End Sub +#End Region + +End Class + +Public Enum DateTimeFormat + ShowClock + ShowDay +End Enum diff --git a/Code/Chapter 27/StatusStripApp/My Project/Application.Designer.vb b/Code/Chapter 27/StatusStripApp/My Project/Application.Designer.vb new file mode 100644 index 0000000..11ed291 --- /dev/null +++ b/Code/Chapter 27/StatusStripApp/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.StatusStripApp.MainWindow + End Sub + End Class +End Namespace diff --git a/Code/Chapter 27/StatusStripApp/My Project/Application.myapp b/Code/Chapter 27/StatusStripApp/My Project/Application.myapp new file mode 100644 index 0000000..dbf9822 --- /dev/null +++ b/Code/Chapter 27/StatusStripApp/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainWindow + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 27/StatusStripApp/My Project/AssemblyInfo.vb b/Code/Chapter 27/StatusStripApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..0985a43 --- /dev/null +++ b/Code/Chapter 27/StatusStripApp/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/Code/Chapter 27/StatusStripApp/My Project/Resources.Designer.vb b/Code/Chapter 27/StatusStripApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..22ca37f --- /dev/null +++ b/Code/Chapter 27/StatusStripApp/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("StatusStripApp.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/Code/Chapter 27/StatusStripApp/My Project/Resources.resx b/Code/Chapter 27/StatusStripApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 27/StatusStripApp/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/Code/Chapter 27/StatusStripApp/My Project/Settings.Designer.vb b/Code/Chapter 27/StatusStripApp/My Project/Settings.Designer.vb new file mode 100644 index 0000000..aee3f1b --- /dev/null +++ b/Code/Chapter 27/StatusStripApp/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.StatusStripApp.My.MySettings + Get + Return Global.StatusStripApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 27/StatusStripApp/My Project/Settings.settings b/Code/Chapter 27/StatusStripApp/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 27/StatusStripApp/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 27/StatusStripApp/StatusStripApp.sln b/Code/Chapter 27/StatusStripApp/StatusStripApp.sln new file mode 100644 index 0000000..b4215a2 --- /dev/null +++ b/Code/Chapter 27/StatusStripApp/StatusStripApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "StatusStripApp", "StatusStripApp.vbproj", "{56DB453C-F172-40E8-B5B8-D6C8DB949FA5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {56DB453C-F172-40E8-B5B8-D6C8DB949FA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {56DB453C-F172-40E8-B5B8-D6C8DB949FA5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {56DB453C-F172-40E8-B5B8-D6C8DB949FA5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {56DB453C-F172-40E8-B5B8-D6C8DB949FA5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 27/StatusStripApp/StatusStripApp.suo b/Code/Chapter 27/StatusStripApp/StatusStripApp.suo new file mode 100644 index 0000000..b436b1e Binary files /dev/null and b/Code/Chapter 27/StatusStripApp/StatusStripApp.suo differ diff --git a/Code/Chapter 27/StatusStripApp/StatusStripApp.vbproj b/Code/Chapter 27/StatusStripApp/StatusStripApp.vbproj new file mode 100644 index 0000000..f78bf3a --- /dev/null +++ b/Code/Chapter 27/StatusStripApp/StatusStripApp.vbproj @@ -0,0 +1,123 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {56DB453C-F172-40E8-B5B8-D6C8DB949FA5} + WinExe + StatusStripApp.My.MyApplication + StatusStripApp + StatusStripApp + 512 + WindowsForms + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + StatusStripApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + StatusStripApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + Form + + + MainWindow.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + MainWindow.vb + Designer + + + 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/Code/Chapter 27/ToolStripApp/MainWindow.Designer.vb b/Code/Chapter 27/ToolStripApp/MainWindow.Designer.vb new file mode 100644 index 0000000..4b7958b --- /dev/null +++ b/Code/Chapter 27/ToolStripApp/MainWindow.Designer.vb @@ -0,0 +1,163 @@ + _ +Partial Class MainWindow + 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() + Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(MainWindow)) + Me.toolStripSeparator1 = New System.Windows.Forms.ToolStripSeparator + Me.toolStripTextBoxMessage = New System.Windows.Forms.ToolStripTextBox + Me.toolStrip1 = New System.Windows.Forms.ToolStrip + Me.toolStripButtonGrowFont = New System.Windows.Forms.ToolStripButton + Me.toolStripButtonShrinkFont = New System.Windows.Forms.ToolStripButton + Me.BottomToolStripPanel = New System.Windows.Forms.ToolStripPanel + Me.TopToolStripPanel = New System.Windows.Forms.ToolStripPanel + Me.RightToolStripPanel = New System.Windows.Forms.ToolStripPanel + Me.LeftToolStripPanel = New System.Windows.Forms.ToolStripPanel + Me.ContentPanel = New System.Windows.Forms.ToolStripContentPanel + Me.toolStripContainer1 = New System.Windows.Forms.ToolStripContainer + Me.toolStrip1.SuspendLayout() + Me.toolStripContainer1.TopToolStripPanel.SuspendLayout() + Me.toolStripContainer1.SuspendLayout() + Me.SuspendLayout() + ' + 'toolStripSeparator1 + ' + Me.toolStripSeparator1.Name = "toolStripSeparator1" + Me.toolStripSeparator1.Size = New System.Drawing.Size(6, 25) + ' + 'toolStripTextBoxMessage + ' + Me.toolStripTextBoxMessage.Name = "toolStripTextBoxMessage" + Me.toolStripTextBoxMessage.Size = New System.Drawing.Size(100, 25) + Me.toolStripTextBoxMessage.Text = "Enter Message" + ' + 'toolStrip1 + ' + Me.toolStrip1.Dock = System.Windows.Forms.DockStyle.None + Me.toolStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.toolStripButtonGrowFont, Me.toolStripButtonShrinkFont, Me.toolStripSeparator1, Me.toolStripTextBoxMessage}) + Me.toolStrip1.Location = New System.Drawing.Point(3, 0) + Me.toolStrip1.Name = "toolStrip1" + Me.toolStrip1.Size = New System.Drawing.Size(197, 25) + Me.toolStrip1.TabIndex = 0 + Me.toolStrip1.Text = "toolStrip1" + ' + 'toolStripButtonGrowFont + ' + Me.toolStripButtonGrowFont.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.toolStripButtonGrowFont.Image = CType(resources.GetObject("toolStripButtonGrowFont.Image"), System.Drawing.Image) + Me.toolStripButtonGrowFont.ImageTransparentColor = System.Drawing.Color.Magenta + Me.toolStripButtonGrowFont.Name = "toolStripButtonGrowFont" + Me.toolStripButtonGrowFont.Size = New System.Drawing.Size(23, 22) + Me.toolStripButtonGrowFont.Text = "toolStripButton2" + Me.toolStripButtonGrowFont.ToolTipText = "Grow Font" + ' + 'toolStripButtonShrinkFont + ' + Me.toolStripButtonShrinkFont.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.toolStripButtonShrinkFont.Image = CType(resources.GetObject("toolStripButtonShrinkFont.Image"), System.Drawing.Image) + Me.toolStripButtonShrinkFont.ImageTransparentColor = System.Drawing.Color.Magenta + Me.toolStripButtonShrinkFont.Name = "toolStripButtonShrinkFont" + Me.toolStripButtonShrinkFont.Size = New System.Drawing.Size(23, 22) + Me.toolStripButtonShrinkFont.Text = "toolStripButton1" + Me.toolStripButtonShrinkFont.ToolTipText = "Shrink Font" + ' + 'BottomToolStripPanel + ' + Me.BottomToolStripPanel.Location = New System.Drawing.Point(0, 0) + Me.BottomToolStripPanel.Name = "BottomToolStripPanel" + Me.BottomToolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal + Me.BottomToolStripPanel.RowMargin = New System.Windows.Forms.Padding(3, 0, 0, 0) + Me.BottomToolStripPanel.Size = New System.Drawing.Size(0, 0) + ' + 'TopToolStripPanel + ' + Me.TopToolStripPanel.Location = New System.Drawing.Point(0, 0) + Me.TopToolStripPanel.Name = "TopToolStripPanel" + Me.TopToolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal + Me.TopToolStripPanel.RowMargin = New System.Windows.Forms.Padding(3, 0, 0, 0) + Me.TopToolStripPanel.Size = New System.Drawing.Size(0, 0) + ' + 'RightToolStripPanel + ' + Me.RightToolStripPanel.Location = New System.Drawing.Point(0, 0) + Me.RightToolStripPanel.Name = "RightToolStripPanel" + Me.RightToolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal + Me.RightToolStripPanel.RowMargin = New System.Windows.Forms.Padding(3, 0, 0, 0) + Me.RightToolStripPanel.Size = New System.Drawing.Size(0, 0) + ' + 'LeftToolStripPanel + ' + Me.LeftToolStripPanel.Location = New System.Drawing.Point(0, 0) + Me.LeftToolStripPanel.Name = "LeftToolStripPanel" + Me.LeftToolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal + Me.LeftToolStripPanel.RowMargin = New System.Windows.Forms.Padding(3, 0, 0, 0) + Me.LeftToolStripPanel.Size = New System.Drawing.Size(0, 0) + ' + 'ContentPanel + ' + Me.ContentPanel.AutoScroll = True + Me.ContentPanel.Size = New System.Drawing.Size(341, 94) + ' + 'toolStripContainer1 + ' + ' + 'toolStripContainer1.ContentPanel + ' + Me.toolStripContainer1.ContentPanel.Size = New System.Drawing.Size(366, 94) + Me.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill + Me.toolStripContainer1.Location = New System.Drawing.Point(0, 0) + Me.toolStripContainer1.Name = "toolStripContainer1" + Me.toolStripContainer1.Size = New System.Drawing.Size(366, 119) + Me.toolStripContainer1.TabIndex = 2 + Me.toolStripContainer1.Text = "toolStripContainer1" + ' + 'toolStripContainer1.TopToolStripPanel + ' + Me.toolStripContainer1.TopToolStripPanel.Controls.Add(Me.toolStrip1) + ' + 'MainWindow + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(366, 119) + Me.Controls.Add(Me.toolStripContainer1) + Me.Name = "MainWindow" + Me.Text = "Status Strip App" + Me.toolStrip1.ResumeLayout(False) + Me.toolStrip1.PerformLayout() + Me.toolStripContainer1.TopToolStripPanel.ResumeLayout(False) + Me.toolStripContainer1.TopToolStripPanel.PerformLayout() + Me.toolStripContainer1.ResumeLayout(False) + Me.toolStripContainer1.PerformLayout() + Me.ResumeLayout(False) + + End Sub + Private WithEvents toolStripSeparator1 As System.Windows.Forms.ToolStripSeparator + Private WithEvents toolStripTextBoxMessage As System.Windows.Forms.ToolStripTextBox + Private WithEvents toolStrip1 As System.Windows.Forms.ToolStrip + Private WithEvents toolStripButtonGrowFont As System.Windows.Forms.ToolStripButton + Private WithEvents toolStripButtonShrinkFont As System.Windows.Forms.ToolStripButton + Friend WithEvents BottomToolStripPanel As System.Windows.Forms.ToolStripPanel + Friend WithEvents TopToolStripPanel As System.Windows.Forms.ToolStripPanel + Friend WithEvents RightToolStripPanel As System.Windows.Forms.ToolStripPanel + Friend WithEvents LeftToolStripPanel As System.Windows.Forms.ToolStripPanel + Friend WithEvents ContentPanel As System.Windows.Forms.ToolStripContentPanel + Private WithEvents toolStripContainer1 As System.Windows.Forms.ToolStripContainer + +End Class diff --git a/Code/Chapter 27/ToolStripApp/MainWindow.resx b/Code/Chapter 27/ToolStripApp/MainWindow.resx new file mode 100644 index 0000000..36b4945 --- /dev/null +++ b/Code/Chapter 27/ToolStripApp/MainWindow.resx @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAI9JREFUWEftV9EK + wCAIdP//0S6hmK02zJrt4YJASPM8yLODiJn2LgEwvlMEl+2Jv2Imk8+DGASgK7/bPiYAAAyAATCgGHhr + MivP6oaVAaxMYLmr0gJLwBc+WYmTqClli7T/A0CQRFYuubrzQBSI7iuwajnmATAABsAAGHjSDWsnbf0G + Z8JywdbPqb/a9hd+AvirFGyhhBYXAAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAF1JREFUWEftljEO + ACAIxPD/j0YhQR10PZaaMF9TgTDcza3zBUBnrXQAMIABDGDgGLDYi4K6t+9exYrgO6MgEkAdXnmZDcD+ + C0HzfXtADfGcgq7DhIsIAxjAAAYwMAHIm9K7meAzEwAAAABJRU5ErkJggg== + + + \ No newline at end of file diff --git a/Code/Chapter 27/ToolStripApp/MainWindow.vb b/Code/Chapter 27/ToolStripApp/MainWindow.vb new file mode 100644 index 0000000..2b09f93 --- /dev/null +++ b/Code/Chapter 27/ToolStripApp/MainWindow.vb @@ -0,0 +1,51 @@ +Option Explicit On +Option Strict On + +Public Class MainWindow + ' The current, max, and min font sizes. + Private currFontSize As Integer = 12 + Const MinFontSize As Integer = 12 + Const MaxFontSize As Integer = 70 + + Public Sub New() + InitializeComponent() + CenterToScreen() + Text = String.Format("Your Font size is: {0}", currFontSize) + End Sub + +#Region "Event Handlers" + Private Sub toolStripButtonShrinkFont_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles toolStripButtonShrinkFont.Click + ' Reduce font size by 5 and refresh display. + currFontSize -= 5 + If (currFontSize <= MinFontSize) Then + currFontSize = MinFontSize + End If + Text = String.Format("Your Font size is: {0}", currFontSize) + toolStripContainer1.Invalidate(True) + End Sub + + Private Sub toolStripButtonGrowFont_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles toolStripButtonGrowFont.Click + ' Increase font size by 5 and refresh display. + currFontSize += 5 + If (currFontSize >= MaxFontSize) Then + currFontSize = MaxFontSize + End If + Text = String.Format("Your Font size is: {0}", currFontSize) + toolStripContainer1.Invalidate(True) + End Sub + + Private Sub ContentPanel_Paint(ByVal sender As System.Object, _ + ByVal e As System.Windows.Forms.PaintEventArgs) Handles toolStripContainer1.ContentPanel.Paint, ContentPanel.Paint + + ' Paint the user-defined message. + Dim g As Graphics = e.Graphics + g.DrawString(toolStripTextBoxMessage.Text, _ + New Font("Times New Roman", currFontSize), _ + Brushes.Black, 10, 60) + End Sub +#End Region + +End Class + diff --git a/Code/Chapter 27/ToolStripApp/My Project/Application.Designer.vb b/Code/Chapter 27/ToolStripApp/My Project/Application.Designer.vb new file mode 100644 index 0000000..4f6ad68 --- /dev/null +++ b/Code/Chapter 27/ToolStripApp/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.ToolStripApp.MainWindow + End Sub + End Class +End Namespace diff --git a/Code/Chapter 27/ToolStripApp/My Project/Application.myapp b/Code/Chapter 27/ToolStripApp/My Project/Application.myapp new file mode 100644 index 0000000..dbf9822 --- /dev/null +++ b/Code/Chapter 27/ToolStripApp/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainWindow + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 27/ToolStripApp/My Project/AssemblyInfo.vb b/Code/Chapter 27/ToolStripApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..192efaa --- /dev/null +++ b/Code/Chapter 27/ToolStripApp/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/Code/Chapter 27/ToolStripApp/My Project/Resources.Designer.vb b/Code/Chapter 27/ToolStripApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..efcdacc --- /dev/null +++ b/Code/Chapter 27/ToolStripApp/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("ToolStripApp.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/Code/Chapter 27/ToolStripApp/My Project/Resources.resx b/Code/Chapter 27/ToolStripApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 27/ToolStripApp/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/Code/Chapter 27/ToolStripApp/My Project/Settings.Designer.vb b/Code/Chapter 27/ToolStripApp/My Project/Settings.Designer.vb new file mode 100644 index 0000000..d349be3 --- /dev/null +++ b/Code/Chapter 27/ToolStripApp/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.ToolStripApp.My.MySettings + Get + Return Global.ToolStripApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 27/ToolStripApp/My Project/Settings.settings b/Code/Chapter 27/ToolStripApp/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 27/ToolStripApp/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 27/ToolStripApp/ToolStripApp.sln b/Code/Chapter 27/ToolStripApp/ToolStripApp.sln new file mode 100644 index 0000000..86ca67b --- /dev/null +++ b/Code/Chapter 27/ToolStripApp/ToolStripApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ToolStripApp", "ToolStripApp.vbproj", "{FE299631-0F5D-4167-9A1F-5D67CCF5195F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FE299631-0F5D-4167-9A1F-5D67CCF5195F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FE299631-0F5D-4167-9A1F-5D67CCF5195F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FE299631-0F5D-4167-9A1F-5D67CCF5195F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FE299631-0F5D-4167-9A1F-5D67CCF5195F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 27/ToolStripApp/ToolStripApp.suo b/Code/Chapter 27/ToolStripApp/ToolStripApp.suo new file mode 100644 index 0000000..3fbb32d Binary files /dev/null and b/Code/Chapter 27/ToolStripApp/ToolStripApp.suo differ diff --git a/Code/Chapter 27/ToolStripApp/ToolStripApp.vbproj b/Code/Chapter 27/ToolStripApp/ToolStripApp.vbproj new file mode 100644 index 0000000..a9700e7 --- /dev/null +++ b/Code/Chapter 27/ToolStripApp/ToolStripApp.vbproj @@ -0,0 +1,111 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {FE299631-0F5D-4167-9A1F-5D67CCF5195F} + WinExe + ToolStripApp.My.MyApplication + ToolStripApp + ToolStripApp + WindowsForms + + + 2.0 + + + + + true + full + true + true + bin\Debug\ + ToolStripApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + ToolStripApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + + + + + + + + + + + + + Form + + + MainWindow.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + MainWindow.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/Code/Chapter 27/ToolStripApp/ToolStripApp.vbproj.user b/Code/Chapter 27/ToolStripApp/ToolStripApp.vbproj.user new file mode 100644 index 0000000..6a34e7d --- /dev/null +++ b/Code/Chapter 27/ToolStripApp/ToolStripApp.vbproj.user @@ -0,0 +1,5 @@ + + + ShowAllFiles + + \ No newline at end of file diff --git a/Code/Chapter 28/BasicImages/BasicImages.sln b/Code/Chapter 28/BasicImages/BasicImages.sln new file mode 100644 index 0000000..c539c8a --- /dev/null +++ b/Code/Chapter 28/BasicImages/BasicImages.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "BasicImages", "BasicImages.vbproj", "{D557B368-F927-465C-8E86-7A4F5607DB23}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D557B368-F927-465C-8E86-7A4F5607DB23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D557B368-F927-465C-8E86-7A4F5607DB23}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D557B368-F927-465C-8E86-7A4F5607DB23}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D557B368-F927-465C-8E86-7A4F5607DB23}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 28/BasicImages/BasicImages.suo b/Code/Chapter 28/BasicImages/BasicImages.suo new file mode 100644 index 0000000..9c4ffc2 Binary files /dev/null and b/Code/Chapter 28/BasicImages/BasicImages.suo differ diff --git a/Code/Chapter 28/BasicImages/BasicImages.vbproj b/Code/Chapter 28/BasicImages/BasicImages.vbproj new file mode 100644 index 0000000..78dd139 --- /dev/null +++ b/Code/Chapter 28/BasicImages/BasicImages.vbproj @@ -0,0 +1,159 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {D557B368-F927-465C-8E86-7A4F5607DB23} + WinExe + BasicImages.My.MyApplication + BasicImages + BasicImages + WindowsForms + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + BasicImages.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + BasicImages.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + MainForm.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + Always + + + Always + + + Always + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 28/BasicImages/BasicImages.vbproj.user b/Code/Chapter 28/BasicImages/BasicImages.vbproj.user new file mode 100644 index 0000000..fdcb14e --- /dev/null +++ b/Code/Chapter 28/BasicImages/BasicImages.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ShowAllFiles + + \ No newline at end of file diff --git a/Code/Chapter 28/BasicImages/MainForm.Designer.vb b/Code/Chapter 28/BasicImages/MainForm.Designer.vb new file mode 100644 index 0000000..6d3f13c --- /dev/null +++ b/Code/Chapter 28/BasicImages/MainForm.Designer.vb @@ -0,0 +1,35 @@ + _ +Partial Class MainForm + 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.SuspendLayout() + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(300, 420) + Me.Name = "MainForm" + Me.Text = "Fun with images" + Me.ResumeLayout(False) + + End Sub + +End Class diff --git a/Code/Chapter 28/BasicImages/MainForm.resx b/Code/Chapter 28/BasicImages/MainForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 28/BasicImages/MainForm.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/Code/Chapter 28/BasicImages/MainForm.vb b/Code/Chapter 28/BasicImages/MainForm.vb new file mode 100644 index 0000000..f3f4832 --- /dev/null +++ b/Code/Chapter 28/BasicImages/MainForm.vb @@ -0,0 +1,28 @@ +Option Explicit On +Option Strict On + +Public Class MainForm + ' To hold the *.bmp data. + Private myImages As Bitmap() = New Bitmap(2) {} + + Sub New() + ' This call is required by the Windows Form Designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call. + myImages(0) = New Bitmap("imageA.bmp") + myImages(1) = New Bitmap("imageB.bmp") + myImages(2) = New Bitmap("imageC.bmp") + CenterToScreen() + End Sub + Private Sub MainForm_Paint(ByVal sender As System.Object, _ + ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint + Dim g As Graphics = e.Graphics + ' Render all three images. + Dim yOffset As Integer = 10 + For Each b As Bitmap In myImages + g.DrawImage(b, 10, yOffset, 90, 90) + yOffset += 100 + Next + End Sub +End Class diff --git a/Code/Chapter 28/BasicImages/My Project/Application.Designer.vb b/Code/Chapter 28/BasicImages/My Project/Application.Designer.vb new file mode 100644 index 0000000..0299178 --- /dev/null +++ b/Code/Chapter 28/BasicImages/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.BasicImages.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 28/BasicImages/My Project/Application.myapp b/Code/Chapter 28/BasicImages/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 28/BasicImages/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 28/BasicImages/My Project/AssemblyInfo.vb b/Code/Chapter 28/BasicImages/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..67f679c --- /dev/null +++ b/Code/Chapter 28/BasicImages/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/Code/Chapter 28/BasicImages/My Project/Resources.Designer.vb b/Code/Chapter 28/BasicImages/My Project/Resources.Designer.vb new file mode 100644 index 0000000..c39bfe2 --- /dev/null +++ b/Code/Chapter 28/BasicImages/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("BasicImages.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/Code/Chapter 28/BasicImages/My Project/Resources.resx b/Code/Chapter 28/BasicImages/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 28/BasicImages/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/Code/Chapter 28/BasicImages/My Project/Settings.Designer.vb b/Code/Chapter 28/BasicImages/My Project/Settings.Designer.vb new file mode 100644 index 0000000..005536f --- /dev/null +++ b/Code/Chapter 28/BasicImages/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.BasicImages.My.MySettings + Get + Return Global.BasicImages.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 28/BasicImages/My Project/Settings.settings b/Code/Chapter 28/BasicImages/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 28/BasicImages/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 28/BasicImages/imageA.bmp b/Code/Chapter 28/BasicImages/imageA.bmp new file mode 100644 index 0000000..ddda3a4 Binary files /dev/null and b/Code/Chapter 28/BasicImages/imageA.bmp differ diff --git a/Code/Chapter 28/BasicImages/imageB.bmp b/Code/Chapter 28/BasicImages/imageB.bmp new file mode 100644 index 0000000..1a84749 Binary files /dev/null and b/Code/Chapter 28/BasicImages/imageB.bmp differ diff --git a/Code/Chapter 28/BasicImages/imageC.bmp b/Code/Chapter 28/BasicImages/imageC.bmp new file mode 100644 index 0000000..b66a223 Binary files /dev/null and b/Code/Chapter 28/BasicImages/imageC.bmp differ diff --git a/Code/Chapter 28/BasicPaintForm/BasicPaintForm.sln b/Code/Chapter 28/BasicPaintForm/BasicPaintForm.sln new file mode 100644 index 0000000..038471f --- /dev/null +++ b/Code/Chapter 28/BasicPaintForm/BasicPaintForm.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "BasicPaintForm", "BasicPaintForm.vbproj", "{5CD7C79A-4486-494F-9CB5-75F02412D48E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5CD7C79A-4486-494F-9CB5-75F02412D48E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5CD7C79A-4486-494F-9CB5-75F02412D48E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5CD7C79A-4486-494F-9CB5-75F02412D48E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5CD7C79A-4486-494F-9CB5-75F02412D48E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 28/BasicPaintForm/BasicPaintForm.suo b/Code/Chapter 28/BasicPaintForm/BasicPaintForm.suo new file mode 100644 index 0000000..c869bff Binary files /dev/null and b/Code/Chapter 28/BasicPaintForm/BasicPaintForm.suo differ diff --git a/Code/Chapter 28/BasicPaintForm/BasicPaintForm.vbproj b/Code/Chapter 28/BasicPaintForm/BasicPaintForm.vbproj new file mode 100644 index 0000000..d15afbd --- /dev/null +++ b/Code/Chapter 28/BasicPaintForm/BasicPaintForm.vbproj @@ -0,0 +1,123 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {5CD7C79A-4486-494F-9CB5-75F02412D48E} + WinExe + BasicPaintForm.My.MyApplication + BasicPaintForm + BasicPaintForm + 512 + WindowsForms + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + BasicPaintForm.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + BasicPaintForm.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + MainForm.vb + Designer + + + 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/Code/Chapter 28/BasicPaintForm/BasicPaintForm.vbproj.user b/Code/Chapter 28/BasicPaintForm/BasicPaintForm.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 28/BasicPaintForm/BasicPaintForm.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 28/BasicPaintForm/MainForm.Designer.vb b/Code/Chapter 28/BasicPaintForm/MainForm.Designer.vb new file mode 100644 index 0000000..165de13 --- /dev/null +++ b/Code/Chapter 28/BasicPaintForm/MainForm.Designer.vb @@ -0,0 +1,39 @@ + _ +Partial Class MainForm + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + 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.SuspendLayout() + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(457, 194) + Me.Name = "MainForm" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Basic Paint Form" + Me.ResumeLayout(False) + + End Sub + +End Class diff --git a/Code/Chapter 28/BasicPaintForm/MainForm.resx b/Code/Chapter 28/BasicPaintForm/MainForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 28/BasicPaintForm/MainForm.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/Code/Chapter 28/BasicPaintForm/MainForm.vb b/Code/Chapter 28/BasicPaintForm/MainForm.vb new file mode 100644 index 0000000..658f538 --- /dev/null +++ b/Code/Chapter 28/BasicPaintForm/MainForm.vb @@ -0,0 +1,24 @@ +Public Class MainForm + ' Used to hold all the Points. + Private myPts As New List(Of Point) + + Private Sub MainForm_Paint(ByVal sender As System.Object, _ + ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint + Dim g As Graphics = e.Graphics + g.DrawString("Hello GDI+", New Font("Times New Roman", 20), _ + Brushes.Green, 0, 0) + + ' Now render all the Points. + For Each p As Point In myPts + g.FillEllipse(Brushes.DarkOrange, p.X, p.Y, 10, 10) + Next + End Sub + + Private Sub MainForm_MouseDown(ByVal sender As System.Object, _ + ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown + ' Add new point to list. + myPts.Add(New Point(e.X, e.Y)) + Invalidate() + End Sub + +End Class diff --git a/Code/Chapter 28/BasicPaintForm/My Project/Application.Designer.vb b/Code/Chapter 28/BasicPaintForm/My Project/Application.Designer.vb new file mode 100644 index 0000000..7944823 --- /dev/null +++ b/Code/Chapter 28/BasicPaintForm/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.BasicPaintForm.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 28/BasicPaintForm/My Project/Application.myapp b/Code/Chapter 28/BasicPaintForm/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 28/BasicPaintForm/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 28/BasicPaintForm/My Project/AssemblyInfo.vb b/Code/Chapter 28/BasicPaintForm/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..4f2cbe2 --- /dev/null +++ b/Code/Chapter 28/BasicPaintForm/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/Code/Chapter 28/BasicPaintForm/My Project/Resources.Designer.vb b/Code/Chapter 28/BasicPaintForm/My Project/Resources.Designer.vb new file mode 100644 index 0000000..e65975b --- /dev/null +++ b/Code/Chapter 28/BasicPaintForm/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("BasicPaintForm.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/Code/Chapter 28/BasicPaintForm/My Project/Resources.resx b/Code/Chapter 28/BasicPaintForm/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 28/BasicPaintForm/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/Code/Chapter 28/BasicPaintForm/My Project/Settings.Designer.vb b/Code/Chapter 28/BasicPaintForm/My Project/Settings.Designer.vb new file mode 100644 index 0000000..8bf13f0 --- /dev/null +++ b/Code/Chapter 28/BasicPaintForm/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.BasicPaintForm.My.MySettings + Get + Return Global.BasicPaintForm.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 28/BasicPaintForm/My Project/Settings.settings b/Code/Chapter 28/BasicPaintForm/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 28/BasicPaintForm/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 28/BrushStyles/BrushStyles.sln b/Code/Chapter 28/BrushStyles/BrushStyles.sln new file mode 100644 index 0000000..6654038 --- /dev/null +++ b/Code/Chapter 28/BrushStyles/BrushStyles.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "BrushStyles", "BrushStyles.vbproj", "{D64782DE-E71C-4555-862C-0946869D9348}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D64782DE-E71C-4555-862C-0946869D9348}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D64782DE-E71C-4555-862C-0946869D9348}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D64782DE-E71C-4555-862C-0946869D9348}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D64782DE-E71C-4555-862C-0946869D9348}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 28/BrushStyles/BrushStyles.suo b/Code/Chapter 28/BrushStyles/BrushStyles.suo new file mode 100644 index 0000000..b71fc00 Binary files /dev/null and b/Code/Chapter 28/BrushStyles/BrushStyles.suo differ diff --git a/Code/Chapter 28/BrushStyles/BrushStyles.vbproj b/Code/Chapter 28/BrushStyles/BrushStyles.vbproj new file mode 100644 index 0000000..257ad26 --- /dev/null +++ b/Code/Chapter 28/BrushStyles/BrushStyles.vbproj @@ -0,0 +1,148 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {D64782DE-E71C-4555-862C-0946869D9348} + WinExe + BrushStyles.My.MyApplication + BrushStyles + BrushStyles + WindowsForms + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + BrushStyles.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + BrushStyles.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + MainForm.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 28/BrushStyles/BrushStyles.vbproj.user b/Code/Chapter 28/BrushStyles/BrushStyles.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 28/BrushStyles/BrushStyles.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 28/BrushStyles/MainForm.Designer.vb b/Code/Chapter 28/BrushStyles/MainForm.Designer.vb new file mode 100644 index 0000000..708359f --- /dev/null +++ b/Code/Chapter 28/BrushStyles/MainForm.Designer.vb @@ -0,0 +1,36 @@ + _ +Partial Class MainForm + 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.SuspendLayout() + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(292, 266) + Me.Name = "MainForm" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Fun with Brush Styles" + Me.ResumeLayout(False) + + End Sub + +End Class diff --git a/Code/Chapter 28/BrushStyles/MainForm.resx b/Code/Chapter 28/BrushStyles/MainForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 28/BrushStyles/MainForm.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/Code/Chapter 28/BrushStyles/MainForm.vb b/Code/Chapter 28/BrushStyles/MainForm.vb new file mode 100644 index 0000000..f970944 --- /dev/null +++ b/Code/Chapter 28/BrushStyles/MainForm.vb @@ -0,0 +1,27 @@ +Option Explicit On +Option Strict On + +Imports System.Drawing.Drawing2D + +Public Class MainForm + Private Sub MainForm_Paint(ByVal sender As System.Object, _ + ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint + Dim g As Graphics = e.Graphics + Dim yOffSet As Integer = 10 + + ' Get all members of the HatchStyle enum. + Dim obj As Array = [Enum].GetValues(GetType(HatchStyle)) + + For x As Integer = 0 To 4 + ' Draw an oval with first 5 HatchStyle values. + ' Configure Brush. + Dim temp As HatchStyle = CType(obj.GetValue(x), HatchStyle) + Dim theBrush As HatchBrush = New HatchBrush(temp, Color.White, Color.Black) + ' Print name of HatchStyle enum. + g.DrawString(temp.ToString(), New Font("Times New Roman", 10), Brushes.Black, 0, yOffSet) + ' Fill a rectangle with the correct brush. + g.FillEllipse(theBrush, 150, yOffSet, 200, 25) + yOffSet += 40 + Next + End Sub +End Class diff --git a/Code/Chapter 28/BrushStyles/My Project/Application.Designer.vb b/Code/Chapter 28/BrushStyles/My Project/Application.Designer.vb new file mode 100644 index 0000000..b0d9a37 --- /dev/null +++ b/Code/Chapter 28/BrushStyles/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.BrushStyles.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 28/BrushStyles/My Project/Application.myapp b/Code/Chapter 28/BrushStyles/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 28/BrushStyles/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 28/BrushStyles/My Project/AssemblyInfo.vb b/Code/Chapter 28/BrushStyles/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..496187a --- /dev/null +++ b/Code/Chapter 28/BrushStyles/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/Code/Chapter 28/BrushStyles/My Project/Resources.Designer.vb b/Code/Chapter 28/BrushStyles/My Project/Resources.Designer.vb new file mode 100644 index 0000000..12cc16e --- /dev/null +++ b/Code/Chapter 28/BrushStyles/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("BrushStyles.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/Code/Chapter 28/BrushStyles/My Project/Resources.resx b/Code/Chapter 28/BrushStyles/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 28/BrushStyles/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/Code/Chapter 28/BrushStyles/My Project/Settings.Designer.vb b/Code/Chapter 28/BrushStyles/My Project/Settings.Designer.vb new file mode 100644 index 0000000..7ceff1e --- /dev/null +++ b/Code/Chapter 28/BrushStyles/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.BrushStyles.My.MySettings + Get + Return Global.BrushStyles.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 28/BrushStyles/My Project/Settings.settings b/Code/Chapter 28/BrushStyles/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 28/BrushStyles/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 28/ColorDlg/ColorDlg.sln b/Code/Chapter 28/ColorDlg/ColorDlg.sln new file mode 100644 index 0000000..018fdb3 --- /dev/null +++ b/Code/Chapter 28/ColorDlg/ColorDlg.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ColorDlg", "ColorDlg.vbproj", "{DD0F28B0-A037-4ABE-ABE8-780CBE18D416}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DD0F28B0-A037-4ABE-ABE8-780CBE18D416}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DD0F28B0-A037-4ABE-ABE8-780CBE18D416}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DD0F28B0-A037-4ABE-ABE8-780CBE18D416}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DD0F28B0-A037-4ABE-ABE8-780CBE18D416}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 28/ColorDlg/ColorDlg.suo b/Code/Chapter 28/ColorDlg/ColorDlg.suo new file mode 100644 index 0000000..c185837 Binary files /dev/null and b/Code/Chapter 28/ColorDlg/ColorDlg.suo differ diff --git a/Code/Chapter 28/ColorDlg/ColorDlg.vbproj b/Code/Chapter 28/ColorDlg/ColorDlg.vbproj new file mode 100644 index 0000000..bf4d202 --- /dev/null +++ b/Code/Chapter 28/ColorDlg/ColorDlg.vbproj @@ -0,0 +1,148 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {DD0F28B0-A037-4ABE-ABE8-780CBE18D416} + WinExe + ColorDlg.My.MyApplication + ColorDlg + ColorDlg + WindowsForms + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + ColorDlg.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + ColorDlg.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + MainForm.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 28/ColorDlg/ColorDlg.vbproj.user b/Code/Chapter 28/ColorDlg/ColorDlg.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 28/ColorDlg/ColorDlg.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 28/ColorDlg/Form1.Designer.vb b/Code/Chapter 28/ColorDlg/Form1.Designer.vb new file mode 100644 index 0000000..ff1d29f --- /dev/null +++ b/Code/Chapter 28/ColorDlg/Form1.Designer.vb @@ -0,0 +1,36 @@ + _ +Partial Class MainForm + 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.SuspendLayout() + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(292, 266) + Me.Name = "MainForm" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Fun with Colors" + Me.ResumeLayout(False) + + End Sub + +End Class diff --git a/Code/Chapter 28/ColorDlg/MainForm.resx b/Code/Chapter 28/ColorDlg/MainForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 28/ColorDlg/MainForm.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/Code/Chapter 28/ColorDlg/MainForm.vb b/Code/Chapter 28/ColorDlg/MainForm.vb new file mode 100644 index 0000000..f9448a3 --- /dev/null +++ b/Code/Chapter 28/ColorDlg/MainForm.vb @@ -0,0 +1,29 @@ +Option Explicit On +Option Strict On + +Public Class MainForm + Private colorDlg As ColorDialog + Private currColor As Color = Color.DimGray + + Sub New() + ' This call is required by the Windows Form Designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call. + CenterToScreen() + colorDlg = New ColorDialog() + Text = "Click on me to change the color" + End Sub + + Private Sub MainForm_MouseDown(ByVal sender As System.Object, _ + ByVal e As System.Windows.Forms.MouseEventArgs) _ + Handles MyBase.MouseDown + If colorDlg.ShowDialog() <> Windows.Forms.DialogResult.Cancel Then + currColor = colorDlg.Color + Me.BackColor = currColor + ' Show current color. + Dim strARGB As String = colorDlg.Color.ToString() + MessageBox.Show(strARGB, "Color is:") + End If + End Sub +End Class diff --git a/Code/Chapter 28/ColorDlg/My Project/Application.Designer.vb b/Code/Chapter 28/ColorDlg/My Project/Application.Designer.vb new file mode 100644 index 0000000..0a74fa7 --- /dev/null +++ b/Code/Chapter 28/ColorDlg/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.ColorDlg.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 28/ColorDlg/My Project/Application.myapp b/Code/Chapter 28/ColorDlg/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 28/ColorDlg/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 28/ColorDlg/My Project/AssemblyInfo.vb b/Code/Chapter 28/ColorDlg/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..97248a9 --- /dev/null +++ b/Code/Chapter 28/ColorDlg/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/Code/Chapter 28/ColorDlg/My Project/Resources.Designer.vb b/Code/Chapter 28/ColorDlg/My Project/Resources.Designer.vb new file mode 100644 index 0000000..2aae7d7 --- /dev/null +++ b/Code/Chapter 28/ColorDlg/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("ColorDlg.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/Code/Chapter 28/ColorDlg/My Project/Resources.resx b/Code/Chapter 28/ColorDlg/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 28/ColorDlg/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/Code/Chapter 28/ColorDlg/My Project/Settings.Designer.vb b/Code/Chapter 28/ColorDlg/My Project/Settings.Designer.vb new file mode 100644 index 0000000..79fcd1f --- /dev/null +++ b/Code/Chapter 28/ColorDlg/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.ColorDlg.My.MySettings + Get + Return Global.ColorDlg.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 28/ColorDlg/My Project/Settings.settings b/Code/Chapter 28/ColorDlg/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 28/ColorDlg/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 28/CoorSystem/CoorSystem.sln b/Code/Chapter 28/CoorSystem/CoorSystem.sln new file mode 100644 index 0000000..0822116 --- /dev/null +++ b/Code/Chapter 28/CoorSystem/CoorSystem.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CoorSystem", "CoorSystem.vbproj", "{617E6737-7BBC-423C-9CFB-10C50493CA6F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {617E6737-7BBC-423C-9CFB-10C50493CA6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {617E6737-7BBC-423C-9CFB-10C50493CA6F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {617E6737-7BBC-423C-9CFB-10C50493CA6F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {617E6737-7BBC-423C-9CFB-10C50493CA6F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 28/CoorSystem/CoorSystem.suo b/Code/Chapter 28/CoorSystem/CoorSystem.suo new file mode 100644 index 0000000..176c5de Binary files /dev/null and b/Code/Chapter 28/CoorSystem/CoorSystem.suo differ diff --git a/Code/Chapter 28/CoorSystem/CoorSystem.vbproj b/Code/Chapter 28/CoorSystem/CoorSystem.vbproj new file mode 100644 index 0000000..e2d3948 --- /dev/null +++ b/Code/Chapter 28/CoorSystem/CoorSystem.vbproj @@ -0,0 +1,148 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {617E6737-7BBC-423C-9CFB-10C50493CA6F} + WinExe + CoorSystem.My.MyApplication + CoorSystem + CoorSystem + WindowsForms + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + CoorSystem.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + CoorSystem.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + MainForm.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 28/CoorSystem/CoorSystem.vbproj.user b/Code/Chapter 28/CoorSystem/CoorSystem.vbproj.user new file mode 100644 index 0000000..55af084 --- /dev/null +++ b/Code/Chapter 28/CoorSystem/CoorSystem.vbproj.user @@ -0,0 +1,16 @@ + + + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 28/CoorSystem/MainForm.Designer.vb b/Code/Chapter 28/CoorSystem/MainForm.Designer.vb new file mode 100644 index 0000000..9a40ac7 --- /dev/null +++ b/Code/Chapter 28/CoorSystem/MainForm.Designer.vb @@ -0,0 +1,143 @@ + _ +Partial Class MainForm + 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.originToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.toolStripMenuItem0by0 = New System.Windows.Forms.ToolStripMenuItem + Me.toolStripMenuItem5by5 = New System.Windows.Forms.ToolStripMenuItem + Me.toolStripMenuItem100by100 = New System.Windows.Forms.ToolStripMenuItem + Me.pointToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.documentToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.pixelToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.unitOfMeasurementToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.inchToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.milliToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.displayToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.menuStrip1 = New System.Windows.Forms.MenuStrip + Me.menuStrip1.SuspendLayout() + Me.SuspendLayout() + ' + 'originToolStripMenuItem + ' + Me.originToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.toolStripMenuItem0by0, Me.toolStripMenuItem5by5, Me.toolStripMenuItem100by100}) + Me.originToolStripMenuItem.Name = "originToolStripMenuItem" + Me.originToolStripMenuItem.Size = New System.Drawing.Size(52, 20) + Me.originToolStripMenuItem.Text = "Origin" + ' + 'toolStripMenuItem0by0 + ' + Me.toolStripMenuItem0by0.Name = "toolStripMenuItem0by0" + Me.toolStripMenuItem0by0.Size = New System.Drawing.Size(124, 22) + Me.toolStripMenuItem0by0.Text = "(0, 0)" + ' + 'toolStripMenuItem5by5 + ' + Me.toolStripMenuItem5by5.Name = "toolStripMenuItem5by5" + Me.toolStripMenuItem5by5.Size = New System.Drawing.Size(124, 22) + Me.toolStripMenuItem5by5.Text = "(5, 5)" + ' + 'toolStripMenuItem100by100 + ' + Me.toolStripMenuItem100by100.Name = "toolStripMenuItem100by100" + Me.toolStripMenuItem100by100.Size = New System.Drawing.Size(124, 22) + Me.toolStripMenuItem100by100.Text = "(100, 100)" + ' + 'pointToolStripMenuItem + ' + Me.pointToolStripMenuItem.Name = "pointToolStripMenuItem" + Me.pointToolStripMenuItem.Size = New System.Drawing.Size(130, 22) + Me.pointToolStripMenuItem.Text = "Point" + ' + 'documentToolStripMenuItem + ' + Me.documentToolStripMenuItem.Name = "documentToolStripMenuItem" + Me.documentToolStripMenuItem.Size = New System.Drawing.Size(130, 22) + Me.documentToolStripMenuItem.Text = "Document" + ' + 'pixelToolStripMenuItem + ' + Me.pixelToolStripMenuItem.Name = "pixelToolStripMenuItem" + Me.pixelToolStripMenuItem.Size = New System.Drawing.Size(130, 22) + Me.pixelToolStripMenuItem.Text = "Pixel" + ' + 'unitOfMeasurementToolStripMenuItem + ' + Me.unitOfMeasurementToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.pixelToolStripMenuItem, Me.inchToolStripMenuItem, Me.milliToolStripMenuItem, Me.displayToolStripMenuItem, Me.documentToolStripMenuItem, Me.pointToolStripMenuItem}) + Me.unitOfMeasurementToolStripMenuItem.Name = "unitOfMeasurementToolStripMenuItem" + Me.unitOfMeasurementToolStripMenuItem.Size = New System.Drawing.Size(133, 20) + Me.unitOfMeasurementToolStripMenuItem.Text = "Unit Of Measurement" + ' + 'inchToolStripMenuItem + ' + Me.inchToolStripMenuItem.Name = "inchToolStripMenuItem" + Me.inchToolStripMenuItem.Size = New System.Drawing.Size(130, 22) + Me.inchToolStripMenuItem.Text = "Inch" + ' + 'milliToolStripMenuItem + ' + Me.milliToolStripMenuItem.Name = "milliToolStripMenuItem" + Me.milliToolStripMenuItem.Size = New System.Drawing.Size(130, 22) + Me.milliToolStripMenuItem.Text = "Millimeter" + ' + 'displayToolStripMenuItem + ' + Me.displayToolStripMenuItem.Name = "displayToolStripMenuItem" + Me.displayToolStripMenuItem.Size = New System.Drawing.Size(130, 22) + Me.displayToolStripMenuItem.Text = "Display" + ' + 'menuStrip1 + ' + Me.menuStrip1.Dock = System.Windows.Forms.DockStyle.Bottom + Me.menuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.unitOfMeasurementToolStripMenuItem, Me.originToolStripMenuItem}) + Me.menuStrip1.Location = New System.Drawing.Point(0, 145) + Me.menuStrip1.Name = "menuStrip1" + Me.menuStrip1.Size = New System.Drawing.Size(402, 24) + Me.menuStrip1.TabIndex = 1 + Me.menuStrip1.Text = "menuStrip1" + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(402, 169) + Me.Controls.Add(Me.menuStrip1) + Me.Name = "MainForm" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "GDI+ Coordinates" + Me.menuStrip1.ResumeLayout(False) + Me.menuStrip1.PerformLayout() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Private WithEvents originToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Private WithEvents toolStripMenuItem0by0 As System.Windows.Forms.ToolStripMenuItem + Private WithEvents toolStripMenuItem5by5 As System.Windows.Forms.ToolStripMenuItem + Private WithEvents toolStripMenuItem100by100 As System.Windows.Forms.ToolStripMenuItem + Private WithEvents pointToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Private WithEvents documentToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Private WithEvents pixelToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Private WithEvents unitOfMeasurementToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Private WithEvents inchToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Private WithEvents milliToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Private WithEvents displayToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Private WithEvents menuStrip1 As System.Windows.Forms.MenuStrip + +End Class diff --git a/Code/Chapter 28/CoorSystem/MainForm.resx b/Code/Chapter 28/CoorSystem/MainForm.resx new file mode 100644 index 0000000..541af56 --- /dev/null +++ b/Code/Chapter 28/CoorSystem/MainForm.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/Code/Chapter 28/CoorSystem/MainForm.vb b/Code/Chapter 28/CoorSystem/MainForm.vb new file mode 100644 index 0000000..d1e9dcc --- /dev/null +++ b/Code/Chapter 28/CoorSystem/MainForm.vb @@ -0,0 +1,70 @@ +Option Explicit On +Option Strict On + +Public Class MainForm + ' The unit of measurement. + Private gUnit As GraphicsUnit = GraphicsUnit.Pixel + + ' Point of origin. + Private renderingOrgPt As New Point(0, 0) + +#Region "Menu Handlers" + Private Sub pointToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pointToolStripMenuItem.Click + gUnit = GraphicsUnit.Point + Invalidate() + End Sub + + Private Sub documentToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles documentToolStripMenuItem.Click + gUnit = GraphicsUnit.Document + Invalidate() + End Sub + + Private Sub displayToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles displayToolStripMenuItem.Click + gUnit = GraphicsUnit.Display + Invalidate() + End Sub + + Private Sub milliToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles milliToolStripMenuItem.Click + gUnit = GraphicsUnit.Millimeter + Invalidate() + End Sub + + Private Sub inchToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles inchToolStripMenuItem.Click + gUnit = GraphicsUnit.Inch + Invalidate() + End Sub + + Private Sub pixelToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pixelToolStripMenuItem.Click + gUnit = GraphicsUnit.Pixel + Invalidate() + End Sub + + Private Sub toolStripMenuItem100by100_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles toolStripMenuItem100by100.Click + renderingOrgPt.X = 100 + renderingOrgPt.Y = 100 + Invalidate() + End Sub + + Private Sub toolStripMenuItem5by5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles toolStripMenuItem5by5.Click + renderingOrgPt.X = 5 + renderingOrgPt.Y = 5 + Invalidate() + End Sub + + Private Sub toolStripMenuItem0by0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles toolStripMenuItem0by0.Click + renderingOrgPt.X = 0 + renderingOrgPt.Y = 0 + Invalidate() + End Sub +#End Region + + Private Sub MainForm_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint + Dim g As Graphics = e.Graphics + ' Configure graphics unit. + g.PageUnit = gUnit + ' Configure origin. + g.TranslateTransform(renderingOrgPt.X, renderingOrgPt.Y) + g.DrawRectangle(New Pen(Color.Red, 5), 0, 0, 100, 100) + Me.Text = String.Format("PageUnit: {0}, Origin: {1}", gUnit, renderingOrgPt.ToString()) + End Sub +End Class diff --git a/Code/Chapter 28/CoorSystem/My Project/Application.Designer.vb b/Code/Chapter 28/CoorSystem/My Project/Application.Designer.vb new file mode 100644 index 0000000..59f4d39 --- /dev/null +++ b/Code/Chapter 28/CoorSystem/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CoorSystem.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 28/CoorSystem/My Project/Application.myapp b/Code/Chapter 28/CoorSystem/My Project/Application.myapp new file mode 100644 index 0000000..01c7691 --- /dev/null +++ b/Code/Chapter 28/CoorSystem/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 28/CoorSystem/My Project/AssemblyInfo.vb b/Code/Chapter 28/CoorSystem/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..6cc2737 --- /dev/null +++ b/Code/Chapter 28/CoorSystem/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/Code/Chapter 28/CoorSystem/My Project/Resources.Designer.vb b/Code/Chapter 28/CoorSystem/My Project/Resources.Designer.vb new file mode 100644 index 0000000..7a5f0eb --- /dev/null +++ b/Code/Chapter 28/CoorSystem/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("CoorSystem.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/Code/Chapter 28/CoorSystem/My Project/Resources.resx b/Code/Chapter 28/CoorSystem/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 28/CoorSystem/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/Code/Chapter 28/CoorSystem/My Project/Settings.Designer.vb b/Code/Chapter 28/CoorSystem/My Project/Settings.Designer.vb new file mode 100644 index 0000000..d5a5135 --- /dev/null +++ b/Code/Chapter 28/CoorSystem/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CoorSystem.My.MySettings + Get + Return Global.CoorSystem.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 28/CoorSystem/My Project/Settings.settings b/Code/Chapter 28/CoorSystem/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 28/CoorSystem/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 28/CoorSystem/UpgradeLog.XML b/Code/Chapter 28/CoorSystem/UpgradeLog.XML new file mode 100644 index 0000000..8674202 --- /dev/null +++ b/Code/Chapter 28/CoorSystem/UpgradeLog.XML @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 28/CustomPenApp/CustomPenApp.sln b/Code/Chapter 28/CustomPenApp/CustomPenApp.sln new file mode 100644 index 0000000..d071339 --- /dev/null +++ b/Code/Chapter 28/CustomPenApp/CustomPenApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CustomPenApp", "CustomPenApp.vbproj", "{254CF2AA-43C3-4988-9FBD-2057902D1593}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {254CF2AA-43C3-4988-9FBD-2057902D1593}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {254CF2AA-43C3-4988-9FBD-2057902D1593}.Debug|Any CPU.Build.0 = Debug|Any CPU + {254CF2AA-43C3-4988-9FBD-2057902D1593}.Release|Any CPU.ActiveCfg = Release|Any CPU + {254CF2AA-43C3-4988-9FBD-2057902D1593}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 28/CustomPenApp/CustomPenApp.suo b/Code/Chapter 28/CustomPenApp/CustomPenApp.suo new file mode 100644 index 0000000..523937e Binary files /dev/null and b/Code/Chapter 28/CustomPenApp/CustomPenApp.suo differ diff --git a/Code/Chapter 28/CustomPenApp/CustomPenApp.vbproj b/Code/Chapter 28/CustomPenApp/CustomPenApp.vbproj new file mode 100644 index 0000000..f4aab09 --- /dev/null +++ b/Code/Chapter 28/CustomPenApp/CustomPenApp.vbproj @@ -0,0 +1,148 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {254CF2AA-43C3-4988-9FBD-2057902D1593} + WinExe + CustomPenApp.My.MyApplication + CustomPenApp + CustomPenApp + WindowsForms + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + CustomPenApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + CustomPenApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + MainForm.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 28/CustomPenApp/CustomPenApp.vbproj.user b/Code/Chapter 28/CustomPenApp/CustomPenApp.vbproj.user new file mode 100644 index 0000000..fdcb14e --- /dev/null +++ b/Code/Chapter 28/CustomPenApp/CustomPenApp.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ShowAllFiles + + \ No newline at end of file diff --git a/Code/Chapter 28/CustomPenApp/MainForm.Designer.vb b/Code/Chapter 28/CustomPenApp/MainForm.Designer.vb new file mode 100644 index 0000000..71a46b6 --- /dev/null +++ b/Code/Chapter 28/CustomPenApp/MainForm.Designer.vb @@ -0,0 +1,36 @@ + _ +Partial Class MainForm + 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.SuspendLayout() + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(292, 266) + Me.Name = "MainForm" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Custom Pens!" + Me.ResumeLayout(False) + + End Sub + +End Class diff --git a/Code/Chapter 28/CustomPenApp/MainForm.resx b/Code/Chapter 28/CustomPenApp/MainForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 28/CustomPenApp/MainForm.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/Code/Chapter 28/CustomPenApp/MainForm.vb b/Code/Chapter 28/CustomPenApp/MainForm.vb new file mode 100644 index 0000000..f7e2764 --- /dev/null +++ b/Code/Chapter 28/CustomPenApp/MainForm.vb @@ -0,0 +1,45 @@ +Option Explicit On +Option Strict On + +Imports System.Drawing.Drawing2D + +Public Class MainForm + Private Sub MainForm_Paint(ByVal sender As System.Object, _ + ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint + Dim g As Graphics = e.Graphics + ' Make a big blue pen. + Dim bluePen As Pen = New Pen(Color.Blue, 20) + + ' Get a stock pen from the Pens type. + Dim pen2 As Pen = Pens.Firebrick + + ' Render some shapes with the pens. + g.DrawEllipse(bluePen, 10, 10, 100, 100) + g.DrawLine(pen2, 10, 130, 110, 130) + g.DrawPie(Pens.Black, 150, 10, 120, 150, 90, 80) + + ' Draw a purple dashed polygon as well... + Dim pen3 As Pen = New Pen(Color.Purple, 5) + pen3.DashStyle = DashStyle.DashDotDot + g.DrawPolygon(pen3, New Point() {New Point(30, 140), _ + New Point(265, 200), New Point(100, 225), _ + New Point(190, 190), New Point(50, 330), _ + New Point(20, 180)}) + + ' And a rectangle containing some text... + Dim r As Rectangle = New Rectangle(150, 10, 130, 60) + g.DrawRectangle(Pens.Blue, r) + g.DrawString("Hello out there...How are ya?", _ + New Font("Arial", 12), Brushes.Black, r) + + ' Draw custom dash pattern all around the boarder of the form. + Dim customDashPen As Pen = New Pen(Color.BlueViolet, 10) + Dim myDashes As Single() = {5.0F, 2.0F, 1.0F, 3.0F} + customDashPen.DashPattern = myDashes + g.DrawRectangle(customDashPen, ClientRectangle) + End Sub + + Private Sub MainForm_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize + Invalidate() + End Sub +End Class diff --git a/Code/Chapter 28/CustomPenApp/My Project/Application.Designer.vb b/Code/Chapter 28/CustomPenApp/My Project/Application.Designer.vb new file mode 100644 index 0000000..5535334 --- /dev/null +++ b/Code/Chapter 28/CustomPenApp/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CustomPenApp.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 28/CustomPenApp/My Project/Application.myapp b/Code/Chapter 28/CustomPenApp/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 28/CustomPenApp/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 28/CustomPenApp/My Project/AssemblyInfo.vb b/Code/Chapter 28/CustomPenApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..a92d8f1 --- /dev/null +++ b/Code/Chapter 28/CustomPenApp/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/Code/Chapter 28/CustomPenApp/My Project/Resources.Designer.vb b/Code/Chapter 28/CustomPenApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..3c75998 --- /dev/null +++ b/Code/Chapter 28/CustomPenApp/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("CustomPenApp.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/Code/Chapter 28/CustomPenApp/My Project/Resources.resx b/Code/Chapter 28/CustomPenApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 28/CustomPenApp/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/Code/Chapter 28/CustomPenApp/My Project/Settings.Designer.vb b/Code/Chapter 28/CustomPenApp/My Project/Settings.Designer.vb new file mode 100644 index 0000000..a5a8dd2 --- /dev/null +++ b/Code/Chapter 28/CustomPenApp/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CustomPenApp.My.MySettings + Get + Return Global.CustomPenApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 28/CustomPenApp/My Project/Settings.settings b/Code/Chapter 28/CustomPenApp/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 28/CustomPenApp/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 28/DraggingImages/DraggingImages.sln b/Code/Chapter 28/DraggingImages/DraggingImages.sln new file mode 100644 index 0000000..789f4e8 --- /dev/null +++ b/Code/Chapter 28/DraggingImages/DraggingImages.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DraggingImages", "DraggingImages.vbproj", "{E3B3A050-6A59-48D2-A646-C5DE5FE8FF9C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E3B3A050-6A59-48D2-A646-C5DE5FE8FF9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E3B3A050-6A59-48D2-A646-C5DE5FE8FF9C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E3B3A050-6A59-48D2-A646-C5DE5FE8FF9C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E3B3A050-6A59-48D2-A646-C5DE5FE8FF9C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 28/DraggingImages/DraggingImages.suo b/Code/Chapter 28/DraggingImages/DraggingImages.suo new file mode 100644 index 0000000..1c9e9f3 Binary files /dev/null and b/Code/Chapter 28/DraggingImages/DraggingImages.suo differ diff --git a/Code/Chapter 28/DraggingImages/DraggingImages.vbproj b/Code/Chapter 28/DraggingImages/DraggingImages.vbproj new file mode 100644 index 0000000..a019a69 --- /dev/null +++ b/Code/Chapter 28/DraggingImages/DraggingImages.vbproj @@ -0,0 +1,153 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {E3B3A050-6A59-48D2-A646-C5DE5FE8FF9C} + WinExe + DraggingImages.My.MyApplication + DraggingImages + DraggingImages + WindowsForms + + + 2.0 + + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + v3.5 + + + true + full + true + true + bin\Debug\ + DraggingImages.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + DraggingImages.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + MainForm.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + Always + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 28/DraggingImages/DraggingImages.vbproj.user b/Code/Chapter 28/DraggingImages/DraggingImages.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 28/DraggingImages/DraggingImages.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 28/DraggingImages/HappyDude.bmp b/Code/Chapter 28/DraggingImages/HappyDude.bmp new file mode 100644 index 0000000..3f7a699 Binary files /dev/null and b/Code/Chapter 28/DraggingImages/HappyDude.bmp differ diff --git a/Code/Chapter 28/DraggingImages/MainForm.Designer.vb b/Code/Chapter 28/DraggingImages/MainForm.Designer.vb new file mode 100644 index 0000000..4660cb1 --- /dev/null +++ b/Code/Chapter 28/DraggingImages/MainForm.Designer.vb @@ -0,0 +1,36 @@ + _ +Partial Class MainForm + 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.SuspendLayout() + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(356, 336) + Me.Name = "MainForm" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Dragging Images" + Me.ResumeLayout(False) + + End Sub + +End Class diff --git a/Code/Chapter 28/DraggingImages/MainForm.resx b/Code/Chapter 28/DraggingImages/MainForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 28/DraggingImages/MainForm.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/Code/Chapter 28/DraggingImages/MainForm.vb b/Code/Chapter 28/DraggingImages/MainForm.vb new file mode 100644 index 0000000..3a05acd --- /dev/null +++ b/Code/Chapter 28/DraggingImages/MainForm.vb @@ -0,0 +1,72 @@ +Option Explicit On +Option Strict On + +Public Class MainForm + + Private happyBox As PictureBox = New PictureBox() + Private oldX As Integer, oldY As Integer + Private isDragging As Boolean + Private dropRect As Rectangle = New Rectangle(100, 100, 140, 170) + + Sub New() + ' This call is required by the Windows Form Designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call. + ' Configure the PictureBox and add to + ' the Form's Controls collection. + happyBox.SizeMode = PictureBoxSizeMode.StretchImage + happyBox.Location = New System.Drawing.Point(64, 32) + happyBox.Size = New System.Drawing.Size(50, 50) + happyBox.Cursor = Cursors.Hand + happyBox.Image = New Bitmap("happyDude.bmp") + + ' Add handlers for the following events. + AddHandler happyBox.MouseDown, AddressOf happyBox_MouseDown + AddHandler happyBox.MouseUp, AddressOf happyBox_MouseUp + AddHandler happyBox.MouseMove, AddressOf happyBox_MouseMove + Controls.Add(happyBox) + End Sub + +#Region "Event handlers" + Private Sub happyBox_MouseDown(ByVal sender As System.Object, _ + ByVal e As System.Windows.Forms.MouseEventArgs) + isDragging = True + ' Save the (x, y) of the mouse down click, + ' because we need it as an offset when dragging the image. + oldX = e.X + oldY = e.Y + End Sub + + Private Sub happyBox_MouseMove(ByVal sender As System.Object, _ + ByVal e As System.Windows.Forms.MouseEventArgs) + If isDragging Then + ' Need to figure new Y value based on where the mouse + ' down click happened. + happyBox.Top = happyBox.Top + (e.Y - oldY) + ' Same deal for X (use oldX as a base line). + happyBox.Left = happyBox.Left + (e.X - oldX) + End If + End Sub + + Private Sub happyBox_MouseUp(ByVal sender As System.Object, _ + ByVal e As System.Windows.Forms.MouseEventArgs) + isDragging = False + ' Is the mouse within the area of the drop rect? + If dropRect.Contains(happyBox.Bounds) Then + MessageBox.Show("You win!", "What an amazing test of skill...") + End If + End Sub + + Private Sub MainForm_Paint(ByVal sender As System.Object, _ + ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint + ' Draw the drop box. + Dim g As Graphics = e.Graphics + g.FillRectangle(Brushes.BlueViolet, dropRect) + ' Display instructions. + g.DrawString("Drag the happy guy in here...", _ + New Font("Times New Roman", 25), Brushes.WhiteSmoke, dropRect) + End Sub +#End Region + +End Class diff --git a/Code/Chapter 28/DraggingImages/My Project/Application.Designer.vb b/Code/Chapter 28/DraggingImages/My Project/Application.Designer.vb new file mode 100644 index 0000000..7ff4693 --- /dev/null +++ b/Code/Chapter 28/DraggingImages/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.DraggingImages.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 28/DraggingImages/My Project/Application.myapp b/Code/Chapter 28/DraggingImages/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 28/DraggingImages/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 28/DraggingImages/My Project/AssemblyInfo.vb b/Code/Chapter 28/DraggingImages/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..b98b084 --- /dev/null +++ b/Code/Chapter 28/DraggingImages/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/Code/Chapter 28/DraggingImages/My Project/Resources.Designer.vb b/Code/Chapter 28/DraggingImages/My Project/Resources.Designer.vb new file mode 100644 index 0000000..017ccca --- /dev/null +++ b/Code/Chapter 28/DraggingImages/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("DraggingImages.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/Code/Chapter 28/DraggingImages/My Project/Resources.resx b/Code/Chapter 28/DraggingImages/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 28/DraggingImages/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/Code/Chapter 28/DraggingImages/My Project/Settings.Designer.vb b/Code/Chapter 28/DraggingImages/My Project/Settings.Designer.vb new file mode 100644 index 0000000..1c5e56b --- /dev/null +++ b/Code/Chapter 28/DraggingImages/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.DraggingImages.My.MySettings + Get + Return Global.DraggingImages.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 28/DraggingImages/My Project/Settings.settings b/Code/Chapter 28/DraggingImages/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 28/DraggingImages/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/DrawingUtilTypes.sln b/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/DrawingUtilTypes.sln new file mode 100644 index 0000000..95e1361 --- /dev/null +++ b/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/DrawingUtilTypes.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DrawingUtilTypes", "DrawingUtilTypes.vbproj", "{58048E58-0826-4793-BD6C-2E126F14EE4A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {58048E58-0826-4793-BD6C-2E126F14EE4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {58048E58-0826-4793-BD6C-2E126F14EE4A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {58048E58-0826-4793-BD6C-2E126F14EE4A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {58048E58-0826-4793-BD6C-2E126F14EE4A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/DrawingUtilTypes.suo b/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/DrawingUtilTypes.suo new file mode 100644 index 0000000..ac2505c Binary files /dev/null and b/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/DrawingUtilTypes.suo differ diff --git a/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/DrawingUtilTypes.vbproj b/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/DrawingUtilTypes.vbproj new file mode 100644 index 0000000..6c4815e --- /dev/null +++ b/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/DrawingUtilTypes.vbproj @@ -0,0 +1,110 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {58048E58-0826-4793-BD6C-2E126F14EE4A} + Exe + DrawingUtilTypes.Program + DrawingUtilTypes + DrawingUtilTypes + 512 + Console + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + DrawingUtilTypes.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + DrawingUtilTypes.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + 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/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/DrawingUtilTypes.vbproj.user b/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/DrawingUtilTypes.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/DrawingUtilTypes.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/My Project/Application.Designer.vb b/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/My Project/Application.myapp b/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/My Project/AssemblyInfo.vb b/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..386ee6c --- /dev/null +++ b/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/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/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/My Project/Resources.Designer.vb b/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/My Project/Resources.Designer.vb new file mode 100644 index 0000000..0bba586 --- /dev/null +++ b/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("DrawingUtilTypes.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/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/My Project/Resources.resx b/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/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/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/My Project/Settings.Designer.vb b/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/My Project/Settings.Designer.vb new file mode 100644 index 0000000..6738068 --- /dev/null +++ b/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.DrawingUtilTypes.My.MySettings + Get + Return Global.DrawingUtilTypes.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/My Project/Settings.settings b/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/Program.vb b/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/Program.vb new file mode 100644 index 0000000..1f232d6 --- /dev/null +++ b/Code/Chapter 28/DrawingUtilTypes/DrawingUtilTypes/Program.vb @@ -0,0 +1,65 @@ +Option Strict On +Option Explicit On + +Imports System.Drawing + +Module Program + Sub Main() + Console.WriteLine("***** Working with Drawing utility types *****") + Console.WriteLine() + UsePoint() + Console.WriteLine() + UseRectangle() + Console.ReadLine() + End Sub + +#Region "Use Point" + Sub UsePoint() + Console.WriteLine("***** Exercise Point *****") + + ' Create and offset a point. + Dim pt As New Point(100, 72) + Console.WriteLine(pt) + pt.Offset(20, 20) + Console.WriteLine(pt) + + ' Overloaded Point operators. + Dim pt2 As Point = pt + If pt = pt2 Then + Console.WriteLine("Points are the same") + Else + Console.WriteLine("Different points") + End If + + ' Change pt2's X value. + pt2.X = 4000 + + ' Now show each point's value + Console.WriteLine("First point: {0}", pt) + Console.WriteLine("Second point: {0}", pt2) + End Sub +#End Region + +#Region "Use Rectangle" + Sub UseRectangle() + Console.WriteLine("***** Point in Rect? *****") + Dim r1 As New Rectangle(0, 0, 100, 100) + Dim pt3 As Point = New Point(101, 101) + If r1.Contains(pt3) Then + Console.WriteLine("Point is within the rect!") + Else + Console.WriteLine("Point is not within the rect!") + End If + + ' Now place point in rectangle's area. + pt3.X = 50 + pt3.Y = 30 + If r1.Contains(pt3) Then + Console.WriteLine("Point is within the rect!") + Else + Console.WriteLine("Point is not within the rect!") + End If + End Sub +#End Region + +End Module diff --git a/Code/Chapter 28/FontDlgForm/FontDlgForm.sln b/Code/Chapter 28/FontDlgForm/FontDlgForm.sln new file mode 100644 index 0000000..7e5389d --- /dev/null +++ b/Code/Chapter 28/FontDlgForm/FontDlgForm.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "FontDlgForm", "FontDlgForm.vbproj", "{5B149348-1B56-4FFD-90CC-59BFDAD5BF3C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5B149348-1B56-4FFD-90CC-59BFDAD5BF3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5B149348-1B56-4FFD-90CC-59BFDAD5BF3C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5B149348-1B56-4FFD-90CC-59BFDAD5BF3C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5B149348-1B56-4FFD-90CC-59BFDAD5BF3C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 28/FontDlgForm/FontDlgForm.suo b/Code/Chapter 28/FontDlgForm/FontDlgForm.suo new file mode 100644 index 0000000..1cc3ac3 Binary files /dev/null and b/Code/Chapter 28/FontDlgForm/FontDlgForm.suo differ diff --git a/Code/Chapter 28/FontDlgForm/FontDlgForm.vbproj b/Code/Chapter 28/FontDlgForm/FontDlgForm.vbproj new file mode 100644 index 0000000..c22b14c --- /dev/null +++ b/Code/Chapter 28/FontDlgForm/FontDlgForm.vbproj @@ -0,0 +1,148 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {5B149348-1B56-4FFD-90CC-59BFDAD5BF3C} + WinExe + FontDlgForm.My.MyApplication + FontDlgForm + FontDlgForm + WindowsForms + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + FontDlgForm.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + FontDlgForm.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + MainForm.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 28/FontDlgForm/FontDlgForm.vbproj.user b/Code/Chapter 28/FontDlgForm/FontDlgForm.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 28/FontDlgForm/FontDlgForm.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 28/FontDlgForm/MainForm.Designer.vb b/Code/Chapter 28/FontDlgForm/MainForm.Designer.vb new file mode 100644 index 0000000..033c8a9 --- /dev/null +++ b/Code/Chapter 28/FontDlgForm/MainForm.Designer.vb @@ -0,0 +1,35 @@ + _ +Partial Class MainForm + 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.SuspendLayout() + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(292, 266) + Me.Name = "MainForm" + Me.Text = "Fun with the Font Dialog" + Me.ResumeLayout(False) + + End Sub + +End Class diff --git a/Code/Chapter 28/FontDlgForm/MainForm.resx b/Code/Chapter 28/FontDlgForm/MainForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 28/FontDlgForm/MainForm.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/Code/Chapter 28/FontDlgForm/MainForm.vb b/Code/Chapter 28/FontDlgForm/MainForm.vb new file mode 100644 index 0000000..b2d8ec2 --- /dev/null +++ b/Code/Chapter 28/FontDlgForm/MainForm.vb @@ -0,0 +1,27 @@ +Option Explicit On +Option Strict On + +Public Class MainForm + Sub New() + ' This call is required by the Windows Form Designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call. + CenterToScreen() + End Sub + Private fontDlg As New FontDialog() + Private currFont As New Font("Times New Roman", 12) + + Private Sub MainForm_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown + If fontDlg.ShowDialog() <> Windows.Forms.DialogResult.Cancel Then + currFont = fontDlg.Font + Me.Text = String.Format("Selected Font: {0} ", currFont) + Invalidate() + End If + End Sub + + Private Sub MainForm_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint + Dim g As Graphics = e.Graphics + g.DrawString("Testing...", currFont, Brushes.Black, 0, 0) + End Sub +End Class diff --git a/Code/Chapter 28/FontDlgForm/My Project/Application.Designer.vb b/Code/Chapter 28/FontDlgForm/My Project/Application.Designer.vb new file mode 100644 index 0000000..3c05656 --- /dev/null +++ b/Code/Chapter 28/FontDlgForm/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.FontDlgForm.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 28/FontDlgForm/My Project/Application.myapp b/Code/Chapter 28/FontDlgForm/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 28/FontDlgForm/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 28/FontDlgForm/My Project/AssemblyInfo.vb b/Code/Chapter 28/FontDlgForm/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..e9ffbf3 --- /dev/null +++ b/Code/Chapter 28/FontDlgForm/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/Code/Chapter 28/FontDlgForm/My Project/Resources.Designer.vb b/Code/Chapter 28/FontDlgForm/My Project/Resources.Designer.vb new file mode 100644 index 0000000..39929e3 --- /dev/null +++ b/Code/Chapter 28/FontDlgForm/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("FontDlgForm.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/Code/Chapter 28/FontDlgForm/My Project/Resources.resx b/Code/Chapter 28/FontDlgForm/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 28/FontDlgForm/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/Code/Chapter 28/FontDlgForm/My Project/Settings.Designer.vb b/Code/Chapter 28/FontDlgForm/My Project/Settings.Designer.vb new file mode 100644 index 0000000..d6b70e4 --- /dev/null +++ b/Code/Chapter 28/FontDlgForm/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.FontDlgForm.My.MySettings + Get + Return Global.FontDlgForm.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 28/FontDlgForm/My Project/Settings.settings b/Code/Chapter 28/FontDlgForm/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 28/FontDlgForm/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 28/FontFamilyApp/FontFamilyApp.sln b/Code/Chapter 28/FontFamilyApp/FontFamilyApp.sln new file mode 100644 index 0000000..5b4c7c9 --- /dev/null +++ b/Code/Chapter 28/FontFamilyApp/FontFamilyApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "FontFamilyApp", "FontFamilyApp.vbproj", "{8D1CA4E8-300D-499D-BEF5-BF64783D30A6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8D1CA4E8-300D-499D-BEF5-BF64783D30A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8D1CA4E8-300D-499D-BEF5-BF64783D30A6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8D1CA4E8-300D-499D-BEF5-BF64783D30A6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8D1CA4E8-300D-499D-BEF5-BF64783D30A6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 28/FontFamilyApp/FontFamilyApp.suo b/Code/Chapter 28/FontFamilyApp/FontFamilyApp.suo new file mode 100644 index 0000000..6cf56dc Binary files /dev/null and b/Code/Chapter 28/FontFamilyApp/FontFamilyApp.suo differ diff --git a/Code/Chapter 28/FontFamilyApp/FontFamilyApp.vbproj b/Code/Chapter 28/FontFamilyApp/FontFamilyApp.vbproj new file mode 100644 index 0000000..22d5026 --- /dev/null +++ b/Code/Chapter 28/FontFamilyApp/FontFamilyApp.vbproj @@ -0,0 +1,148 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {8D1CA4E8-300D-499D-BEF5-BF64783D30A6} + WinExe + FontFamilyApp.My.MyApplication + FontFamilyApp + FontFamilyApp + WindowsForms + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + FontFamilyApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + FontFamilyApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + MainForm.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 28/FontFamilyApp/FontFamilyApp.vbproj.user b/Code/Chapter 28/FontFamilyApp/FontFamilyApp.vbproj.user new file mode 100644 index 0000000..1659b79 --- /dev/null +++ b/Code/Chapter 28/FontFamilyApp/FontFamilyApp.vbproj.user @@ -0,0 +1,17 @@ + + + ShowAllFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 28/FontFamilyApp/MainForm.Designer.vb b/Code/Chapter 28/FontFamilyApp/MainForm.Designer.vb new file mode 100644 index 0000000..03a4bdc --- /dev/null +++ b/Code/Chapter 28/FontFamilyApp/MainForm.Designer.vb @@ -0,0 +1,36 @@ + _ +Partial Class MainForm + 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.SuspendLayout() + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(469, 264) + Me.Name = "MainForm" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Form1" + Me.ResumeLayout(False) + + End Sub + +End Class diff --git a/Code/Chapter 28/FontFamilyApp/MainForm.resx b/Code/Chapter 28/FontFamilyApp/MainForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 28/FontFamilyApp/MainForm.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/Code/Chapter 28/FontFamilyApp/MainForm.vb b/Code/Chapter 28/FontFamilyApp/MainForm.vb new file mode 100644 index 0000000..8108e8b --- /dev/null +++ b/Code/Chapter 28/FontFamilyApp/MainForm.vb @@ -0,0 +1,36 @@ +Option Explicit On +Option Strict On + +Public Class MainForm + Private Sub MainForm_Paint(ByVal sender As System.Object, _ + ByVal e As System.Windows.Forms.PaintEventArgs) _ + Handles MyBase.Paint + Dim g As Graphics = e.Graphics + Dim myFamily As FontFamily = New FontFamily("Verdana") + Dim myFont As Font = New Font(myFamily, 12) + Dim y As Integer = 0 + Dim fontHeight As Integer = myFont.Height + + ' Show units of measurement for FontFamily members. + Me.Text = "Measurements are in GraphicsUnit." & myFont.Unit.ToString() + g.DrawString("The Verdana family.", myFont, Brushes.Blue, 10, y) + y += 20 + ' Print our family ties... + g.DrawString("Ascent for bold Verdana: " _ + & myFamily.GetCellAscent(FontStyle.Bold), _ + myFont, Brushes.Black, 10, y + fontHeight) + y += 20 + g.DrawString("Descent for bold Verdana: " _ + & myFamily.GetCellDescent(FontStyle.Bold), _ + myFont, Brushes.Black, 10, y + fontHeight) + y += 20 + g.DrawString("Line spacing for bold Verdana: " _ + & myFamily.GetLineSpacing(FontStyle.Bold), _ + myFont, Brushes.Black, 10, y + fontHeight) + y += 20 + g.DrawString("Height for bold Verdana: " & _ + myFamily.GetEmHeight(FontStyle.Bold), _ + myFont, Brushes.Black, 10, y + fontHeight) + y += 20 + End Sub +End Class diff --git a/Code/Chapter 28/FontFamilyApp/My Project/Application.Designer.vb b/Code/Chapter 28/FontFamilyApp/My Project/Application.Designer.vb new file mode 100644 index 0000000..1129d45 --- /dev/null +++ b/Code/Chapter 28/FontFamilyApp/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.FontFamilyApp.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 28/FontFamilyApp/My Project/Application.myapp b/Code/Chapter 28/FontFamilyApp/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 28/FontFamilyApp/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 28/FontFamilyApp/My Project/AssemblyInfo.vb b/Code/Chapter 28/FontFamilyApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..26c6475 --- /dev/null +++ b/Code/Chapter 28/FontFamilyApp/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/Code/Chapter 28/FontFamilyApp/My Project/Resources.Designer.vb b/Code/Chapter 28/FontFamilyApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..2ed85c8 --- /dev/null +++ b/Code/Chapter 28/FontFamilyApp/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("FontFamilyApp.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/Code/Chapter 28/FontFamilyApp/My Project/Resources.resx b/Code/Chapter 28/FontFamilyApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 28/FontFamilyApp/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/Code/Chapter 28/FontFamilyApp/My Project/Settings.Designer.vb b/Code/Chapter 28/FontFamilyApp/My Project/Settings.Designer.vb new file mode 100644 index 0000000..4d4be1c --- /dev/null +++ b/Code/Chapter 28/FontFamilyApp/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.FontFamilyApp.My.MySettings + Get + Return Global.FontFamilyApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 28/FontFamilyApp/My Project/Settings.settings b/Code/Chapter 28/FontFamilyApp/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 28/FontFamilyApp/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 28/GradientBrushes/GradientBrushes.sln b/Code/Chapter 28/GradientBrushes/GradientBrushes.sln new file mode 100644 index 0000000..0ad2c9f --- /dev/null +++ b/Code/Chapter 28/GradientBrushes/GradientBrushes.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "GradientBrushes", "GradientBrushes.vbproj", "{79C104C7-E763-4719-821B-77AF78B9FD6D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {79C104C7-E763-4719-821B-77AF78B9FD6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {79C104C7-E763-4719-821B-77AF78B9FD6D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {79C104C7-E763-4719-821B-77AF78B9FD6D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {79C104C7-E763-4719-821B-77AF78B9FD6D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 28/GradientBrushes/GradientBrushes.suo b/Code/Chapter 28/GradientBrushes/GradientBrushes.suo new file mode 100644 index 0000000..56ab867 Binary files /dev/null and b/Code/Chapter 28/GradientBrushes/GradientBrushes.suo differ diff --git a/Code/Chapter 28/GradientBrushes/GradientBrushes.vbproj b/Code/Chapter 28/GradientBrushes/GradientBrushes.vbproj new file mode 100644 index 0000000..2fc2c71 --- /dev/null +++ b/Code/Chapter 28/GradientBrushes/GradientBrushes.vbproj @@ -0,0 +1,148 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {79C104C7-E763-4719-821B-77AF78B9FD6D} + WinExe + GradientBrushes.My.MyApplication + GradientBrushes + GradientBrushes + WindowsForms + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + GradientBrushes.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + GradientBrushes.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + MainForm.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 28/GradientBrushes/GradientBrushes.vbproj.user b/Code/Chapter 28/GradientBrushes/GradientBrushes.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 28/GradientBrushes/GradientBrushes.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 28/GradientBrushes/MainForm.Designer.vb b/Code/Chapter 28/GradientBrushes/MainForm.Designer.vb new file mode 100644 index 0000000..3b156d5 --- /dev/null +++ b/Code/Chapter 28/GradientBrushes/MainForm.Designer.vb @@ -0,0 +1,36 @@ + _ +Partial Class MainForm + 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.SuspendLayout() + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(362, 343) + Me.Name = "MainForm" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Fun with Gradient Brushes." + Me.ResumeLayout(False) + + End Sub + +End Class diff --git a/Code/Chapter 28/GradientBrushes/MainForm.resx b/Code/Chapter 28/GradientBrushes/MainForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 28/GradientBrushes/MainForm.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/Code/Chapter 28/GradientBrushes/MainForm.vb b/Code/Chapter 28/GradientBrushes/MainForm.vb new file mode 100644 index 0000000..6894e0a --- /dev/null +++ b/Code/Chapter 28/GradientBrushes/MainForm.vb @@ -0,0 +1,35 @@ +Option Explicit On +Option Strict On + +Imports System.Drawing.Drawing2D + +Public Class MainForm + + Private Sub MainForm_Paint(ByVal sender As System.Object, _ + ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint + Dim g As Graphics = e.Graphics + Dim r As Rectangle = New Rectangle(10, 10, 100, 100) + + ' A gradient brush. + Dim theBrush As LinearGradientBrush = Nothing + Dim yOffSet As Integer = 10 + + ' Get all members of the LinearGradientMode enum. + Dim obj As Array = [Enum].GetValues(GetType(LinearGradientMode)) + + For x As Integer = 0 To obj.Length - 1 + ' Draw an oval with a LinearGradientMode member. + ' Configure Brush. + Dim temp As LinearGradientMode = CType(obj.GetValue(x), LinearGradientMode) + theBrush = New LinearGradientBrush(r, Color.GreenYellow, Color.Blue, temp) + + ' Print name of LinearGradientMode enum. + g.DrawString(temp.ToString(), _ + New Font("Times New Roman", 10), _ + New SolidBrush(Color.Black), 0, yOffSet) + ' Fill a rectangle with the correct brush. + g.FillRectangle(theBrush, 150, yOffSet, 200, 50) + yOffSet += 80 + Next + End Sub +End Class diff --git a/Code/Chapter 28/GradientBrushes/My Project/Application.Designer.vb b/Code/Chapter 28/GradientBrushes/My Project/Application.Designer.vb new file mode 100644 index 0000000..9dc98e8 --- /dev/null +++ b/Code/Chapter 28/GradientBrushes/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.GradientBrushes.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 28/GradientBrushes/My Project/Application.myapp b/Code/Chapter 28/GradientBrushes/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 28/GradientBrushes/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 28/GradientBrushes/My Project/AssemblyInfo.vb b/Code/Chapter 28/GradientBrushes/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..02ee227 --- /dev/null +++ b/Code/Chapter 28/GradientBrushes/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/Code/Chapter 28/GradientBrushes/My Project/Resources.Designer.vb b/Code/Chapter 28/GradientBrushes/My Project/Resources.Designer.vb new file mode 100644 index 0000000..95c7cfe --- /dev/null +++ b/Code/Chapter 28/GradientBrushes/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("GradientBrushes.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/Code/Chapter 28/GradientBrushes/My Project/Resources.resx b/Code/Chapter 28/GradientBrushes/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 28/GradientBrushes/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/Code/Chapter 28/GradientBrushes/My Project/Settings.Designer.vb b/Code/Chapter 28/GradientBrushes/My Project/Settings.Designer.vb new file mode 100644 index 0000000..c9e2cb2 --- /dev/null +++ b/Code/Chapter 28/GradientBrushes/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.GradientBrushes.My.MySettings + Get + Return Global.GradientBrushes.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 28/GradientBrushes/My Project/Settings.settings b/Code/Chapter 28/GradientBrushes/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 28/GradientBrushes/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 28/HitTestingImages/HitTestingImages.sln b/Code/Chapter 28/HitTestingImages/HitTestingImages.sln new file mode 100644 index 0000000..70ca33c --- /dev/null +++ b/Code/Chapter 28/HitTestingImages/HitTestingImages.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "HitTestingImages", "HitTestingImages.vbproj", "{DC947AD4-F7B9-42D7-B0A3-68D085B55002}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DC947AD4-F7B9-42D7-B0A3-68D085B55002}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DC947AD4-F7B9-42D7-B0A3-68D085B55002}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DC947AD4-F7B9-42D7-B0A3-68D085B55002}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DC947AD4-F7B9-42D7-B0A3-68D085B55002}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 28/HitTestingImages/HitTestingImages.suo b/Code/Chapter 28/HitTestingImages/HitTestingImages.suo new file mode 100644 index 0000000..8e1f247 Binary files /dev/null and b/Code/Chapter 28/HitTestingImages/HitTestingImages.suo differ diff --git a/Code/Chapter 28/HitTestingImages/HitTestingImages.vbproj b/Code/Chapter 28/HitTestingImages/HitTestingImages.vbproj new file mode 100644 index 0000000..d345532 --- /dev/null +++ b/Code/Chapter 28/HitTestingImages/HitTestingImages.vbproj @@ -0,0 +1,159 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {DC947AD4-F7B9-42D7-B0A3-68D085B55002} + WinExe + HitTestingImages.My.MyApplication + HitTestingImages + HitTestingImages + WindowsForms + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + HitTestingImages.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + HitTestingImages.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + MainForm.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + Always + + + Always + + + Always + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 28/HitTestingImages/HitTestingImages.vbproj.user b/Code/Chapter 28/HitTestingImages/HitTestingImages.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 28/HitTestingImages/HitTestingImages.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 28/HitTestingImages/MainForm.Designer.vb b/Code/Chapter 28/HitTestingImages/MainForm.Designer.vb new file mode 100644 index 0000000..1a1f94a --- /dev/null +++ b/Code/Chapter 28/HitTestingImages/MainForm.Designer.vb @@ -0,0 +1,35 @@ + _ +Partial Class MainForm + 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.SuspendLayout() + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(397, 415) + Me.Name = "MainForm" + Me.Text = "Hit testing regions" + Me.ResumeLayout(False) + + End Sub + +End Class diff --git a/Code/Chapter 28/HitTestingImages/MainForm.resx b/Code/Chapter 28/HitTestingImages/MainForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 28/HitTestingImages/MainForm.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/Code/Chapter 28/HitTestingImages/MainForm.vb b/Code/Chapter 28/HitTestingImages/MainForm.vb new file mode 100644 index 0000000..71e90db --- /dev/null +++ b/Code/Chapter 28/HitTestingImages/MainForm.vb @@ -0,0 +1,119 @@ +Option Explicit On +Option Strict On + +Imports System.Drawing.Drawing2D + +Enum ClickedImage + ImageA + ImageB + ImageC + StrangePath +End Enum + +Public Class MainForm + + ' To hold the *.bmp data. + Private myImages As Bitmap() = New Bitmap(2) {} + Private imageRects As Rectangle() = New Rectangle(2) {} + Private isImageClicked As Boolean = False + Private imageClicked As ClickedImage = ClickedImage.ImageA + Private myPath As GraphicsPath = New GraphicsPath() + + Sub New() + ' This call is required by the Windows Form Designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call. + myImages(0) = New Bitmap("imageA.bmp") + myImages(1) = New Bitmap("imageB.bmp") + myImages(2) = New Bitmap("imageC.bmp") + + ' Set up the rectangles. + imageRects(0) = New Rectangle(10, 10, 90, 90) + imageRects(1) = New Rectangle(10, 110, 90, 90) + imageRects(2) = New Rectangle(10, 210, 90, 90) + + ' Create an interesting path. + myPath.StartFigure() + myPath.AddLine(New Point(150, 10), New Point(120, 150)) + myPath.AddArc(200, 200, 100, 100, 0, 90) + Dim point1 As Point = New Point(250, 250) + Dim point2 As Point = New Point(350, 275) + Dim point3 As Point = New Point(350, 325) + Dim point4 As Point = New Point(250, 350) + Dim points As Point() = {point1, point2, point3, point4} + myPath.AddCurve(points) + myPath.CloseFigure() + CenterToScreen() + End Sub + +#Region "Event handlers" + Private Sub MainForm_Paint(ByVal sender As System.Object, _ + ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint + Dim g As Graphics = e.Graphics + ' Render all three images. + Dim yOffset As Integer = 10 + For Each b As Bitmap In myImages + g.DrawImage(b, 10, yOffset, 90, 90) + yOffset += 100 + Next + + ' Draw the graphics path. + g.FillPath(Brushes.Sienna, myPath) + + ' Draw outline (if clicked) + If isImageClicked = True Then + Dim outline As Pen = New Pen(Color.Red, 5) + Select Case imageClicked + Case ClickedImage.ImageA + g.DrawRectangle(outline, imageRects(0)) + Exit Select + Case ClickedImage.ImageB + g.DrawRectangle(outline, imageRects(1)) + Exit Select + Case ClickedImage.ImageC + g.DrawRectangle(outline, imageRects(2)) + Exit Select + Case ClickedImage.StrangePath + g.DrawPath(outline, myPath) + Exit Select + Case Else + Exit Select + End Select + End If + End Sub + + Private Sub MainForm_MouseDown(ByVal sender As System.Object, _ + ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown + ' Get (x, y) of mouse click. + Dim mousePt As Point = New Point(e.X, e.Y) + + ' See if the mouse is anywhere in the 3 Rectangles. + If imageRects(0).Contains(mousePt) Then + isImageClicked = True + imageClicked = ClickedImage.ImageA + Me.Text = "You clicked image A" + ElseIf imageRects(1).Contains(mousePt) Then + isImageClicked = True + imageClicked = ClickedImage.ImageB + Me.Text = "You clicked image B" + ElseIf imageRects(2).Contains(mousePt) Then + isImageClicked = True + imageClicked = ClickedImage.ImageC + Me.Text = "You clicked image C" + ElseIf myPath.IsVisible(mousePt) Then + isImageClicked = True + imageClicked = ClickedImage.StrangePath + Me.Text = "You clicked the strange shape..." + Else + ' Not in any shape, set defaults. + isImageClicked = False + Me.Text = "Hit Testing Images" + End If + + ' Redraw the client area. + Invalidate() + End Sub +#End Region + +End Class diff --git a/Code/Chapter 28/HitTestingImages/My Project/Application.Designer.vb b/Code/Chapter 28/HitTestingImages/My Project/Application.Designer.vb new file mode 100644 index 0000000..4ab5124 --- /dev/null +++ b/Code/Chapter 28/HitTestingImages/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.HitTestingImages.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 28/HitTestingImages/My Project/Application.myapp b/Code/Chapter 28/HitTestingImages/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 28/HitTestingImages/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 28/HitTestingImages/My Project/AssemblyInfo.vb b/Code/Chapter 28/HitTestingImages/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..be25269 --- /dev/null +++ b/Code/Chapter 28/HitTestingImages/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/Code/Chapter 28/HitTestingImages/My Project/Resources.Designer.vb b/Code/Chapter 28/HitTestingImages/My Project/Resources.Designer.vb new file mode 100644 index 0000000..5c3eacb --- /dev/null +++ b/Code/Chapter 28/HitTestingImages/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("HitTestingImages.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/Code/Chapter 28/HitTestingImages/My Project/Resources.resx b/Code/Chapter 28/HitTestingImages/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 28/HitTestingImages/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/Code/Chapter 28/HitTestingImages/My Project/Settings.Designer.vb b/Code/Chapter 28/HitTestingImages/My Project/Settings.Designer.vb new file mode 100644 index 0000000..3d5be7c --- /dev/null +++ b/Code/Chapter 28/HitTestingImages/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.HitTestingImages.My.MySettings + Get + Return Global.HitTestingImages.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 28/HitTestingImages/My Project/Settings.settings b/Code/Chapter 28/HitTestingImages/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 28/HitTestingImages/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 28/HitTestingImages/imageA.bmp b/Code/Chapter 28/HitTestingImages/imageA.bmp new file mode 100644 index 0000000..ddda3a4 Binary files /dev/null and b/Code/Chapter 28/HitTestingImages/imageA.bmp differ diff --git a/Code/Chapter 28/HitTestingImages/imageB.bmp b/Code/Chapter 28/HitTestingImages/imageB.bmp new file mode 100644 index 0000000..1a84749 Binary files /dev/null and b/Code/Chapter 28/HitTestingImages/imageB.bmp differ diff --git a/Code/Chapter 28/HitTestingImages/imageC.bmp b/Code/Chapter 28/HitTestingImages/imageC.bmp new file mode 100644 index 0000000..b66a223 Binary files /dev/null and b/Code/Chapter 28/HitTestingImages/imageC.bmp differ diff --git a/Code/Chapter 28/MyResourcesWinApp/MainForm.Designer.vb b/Code/Chapter 28/MyResourcesWinApp/MainForm.Designer.vb new file mode 100644 index 0000000..9cadffa --- /dev/null +++ b/Code/Chapter 28/MyResourcesWinApp/MainForm.Designer.vb @@ -0,0 +1,88 @@ + _ +Partial Class MainForm + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.PictureBox1 = New System.Windows.Forms.PictureBox + Me.Label1 = New System.Windows.Forms.Label + Me.btnLoadResources = New System.Windows.Forms.Button + Me.myPictureBox = New System.Windows.Forms.PictureBox + CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.myPictureBox, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'PictureBox1 + ' + Me.PictureBox1.Image = Global.MyResourcesWinApp.My.Resources.Resources.HappyDude + Me.PictureBox1.Location = New System.Drawing.Point(12, 41) + Me.PictureBox1.Name = "PictureBox1" + Me.PictureBox1.Size = New System.Drawing.Size(49, 45) + Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage + Me.PictureBox1.TabIndex = 0 + Me.PictureBox1.TabStop = False + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(12, 13) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(229, 13) + Me.Label1.TabIndex = 1 + Me.Label1.Text = "This image in embedded in the Form's *.resx file" + ' + 'btnLoadResources + ' + Me.btnLoadResources.Location = New System.Drawing.Point(12, 111) + Me.btnLoadResources.Name = "btnLoadResources" + Me.btnLoadResources.Size = New System.Drawing.Size(129, 23) + Me.btnLoadResources.TabIndex = 2 + Me.btnLoadResources.Text = "Load Resources" + Me.btnLoadResources.UseVisualStyleBackColor = True + ' + 'myPictureBox + ' + Me.myPictureBox.Location = New System.Drawing.Point(15, 160) + Me.myPictureBox.Name = "myPictureBox" + Me.myPictureBox.Size = New System.Drawing.Size(100, 50) + Me.myPictureBox.TabIndex = 3 + Me.myPictureBox.TabStop = False + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(292, 266) + Me.Controls.Add(Me.myPictureBox) + Me.Controls.Add(Me.btnLoadResources) + Me.Controls.Add(Me.Label1) + Me.Controls.Add(Me.PictureBox1) + Me.Name = "MainForm" + Me.Text = "Embedded Images" + CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.myPictureBox, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox + Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents btnLoadResources As System.Windows.Forms.Button + Friend WithEvents myPictureBox As System.Windows.Forms.PictureBox + +End Class diff --git a/Code/Chapter 28/MyResourcesWinApp/MainForm.resx b/Code/Chapter 28/MyResourcesWinApp/MainForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 28/MyResourcesWinApp/MainForm.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/Code/Chapter 28/MyResourcesWinApp/MainForm.vb b/Code/Chapter 28/MyResourcesWinApp/MainForm.vb new file mode 100644 index 0000000..1b91f60 --- /dev/null +++ b/Code/Chapter 28/MyResourcesWinApp/MainForm.vb @@ -0,0 +1,28 @@ +Option Explicit On +Option Strict On + +Imports System.Resources +Imports System.Reflection + +Public Class MainForm + Sub New() + ' This call is required by the Windows Form Designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call. + CenterToScreen() + End Sub + + Private Sub btnLoadResources_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles btnLoadResources.Click + ' Make a resource manager. + Dim rm As ResourceManager = _ + New ResourceManager("MyResourcesWinApp.MyResources", Assembly.GetExecutingAssembly()) + ' Get the embedded string (case sensitive!) + MessageBox.Show(rm.GetString("WelcomeString")) + ' Get the embedded bitmap (case sensitive!) + myPictureBox.Image = CType(rm.GetObject("HappyDude"), Bitmap) + ' Clean up. + rm.ReleaseAllResources() + End Sub +End Class diff --git a/Code/Chapter 28/MyResourcesWinApp/My Project/Application.Designer.vb b/Code/Chapter 28/MyResourcesWinApp/My Project/Application.Designer.vb new file mode 100644 index 0000000..ec16471 --- /dev/null +++ b/Code/Chapter 28/MyResourcesWinApp/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.MyResourcesWinApp.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 28/MyResourcesWinApp/My Project/Application.myapp b/Code/Chapter 28/MyResourcesWinApp/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 28/MyResourcesWinApp/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 28/MyResourcesWinApp/My Project/AssemblyInfo.vb b/Code/Chapter 28/MyResourcesWinApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..8360e9e --- /dev/null +++ b/Code/Chapter 28/MyResourcesWinApp/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/Code/Chapter 28/MyResourcesWinApp/My Project/Resources.Designer.vb b/Code/Chapter 28/MyResourcesWinApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..58739b9 --- /dev/null +++ b/Code/Chapter 28/MyResourcesWinApp/My Project/Resources.Designer.vb @@ -0,0 +1,70 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("MyResourcesWinApp.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 HappyDude() As System.Drawing.Bitmap + Get + Dim obj As Object = ResourceManager.GetObject("HappyDude", resourceCulture) + Return CType(obj,System.Drawing.Bitmap) + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 28/MyResourcesWinApp/My Project/Resources.resx b/Code/Chapter 28/MyResourcesWinApp/My Project/Resources.resx new file mode 100644 index 0000000..8658021 --- /dev/null +++ b/Code/Chapter 28/MyResourcesWinApp/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\HappyDude.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/Code/Chapter 28/MyResourcesWinApp/My Project/Settings.Designer.vb b/Code/Chapter 28/MyResourcesWinApp/My Project/Settings.Designer.vb new file mode 100644 index 0000000..8eaa320 --- /dev/null +++ b/Code/Chapter 28/MyResourcesWinApp/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.MyResourcesWinApp.My.MySettings + Get + Return Global.MyResourcesWinApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 28/MyResourcesWinApp/My Project/Settings.settings b/Code/Chapter 28/MyResourcesWinApp/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 28/MyResourcesWinApp/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 28/MyResourcesWinApp/MyResources.Designer.vb b/Code/Chapter 28/MyResourcesWinApp/MyResources.Designer.vb new file mode 100644 index 0000000..c42951b --- /dev/null +++ b/Code/Chapter 28/MyResourcesWinApp/MyResources.Designer.vb @@ -0,0 +1,83 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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 Class MyResources + + Private Shared resourceMan As Global.System.Resources.ResourceManager + + Private Shared resourceCulture As Global.System.Globalization.CultureInfo + + _ + Friend Sub New() + MyBase.New + End Sub + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend Shared 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("MyResourcesWinApp.MyResources", GetType(MyResources).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 Shared Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set + resourceCulture = value + End Set + End Property + + Friend Shared ReadOnly Property HappyDude() As System.Drawing.Bitmap + Get + Dim obj As Object = ResourceManager.GetObject("HappyDude", resourceCulture) + Return CType(obj,System.Drawing.Bitmap) + End Get + End Property + + ''' + ''' Looks up a localized string similar to Some text data.... + ''' + Friend Shared ReadOnly Property WelcomeString() As String + Get + Return ResourceManager.GetString("WelcomeString", resourceCulture) + End Get + End Property + End Class +End Namespace diff --git a/Code/Chapter 28/MyResourcesWinApp/MyResources.resx b/Code/Chapter 28/MyResourcesWinApp/MyResources.resx new file mode 100644 index 0000000..2bd776a --- /dev/null +++ b/Code/Chapter 28/MyResourcesWinApp/MyResources.resx @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + Qk12AgAAAAAAAHYAAAAoAAAAIAAAACAAAAABAAQAAAAAAAAAAADEDgAAxA4AABAAAAAQAAAAAAAA/wAA + gP8AgAD/AICA/4AAAP+AAID/gIAA/4CAgP/AwMD/AAD//wD/AP8A/////wAA//8A/////wD//////wAA + AAAAAAAAAAAAAAAAAAAAAAAAAAC7u7u7AAAAAAAAAAAAAAu7u7u7u7uwAAAAAAAAAAC7u7u7u7u7uwAA + AAAAAAC7u7u7u7u7u7u7AAAAAAALu7u7uwAAu7u7u7AAAAAAu7u7u7CZmQu7u7u7AAAAALu7u7sJmZmQ + u7u7uwAAAAu7u7uwkAAACQu7u7uwAAC7u7u7AAu7u7AAu7u7uwAAu7u7sAu7u7u7sAu7u7sAALu7u7C7 + u7u7u7sLu7u7AAu7u7sLu7u7u7u7sLu7u7ALuwAAu7u7u7u7u7sAALuwC7u7sLu7u7u7u7u7C7u7sAu7 + u7sLu7u7u7u7sLu7u7ALu7u7C7u7u7u7u7C7u7uwC7u7u7uwC7u7sAu7u7u7sAu7u7u7AAC7uwAAu7u7 + u7ALu7u7uwAAu7sAALu7u7uwALu7u7sAALu7AAC7u7u7AAC7u7u7AAC7uwAAu7u7uwAAu7u7uwAAu7sA + ALu7u7sAAAu7u7uwC7u7sAu7u7uwAAAAu7u7u7u7u7u7u7u7AAAAALu7u7u7u7u7u7u7uwAAAAALu7u7 + u7u7u7u7u7AAAAAAALu7u7u7u7u7u7sAAAAAAAAAu7u7u7u7u7sAAAAAAAAAAAu7u7u7u7uwAAAAAAAA + AAAAALu7u7sAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + + + + Some text data... + + \ No newline at end of file diff --git a/Code/Chapter 28/MyResourcesWinApp/MyResourcesWinApp.sln b/Code/Chapter 28/MyResourcesWinApp/MyResourcesWinApp.sln new file mode 100644 index 0000000..a86f508 --- /dev/null +++ b/Code/Chapter 28/MyResourcesWinApp/MyResourcesWinApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MyResourcesWinApp", "MyResourcesWinApp.vbproj", "{211508A4-1732-4CB4-8CA3-DF06972CC7DB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {211508A4-1732-4CB4-8CA3-DF06972CC7DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {211508A4-1732-4CB4-8CA3-DF06972CC7DB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {211508A4-1732-4CB4-8CA3-DF06972CC7DB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {211508A4-1732-4CB4-8CA3-DF06972CC7DB}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 28/MyResourcesWinApp/MyResourcesWinApp.suo b/Code/Chapter 28/MyResourcesWinApp/MyResourcesWinApp.suo new file mode 100644 index 0000000..ad2bb8a Binary files /dev/null and b/Code/Chapter 28/MyResourcesWinApp/MyResourcesWinApp.suo differ diff --git a/Code/Chapter 28/MyResourcesWinApp/MyResourcesWinApp.vbproj b/Code/Chapter 28/MyResourcesWinApp/MyResourcesWinApp.vbproj new file mode 100644 index 0000000..ac5555b --- /dev/null +++ b/Code/Chapter 28/MyResourcesWinApp/MyResourcesWinApp.vbproj @@ -0,0 +1,160 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {211508A4-1732-4CB4-8CA3-DF06972CC7DB} + WinExe + MyResourcesWinApp.My.MyApplication + MyResourcesWinApp + MyResourcesWinApp + WindowsForms + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + MyResourcesWinApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + MyResourcesWinApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + True + True + MyResources.resx + + + + + Designer + MainForm.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + Designer + My.Resources + ResXFileCodeGenerator + MyResources.Designer.vb + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 28/MyResourcesWinApp/MyResourcesWinApp.vbproj.user b/Code/Chapter 28/MyResourcesWinApp/MyResourcesWinApp.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 28/MyResourcesWinApp/MyResourcesWinApp.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 28/MyResourcesWinApp/Resources/HappyDude.bmp b/Code/Chapter 28/MyResourcesWinApp/Resources/HappyDude.bmp new file mode 100644 index 0000000..3f7a699 Binary files /dev/null and b/Code/Chapter 28/MyResourcesWinApp/Resources/HappyDude.bmp differ diff --git a/Code/Chapter 28/PenCapApp/MainForm.Designer.vb b/Code/Chapter 28/PenCapApp/MainForm.Designer.vb new file mode 100644 index 0000000..32387d2 --- /dev/null +++ b/Code/Chapter 28/PenCapApp/MainForm.Designer.vb @@ -0,0 +1,36 @@ + _ +Partial Class MainForm + 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.SuspendLayout() + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(357, 364) + Me.Name = "MainForm" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Pen Cap App" + Me.ResumeLayout(False) + + End Sub + +End Class diff --git a/Code/Chapter 28/PenCapApp/MainForm.resx b/Code/Chapter 28/PenCapApp/MainForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 28/PenCapApp/MainForm.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/Code/Chapter 28/PenCapApp/MainForm.vb b/Code/Chapter 28/PenCapApp/MainForm.vb new file mode 100644 index 0000000..081df64 --- /dev/null +++ b/Code/Chapter 28/PenCapApp/MainForm.vb @@ -0,0 +1,33 @@ +Option Explicit On +Option Strict On + +Imports System.Drawing.Drawing2D + +Public Class MainForm + Private Sub MainForm_Paint(ByVal sender As System.Object, _ + ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint + Dim g As Graphics = e.Graphics + Dim thePen As Pen = New Pen(Color.Black, 10) + Dim yOffSet As Integer = 10 + ' Get all members of the LineCap enum. + Dim obj As Array = [Enum].GetValues(GetType(LineCap)) + For x As Integer = 0 To obj.Length - 1 + ' Draw a line with a LineCap member. + ' Get next cap and configure pen. + Dim temp As LineCap = CType(obj.GetValue(x), LineCap) + thePen.StartCap = temp + thePen.EndCap = temp + ' Print name of LineCap enum. + g.DrawString(temp.ToString(), New Font("Times New Roman", 10), _ + New SolidBrush(Color.Black), 0, yOffSet) + ' Draw a line with the correct cap. + g.DrawLine(thePen, 100, yOffSet, Width - 50, yOffSet) + yOffSet += 40 + Next + End Sub + + Private Sub MainForm_Resize(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles MyBase.Resize + Invalidate() + End Sub +End Class diff --git a/Code/Chapter 28/PenCapApp/My Project/Application.Designer.vb b/Code/Chapter 28/PenCapApp/My Project/Application.Designer.vb new file mode 100644 index 0000000..84f190f --- /dev/null +++ b/Code/Chapter 28/PenCapApp/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.PenCapApp.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 28/PenCapApp/My Project/Application.myapp b/Code/Chapter 28/PenCapApp/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 28/PenCapApp/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 28/PenCapApp/My Project/AssemblyInfo.vb b/Code/Chapter 28/PenCapApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..a077b90 --- /dev/null +++ b/Code/Chapter 28/PenCapApp/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/Code/Chapter 28/PenCapApp/My Project/Resources.Designer.vb b/Code/Chapter 28/PenCapApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..d766aea --- /dev/null +++ b/Code/Chapter 28/PenCapApp/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("PenCapApp.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/Code/Chapter 28/PenCapApp/My Project/Resources.resx b/Code/Chapter 28/PenCapApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 28/PenCapApp/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/Code/Chapter 28/PenCapApp/My Project/Settings.Designer.vb b/Code/Chapter 28/PenCapApp/My Project/Settings.Designer.vb new file mode 100644 index 0000000..69a4d2d --- /dev/null +++ b/Code/Chapter 28/PenCapApp/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.PenCapApp.My.MySettings + Get + Return Global.PenCapApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 28/PenCapApp/My Project/Settings.settings b/Code/Chapter 28/PenCapApp/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 28/PenCapApp/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 28/PenCapApp/PenCapApp.sln b/Code/Chapter 28/PenCapApp/PenCapApp.sln new file mode 100644 index 0000000..b50c7e4 --- /dev/null +++ b/Code/Chapter 28/PenCapApp/PenCapApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "PenCapApp", "PenCapApp.vbproj", "{FA834229-4205-4BD5-A52F-1F22BF1C9240}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FA834229-4205-4BD5-A52F-1F22BF1C9240}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA834229-4205-4BD5-A52F-1F22BF1C9240}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA834229-4205-4BD5-A52F-1F22BF1C9240}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA834229-4205-4BD5-A52F-1F22BF1C9240}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 28/PenCapApp/PenCapApp.suo b/Code/Chapter 28/PenCapApp/PenCapApp.suo new file mode 100644 index 0000000..9fd2c4c Binary files /dev/null and b/Code/Chapter 28/PenCapApp/PenCapApp.suo differ diff --git a/Code/Chapter 28/PenCapApp/PenCapApp.vbproj b/Code/Chapter 28/PenCapApp/PenCapApp.vbproj new file mode 100644 index 0000000..ff995c9 --- /dev/null +++ b/Code/Chapter 28/PenCapApp/PenCapApp.vbproj @@ -0,0 +1,148 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {FA834229-4205-4BD5-A52F-1F22BF1C9240} + WinExe + PenCapApp.My.MyApplication + PenCapApp + PenCapApp + WindowsForms + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + PenCapApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + PenCapApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + MainForm.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 28/PenCapApp/PenCapApp.vbproj.user b/Code/Chapter 28/PenCapApp/PenCapApp.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 28/PenCapApp/PenCapApp.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 28/ResXWriter/HappyDude.bmp b/Code/Chapter 28/ResXWriter/HappyDude.bmp new file mode 100644 index 0000000..3f7a699 Binary files /dev/null and b/Code/Chapter 28/ResXWriter/HappyDude.bmp differ diff --git a/Code/Chapter 28/ResXWriter/MainForm.Designer.vb b/Code/Chapter 28/ResXWriter/MainForm.Designer.vb new file mode 100644 index 0000000..4e7e342 --- /dev/null +++ b/Code/Chapter 28/ResXWriter/MainForm.Designer.vb @@ -0,0 +1,46 @@ + _ +Partial Class MainForm + 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.btnGenResX = New System.Windows.Forms.Button + Me.SuspendLayout() + ' + 'btnGenResX + ' + Me.btnGenResX.Location = New System.Drawing.Point(12, 29) + Me.btnGenResX.Name = "btnGenResX" + Me.btnGenResX.Size = New System.Drawing.Size(267, 23) + Me.btnGenResX.TabIndex = 1 + Me.btnGenResX.Text = "Generate a *.resx file" + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(292, 86) + Me.Controls.Add(Me.btnGenResX) + Me.Name = "MainForm" + Me.Text = "ResX Writer" + Me.ResumeLayout(False) + + End Sub + Private WithEvents btnGenResX As System.Windows.Forms.Button + +End Class diff --git a/Code/Chapter 28/ResXWriter/MainForm.resx b/Code/Chapter 28/ResXWriter/MainForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 28/ResXWriter/MainForm.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/Code/Chapter 28/ResXWriter/MainForm.vb b/Code/Chapter 28/ResXWriter/MainForm.vb new file mode 100644 index 0000000..d56c250 --- /dev/null +++ b/Code/Chapter 28/ResXWriter/MainForm.vb @@ -0,0 +1,17 @@ +Imports System.Resources + +Public Class MainForm + + Private Sub btnGenResX_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles btnGenResX.Click + ' Make an resx writer & specify the file to write to. + Dim w As ResXResourceWriter = New ResXResourceWriter("C:\ResXForm.resx") + ' Add happy dude & string. + Dim bMap As Bitmap = New Bitmap("happyDude.bmp") + w.AddResource("happyDude", bMap) + w.AddResource("welcomeString", "Hello new resource format!") + ' Commit it. + w.Generate() + w.Close() + End Sub +End Class diff --git a/Code/Chapter 28/ResXWriter/My Project/Application.Designer.vb b/Code/Chapter 28/ResXWriter/My Project/Application.Designer.vb new file mode 100644 index 0000000..88ea91a --- /dev/null +++ b/Code/Chapter 28/ResXWriter/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.ResXWriter.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 28/ResXWriter/My Project/Application.myapp b/Code/Chapter 28/ResXWriter/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 28/ResXWriter/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 28/ResXWriter/My Project/AssemblyInfo.vb b/Code/Chapter 28/ResXWriter/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..2a50ba4 --- /dev/null +++ b/Code/Chapter 28/ResXWriter/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/Code/Chapter 28/ResXWriter/My Project/Resources.Designer.vb b/Code/Chapter 28/ResXWriter/My Project/Resources.Designer.vb new file mode 100644 index 0000000..47bdb08 --- /dev/null +++ b/Code/Chapter 28/ResXWriter/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("ResXWriter.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/Code/Chapter 28/ResXWriter/My Project/Resources.resx b/Code/Chapter 28/ResXWriter/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 28/ResXWriter/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/Code/Chapter 28/ResXWriter/My Project/Settings.Designer.vb b/Code/Chapter 28/ResXWriter/My Project/Settings.Designer.vb new file mode 100644 index 0000000..95ebf1d --- /dev/null +++ b/Code/Chapter 28/ResXWriter/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.ResXWriter.My.MySettings + Get + Return Global.ResXWriter.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 28/ResXWriter/My Project/Settings.settings b/Code/Chapter 28/ResXWriter/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 28/ResXWriter/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 28/ResXWriter/ResXWriter.sln b/Code/Chapter 28/ResXWriter/ResXWriter.sln new file mode 100644 index 0000000..811a1e6 --- /dev/null +++ b/Code/Chapter 28/ResXWriter/ResXWriter.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ResXWriter", "ResXWriter.vbproj", "{E6250875-7F12-4C1F-99B5-908C3472D347}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E6250875-7F12-4C1F-99B5-908C3472D347}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E6250875-7F12-4C1F-99B5-908C3472D347}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E6250875-7F12-4C1F-99B5-908C3472D347}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E6250875-7F12-4C1F-99B5-908C3472D347}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 28/ResXWriter/ResXWriter.suo b/Code/Chapter 28/ResXWriter/ResXWriter.suo new file mode 100644 index 0000000..4e2d683 Binary files /dev/null and b/Code/Chapter 28/ResXWriter/ResXWriter.suo differ diff --git a/Code/Chapter 28/ResXWriter/ResXWriter.vbproj b/Code/Chapter 28/ResXWriter/ResXWriter.vbproj new file mode 100644 index 0000000..3a8918e --- /dev/null +++ b/Code/Chapter 28/ResXWriter/ResXWriter.vbproj @@ -0,0 +1,148 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {E6250875-7F12-4C1F-99B5-908C3472D347} + WinExe + ResXWriter.My.MyApplication + ResXWriter + ResXWriter + WindowsForms + + + 2.0 + + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + ResXWriter.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + ResXWriter.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + MainForm.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + Always + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 28/ResXWriter/ResXWriter.vbproj.user b/Code/Chapter 28/ResXWriter/ResXWriter.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 28/ResXWriter/ResXWriter.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 28/SolidBrushApp/MainForm.Designer.vb b/Code/Chapter 28/SolidBrushApp/MainForm.Designer.vb new file mode 100644 index 0000000..39d0b32 --- /dev/null +++ b/Code/Chapter 28/SolidBrushApp/MainForm.Designer.vb @@ -0,0 +1,36 @@ + _ +Partial Class MainForm + 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.SuspendLayout() + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(292, 266) + Me.Name = "MainForm" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Fun with Brushes" + Me.ResumeLayout(False) + + End Sub + +End Class diff --git a/Code/Chapter 28/SolidBrushApp/MainForm.resx b/Code/Chapter 28/SolidBrushApp/MainForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 28/SolidBrushApp/MainForm.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/Code/Chapter 28/SolidBrushApp/MainForm.vb b/Code/Chapter 28/SolidBrushApp/MainForm.vb new file mode 100644 index 0000000..32a291e --- /dev/null +++ b/Code/Chapter 28/SolidBrushApp/MainForm.vb @@ -0,0 +1,31 @@ +Option Explicit On +Option Strict On + +Public Class MainForm + + Private Sub MainForm_Paint(ByVal sender As System.Object, _ + ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint + Dim g As Graphics = e.Graphics + ' Make a blue SolidBrush. + Dim blueBrush As SolidBrush = New SolidBrush(Color.Blue) + + ' Get a stock brush from the Brushes type. + Dim pen2 As SolidBrush = CType(Brushes.Firebrick, SolidBrush) + + ' Render some shapes with the brushes. + g.FillEllipse(blueBrush, 10, 10, 100, 100) + g.FillPie(Brushes.Black, 150, 10, 120, 150, 90, 80) + + ' Draw a purple polygon as well... + Dim brush3 As SolidBrush = New SolidBrush(Color.Purple) + g.FillPolygon(brush3, New Point() {New Point(30, 140), _ + New Point(265, 200), New Point(100, 225), _ + New Point(190, 190), New Point(50, 330), _ + New Point(20, 180)}) + + ' And a rectangle with some text... + Dim r As Rectangle = New Rectangle(150, 10, 130, 60) + g.FillRectangle(Brushes.Blue, r) + g.DrawString("Hello out there...How are ya?", New Font("Arial", 12), Brushes.White, r) + End Sub +End Class diff --git a/Code/Chapter 28/SolidBrushApp/My Project/Application.Designer.vb b/Code/Chapter 28/SolidBrushApp/My Project/Application.Designer.vb new file mode 100644 index 0000000..0cc7c74 --- /dev/null +++ b/Code/Chapter 28/SolidBrushApp/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SolidBrushApp.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 28/SolidBrushApp/My Project/Application.myapp b/Code/Chapter 28/SolidBrushApp/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 28/SolidBrushApp/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 28/SolidBrushApp/My Project/AssemblyInfo.vb b/Code/Chapter 28/SolidBrushApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..bb6b4a3 --- /dev/null +++ b/Code/Chapter 28/SolidBrushApp/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/Code/Chapter 28/SolidBrushApp/My Project/Resources.Designer.vb b/Code/Chapter 28/SolidBrushApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..bc9f751 --- /dev/null +++ b/Code/Chapter 28/SolidBrushApp/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("SolidBrushApp.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/Code/Chapter 28/SolidBrushApp/My Project/Resources.resx b/Code/Chapter 28/SolidBrushApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 28/SolidBrushApp/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/Code/Chapter 28/SolidBrushApp/My Project/Settings.Designer.vb b/Code/Chapter 28/SolidBrushApp/My Project/Settings.Designer.vb new file mode 100644 index 0000000..445983d --- /dev/null +++ b/Code/Chapter 28/SolidBrushApp/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SolidBrushApp.My.MySettings + Get + Return Global.SolidBrushApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 28/SolidBrushApp/My Project/Settings.settings b/Code/Chapter 28/SolidBrushApp/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 28/SolidBrushApp/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 28/SolidBrushApp/SolidBrushApp.sln b/Code/Chapter 28/SolidBrushApp/SolidBrushApp.sln new file mode 100644 index 0000000..4968449 --- /dev/null +++ b/Code/Chapter 28/SolidBrushApp/SolidBrushApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SolidBrushApp", "SolidBrushApp.vbproj", "{1D93C41F-FC4B-43B3-A345-4F39BC0039CC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1D93C41F-FC4B-43B3-A345-4F39BC0039CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1D93C41F-FC4B-43B3-A345-4F39BC0039CC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1D93C41F-FC4B-43B3-A345-4F39BC0039CC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1D93C41F-FC4B-43B3-A345-4F39BC0039CC}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 28/SolidBrushApp/SolidBrushApp.suo b/Code/Chapter 28/SolidBrushApp/SolidBrushApp.suo new file mode 100644 index 0000000..2206a1a Binary files /dev/null and b/Code/Chapter 28/SolidBrushApp/SolidBrushApp.suo differ diff --git a/Code/Chapter 28/SolidBrushApp/SolidBrushApp.vbproj b/Code/Chapter 28/SolidBrushApp/SolidBrushApp.vbproj new file mode 100644 index 0000000..3d0603b --- /dev/null +++ b/Code/Chapter 28/SolidBrushApp/SolidBrushApp.vbproj @@ -0,0 +1,148 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {1D93C41F-FC4B-43B3-A345-4F39BC0039CC} + WinExe + SolidBrushApp.My.MyApplication + SolidBrushApp + SolidBrushApp + WindowsForms + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + SolidBrushApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SolidBrushApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + MainForm.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 28/SolidBrushApp/SolidBrushApp.vbproj.user b/Code/Chapter 28/SolidBrushApp/SolidBrushApp.vbproj.user new file mode 100644 index 0000000..fdcb14e --- /dev/null +++ b/Code/Chapter 28/SolidBrushApp/SolidBrushApp.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ShowAllFiles + + \ No newline at end of file diff --git a/Code/Chapter 28/SwellingFontApp/MainForm.Designer.vb b/Code/Chapter 28/SwellingFontApp/MainForm.Designer.vb new file mode 100644 index 0000000..fa41741 --- /dev/null +++ b/Code/Chapter 28/SwellingFontApp/MainForm.Designer.vb @@ -0,0 +1,115 @@ + _ +Partial Class MainForm + 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.timesToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.arialToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.listInstalledFontsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.wingDingsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.configureToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem + Me.swellToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.fontFaceToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.menuStrip1 = New System.Windows.Forms.MenuStrip + Me.swellTimer = New System.Windows.Forms.Timer(Me.components) + Me.menuStrip1.SuspendLayout() + Me.SuspendLayout() + ' + 'timesToolStripMenuItem + ' + Me.timesToolStripMenuItem.Name = "timesToolStripMenuItem" + Me.timesToolStripMenuItem.Size = New System.Drawing.Size(172, 22) + Me.timesToolStripMenuItem.Text = "&Times New Roman" + ' + 'arialToolStripMenuItem + ' + Me.arialToolStripMenuItem.Name = "arialToolStripMenuItem" + Me.arialToolStripMenuItem.Size = New System.Drawing.Size(172, 22) + Me.arialToolStripMenuItem.Text = "&Arial" + ' + 'listInstalledFontsToolStripMenuItem + ' + Me.listInstalledFontsToolStripMenuItem.Name = "listInstalledFontsToolStripMenuItem" + Me.listInstalledFontsToolStripMenuItem.Size = New System.Drawing.Size(175, 22) + Me.listInstalledFontsToolStripMenuItem.Text = "&List Installed Fonts" + ' + 'wingDingsToolStripMenuItem + ' + Me.wingDingsToolStripMenuItem.Name = "wingDingsToolStripMenuItem" + Me.wingDingsToolStripMenuItem.Size = New System.Drawing.Size(172, 22) + Me.wingDingsToolStripMenuItem.Text = "&WingDings" + ' + 'configureToolStripMenuItem1 + ' + Me.configureToolStripMenuItem1.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.swellToolStripMenuItem, Me.fontFaceToolStripMenuItem, Me.listInstalledFontsToolStripMenuItem}) + Me.configureToolStripMenuItem1.Name = "configureToolStripMenuItem1" + Me.configureToolStripMenuItem1.Size = New System.Drawing.Size(66, 20) + Me.configureToolStripMenuItem1.Text = "&Configure" + ' + 'swellToolStripMenuItem + ' + Me.swellToolStripMenuItem.Name = "swellToolStripMenuItem" + Me.swellToolStripMenuItem.Size = New System.Drawing.Size(175, 22) + Me.swellToolStripMenuItem.Text = "&Swell?" + ' + 'fontFaceToolStripMenuItem + ' + Me.fontFaceToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.arialToolStripMenuItem, Me.timesToolStripMenuItem, Me.wingDingsToolStripMenuItem}) + Me.fontFaceToolStripMenuItem.Name = "fontFaceToolStripMenuItem" + Me.fontFaceToolStripMenuItem.Size = New System.Drawing.Size(175, 22) + Me.fontFaceToolStripMenuItem.Text = "&Font Face" + ' + 'menuStrip1 + ' + Me.menuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.configureToolStripMenuItem1}) + Me.menuStrip1.Location = New System.Drawing.Point(0, 0) + Me.menuStrip1.Name = "menuStrip1" + Me.menuStrip1.Size = New System.Drawing.Size(374, 24) + Me.menuStrip1.TabIndex = 1 + Me.menuStrip1.Text = "menuStrip1" + ' + 'swellTimer + ' + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(374, 162) + Me.Controls.Add(Me.menuStrip1) + Me.Name = "MainForm" + Me.Text = "Swelling Font App" + Me.menuStrip1.ResumeLayout(False) + Me.menuStrip1.PerformLayout() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Private WithEvents timesToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Private WithEvents arialToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Private WithEvents listInstalledFontsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Private WithEvents wingDingsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Private WithEvents configureToolStripMenuItem1 As System.Windows.Forms.ToolStripMenuItem + Private WithEvents swellToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Private WithEvents fontFaceToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Private WithEvents menuStrip1 As System.Windows.Forms.MenuStrip + Friend WithEvents swellTimer As System.Windows.Forms.Timer + +End Class diff --git a/Code/Chapter 28/SwellingFontApp/MainForm.resx b/Code/Chapter 28/SwellingFontApp/MainForm.resx new file mode 100644 index 0000000..ed0db65 --- /dev/null +++ b/Code/Chapter 28/SwellingFontApp/MainForm.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 126, 17 + + \ No newline at end of file diff --git a/Code/Chapter 28/SwellingFontApp/MainForm.vb b/Code/Chapter 28/SwellingFontApp/MainForm.vb new file mode 100644 index 0000000..87b4ac4 --- /dev/null +++ b/Code/Chapter 28/SwellingFontApp/MainForm.vb @@ -0,0 +1,94 @@ +Option Explicit On +Option Strict On + +Imports System.Drawing.Text + +Public Class MainForm + Private swellValue As Integer + Private strFontFace As String = "WingDings" + Private installedFonts As String + + Sub New() + ' This call is required by the Windows Form Designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call. + BackColor = Color.Honeydew + CenterToScreen() + ' Configure the Timer. + swellTimer.Enabled = True + swellTimer.Interval = 100 + End Sub + +#Region "Event handlers" + Private Sub swellToolStripMenuItem_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles swellToolStripMenuItem.Click + swellTimer.Enabled = Not swellTimer.Enabled + End Sub + + Private Sub arialToolStripMenuItem_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles arialToolStripMenuItem.Click + strFontFace = "Arial" + Invalidate() + End Sub + + Private Sub timesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timesToolStripMenuItem.Click + strFontFace = "Times New Roman" + Invalidate() + End Sub + + Private Sub wingDingsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles wingDingsToolStripMenuItem.Click + strFontFace = "WingDings" + Invalidate() + End Sub + + Private Sub listInstalledFontsToolStripMenuItem_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles listInstalledFontsToolStripMenuItem.Click + Dim fonts As InstalledFontCollection = New InstalledFontCollection() + For i As Integer = 0 To fonts.Families.Length - 1 + installedFonts &= fonts.Families(i).Name & " " + Next + ' This time, we need to invalidate the entire client area, + ' as we will paint the installedFonts string on the lower half + ' of the client rectangle. + Invalidate() + End Sub + + Private Sub swellTimer_Tick(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles swellTimer.Tick + ' Increase current swellValue by 5. + swellValue += 5 + ' If this value is greater than or equal to 50, reset to zero. + If swellValue >= 50 Then + swellValue = 0 + End If + ' Just invalidate the 'minimal dirty rectangle to help reduce flicker. + Invalidate(New Rectangle(0, 0, ClientRectangle.Width, 100)) + End Sub + + Private Sub MainForm_Paint(ByVal sender As System.Object, _ + ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint + Dim g As Graphics = e.Graphics + Dim theFont As Font = New Font(strFontFace, 12 + swellValue) + Dim message As String = "Hello GDI+" + + ' Display message in the center of the window! + Dim windowCenter As Single = CSng(Me.DisplayRectangle.Width / 2) + Dim stringSize As SizeF = e.Graphics.MeasureString(message, theFont) + Dim startPos As Single = windowCenter - (stringSize.Width / 2) + g.DrawString(message, theFont, Brushes.Blue, startPos, 10) + + ' Show installed fonts in the rectangle below the swell area. + Dim myRect As Rectangle = New Rectangle(0, 100, ClientRectangle.Width, ClientRectangle.Height) + ' Paint this area of the Form black. + g.FillRectangle(New SolidBrush(Color.Black), myRect) + g.DrawString(installedFonts, New Font("Arial", 12), Brushes.White, myRect) + End Sub + + Private Sub MainForm_Resize(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles MyBase.Resize + Invalidate() + End Sub +#End Region + +End Class diff --git a/Code/Chapter 28/SwellingFontApp/My Project/Application.Designer.vb b/Code/Chapter 28/SwellingFontApp/My Project/Application.Designer.vb new file mode 100644 index 0000000..402245f --- /dev/null +++ b/Code/Chapter 28/SwellingFontApp/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SwellingFontApp.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 28/SwellingFontApp/My Project/Application.myapp b/Code/Chapter 28/SwellingFontApp/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 28/SwellingFontApp/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 28/SwellingFontApp/My Project/AssemblyInfo.vb b/Code/Chapter 28/SwellingFontApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..8b1dd81 --- /dev/null +++ b/Code/Chapter 28/SwellingFontApp/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/Code/Chapter 28/SwellingFontApp/My Project/Resources.Designer.vb b/Code/Chapter 28/SwellingFontApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..1ce0620 --- /dev/null +++ b/Code/Chapter 28/SwellingFontApp/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("SwellingFontApp.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/Code/Chapter 28/SwellingFontApp/My Project/Resources.resx b/Code/Chapter 28/SwellingFontApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 28/SwellingFontApp/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/Code/Chapter 28/SwellingFontApp/My Project/Settings.Designer.vb b/Code/Chapter 28/SwellingFontApp/My Project/Settings.Designer.vb new file mode 100644 index 0000000..39dbd0e --- /dev/null +++ b/Code/Chapter 28/SwellingFontApp/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SwellingFontApp.My.MySettings + Get + Return Global.SwellingFontApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 28/SwellingFontApp/My Project/Settings.settings b/Code/Chapter 28/SwellingFontApp/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 28/SwellingFontApp/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 28/SwellingFontApp/SwellingFontApp.sln b/Code/Chapter 28/SwellingFontApp/SwellingFontApp.sln new file mode 100644 index 0000000..af26597 --- /dev/null +++ b/Code/Chapter 28/SwellingFontApp/SwellingFontApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SwellingFontApp", "SwellingFontApp.vbproj", "{C03CF165-9DBC-4F2D-B778-6DAA512ACB44}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C03CF165-9DBC-4F2D-B778-6DAA512ACB44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C03CF165-9DBC-4F2D-B778-6DAA512ACB44}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C03CF165-9DBC-4F2D-B778-6DAA512ACB44}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C03CF165-9DBC-4F2D-B778-6DAA512ACB44}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 28/SwellingFontApp/SwellingFontApp.suo b/Code/Chapter 28/SwellingFontApp/SwellingFontApp.suo new file mode 100644 index 0000000..dcf068f Binary files /dev/null and b/Code/Chapter 28/SwellingFontApp/SwellingFontApp.suo differ diff --git a/Code/Chapter 28/SwellingFontApp/SwellingFontApp.vbproj b/Code/Chapter 28/SwellingFontApp/SwellingFontApp.vbproj new file mode 100644 index 0000000..7ac4008 --- /dev/null +++ b/Code/Chapter 28/SwellingFontApp/SwellingFontApp.vbproj @@ -0,0 +1,148 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {C03CF165-9DBC-4F2D-B778-6DAA512ACB44} + WinExe + SwellingFontApp.My.MyApplication + SwellingFontApp + SwellingFontApp + WindowsForms + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + SwellingFontApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SwellingFontApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + MainForm.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 28/SwellingFontApp/SwellingFontApp.vbproj.user b/Code/Chapter 28/SwellingFontApp/SwellingFontApp.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 28/SwellingFontApp/SwellingFontApp.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 28/TexturedBrushes/Clouds.bmp b/Code/Chapter 28/TexturedBrushes/Clouds.bmp new file mode 100644 index 0000000..2964f10 Binary files /dev/null and b/Code/Chapter 28/TexturedBrushes/Clouds.bmp differ diff --git a/Code/Chapter 28/TexturedBrushes/MainForm.Designer.vb b/Code/Chapter 28/TexturedBrushes/MainForm.Designer.vb new file mode 100644 index 0000000..dcf538b --- /dev/null +++ b/Code/Chapter 28/TexturedBrushes/MainForm.Designer.vb @@ -0,0 +1,36 @@ + _ +Partial Class MainForm + 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.SuspendLayout() + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(540, 334) + Me.Name = "MainForm" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Bitmap brushes!" + Me.ResumeLayout(False) + + End Sub + +End Class diff --git a/Code/Chapter 28/TexturedBrushes/MainForm.resx b/Code/Chapter 28/TexturedBrushes/MainForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 28/TexturedBrushes/MainForm.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/Code/Chapter 28/TexturedBrushes/MainForm.vb b/Code/Chapter 28/TexturedBrushes/MainForm.vb new file mode 100644 index 0000000..2b58c5a --- /dev/null +++ b/Code/Chapter 28/TexturedBrushes/MainForm.vb @@ -0,0 +1,46 @@ +Option Explicit On +Option Strict On + +Public Class MainForm + Private texturedTextBrush As Brush + Private texturedBGroundBrush As Brush + + Sub New() + ' This call is required by the Windows Form Designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call. + CenterToScreen() + + ' Load images brushes. + Try + Dim bGroundBrushImage As Image = New Bitmap("Clouds.bmp") + texturedBGroundBrush = New TextureBrush(bGroundBrushImage) + Dim textBrushImage As Image = New Bitmap("Soap Bubbles.bmp") + texturedTextBrush = New TextureBrush(textBrushImage) + Catch + MessageBox.Show("Can't find bitmap files!") + Application.Exit() + End Try + End Sub + +#Region "Event Handlers" + Private Sub MainForm_Paint(ByVal sender As System.Object, _ + ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint + Dim g As Graphics = e.Graphics + Dim r As Rectangle = ClientRectangle + + ' Paint the clouds on the client area. + g.FillRectangle(texturedBGroundBrush, r) + + ' Some big bold text with a textured brush. + g.DrawString("Bitmaps as brushes! Way cool...", _ + New Font("Arial", 50, FontStyle.Bold Or FontStyle.Italic), texturedTextBrush, r) + End Sub + + Private Sub MainForm_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize + Invalidate() + End Sub +#End Region + +End Class diff --git a/Code/Chapter 28/TexturedBrushes/My Project/Application.Designer.vb b/Code/Chapter 28/TexturedBrushes/My Project/Application.Designer.vb new file mode 100644 index 0000000..153d7cc --- /dev/null +++ b/Code/Chapter 28/TexturedBrushes/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.TexturedBrushes.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 28/TexturedBrushes/My Project/Application.myapp b/Code/Chapter 28/TexturedBrushes/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 28/TexturedBrushes/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 28/TexturedBrushes/My Project/AssemblyInfo.vb b/Code/Chapter 28/TexturedBrushes/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..c24354e --- /dev/null +++ b/Code/Chapter 28/TexturedBrushes/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/Code/Chapter 28/TexturedBrushes/My Project/Resources.Designer.vb b/Code/Chapter 28/TexturedBrushes/My Project/Resources.Designer.vb new file mode 100644 index 0000000..6462fcd --- /dev/null +++ b/Code/Chapter 28/TexturedBrushes/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("TexturedBrushes.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/Code/Chapter 28/TexturedBrushes/My Project/Resources.resx b/Code/Chapter 28/TexturedBrushes/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 28/TexturedBrushes/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/Code/Chapter 28/TexturedBrushes/My Project/Settings.Designer.vb b/Code/Chapter 28/TexturedBrushes/My Project/Settings.Designer.vb new file mode 100644 index 0000000..1ea872f --- /dev/null +++ b/Code/Chapter 28/TexturedBrushes/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.TexturedBrushes.My.MySettings + Get + Return Global.TexturedBrushes.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 28/TexturedBrushes/My Project/Settings.settings b/Code/Chapter 28/TexturedBrushes/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 28/TexturedBrushes/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 28/TexturedBrushes/Soap Bubbles.bmp b/Code/Chapter 28/TexturedBrushes/Soap Bubbles.bmp new file mode 100644 index 0000000..f4e47bb Binary files /dev/null and b/Code/Chapter 28/TexturedBrushes/Soap Bubbles.bmp differ diff --git a/Code/Chapter 28/TexturedBrushes/TexturedBrushes.sln b/Code/Chapter 28/TexturedBrushes/TexturedBrushes.sln new file mode 100644 index 0000000..7ff02b9 --- /dev/null +++ b/Code/Chapter 28/TexturedBrushes/TexturedBrushes.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TexturedBrushes", "TexturedBrushes.vbproj", "{43F65DD5-34F9-47D0-A439-2018F561899A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {43F65DD5-34F9-47D0-A439-2018F561899A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {43F65DD5-34F9-47D0-A439-2018F561899A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {43F65DD5-34F9-47D0-A439-2018F561899A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {43F65DD5-34F9-47D0-A439-2018F561899A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 28/TexturedBrushes/TexturedBrushes.suo b/Code/Chapter 28/TexturedBrushes/TexturedBrushes.suo new file mode 100644 index 0000000..bf89d05 Binary files /dev/null and b/Code/Chapter 28/TexturedBrushes/TexturedBrushes.suo differ diff --git a/Code/Chapter 28/TexturedBrushes/TexturedBrushes.vbproj b/Code/Chapter 28/TexturedBrushes/TexturedBrushes.vbproj new file mode 100644 index 0000000..63467e2 --- /dev/null +++ b/Code/Chapter 28/TexturedBrushes/TexturedBrushes.vbproj @@ -0,0 +1,156 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {43F65DD5-34F9-47D0-A439-2018F561899A} + WinExe + TexturedBrushes.My.MyApplication + TexturedBrushes + TexturedBrushes + WindowsForms + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + TexturedBrushes.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + TexturedBrushes.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + MainForm.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + Always + + + Always + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 28/TexturedBrushes/TexturedBrushes.vbproj.user b/Code/Chapter 28/TexturedBrushes/TexturedBrushes.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 28/TexturedBrushes/TexturedBrushes.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 29/AnchoringControls/AnchoringControls.sln b/Code/Chapter 29/AnchoringControls/AnchoringControls.sln new file mode 100644 index 0000000..32aba56 --- /dev/null +++ b/Code/Chapter 29/AnchoringControls/AnchoringControls.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AnchoringControls", "AnchoringControls.vbproj", "{ECBE7544-B732-42B9-AD36-178BAACC4770}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {ECBE7544-B732-42B9-AD36-178BAACC4770}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ECBE7544-B732-42B9-AD36-178BAACC4770}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ECBE7544-B732-42B9-AD36-178BAACC4770}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ECBE7544-B732-42B9-AD36-178BAACC4770}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 29/AnchoringControls/AnchoringControls.suo b/Code/Chapter 29/AnchoringControls/AnchoringControls.suo new file mode 100644 index 0000000..b028d86 Binary files /dev/null and b/Code/Chapter 29/AnchoringControls/AnchoringControls.suo differ diff --git a/Code/Chapter 29/AnchoringControls/AnchoringControls.vbproj b/Code/Chapter 29/AnchoringControls/AnchoringControls.vbproj new file mode 100644 index 0000000..12563c4 --- /dev/null +++ b/Code/Chapter 29/AnchoringControls/AnchoringControls.vbproj @@ -0,0 +1,148 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {ECBE7544-B732-42B9-AD36-178BAACC4770} + WinExe + AnchoringControls.My.MyApplication + AnchoringControls + AnchoringControls + WindowsForms + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + AnchoringControls.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + AnchoringControls.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + MainForm.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 29/AnchoringControls/AnchoringControls.vbproj.user b/Code/Chapter 29/AnchoringControls/AnchoringControls.vbproj.user new file mode 100644 index 0000000..1659b79 --- /dev/null +++ b/Code/Chapter 29/AnchoringControls/AnchoringControls.vbproj.user @@ -0,0 +1,17 @@ + + + ShowAllFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 29/AnchoringControls/MainForm.Designer.vb b/Code/Chapter 29/AnchoringControls/MainForm.Designer.vb new file mode 100644 index 0000000..8e270be --- /dev/null +++ b/Code/Chapter 29/AnchoringControls/MainForm.Designer.vb @@ -0,0 +1,175 @@ + _ +Partial Class MainForm + 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.ancBotLeft = New System.Windows.Forms.MenuItem + Me.ancBotRight = New System.Windows.Forms.MenuItem + Me.ancRight = New System.Windows.Forms.MenuItem + Me.ancTopRight = New System.Windows.Forms.MenuItem + Me.mnuDock = New System.Windows.Forms.MenuItem + Me.dockTop = New System.Windows.Forms.MenuItem + Me.dockBottom = New System.Windows.Forms.MenuItem + Me.dockLeft = New System.Windows.Forms.MenuItem + Me.dockRight = New System.Windows.Forms.MenuItem + Me.dockFill = New System.Windows.Forms.MenuItem + Me.dockNone = New System.Windows.Forms.MenuItem + Me.btnTheButton = New System.Windows.Forms.Button + Me.ancBottom = New System.Windows.Forms.MenuItem + Me.ancNone = New System.Windows.Forms.MenuItem + Me.ancTopLeft = New System.Windows.Forms.MenuItem + Me.ancTop = New System.Windows.Forms.MenuItem + Me.mnuAnchor = New System.Windows.Forms.MenuItem + Me.ancLeft = New System.Windows.Forms.MenuItem + Me.mnuMainMenu = New System.Windows.Forms.MainMenu(Me.components) + Me.SuspendLayout() + ' + 'ancBotLeft + ' + Me.ancBotLeft.Index = 7 + Me.ancBotLeft.Text = "BottomLeft" + ' + 'ancBotRight + ' + Me.ancBotRight.Index = 8 + Me.ancBotRight.Text = "BottomRight" + ' + 'ancRight + ' + Me.ancRight.Index = 3 + Me.ancRight.Text = "Right" + ' + 'ancTopRight + ' + Me.ancTopRight.Index = 6 + Me.ancTopRight.Text = "TopRight" + ' + 'mnuDock + ' + Me.mnuDock.Index = 1 + Me.mnuDock.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.dockTop, Me.dockBottom, Me.dockLeft, Me.dockRight, Me.dockFill, Me.dockNone}) + Me.mnuDock.Text = "Dock Value" + ' + 'dockTop + ' + Me.dockTop.Index = 0 + Me.dockTop.Text = "Top" + ' + 'dockBottom + ' + Me.dockBottom.Index = 1 + Me.dockBottom.Text = "Bottom" + ' + 'dockLeft + ' + Me.dockLeft.Index = 2 + Me.dockLeft.Text = "Left" + ' + 'dockRight + ' + Me.dockRight.Index = 3 + Me.dockRight.Text = "Right" + ' + 'dockFill + ' + Me.dockFill.Index = 4 + Me.dockFill.Text = "Fill" + ' + 'dockNone + ' + Me.dockNone.Index = 5 + Me.dockNone.Text = "None" + ' + 'btnTheButton + ' + Me.btnTheButton.Location = New System.Drawing.Point(169, 98) + Me.btnTheButton.Name = "btnTheButton" + Me.btnTheButton.Size = New System.Drawing.Size(120, 40) + Me.btnTheButton.TabIndex = 1 + Me.btnTheButton.Text = "The Button" + ' + 'ancBottom + ' + Me.ancBottom.Index = 2 + Me.ancBottom.Text = "Bottom" + ' + 'ancNone + ' + Me.ancNone.Index = 4 + Me.ancNone.Text = "None" + ' + 'ancTopLeft + ' + Me.ancTopLeft.Index = 5 + Me.ancTopLeft.Text = "TopLeft" + ' + 'ancTop + ' + Me.ancTop.Index = 0 + Me.ancTop.Text = "Top" + ' + 'mnuAnchor + ' + Me.mnuAnchor.Index = 0 + Me.mnuAnchor.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.ancTop, Me.ancLeft, Me.ancBottom, Me.ancRight, Me.ancNone, Me.ancTopLeft, Me.ancTopRight, Me.ancBotLeft, Me.ancBotRight}) + Me.mnuAnchor.Text = "Anchor Value" + ' + 'ancLeft + ' + Me.ancLeft.Index = 1 + Me.ancLeft.Text = "Left" + ' + 'mnuMainMenu + ' + Me.mnuMainMenu.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuAnchor, Me.mnuDock}) + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(459, 237) + Me.Controls.Add(Me.btnTheButton) + Me.Menu = Me.mnuMainMenu + Me.Name = "MainForm" + Me.Text = "Anchoring and Docking Controls" + Me.ResumeLayout(False) + + End Sub + Private WithEvents ancBotLeft As System.Windows.Forms.MenuItem + Private WithEvents ancBotRight As System.Windows.Forms.MenuItem + Private WithEvents ancRight As System.Windows.Forms.MenuItem + Private WithEvents ancTopRight As System.Windows.Forms.MenuItem + Private WithEvents mnuDock As System.Windows.Forms.MenuItem + Private WithEvents dockTop As System.Windows.Forms.MenuItem + Private WithEvents dockBottom As System.Windows.Forms.MenuItem + Private WithEvents dockLeft As System.Windows.Forms.MenuItem + Private WithEvents dockRight As System.Windows.Forms.MenuItem + Private WithEvents dockFill As System.Windows.Forms.MenuItem + Private WithEvents dockNone As System.Windows.Forms.MenuItem + Private WithEvents btnTheButton As System.Windows.Forms.Button + Private WithEvents ancBottom As System.Windows.Forms.MenuItem + Private WithEvents ancNone As System.Windows.Forms.MenuItem + Private WithEvents ancTopLeft As System.Windows.Forms.MenuItem + Private WithEvents ancTop As System.Windows.Forms.MenuItem + Private WithEvents mnuAnchor As System.Windows.Forms.MenuItem + Private WithEvents ancLeft As System.Windows.Forms.MenuItem + Private WithEvents mnuMainMenu As System.Windows.Forms.MainMenu + +End Class diff --git a/Code/Chapter 29/AnchoringControls/MainForm.resx b/Code/Chapter 29/AnchoringControls/MainForm.resx new file mode 100644 index 0000000..a6a1dba --- /dev/null +++ b/Code/Chapter 29/AnchoringControls/MainForm.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/Code/Chapter 29/AnchoringControls/MainForm.vb b/Code/Chapter 29/AnchoringControls/MainForm.vb new file mode 100644 index 0000000..f2d442f --- /dev/null +++ b/Code/Chapter 29/AnchoringControls/MainForm.vb @@ -0,0 +1,83 @@ +Option Explicit On +Option Strict On + +Public Class MainForm + +#Region "Menu handlers" + Private Sub ancTop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ancTop.Click + btnTheButton.Anchor = AnchorStyles.Top + btnTheButton.Text = "Anchor: " + btnTheButton.Anchor.ToString() + "" & Chr(10) & "Dock: " + btnTheButton.Dock.ToString() + End Sub + + Private Sub ancLeft_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ancLeft.Click + btnTheButton.Anchor = AnchorStyles.Left + btnTheButton.Text = "Anchor: " + btnTheButton.Anchor.ToString() + "" & Chr(10) & "Dock: " + btnTheButton.Dock.ToString() + End Sub + + Private Sub ancBottom_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ancBottom.Click + btnTheButton.Anchor = AnchorStyles.Bottom + btnTheButton.Text = "Anchor: " + btnTheButton.Anchor.ToString() + "" & Chr(10) & "Dock: " + btnTheButton.Dock.ToString() + End Sub + + Private Sub ancRight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ancRight.Click + btnTheButton.Anchor = AnchorStyles.Right + btnTheButton.Text = "Anchor: " + btnTheButton.Anchor.ToString() + "" & Chr(10) & "Dock: " + btnTheButton.Dock.ToString() + End Sub + + Private Sub ancNone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ancNone.Click + btnTheButton.Anchor = AnchorStyles.None + btnTheButton.Text = "Anchor: " + btnTheButton.Anchor.ToString() + "" & Chr(10) & "Dock: " + btnTheButton.Dock.ToString() + End Sub + + Private Sub ancTopLeft_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ancTopLeft.Click + btnTheButton.Anchor = AnchorStyles.Top Or AnchorStyles.Left + btnTheButton.Text = "Anchor: " + btnTheButton.Anchor.ToString() + "" & Chr(10) & "Dock: " + btnTheButton.Dock.ToString() + End Sub + + Private Sub ancTopRight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ancTopRight.Click + btnTheButton.Anchor = AnchorStyles.Top Or AnchorStyles.Right + btnTheButton.Text = "Anchor: " + btnTheButton.Anchor.ToString() + "" & Chr(10) & "Dock: " + btnTheButton.Dock.ToString() + End Sub + + Private Sub ancBotLeft_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ancBotLeft.Click + btnTheButton.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left + btnTheButton.Text = "Anchor: " + btnTheButton.Anchor.ToString() + "" & Chr(10) & "Dock: " + btnTheButton.Dock.ToString() + End Sub + + Private Sub ancBotRight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ancBotRight.Click + btnTheButton.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right + btnTheButton.Text = "Anchor: " + btnTheButton.Anchor.ToString() + "" & Chr(10) & "Dock: " + btnTheButton.Dock.ToString() + End Sub + + Private Sub dockTop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dockTop.Click + btnTheButton.Dock = DockStyle.Top + btnTheButton.Text = "Anchor: " + btnTheButton.Anchor.ToString() + "" & Chr(10) & "Dock: " + btnTheButton.Dock.ToString() + End Sub + + Private Sub dockBottom_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dockBottom.Click + btnTheButton.Dock = DockStyle.Bottom + btnTheButton.Text = "Anchor: " + btnTheButton.Anchor.ToString() + "" & Chr(10) & "Dock: " + btnTheButton.Dock.ToString() + End Sub + + Private Sub dockLeft_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dockLeft.Click + btnTheButton.Dock = DockStyle.Left + btnTheButton.Text = "Anchor: " + btnTheButton.Anchor.ToString() + "" & Chr(10) & "Dock: " + btnTheButton.Dock.ToString() + End Sub + + Private Sub dockRight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dockRight.Click + btnTheButton.Dock = DockStyle.Right + btnTheButton.Text = "Anchor: " + btnTheButton.Anchor.ToString() + "" & Chr(10) & "Dock: " + btnTheButton.Dock.ToString() + End Sub + + Private Sub dockFill_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dockFill.Click + btnTheButton.Dock = DockStyle.Fill + btnTheButton.Text = "Anchor: " + btnTheButton.Anchor.ToString() + "" & Chr(10) & "Dock: " + btnTheButton.Dock.ToString() + End Sub + + Private Sub dockNone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dockNone.Click + btnTheButton.Dock = DockStyle.None + btnTheButton.Text = "Anchor: " + btnTheButton.Anchor.ToString() + "" & Chr(10) & "Dock: " + btnTheButton.Dock.ToString() + End Sub +#End Region + +End Class diff --git a/Code/Chapter 29/AnchoringControls/My Project/Application.Designer.vb b/Code/Chapter 29/AnchoringControls/My Project/Application.Designer.vb new file mode 100644 index 0000000..10d73f6 --- /dev/null +++ b/Code/Chapter 29/AnchoringControls/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.AnchoringControls.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 29/AnchoringControls/My Project/Application.myapp b/Code/Chapter 29/AnchoringControls/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 29/AnchoringControls/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 29/AnchoringControls/My Project/AssemblyInfo.vb b/Code/Chapter 29/AnchoringControls/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..dbba0fe --- /dev/null +++ b/Code/Chapter 29/AnchoringControls/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/Code/Chapter 29/AnchoringControls/My Project/Resources.Designer.vb b/Code/Chapter 29/AnchoringControls/My Project/Resources.Designer.vb new file mode 100644 index 0000000..07f30f4 --- /dev/null +++ b/Code/Chapter 29/AnchoringControls/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("AnchoringControls.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/Code/Chapter 29/AnchoringControls/My Project/Resources.resx b/Code/Chapter 29/AnchoringControls/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 29/AnchoringControls/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/Code/Chapter 29/AnchoringControls/My Project/Settings.Designer.vb b/Code/Chapter 29/AnchoringControls/My Project/Settings.Designer.vb new file mode 100644 index 0000000..f18eca3 --- /dev/null +++ b/Code/Chapter 29/AnchoringControls/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.AnchoringControls.My.MySettings + Get + Return Global.AnchoringControls.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 29/AnchoringControls/My Project/Settings.settings b/Code/Chapter 29/AnchoringControls/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 29/AnchoringControls/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 29/Buttons/Buttons.sln b/Code/Chapter 29/Buttons/Buttons.sln new file mode 100644 index 0000000..ea31000 --- /dev/null +++ b/Code/Chapter 29/Buttons/Buttons.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Buttons", "Buttons.vbproj", "{1C23C51F-6507-462E-8885-779A240BD245}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1C23C51F-6507-462E-8885-779A240BD245}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1C23C51F-6507-462E-8885-779A240BD245}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1C23C51F-6507-462E-8885-779A240BD245}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1C23C51F-6507-462E-8885-779A240BD245}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 29/Buttons/Buttons.suo b/Code/Chapter 29/Buttons/Buttons.suo new file mode 100644 index 0000000..6894c28 Binary files /dev/null and b/Code/Chapter 29/Buttons/Buttons.suo differ diff --git a/Code/Chapter 29/Buttons/Buttons.vbproj b/Code/Chapter 29/Buttons/Buttons.vbproj new file mode 100644 index 0000000..baacee5 --- /dev/null +++ b/Code/Chapter 29/Buttons/Buttons.vbproj @@ -0,0 +1,148 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {1C23C51F-6507-462E-8885-779A240BD245} + WinExe + Buttons.My.MyApplication + Buttons + Buttons + WindowsForms + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + Buttons.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + Buttons.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + MainForm.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 29/Buttons/Buttons.vbproj.user b/Code/Chapter 29/Buttons/Buttons.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 29/Buttons/Buttons.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 29/Buttons/MainForm.Designer.vb b/Code/Chapter 29/Buttons/MainForm.Designer.vb new file mode 100644 index 0000000..bbfbd8e --- /dev/null +++ b/Code/Chapter 29/Buttons/MainForm.Designer.vb @@ -0,0 +1,92 @@ + _ +Partial Class MainForm + 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() + Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(MainForm)) + Me.btnImage = New System.Windows.Forms.Button + Me.btnStandard = New System.Windows.Forms.Button + Me.btnPopup = New System.Windows.Forms.Button + Me.btnFlat = New System.Windows.Forms.Button + Me.SuspendLayout() + ' + 'btnImage + ' + Me.btnImage.BackgroundImage = CType(resources.GetObject("btnImage.BackgroundImage"), System.Drawing.Image) + Me.btnImage.Font = New System.Drawing.Font("Microsoft Sans Serif", 20.0!, System.Drawing.FontStyle.Bold) + Me.btnImage.ForeColor = System.Drawing.Color.Black + Me.btnImage.Image = CType(resources.GetObject("btnImage.Image"), System.Drawing.Image) + Me.btnImage.Location = New System.Drawing.Point(18, 207) + Me.btnImage.Name = "btnImage" + Me.btnImage.Size = New System.Drawing.Size(312, 72) + Me.btnImage.TabIndex = 7 + Me.btnImage.Text = "Image Button" + Me.btnImage.TextAlign = System.Drawing.ContentAlignment.TopCenter + ' + 'btnStandard + ' + Me.btnStandard.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!) + Me.btnStandard.ForeColor = System.Drawing.SystemColors.ControlText + Me.btnStandard.Location = New System.Drawing.Point(18, 95) + Me.btnStandard.Name = "btnStandard" + Me.btnStandard.Size = New System.Drawing.Size(312, 88) + Me.btnStandard.TabIndex = 6 + Me.btnStandard.Text = "I am a standard button" + ' + 'btnPopup + ' + Me.btnPopup.FlatStyle = System.Windows.Forms.FlatStyle.Popup + Me.btnPopup.ForeColor = System.Drawing.SystemColors.ControlText + Me.btnPopup.Location = New System.Drawing.Point(178, 39) + Me.btnPopup.Name = "btnPopup" + Me.btnPopup.Size = New System.Drawing.Size(152, 32) + Me.btnPopup.TabIndex = 5 + Me.btnPopup.Text = "I am a Popup!" + ' + 'btnFlat + ' + Me.btnFlat.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.btnFlat.ForeColor = System.Drawing.Color.Blue + Me.btnFlat.Location = New System.Drawing.Point(18, 39) + Me.btnFlat.Name = "btnFlat" + Me.btnFlat.Size = New System.Drawing.Size(152, 32) + Me.btnFlat.TabIndex = 4 + Me.btnFlat.Text = "I am flat..." + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(349, 319) + Me.Controls.Add(Me.btnImage) + Me.Controls.Add(Me.btnStandard) + Me.Controls.Add(Me.btnPopup) + Me.Controls.Add(Me.btnFlat) + Me.Name = "MainForm" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Fun with Buttons" + Me.ResumeLayout(False) + + End Sub + Private WithEvents btnImage As System.Windows.Forms.Button + Private WithEvents btnStandard As System.Windows.Forms.Button + Private WithEvents btnPopup As System.Windows.Forms.Button + Private WithEvents btnFlat As System.Windows.Forms.Button + +End Class diff --git a/Code/Chapter 29/Buttons/MainForm.resx b/Code/Chapter 29/Buttons/MainForm.resx new file mode 100644 index 0000000..09b1ac8 --- /dev/null +++ b/Code/Chapter 29/Buttons/MainForm.resx @@ -0,0 +1,1232 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + Qk0mAQEAAAAAACYBAAAoAAAAAAEAAAABAAABAAgAAAAAAAAAAAASCwAAEgsAADwAAAA8AAAA/////3N7 + zv9rc8b/Y2u9/2tzzv9ja8b/a3vO/2Nzxv9jc87/UmO9/3OEzv9re8b/Y3O9/1Jjtf9CWrX/Y3vO/1Jr + vf9Sa8b/SmO1/0pjvf8YMYz/a4TO/2N7xv9Sa7X/MVK1/ylKrf9rhMb/UnPO/0prxv9CY73/OVq1/zFS + rf9Sc8b/Smu9/0Jjtf8pUrX/Y4TO/1Jzvf9Ka7X/SnPO/0Jrxv8xWrX/KVKt/2OExv9Sc7X/UnvO/0pz + xv9Ca73/OWO1/1J7xv9Kc73/Qmu1/0p7zv9Cc8b/QnO9/zlrvf8xY7X/UoTO/zlrtf8AAAD/JBYkFQ8g + LQcQIBwiECAQICAgIAgPJBUGDzEPIDERIBAiIR0mECUgLRYkJCQgJA8gDyAgDyAgIDEWGyQWLQckJA8z + ICAgICAHLTEgCw8bJA8VFjkgICAkFiAtKyQtICAkOSQkJBUVDzkkJAstJBYgJCAWMSAkFSQtKwckJBUV + JA8gETEaGzExICAgICAxMSsPFiAGJBUVFSQgJCQkDy0WDy0WMQ8kDysVDxUlIA8gMQcrJBUkFRYkFiQV + FQ8GJBUWLTEgBw8xJCQVChUkFRUVCiQKFRoIESYiHjciIi8hJCQkChUVChUPISIrFRUVJA8rICAxIBcR + JSArICQVJDEPDyUgDBAgKyAkFhEQIRUPIBAgIDErMS0kKxsrICQkFSAPIBIhICAGFSQkIBUbDy0tKy0P + JCUHICAuJDEtFiAgJDkrEzMtMSA5FisICjkVFSQkLQ8gIS4tFjEgJSAgOSQkJBUWJBUGJBUVFiQPJCQV + MSQkFjEPJBUVDxYWDxYVDwYkFiAxBw8kLSsHIDEIJQgWJCArDw85JCQMLQ8kFRUkICQPJAwILQ8bDDEg + IBUkFRUgDzEHJCAtICA5JCQkKyAWLSUHJCQVICstDw85OQoVChUVFQoVChUIIBIeIhAQIBYxJCQKFRUK + ORYgLSsPOQg5CCQgIAcgIBYgDxUVFS0WKyAuMRYxBy0WDw85ISAgIDEQICAxIAgrLSQxGwYVJAoVFQo5 + JBUVJCAgIA8kFTkkFSAlJBYgORYkORUPKxsrDyAPFi4vIQgkJA8gMTkVJCsHJAYQIBAhIBAlDyARLyAK + FRUPLTEkJDkVKyAlICsVFTkGIBAhDxUVJCQbJC0VGys5FSAxBzEWBxYxMQclMSQxFhUIICArDysWICQV + FRUkFRUVMQ8kICsWKyAQECQVFRUkFTEgDxwvDiIhICAkMRUWICAHMSUgDwgWCCskChUVJBUkKxUkJDkV + FRUkEBAhIBAuISAgFiQkFRUVICEgLiUgKyQkJAcgIQcgBg85FRUVDw8gDyAPMQ8xKy0gIDEkESAgIC0h + ICUWMQsGFS0kFSQVFQoVFQoVJBUkJBUkJCAVFRUkLSAgESUgICsWMSAlIC4gICsIJRMlMicQICsPKxYg + FhYtJA8xFisQGy4hIC8lOSQtKw8WDxUVJBsHISAgIA8kJA8xEBUVDy0xJBUkJCQVFRUtBxUkICAxCAcg + BwcHICsgJS0WCA8xESUgFhUkJBUkFQ8kBysbESAgECUPFRUVFRUkBxATEhIiECEgJQcrICQQICAgIDEW + FjkVFRUVJCsIMS0kLQ8LDyQ5FRUVFRUtESEhJSAkDyQVFQ8SMDMcLSQVFTkkICsPOSQkFSQ5CxU5FRYk + FSQWECAhHTMPChUVLRUPJAcgLSAbJBUVJBUkFSQVFRUkFSQVJBUVORUVFSQVFQ8gJTEgDw8PLSAgMSAr + ICQVDyAQExIiJTERICAxIDkgJDkkJA8tETAhITMRLSQkFRUGLSQPOQYPKwcQIS4kFTEgFRUtKy0rDyQr + Fg8WKw8PKxsVJAcHICUxIBYPFiURESAlJBYxECAQICQVJBoPJS0WFQ8tFjExIA8VFRU5FSQWICUgECAI + DysgESUQIBUPFhAQJSAgMSQkDw8xDw8rMQ8rByQLJCQkBjkkCgoVChUWFS0VJBUVLRUWLQ0eHzMuDxUV + FjEgDwY5FSQGDy0PFisGORUVOQcQEDERFRUKFQoVFRUVFjEPKyQkFRUKFRUkFTkkDysgJCQPJBUVChUV + FRUgMSAtFTkkKwgrFgcIByQkOSQPOSAbDzEgICQVLQskFQYWLQ8kFQYhHSIQFSQ5FQQkFSQVCy0rFS0P + LRIJIC4IDwcVFgcWLSskGysgIBsrMSQLDysgBxEHIAgrByAQJRAgDwogICURJTEHFi0VFQYkDzkrFRUV + DzkVFQoVDxUkJCAgIS0VORUPIBYgFhAgICQlIRARByAgFisPFgcHGysgBxYtFg8PJCQPOSQVFRUVFRUK + JCQPOQcuFRUgJAcJHS4gLy8JICQVFRUkDysWKyAPJCQVJBUVORUVJAoVFQoVChUVOQgkJBUxICQVFSQP + Fg8PLQcxICskFRUkLRUkJC0gORYPFiskDxsxEQckMSQVJA8GJBUVFSQGDyAgKyQkDxUWJCAxFQoVJBUG + FRUVFQ8xFRUtFiQkFg8rDxUKICUVFTkVJCAPDyQWCBYWBy4lIAcrIDEgETExJSArICAlICAlMQcxICAg + FiALLTEaBzkVFSQkDw8VJBUVChUGFiQlICUQJBUVFQoVFRUgFiAWMTEgIA8tJCQrICAgICAWJRsHICAg + KyAWKyAxICAgICUcIC0WLS0LFiAgMQctFRUkCiQSIRUIJDkKFSQVLSstICUgBxsrFRUkFRUVFQoVFRUV + FRUVFRUVJC0gICArLRUVOSAkLRUVJCAgEA85GxEWDysgEA8tFSQbMQckFg8gDyQVKy0rLSQVOSQkJBUk + BxYIMSAlLQ8PFSQVChUKFSQVJCQgMTEgKyAtMSsgMSQVFSQPLSQVFRU5ICs5CCQaGysgFiAWLQcuDBYW + ICAxFiAgFg8gESUgByUlFiQaJA8rIAYHFhUPDwcxJA8VChU5JDEgMTEgDxUkChUKFRU5ECEgISEgJSAr + CxoWIA8kFjElMQ8rFiAWICAxLSAHBy0QIRwQDiIwLy4kJCArICsbFRUKFQokChUKFRUKFRUVFSQPBxUP + IDEgBzEPLTkkJAoVFTkPOSA5MRUVJDEcJSAgDxUVJCQVFRUVJCQkDxUkJCQgMRYbESUbKyAVJCQbJSAx + DzkPGxYxDysxJBUVMQctLRY5JCQgGxUGJBUKFSQVChUVFSQxDw8gECAkFgcbCCstChUkFSQVChUVFRUP + FQ8xESUgICUxDDEHIBYPBxAlIAcRMQcrMRYPMSAgIA8VFhYWDwsxICsxJBYWDxYtJCQVDxUkBwgWFRUK + FRUkMTkPJBYcECYSICAVFQ8PICsHICUgICAgAjEgJSsWJAw5BxYxICEhEBASHx8iISUgByAgMRUVFQoV + FQoVFQoKFRUKJCQxMSAgMSUgFiAxKxUkFRUVFRUVJCQtFQ8tDyAQISEhJBU5JDEPLSQkORUPJBU5FSQV + FSAxJSAxICAkDwYWMS4gMQYkFTkHKyAgIBYWDyQxKyAtDw8gJCstKzkVFRUVJBUKCiQPJC0kFQ8WMQgW + KyAgFRUVFRUVJDkKFTkkKyUxIA8IFhEgKwggJSAWMSUgIBAlMQcgFiAWMQcrDyQVKyAkJTEgIAcgByAk + MQ8WByAtICQPDxYkFRUkFQ8rIA8rICAIICUSECEyICsWKyARLCAyEQwgMSUgECAgICAgFjkPORUgECEu + JRAfHyITIScgEBYkOSskFSQVJCQVFQoVChUtLiArESAgIDkWICAgDxUVJCQ5JCsHJBUVFQ8xDyAgJCQV + FhYPDysVBhUxLTEWDxUVFSQgByA5DzEPMQc5Fg8GDyQkFSQgCCAgMQctMRAtJAgtJCQxKyAPJA8PFQoV + ChUVFRUPORUVFTkVLSAWMSAlByQkJBUKFRUPJBUPJCAHIAcrLRYgJSAMMSAHDzEgESElICAxMSAaFgcH + JTEGKxYgJRAgJRAWICsPJCQWIDE1JSAMIDExMTEtBzEWGyAxFhYkFRUkMRAQECElESAgIBAcECUcIBAg + ICAQJSAHOQcPFRUVCiQHJBUbEB4fHzAmICA5FQ8bIBsxLRYPIC4bLiQtFQYWECUlIA8VICslDyQtJBUV + DxYRICQVFRUKFRUkFQ85KyAgOSQkORUkDyQWDy0WDzEkLSsgIDEWDxYPJA8bKyAkDzEbDCAgISAgKzEg + DwYkFSQxICAgJCsgJBUkFSQVChUtICQVCiQVFRUkJA8WByQrGw8xJCQVMRY5JDEPIDECJA8yECAQICAH + ICsgByAhISEiISAlICAQECAgICUgJRAQJiEgIAwHJQQgKwgWFjEgEBElByAgJSEQEBErDwcxJCQ5IAck + GxYHMSAHFgcgEBEhECEQEBAHLQ85JBYPKyAVJBUVChUVChUtBxIOJhAhFRUgIS8mLiAgIS8SMyAxJDk5 + DyAxBxUkJA8gJCQPFRUVKy0gIBwgIS8lIDEKFSQVJA8HESAxDyQgLQcuLRUkJBUVFRUgEBAhMhErJCst + Cy0PFjkHMQ8rICEPLQ85JCQkOSQkDyQtKyEuESQVFRUVCiQWJA8kJCQPFSQVFQYtCCQVDxU5GxYWDzEP + FSQWJCElLSsgIBAcJSAgMSAgJBYrDwcQByEQICURFgYgIDElECAlBxYHECAgIBAQJSAgJAcgBxAlISAx + IAcQICAlIAcxIAcPFTkVChUVFSQrFS0kJCQVDzkPJBUVFSQVJA8rLQY5JCQVFRUVCiQVFRUWGyAgICEc + JiIiMCIiIiEHDxUFHAcIJDkTICQPJA8VJBUkKyQkLSQKFSQxISARHCUgFQoVDyAkFS0kCCsVIBYuJQcP + FTEWORUGJCsgIRAhLiAgJAYkOQ8PFQ8xJSAkFRUVBg8VJBUkJA8WIDEWLQ8GJBUVFRU5JBUgJS0VJCQV + ChUkFiskLSQVORUgMQcgKxs5LQclICQPByEhIRAhDSEgJSAgCSQVCg8HJRArFjEWGiUgIDEgIDEtICUQ + EDEgICEQJSAWDzEgEQclICsgCAwgIBE5DyQgDyQrDyQVJA8VJBUWICQ5FQoVChUkFSQVFQoVCCsgDyAG + LSUPFRUVCiQkICIiMxMtFRMOMB4OEiEgFiQVChU5KyAWGhUkIA85FRUKFSQPICsVFRUKChUVIDEkESAk + JCQtDxYkFS0POSQkDxEuMQcPJCQPDysgGysgICAhDxY5FRUVJDEIKxskFRUVJA85IAcxIA8xMRsWGyQ5 + JCQtJCQkFSQxICAgKxsVJCQxDyAgDxUVJAsWFRUgKyAHKw8rGwcrIBEQDyQgESAhECUxECskFSQkMSAr + ByAWICAQICsgDC0HKyUhJRAlIBAQIRAgMSAWFjE5Dw8HFRotDw8VFi0QICAHDzEkFjkQICAgDyQGFRUV + FRUKFRUVJBU5JBYPDyArJCsbDzkVFSQVChUPIg4kFQoVCiQFECIcFSQVChUKJC0gDyQkDxUWFRUVChUk + JDkPFSQVJBUVChUVChUkDxslFistJCQWJA8VDzElIDEWICQHDzEgIBUVIAgrJCQgJCQHOTEHJSAgFSQk + JDkVFSQPIBYkJCAgKxUVJBUVFRUPIC0IIBwiECAxICUkDysgKw8xKy0PJCAPGyAgMSAkFg8WICEQDxUk + ChUVFiUQMQ8HDyQkDwcxICAgMSUQEAcgByAgJSAHDwcgMSAgECUQICAgMQckByUxKw8kJBUVOQ8xICAW + ICUkDxsWICAQIDEkFQ8WORUPJBUkFSQVJCQWLSsVDzEHMSsVFSQVChUKFRUKFQoVChUVCiQKFRUVFRUV + JBUVLSAWMSQRJBUkFhUVFRUVFQ8rJCQkChUKChUKFRUkIBEgBxY5DxUkJCAgIBArDw8lORYgMRYPORUk + IAgkJBYbMSAxIDEgICsgLSQkDystJDEgGw8gFi0VFQ8kFS0rLRYtDyAiMCIhLiARIBYPFhsrBw8kJC0V + LRoHFg8gDzErESEHORUVFRUVDyAgFgsgKwckDCAgICUgFiAIMQ8WFislESArLSstFhslIREuIBAgIDEa + Bi0REA8xBxYkDw8PByUgKyQkJBUWMSAgFiAlEA85FRorORUkFRUPFhskORYPJBUbOQcPFiQkJCQkFRUK + FQokFQoVChUVFQoVChUKFRUkFSQGDw85FSQPFSQxFiQVFSsPKwgxDy0kJAoVChUKFRUgHC4kJCsgICAH + MRYVLSsgByUgMRUkFQokCiQxICQ5KwgPDzELMSAgDwoxKwg5FTkVJBUrDy0kJDkVLSQVICAtKyAkEBEO + IiEgICAxMSQWDxYkBhYPJBUbJBU5DysgICUPIAcgKw85JA8MMSUgICAlICARICQHEBAlMSQkKyQgIDEg + FhUWJAcrERAlByslECAQJBUrIC4QICUgKyAxBysgDzEPFQskJSAhIS8xLSQVJBUkDxYtJCQrCCskCwYk + JDEPMgcxMSAgFiAGFRUKFRUKFQokJBUVCiQVChUVLSQVJCQ5JCQVFRUVFjkPMQ8LMQ8PIDExFggrJBUk + JAoVFSQVDyAgMQgHICUgKxsVDwYPFiAgMQcVFRUVJBUKICsPIA85FQ8IJAcWJBU5Bg8kJA8kFSQVFS0k + FSQkFSQ5Fi4hFiAgFQoVJBwmIi8bIA8kICstIDEkKzEkFRUgFSQgLhAgMRYPKyAWGgclOSAgIBYgByAl + ECUWFiUgECACICAMIAwgJCsPIAcgBy0QMQ8gIBElICAgDxYQECEhHQkRJSAgIDECICQkDw8RIQkHIRYV + JCQPJQg5FRUkLRUkLSQVFQYVOS0WBwclMQgrICskORUVFQoVFSQxLSQVFRUkFiQWJA8VFQYVFSQWICAW + FisPFg8kJCQPJDkVCg8PJBUPOSQkFTkVDxUtJSAgKwckMS0kJCAgISAbDyQVChUVFS0gICsWKwskFRUV + OQ8kFg8rDyQgJCQkFRUkFSQ5JAggBwccFi4gERUVFTkKESEQISAhICsHICUQGyQPICQ5FhsLJCsPKwgW + JCAVJCArDyAWMSEhICsgMSAPJCAHICAgMSAQJSArICAxICEQECARICQRJREQIRAQISAgIBIiHRchECAg + ICAgJSAgICArDxUVDwckCxUVKwQVFRUtDw8kKwYkFRUVJBUPFg8gBwYxICUTDyQkFRUVJBUkFS0VFTkk + LSAgByAWOS0kJC0rIDkbKw8gMQcxFiAgMQ8kFRUkFRUkJAgVJBUVJBUVGxUWICAWMQcQIDEQECEgJBUV + JBUkJA8VGyQxIAggORU5FRUWLSQPGyUgFSQgFiAVORUVDyAWICUhIRAxICQVChUVORUPMQcWFi4QICAx + BxYxFhYlBxoVJC0PDwYxERYgICAgIAwgORYQMSAWBg8VJBUVJDEkICAlICAlICUxIBAQECAlEBsVJAct + JRAQEBAQEiYhJhIQISUgJRAhICAQEBAlDxYVGisgJA8kDw85JCQVJDErIA8rLRUVORUVOQ8gJBUrIDkH + IDEPDzkVFRUVFRUVFQoPOSURJSExDzEkJC0VDw8WICAhIRAgMRYxBw8kFSQtJDkkBwc5FRUKFQoVFTkk + LRUkGxY5JAcQLjEgJCQKFRUVFSQ5ChUVDxUWDyQVJCQVJCQkKyAkMQ8gMQ8kFiQkFSQxJBYhISEgJS0V + JCQKFQokJAcgISAHFhogIBEgICAxESAbFhUkFRUkJBUkJBAgISAkFgcPFgcWJA85FRUkFRUHMRAxGyUQ + ERAgByAlECUgIBAkJBUkFRUVORUVOQ8gEyAkOQYFISEhHTMQISEgIRAbLRsVIBAgMSQkFQ8rBiAHDysI + JBUPKyQVFQ8kFgYkDy0WIDEHJQ8PJCQkFQoVFSQkFiAxIBAPFisVJBUWOTErDyAQJSAhIBYWGyArLTEV + FRUPDyArIBAWJAokFSQPJBUVFRUkDw8gFgclDyQPJBUkFSQkFTkkJBUkJC0kDxUtDyQkDw8PFiArDyUg + IC0kDzEkFQ8gERAgFiAVChUVFQoVFRUgMSEgICAgIBAhISAgIAwxICAgJBUkChUVDxUkIBYVFhEWKyAk + MSUgJBUVFRUVJA8PDyAxBzElICAlESUPBxoPJBUVFQoVChUKJBUVBiQVFRUVFQ8QISYQISEhJhAQExch + ITExMSAgFjkgDy0aFSQtFjkkJA8gDyQVJCQVJDErIDEWBzkPOQ8WIC0kChUgBzEWGxYtIDEgIAcxDxUg + ICAgISEhICsQHBcgJCQrDysgEDIxMSAVORUkFRUgJC0kDzkPDyArBiQHFQgkJBUkFSQkFSQPKw8xLQ8r + LRUVFRUkFRUkMQ8VLSURICAkMRUkDw8kMRAgGxEPJBUVFQokFRUVJAgxCBU5ECElIB0zISARISUxFgc5 + FRU5MSArMRUkLQcgKyAgIBAQFhYWKxYPLRYPORYgFjEgICAgFjEkMQwtJCQVJAoVChUkFRUKFTkKFQoV + JCQ5FQ8WGy0QCCsVJCQtFhskGxYgEDEgFi4QLQ8PKy0PKxsrFisxJBUVOSAgIBEgJA8VFRUVGxYtGjkx + ICAhICskJBUgByAgFhYPJBYxECAWDxUbJA8MEBAgLSAgIRMgIAcPDyQtKy0kDxUVFRUVLSsgLSAgDzkV + OSQtJCAkJCQkICAcJRAgDxYtFSQVFSQgFSQkFg85DysgMSAlICsVJBEgFRUKFQoVCiQxJBU5FRUkByQk + FSEQIS4PICAQMSAgJTEkDyQPFiAlCCAgJSAlBwYPJS8hICAxICAgKxYtFRUkCCQgBysrFjEtFgctFRUV + FRUVFSQVFQoVFQoVJBUVFRUVBxYkFQoVFRYgDxUVFRUVCjkIJBUkICEQEC4xFhsVFiAHMQ8xLRUKJA85 + DwkgIAgrESQgJBUVJAckDxUIFQ8gBxYxDyAxICArIAcxGzkWMSQVFRUtIBEgMSAlEQ8gFiAVJBUWBy0P + JCQkFRUVFRUIKxAgMSQVJDkkFRUkBistCgYQIg43MCEkDyQkFSQPJCQxDyQkFQ8bJQcgIDEgICUgORUK + JBUVKyAkDyQVJCQxIC0xBiQPEBwSIRAgICAQECAxJA8rLRUVBiskEQcxDyQ5KyAQEBAgDAclICAtFiQk + FRUxKyAgDxYkBzEHDxYPFRUVJCQkJBUkFRUxFSQkFQoPJC0kMQ8kFTkkFRUkFRUKFRUKLSQPMSAgISEg + ByQWDyQWORoPFRUkORYkFhU5FRUQCxsWMSAWFSQkFRUxGysgMSAgICsWMSAxLTEgEQcPJBUVJBUVFSQP + OQ8WJBU5FSQgOSAxIDkPJA8VJBUVOSs5FTkPDxUbFRUPGystFTkPJCQkOQcWEBIeHyIxDxotFjkPJA8k + DystMQ8kEAcWICAcOQoVChUVLRYtBw8kLRYWICArDzkKFTkPEC8hICAgMSAgESUgIC0WFRUPFS0WFRUk + JA8WDw8gICARJSAQIBYPLQ8rDyQPKxUkDzEVFSQtJC0kFTkPJCQVFRUVJBYIFislKw8kFQ8kBg8kChU5 + DxU5ChUKFSQWLiAHIRwgJQ8xDxotJCQVBjkPDxYHICAkChUVJBsrDyQWOSQVFQoVORYHISAgGzEPBjkg + MQcWICs5LSQtFSQVFQokFRUKORUVFSQVDxYgIDEHFiQVJCQVFRUVLRUkDzkPFRUxMRYtDyQLJBUVFRUk + ORUVFRAeHjouICQHKzEkFjEgIBYPIBUkOSAQEBYKJAokJA8kJCQtJA8POQggIBELFQoVCjkTIiIvIBAQ + JSAlGyskFTkgICsWJBYkJBUkJA8rIBAQICEhJSQgKwcrMRsWJCQVORUkDy0KJBUPKwgWKzEPJAcWIBYg + MSskFg8WDysVORU5FRUkFQ8kFRUVJBUVDxEhLiAHMQ8VFSstFS0GJCQVFSQbOQYkFSQVFTkKJCAgDxUV + ChUkDxUkFiAhMiExFjkPIA8gMQ8HIBUVFRUVJBUkFQoVFQokFQoxIAckIC0xDyQkFTEgMS0VJCQWJCQV + FSQtLRYcKyAkMSQ5DzkVChUkFRUVAhAeHhwlLiAgDw8WICsIFTkkJAcgEC4kFTkxDwM5FhUtFjErGxUV + MSAxJBUVChUVFQ8hIiERIBEgMSQkJA8PMSAgDxYVFRUkDxYhICAhISIiICAlICAgIBExFRUVJBUPFisP + LSsGKzElByAHKyAlISUgKwcgIBYxFSAgJBYkFiQtFg85FRUVFSQkFQokGhsVJBUPMSAxBw8kFiAkJBUk + FRUkFRUVJBULLQskFTkVJBU5FSQWDyAHBw8GFg8tFSQkJBU5JCQVCgokJCQkFQoVChUVFSQPDzkVFSQb + JCQPJC0kDyQPKyAPDzkKFTkVJCAlDxUtFiQPJBUVJBUKFSQtMS0VEBIeHx4fKR4mHCAxFRUVJBYkMRsV + FSsgKy0HDyQGJCsbFiAVJAccLyAPFRUkFQoVFRYlISEQIBYxBjErJBUVFi05FQ8xDysHESEhERAQExAQ + LhAQJREWJCQaJCQWJDkGKw8WICAHGysgICAhCSUhECAgDCAgJSAlBzEIFg8kFjEVFRU5FQYkDw85FRUV + ChUKJBYrBy0VMTElIC0VDyQPBhUVJA8PJA8rFSQWByAuFiAQORU5JBU5DzkkBiQVFRUkChUKFSQVFQ8k + FRUVJBUVFSQbJCQVFTkKJBUkDzEgJRYgECAlICQkFRUVFRUVOSAkCiQlECAVFRYgMSQVKxskDxUkFRUV + ByESHiEWJBUVDyQPMgcVLQ8bFhUrMQ8gLSsPJDkgFQokIh4HJDEkFSQVChUPICAQITIhECAxICAHJBUx + BhUPKyAgICsVFQoVFRAlIBAHMSAgFhsxDyAMMSUWFhYgFi0rDysWICURECUHJAcxISAgIRARIDELMSAx + FQ8VCjkVJBUxMRUWJA85ChUKFRUbDyQkICAgIA8VJDEVLSQxJBYrFg8PIA8xDyQxGxElCiQVChUkFRUK + FSQKFQoVChUVFQoVFSQkJBU5FSQVLSQ5Dw8VFRUVFQoVJBUPJCAPJCUIMSQbFSQkJBU5FRUtFiQHICAW + GxUVFS0gOSAgChUKFRUVChUVJBAvIRYVOTEPMRYlIBUrFSQtCCArMSQtDzkWIBUVLR4hIBYVBg8VJBUk + FTkPIBEhECEQICArLQ8kFRUGJA8HMSAkJAoVFRUPIBARLhAbKxYkFjEMGxYgByQgFisPIA8HIDEWFi0r + IBAlJQcrDw8kICUHMSAkBjEkFRUVFQYuIBskJC0xJBUVFQoVFSQPORYgBxYkFSQkDysGDw8gICAgISEQ + ICQQMRYHFTkKChUKFRUKFSQVFTkVFQokCgoVCiQKFSQVChUPJCsHJCQkFQo5FRUkFRUVFSQkFi0kFhUV + FSQVFRUVChUVFSAgICsgKy0PJBUVFQcgFRUVFQoVCiQVFQ8kEBAgIAcrJQcgJCAtJAoVBhYxMQgVFSQV + Dy0kKxEiIQ8rJCQxJQ8kFRUkFTkVJA8uEBAgFhYkFTErJBYPFg8kFRUKFRU5JBUxEBAhIC0lICUWJCUg + IRYHKwwPFgslMRAxDzEHDA8PLRUtFjEWICsWMREgICQHMQ8VFQ8rIBYxGxYxFg8kFQ85FRUkFg8PFjIr + LRYxLRUVFSstKyAiEjAhIS4gBw8VFRUKFTkVChUVFRUVFRUkKw8PJBUVJBUVFRUkJBUkMSAgIQcWIDkV + FSQkFSQVFRUGJCQWIA8kBiQkMQ8kFRUVJCQkGzkPByArDw8xDw8kJCQ5FTkkJBUkJBUVFSAhIS8gMREg + FSQkATEkLSsgBw8WMSQxDzEWLQ8PICAWGwcgETEgDxUVORUkJBUrByAgISEgMQckDxUWMTEkJBUKDxsP + DyQGICYmIhARICAlICAlITIRJSAgByAgICAHJCQkJBUkLSsVJA8WESAgICAlICAWJBYxFS0HIBYgFisI + FiQgIDEPCCQWBzkWIDkHFRUtFiQPORUVJCAQEBAXEBAhMSQVORUKFQoVFRUVLRUVJAY5FgYxLiAkFRUV + JBUkJCQkFiAgICAgLQotDyQVFSQkFisgKyAlDyQGORUkFiA5FRUVORUVDzEkJDEPJCQkFiUxLhUVFSQP + Fgc5FRUPJBUkICIhIDEHFiQVDyA5IBYPBw8kECAQBysbJC0kLRUtIDEWLQcgIDExJA8VJCQVMTEcECAQ + IRAhDzEWFiAgIAcgLiUrFisgKwgkEBASISEhJSAQEBAQKyAlJREWICUgFSAxBxUVFRUgFiQkJBYgCRAb + ECAQIBYWFQ8PMS0xIBEgFhUPMRAgJSsxDysWDysWMSQPKzkPDxYPDxUxBzERICAkDxYtJCQVORUkFTkx + LRYrLSsxKxEyIC4kFRUkORYkCw8PICAREAcxFRUVFSQkDwY5JA8gICUIGxU5FSQVJC0HKwcPJCQkJDkg + GyQVJBUgICQPByAkJCQkMTEgFQckJBUkJBYIFhsHFiQxFisgIBYgMTE5JSAgECAgJDEPBg8kGxwgDysg + JAclDxskFSQVFSQPFhYgJRAQIBYrECArByAgEBAgICAgJSAWJCQIECEhISEhISEQIDEgEBAlICAgMSUg + BzkkFS0WICAxBzEPIDEQJSAhDyAxICQWMRYgJQgxFSQtJAY5CCAgBzEgICslDyQIJBsHBzEkFjkVICAx + JREuICAxFiQPJBUPDDkHIBYuIBEmIA8tIA8VChU5FQYkOQ8xFhwhIRwkFSQVChUVFSsPJBYxIDExFRUV + DyAHLRYkGxYkLSQGJBUVJCQVJA8VDzkGJDkVFSQVCCAgIDExJCQWJBUHMSQHOSAgEBEgIBEhFiAHIA85 + FQ8kGxAgJCQ5ESIwEyAgJCAPJBYkORUWFQ8tFjk5DzkgESURICAgBwcrICAgESEmIRAtJBUVFQoVJA8k + KwcgLSsMICAhECArDCAtMQ8HJBYrICQlBwcrIA8PESEWFSQVByUQLgcgLSQVORUVFRUVFSQVJCAlLgcb + DzkVJBUkLSQVJCQWLRUGGyAlDyskJAYWMQ8xIA8kFiQIMSsILSAgJBUKFSQVFRUKFRUVByAhITEVFRUV + CiQVFS0WGzERESUgLRUkJCQPKyAuKyAbFiQkJCQVFRUVFRUrORUkFgcWDzkVDxUkCAcgGxYPORUVOSQk + MQcrICUHMSAlIBYxIBYkFSQxJCQrISQVFSUeHg4hECAWIDEPFg8rGzkrDw8VJBUMICEhISEgITEgFhAg + FiAaByQVFRUVChUVFRUKFRUaFRUkKyUgByAkCC0rByArFRUbJBUgBzkkFSQPKyAhHC0WIDEgIAcxFg8k + FQoVIBUkFSQkFRUHMQYVORUPFRUVCjkkDxUVDyQVFSsgBy4bByAxDysuIAchGw8VJA8VFQ8kORUkFQoV + ChUVFRUVJCQxIAckChUkChUVFRUkDysvMiAgIBUVJDEWIC0gICUPOQ8VFRUkBjkVFRU5Dw8kFgchGyQk + FTkVJBYgICsWJA8PLSQPGwcgMRsrLiAgJAcrICUgGxYVFRUkCBsVFRU5BxAhISEhISAHDzEkFiArIAcx + JCQPICAgFg8rIBYaBw8gICQkFRUVKxYgJSQWDyQVJBUVORUWFiAgBzErCzkVDxUkLSQxFhUkJBUVFQ8W + ORUPEBIvISAHDxYkMQ85JBUkDyAgDzkVFSQkMQgxJBUVORYPFjkkJCcrIBUtMSQkJDkWFTEWICUgJRAh + KxU5FSQkFSQVCgoVFRUKFSQKDyQtMSQkMRUkFSQVFQokFRUPLRYgIRIhLxAPORUVICsHKwcxDw8rLRUV + OSQVFRUKFTErIDMtJBUkFRUVFSQgDxYWLSQHFhUVFQ8rIBArFhshJRYPIAcgICsxJA8WBzEVFRUVJBUt + DwgxIRMuMSQWICAxECAlDxYkFQ8WDyAkICQkICQrMSsPBzkgICAHMRAgIBogICQGFhokMRAlICsHCBYP + KyQkICsPByQkFSQVJAsxKwgVFTkREBAhMi0rICQ5DxUVLSsHJS4rFhUVFQ8WByAgIBUVOSQVFRsWJA85 + FRYgICQVDyAPICAgESARLiQVChUKFRUVFSQVJBUKFSQkJA85FQ8uIA8KFSQPFSQVFSQ5DyQ5CDEhExAg + JCQkJBYtFiAgMSstLSskFRUkFRU5JA8PICAHIBYWFjkLDzkkKyAtDxogIDEkOQ8HDzEgIC0rMQgWICsg + MSAgLQ8kIDEgFRUVOQ8PCjkVIBAhJi4PMTElICURIDEkDw85DzEHFiAgICAFIAcPJDEHICAHCyAxGiAR + IBYlMSQPByAgMREgKzEtFgcPBw8WJCAWJAgrOQ8kDw8WORUkJCAhIiIgFg8VFRUkFQoVDxYRIBsWLRYx + JA8kFiQxDxUKFRUgMQcrJCQgLx0VJCsWMSAQMSAgFi05FRUKFRUKJBUVFRUkFRUVFRYkFQo5CCQVOSQk + JDkkBgokFRUVJBUVFTEgMRUWLSQgHCAQIA8HFiQgICQkFRUVChsrDysPKy0PDzkIMQ8rDyAgMRUPIDEl + IAckMTExBzkgDyQWLSAPICAPFiskByAgFSQVDw8VORUKFS4hEBEiIRAgICARJSAgKzkVFRUPFS0VEAgh + MSsWMQ8rBzkVMTErICAgJRYgICAlECUQESUgIAcWBysHJBY5IAwgITIgDwYVLQwxLSQGDzEkEBESEjEk + JBUVFQ8VCjkVFSQxESAHFiQPIA8PKw8kJBUVFQYgICAWHBIgFRUPByUtFRUVICQPFRUkFRUKFRUKJBUV + JAoVFTkPLQ8kJAokFRUKJBUVFTkkJDkVFRU5FSQPFS4RLisgJCsJIS4xICQ5CCUbICQVFRUrGxYgFg8W + FTkVKw8kCCEhECAgFiQHLQ8kFSAgIDElFiAWMSsIKzEWOQYgMTExDzkVORYtFRUKJCQGIRwgECEhICAx + JSAgICAVJCQVFRUkJCsgFhoPIBYWDxUVFg8WByAgECAxICAQECUQICUgIBYWMTEgMRYxJSAxIAsIKzEk + FRUkCCQkDystJCQVFSQPFSskKxYkMSQPFRU5FRUVOQ8kFRUVOQgtFTEVOQ8WJBYkByEgFS0cIS4RICAt + JBUKFRUVFRUkORUVFRUVFRUVLSQWFQ8rMRUVChUKFRUVChUkFRUkJBUkFRUkORUVMQcgCA8GJAcgFi0k + FRUPLRYtJC0kDyQkJCQWKw8VDw8xFiAQFRwgKw8gFiQVFTkCDw8HIBsaDy0gJSUHJA8PDxAgJCQKJBYg + JBUVFRUVFS0QISUuHTMhICAQJSArByQVFTkgICstFSQtByAWBysPJCArDysxFiAQICUlISEhEiIvLiAP + FgcgBysQIBEhIAcgKwYkFSQtFjkVFTEbBhUVJCQ5ICUgESAgIBYgJSQVFRUVJCsPORU5FRUkFSQVDxUV + JC0PDzExFRUVChUQIRYgFSQVCjkkOSQPJBUVCiQVFTkVFRUkDw8tCCQkFRUKFQoKFQo5Dy0VORUVJCQb + KxUVChUVOSQrORUVLQ8PFRU5FQ8xFg8PMQ8xDwcgIC4gLQ85IBwTLjEVIBY5ICQxFRUPOQcrLRAlICAl + ISEtFjEPKyAgDw8kJA8gFSQVFRUVJBUVISEQIA8gIBARICAQIDkkJBUWMSUHICAlICUIOQ8PMQwgFjEV + DxUkJAYWGysRFyEhEg4zISUPFSAyESEgKxAlJBUHOSAHFiQWFSQkMTkVFQoVFSQlICQHECEvECAgORUP + MSAgFQYVFRUVFQYkJCQkDxUVJBUgDyQ5ChUVChUkChUVChUKFSQPJCQkJBUGJBUPORYVJBU5JCQxJCQk + ORUVJAoVJBUkDyQkFRUrIA85ChUKJCQgDyQkFSQrJDkVBiQkFSAkJBUtOQYkJRAvIiIiHioeIhEQESAx + CDEPOSQVFQ8PGyURMSAgERMlFiAPJQcrGzEkFiAgKyQKIBsVFRUkFQ8QHCIhECAgICElICsPJDEtBhUV + JCQRBzEPJCQWICARJA8LKxY5CiQkFRUVBjEHICYSEg4iHjMiIRIlMQcPFTEIJSUQIBYxBy0WIBYVJAoV + FTEWFRElCCAxDyQ5FRUVDyQgICAkFSQVFjkkDyQWJDkVFRUVESQVChUKFQoVChUKChUVFSQVOSQkLQ8k + JBUVJCQgGzEPDwgWJBYPKxUVFSQVFSQkLRUPOQ8tGy4kChUVJBUkDzErDxUPJCAPFiQVFS0WKy0kOQcr + FiAgECEhEiIfEA8VFSQhITEbKxYIJSs5DysgICUgMRAgDw8xIDEgIAcrDyAWJAY5FSQgMS0KFQoVOQYh + LyEuICAWIBERJQcgORYVFQ8VLSsVFRUVLRUkBhUVOQ8PFSQVFSQVMRUVFRUVFQghEiISEQctIA8POSsH + JAYVGxUVFgckFg8tFRUVFQ8tDyQkCDkKFQokFQokMSQPCDEgFRUkFSQWJCQWKw8kJBU5GyAkChUVChUV + ChUVFSQVFRU5FRUkJAYrGyQVFRUkFRUPMSQtJSQgECAtFhskChUPKyQVFQ8rDysVChUVChUkJDkLDyQk + LSAgKxYkDyQPJBskFSQPLSAxMQoWICURFjkVCgoVMSEyECAgKyAgBxYtEBAcIBYtJBUPMQcRICAxDyA5 + FRUVJA8xCw8gFQoVChUVJBMwIiEuEBAlICUbKyQVOSAxFisPFhU5FRUVFSQ5FQ8LFRUVBiAWCCQrJAoV + ChUVJAcgIDEPFQoVJBUPFRUVFSQGICUbFggkFRUVJCQREjMhJBUVFQoVFQoVJCQtCg8VFSQtFQ8gByAl + ICAgBxYgKyAgFRUkChUkChUKFSQVOQ8rDxUkJBskDxUkOSQ5FRUVFSQPJCAhIREhHSYuICUdJRsrICAx + LSQVFRUKJCQVFSQWORYPBhYuICAIKxUkORUkJBUkFSQkFSAxIBsPFRUKFRUkFRUHERAlICAgKw8WIDEQ + MyEkFRU5JCQPKy0rGysVDw85FQ8rIDEkDyQkFSQKJBUVBiEiIRwgIAUxJCQPJA8gECAPFhUVFSQkFiAV + FhYWOSQVOQ8WFRUkFSQPFRUKFRUGFRUVFQoVFSQVDyUxIBYkGhExIBYWORUkChUVFQoPEBIlLSsxKyQV + FRUVFTkkORUVJBUaDysHMRAiIiIcJQcQJBUVFSQKFQokFQoVDxYPICAIKw8kFRUkFSQPFg8gJCQkFRUG + FSAgISYTLhskDyQPLRUkDwcWORUPORUVFTkPJA8rFiQgERAgKy0tFhUVFRUPJCQ5FRs5CBUVJBUVChUV + FQoVFQ8kICAHIC4hITIHByAHGxUVFQYrLSAVFRUkLSsWDysbICAtJA8WLSsVFRUkChUVFiUhIRAgMRYG + MRYkFSQkMTkVFiQWORYkFQ8PJCsGFQ8xDzEkFRYWFjExORUHICQVJA8kDxUkJSAlBzEHICAWByAxLg8V + FRUKFSQVChUgISEgByUgBxYkDxYPDxUVLQYPLQ8tKxsDIBEiIiEuDyQ5FRUKFQoVJCQkJA8kLTElMSAk + JBUKFRUVJBYtBg8kFRUVJBUKFiAkJBUVJBUVFSQVJBUPMQgkFQckJCQkJA8gICAPFiAQJSAlMQckJCQk + OQ8VFRUVFRUkChUVIBsrDxUVFRUVJA8WLRAhISEhLjEVOSQkFSQtICAkDw8kLQcxJC0VFgcgECUgJBYV + LSQVJBUKJA8HIBAhMiEhIDEgIBYPFQcVFTkHMQgHJA8xGg8WDzkWFSQkMQcgMRYgFjEHJA8LLiEQIBYt + DyAgByAWLREgIDEHICQxJAoVCiQVChUVOREOIiEQIBExGxYkFjkGChUVFSQrFhUkChU5IBEiECQVChUK + FRUVCiQkJC0xIBYxMQ8PFRUVFQoVOQ8gMSQkJBUkGyskFRUKFQoVJBUVORUkOQ85FSQkJDkGGyArFiAW + ICstECAxIBAgEQcPJCAgDw8PDyAVJBUkFRUVJAchJRskFTkKJBUxDyAQEBAmCSEWFRUVDy0xIBAQFhUx + FiQWCCQPICQgMREQHCAgDwYVFhUkFRUVOS0xESEQIRAgICsbFiQVFQYVJBYxJDEVJAgVJCQVFSQtCyQh + ECUgFggaJBUkDxAiMyERICsHEAYrByAxJTEPJBUGLRYPJBUVFRUVFQYkECYdIRElEBAhICAgFRUkDzEP + ByAVJBUkFQ8hEyAVChUKFSQVOSQkFhUVFRUPIA8kFSQVFSQtFgYkMQY5IBYtByAgFjkVFRUVChUKFRUP + Kw8kJCQVFRUVOSsgIDEgIBAgICAxICEtJSAxJTEgByQVKw8PJBUVFSQVFTkWESEhIBslICAxKyAgJRAR + ICEiCBUKFTEWICAgICstIA8IMSQVKxYWIAclIBARFiQkFjklJCQkJBUVORUPJC4QECAWKyQVLSstFggt + FQ8VDxY5DyQVFS0WJCAHFg8rCCsxJA8PFRUVBxASJiAWGhYgIAcVBxUKChUKFSQPJBYkDyQWFTkVFRUI + MSAgMSsgBwc5BiQrJBUrFistJAoVFSQkBhAhIBUVFRUVFQoPLQ8HMTkVChU5JA8kJDkVBiQ5CDktFiQx + JS0kFhAyIBUVFRUKFRUKFS0PMSQtFQoVFQcuIAsgDyUgIRAxCCsgICAgICAgIDEgICAgKy0kJBUGJDEW + ICsQIRIhICUhERYHICAhFyAxFiQVFSQHFhExEQcxBysPKy0kFQgxIBYgOSArIDEWCCAgMSAPJAo5FSQV + FRYHICUQISAxBw8PFRYrIDEPKyAWFistJCArIBYxMSsPKxYVDyQxJA85FRUaIAwQESAaBysWLRUkFRUV + GiQkJA8WLRYtBhotFQoVFQoVDxAgMSURMSQgFjkkBi0WBxUVFQ8kJDkWIR0uLSQkDw8WJCUxDyQVFSQK + FSQVLQ8VJBUVChUKJBYbBiQVFSQVMREgFTkkJC0KFRUPFg8PJBUkJCQkDwggKyA5ICQWFjkHJS8hMhAx + ICsQICAxJSAlJCAgICAgJTEILSAWECEhICAhIRwmIREhICQPMTkgDyQkJBUkLSstMQ8kKyAWFiAxIAcP + Fi0PFRYWByAlLRYPDxUKORU5IBAuICEvECErGhYIGyAgFiAgICQPFRYHBxYVCBUkFRUVLSQPDwYWFhUk + MSAgFiAgICAlJA8VFSsPFiAgKwcWGysPJBYkJBU5FQoVFQokLQcWFQ8xICAHBysWKxslICAkKw8VFSQQ + EjMRIAcxESUgIBYVJCQVFRUVJBUkFRUVJAoVFRUkFTkkChUVFRUkFhsrIBUVFRUVJCQ5FRUkJCQPFRU5 + KyAgFQcPFiAPJAcREBAgIBYHIBAQMSAgBw8rICAlEBEgFRUkJCQHERAzEiEhECEgDxY5FSQPFiQ5DyQk + FTkPLSArDyAgETEgMQ8xIDEPJCQ5LSAkICAWMSQVJBUVMSAQEBAQExAlCCAhMSArDyAgFiQVFQ8VFTkW + JBYkFRUaJBUVJBU5FRUtDw8hIi8hIBAgICAWJAgxICAWESAgICUILRYWIBYWKw8VFQoVJBUtDysVDyQt + JCAgICAlEBAQISAgJCQVLSEiJSElICUgECQxDyQVOSQkCgoKFRUkFSQkFTkkFSQVFRUPGysVLSQxICA5 + FRUVFSQkJBUVFQcxOTEVDw8VIA8kICExBzkkFTkPJCAuLxAuECAgGysxDyQIOSAgJQ8kFRUGDzEgBxAh + HSIgKxskFRUVOSQgByAkFQoVJCAPCDEMICUHIDEWORUIDxUkFTEVIA8rDyQ5FQ8VJA8VFSAgICAQEDEg + BxAlGxUVFRUkFRUVMSAWIBEgKyQVDzkVFSQVChUVDyQVJBYSHiIiEBAgORUkBxAQESEQAyAlEBAlHDIR + MRsVFSQVChUVFTkVFSQVFQ8rIBEgIBAhJSArDyQVFRUPEBEHFiAPMTEVJCQVFSAkDyQVJA85IBYPJBYr + DxUVJCQxKyAPJBUWCCsgDxYtBzkkLRUVLSsPJAYkKw8gMSUgMQsWDw8lGwoVCg8gIhAmISEQMiAPORUV + FQYkFQ8rDyQWJDkkDyAVIiIlIA8VJBUVJA8kDw8HDzkkJCQKOQwgOQcxKwcQBw8kOSQPByAWJCsgBxsW + DysbOSAkJAY5MRAgICEhISEkJBY5JBUVDxU5DysHFiAHDBElIBYKORUkFRUKJBUVFRUkFRAOISEgFgcx + DDEuECAkFiArESAgESYSIRAgICsVFRUVFRUVJBUVCiQtDwcgIRYgFQ8WMQ8kJAoVFTElMQgMIA8PJA8k + MSAQICsVFRYVFiA5IBsPMQ85FTkGDyArGiAWICQxJDEgMTEWMSQWJCQgDy0WFQ8gKy0gIBEvIBAhESAW + JCQkIBATERAQISEQBw8kByQkFhU5JA8xIA8WByArIBAHIAgxJAoVJBYPIA85JCsPJBUkOSQkCBUPGw8x + DyQkLRYkKyALICURJTExKw8rICsIFjkVFgcQIBAhCRAgFiAxFRU5JAoVJAcgIAcxICAgJSArLRUVFRUk + FhUVChUVChUVCBYmCSEgFhsgDCAgICArESU5EBIhISYiLyEHMSQPORUkFRUPJBUkORUVJBUtFhULOQgg + JBUWORUVERAuMSAQIS0xIC4iITIgIBYkJCArMRsWJBUkLSQPJCAPGyAxJCsxBwgtIBYbLSAPDy0rLSQP + JDEgIBYgICUQECEiISEhCyQGICsIMhAgJSURJSAgGjExFi0WKwggMRYkGiQuICEgJDEVFQoVCjkkLSQG + FRUxICQPFRUVFTEWFiskDyQtFhYkICAgICAQIC4uICAtFhsgJSsPJDkVDyAgIC4gERYHKwgkFRUkFhsa + JCsgECUQIiAgFhUVFSQPJA8VJBUkChUVJCQtISAQICs5BiQHJSAgICAgEBAxCCsQEBAhLgckFhYGGxYk + ICQVJBUVJBUkJBUkJA8kIBYPMQ8VFSQxERYgEBASEBAQISEQIDEkBzEgBw8kJBU5FRUVMRYVDysHOQ8G + MS0rDysWFhYxFisPJA8VJBYgJQckDysbEC4QISEQECAxIC0WDxYHEBARIDEgJSAgICArICArICAQICAg + FiAHByAVJCQVFQ8VFSQkFSQgECAPJDkVFSQPGyAgKzkLDyQHLSAQMSUgICAWESUHISArICAbJCAWORUP + ORUkJBUgLQ85FQ8WLSsWMSAHICENEAcmEDEWFTErFisgDxUVFRUVChUVJBAhMhsHFiQkIBwQMSAWMRsV + FQoKFRUkCDEQJSAgJTElBxsxBy0xFRUWJBUPIBYWKw8rIBQgFRUVFSAhICAQICAhIC4IJDEgMSQWICQP + FRUkBjkPFi0PFSQgFhYxMQ8WLSAgMQcWIC0HIBYPOTExGyQgJQggMSArLg0hEyEvISEhMTEQMhEQMxwh + ICAgICsPICAWByAHIBAQMSAgEDEgFRUVFRUVFTEHJBUPMSAVFRUVBi0rFisgECAkJBUkJCsgIAcRESUg + DyscIA8tFSAHICArDyQVDyQVFSQVJA8rFSQPFQ8gFgcxICsgLRUVCiAHJCAWDyAGICsPICQKFRUKFRUH + BxwQISUWFiAkGxYkBw85JCQkChUKFRUgLhAuISAgJCsHMQ8rCCQkGxYPKyAgICAgICAWJDkVFQoVFREg + ICAPECEkJBUVFhstOQ8kORUkFSQPLRU5KyQgICQtMRYbKyUPICAgKw8rBisgKxYgBxYPFiAgJSAlESAg + ECEQISEiDiEIOQgQICAQIi8zHCUQICsQHCAaIBAhJQcgLhEgJC0VFRU5MTkgDxUPByAPKzEkJCQWDyAH + FhsWCBUkJCQtBg8gEBAtDyAQJSs5FSsgKxYxIBYxDzkKFQoVFQ8WFRUPOQokFTkVFRYlJBUVFTkVGjEr + LSQrJBYPLRUVChUkFRUVJCQVFRUIICQVFRUkBjEkDwoVFSQKFRUVFS4dDhAgJBUgICAgICAyICURJREl + ICArByQHDw8kFSQKFRUVORUkORUGMS0xJBUkFRUVOSQVDyQVFSQkDw8IDzkWFQY5BxYgOTEkIDEVIC0x + ICUHJDEPKwctKxwrICAgBiQPIRIiISIhMQoVFSQtISIeHh4zISAPCCEgECAgGiA5ECElIQ8VDyA5ByAH + FiQtJA8xJBYgIAwgICAkMQ8kDxUVFSQHFSQrMTEgECUWICAHICAgICAbICUxDxUVJAoVFSQRICQ5JBUV + JBUPFSQtBwoVFRUkBiQgEA85JA8WFRUVFhUkFRUtFRUVDxUVJCQkFQoVCjkPDxUVFQoVChUKFS0gESEQ + ICsgIBwhIA8kICEQIBAxIAg5DyAWGysgDyQkJBUVCgoVChUVJCAQITEkFRUkJBUkICQkMSsVJBUPLSQV + DyQxJBYtFQ8HMRAgICAQECAxICAVMQ85Fg8WDy4WJBUkDyAREAcPESA5FRUKFRUgEiIeHg4zMRYWICAg + MSQgIBARJA8PJDEgICAgKy0VFQ8WFQotMSAhECAWJCQVJCsxLRYlIDkVICstDy0kGyALICEOIhEkJCAH + ICsVLSQkLRUWMSAkBjEkJDEkFS0WDxUVJDEkFRUVFisWByQPJBUVKyQVFSQWJBUVCjkkFRUVDxU5FRUV + BiQ5FSQVFRUKFQoVFRUkIA8HIAcgDwYVFQ8gJCAlICQVFRU5FjEgKyAlBxYtJBUVFQoVGyskFi4RIBYk + LSQGMSQgMSAbIBYtJCQVKyQVFiAWJCQxJCAxECEuIBEgLQ8xIDEgICArIDkEORUVOSQ5FRUkFRUVFRUV + FQokJCAgISIiIiEgJCAlECUgECEIJBU5FRUgEDMhJQ8rFRUrIC0gJSUPJC0rICAkFRUPByAQMQ8GKy0G + JBUPFRogECETFyEgJCsgDyAPFiQkJBUkByUtFRoIFg8kFSQrICQKOQcPFSQxIC4gMjElIA8WICAxJC4g + MSQKFQoVDzEGFRUVFSQVJAoVFQoVJBUkFRUVFQokFSQxLiEQIDkVCgoVFRUVHCAVFhUkDyQPDwcgMSAr + JBUVFSQVFQ8gLRslICAtDysVOQ8MIBErICAkJCQVOQ8kJBUkMS0IIAcgEBEgFSQVFRUPMSAgIC8hIBsW + JCQVJBUVFQoVFQokFRU5JBUVJBUVDyEiDh4eMyAgECEHIDEHMRUkFQoVCi0QIh0hJSAgMSArEzEgDxYP + GxYIKzEbITIhISAgJBYWKyQVJCAgIDEQFTkIFi4gICsVORUkJBUVMREgJBUVORUGJDEWIBUVJCQVKyUQ + EAcHBzEgMTEWIDEQICAPKzkPFSQVCjkHKw85FRUVFSQVFSQVChUVFSQPOQoVFRUKFRASITEPJBUVFRUV + FSQWIS0xICAgFiQ5ByAgDzEgICQkFRU5FSQrIBshIActGxYgOSArMQgrLRUkFRUVIAw5LRUVJBUbMRUP + JBU5JBUkFS0gEBcHKxAyICsVFSQkFQoVChUkFSQkDyQWLSsPFRYtAQchDh4wIRAdIRYgFjEPJBUVFSQV + OSUNLyEgEBAgHCAgJCstMQsPOSAQExAmEC4QDzktJA8kFSQVLQ8gJBUKFSQmIiUPFRUVDwcWICAQIBUV + JA8VOQoVBiQVJCQtDyAgLiUgJCQgFiUWFgwHByAWKw8VFSQVChUKKwcgFRU5FRUkFQoVJAoVJBYWORYk + FQoKFSQkICAVFSQ5FRU5BjkKBiAQFiAgKw8kFRUxJSEcISAgJBUVFRUxIS0rFisxDysPDwgxDw8kKxUk + DxUPFSQxDxUVJBUkFRUkLRUVCiQVJA8lIDEgICAkIBsgOSQGFRUVORUPFiQgJBYgFiAgISAkFTkVJCQR + IhIQJRAgKw8HJBUVFRUkFRUbIB4mICAQEQcgLRYPIBYrLRYgICUuEBEgFRUVFQYxBhUVFQokJAoVFQok + EBAhFg8VLSsgGyEhEiQWLSQbFRU5JBYPFg8rCCEhIREkCiQVDyQkByAgETErBwg5FRUKFQoVFQokJA8k + DyQVFRUkFSQPFSAxIAckFRUVFQoVFTkVDyQVBxskFRUVFSQgISAtBiQkJBUVIBEhEjAhIA8kOSQPGyAQ + ICEgJA85FRUkLSQxDwYPJBYPJDEWKxYtORUVFQokFSQkDyQxFiAkIDEPICAHJCQPKyQIKzkkFSQgIDEb + MSAhIBAgICAPJAoKFRUKFQQPICQHICAhFiAbIDEWBy0kJCQgECAtOSQPFg85FhsgBzEgKyAPFjkWDxUV + FRoVJA8kFRUKFQoVCgoVMQ85DxYxJA8gEDMNJiQxJBYWFg8rFiAhIS8vDiIQICQVCiQVChUVJBYQFjEG + FSQVFSQVJCQVChUKFQo5FRUVJBUKFRUVByUgFiQVOSQxJBUVFQoVFSsVJAckFi0VChUVCBASIS4uIA8P + MS0lECERMQ8rJBYPORUHISAgHAckLSQ5FSQPJDEkJCQtFQ8gECAgFg8PDxUVFRUVLRUgDyAWDyQPJC0r + IBUtMQ8gFi0PFjEVJBUgJRARJRAQICQkFRUVFQoVJBUVChUVFRYQECAhIS8hIBskJCQVFQcgFhYgJCQV + DyQaECAlICAHFiQGFTkxJCQbFgYWORUVFQoVChUVJAoHFhUgBzIQMiERIDEgBww5ByArDyAQIh4SEDEV + BjkVChUkJBUVFREHIBYHJCsbJBUVChUVFRUkChUVChUkFRUKChUVJCQtFgUkJA8VDyQtFiQkChUbERYl + ICUkFjkVFRUxECIhISEmISAQISAgKzEHICAgJBUVFRshJSAWLQ8rJCQkLQ8PFS0VFSQhEDIkByAlKyAr + LQ8kJBUkDyQILSQkORYWBg8kFiQWKyAWJC0rCAYxJC0gIBAhIRIxCgoKFQoVDyQrOSQgECIyITAwDiIw + Ii4WDy0VFRU5IBYIKyAgIDEgIBoRIA8kDzkPJCQPBiAlMSUPJA8WDyQkOSQgGysPGysPMSAREBAWOQ8V + FSEQISUPByAgIiAkDxUKFRUKFQokChUKJAoVFSQGJC0WKyQVFRUVChUKFQoVChUkJBUVFRUkChUKJCQ5 + FTkkIBYgFiQkFRUKJCAhBw8xICAPJBYVFRUQDSIiEyEhISAQFhEgIC4RFiQVJAo5ByEcLQ8kDw8xFSQk + FQ8rJDEgJSAHMSAPIBsWLQ8kJBU5FSQ5KxYWGxUPJDkWLS0PBy0kLRUVBjEkJCsHICExDyQVFRUVFSQt + KxYPByAhIiIfGR8fHx8eHg4iHCsVJAoVFRUgIA8WICUhEBE5BjkVIA8VBiQVFSQWICAxFiUREBAxKwsx + MSUgMSUPKwcxJSAPJBUKFQogMQcPMRYRISQKFQoVJBUKJCQkFRUVFRUKFSQVFRYWJBUxFi0VFQoVJA8k + FRUVFQoVLSQVFRUkFSQKFRUVFRUPOQcWDxUVFQoKIDkVFQ8VJDkVORUVOSQgIDEHMSAPJBUVDzExORUV + FRUkJA8hIhIgJA85LRUVOSQHMQYkBwclISArFiQPJBYrJQ8VCg8kDwYgJBUkFRUPFSsgOQ8PFiskKxUW + MQcxDysHIDEVCgoVJA8WASAxICAhIRAQEiIOIiITDSYTISEuDyQkFRU5JBYPJCAQESUPDxUVJCArIDkV + CjEPJSAHBxEgIC0VBhAQICAgJSAQICQPMQckORUkFRUkFS0rICAhIS0VFRU5FRUVChUkFSQVChUVOQsV + FjkPDwwgKwgrJCQkFSQVMSQ5FQokFRUWDxYgICQVFQoVFTkkFhYtFiQVORUVFQ8gMTkkJBUPDxUVChUV + FRUVJBUVFRUKJBUPDxUkOSQkMQ8kBCETITEkDyQVFRUVBiQKFRUtFiArIBsxDBAgICAgKyQgMSstJBU5 + FQ85FRUVJBUkMQ8gIBYuICEQIBYgIAcgICAgICsPKyAgJSAxCCURDxEgKxskJDkGJCAHMg8gKy0rJA8b + KyAgECAxBiQkFSQPDxUVKy0kByQWICAlEDEVFRUtMTEhMSUQLiAtFRYgGxYPBhUWFjERFg8QIRAkCgoK + FQoVChUVFRUkJCQVJBUVDxYHFjEgIA8WFhYtBxYVFQYVFRUVFRUkLSsbFiQKChUkBxUkCQckDystDyQk + ChUVISEWBxUkMRUrFRUVChUKFQoVChUKFRUVFQ8tGisPLi0kJA8WIS8gByQtJBUkLSQVOSQVDxUVJBYW + IDEgMTEQMgcbKwcgBxYPDw8VJA8tLSQWFSQPFiAgIRAQEC4uIDkxKyAQMSAgFiAgMRwQIBYPGxYxESUg + FhUVFSQVLQglICAPFSsHJSAgIDkhMSQgJTEgFhUtDw8rFiAgEDEgKw8kFQoVCg8gByAhIBYgKyAgEBIh + JRYrICQPJBUgIBUVCjkVFRUKFSQVDxUkBjEVFRUkFRUVCCQGICsHDzkEJBYkMRUkKxUVFSQVJA8gJSQK + FRUVFSQgDyskMQcgBysxCC0kJBASECAPBzExMTEHDxUkFSQVFSQVFSQVCiQ5JBUbJA8VFSQkORAvIS4k + FhUtJCQkFggVLSstJBUtJAcHDwcWLRYrFQ8gDzExMTErICsHKxYtMSAtJC0kIBAhECEMECAgIBAgICAg + IBskByUHBxYgJBUgICAgIDEVChUVChUkGxYxIA85Dy0tKyAWICEuBxsxOSQVDysPCxsHDyAHICAkFRUV + FRUkICUcIA8VFSAvHQ4iEhMgIDEWFiAgMRUkFSQVJCQkORYrBzkWKy0rFRUkFSQVJBUVFRUPORUVFRYx + BxYPLQg5JCQVChUVCC0VFTkkJBUtFTEkDyQWMRAgICsWKy4rICYNICAWERAROSQkFSQVFQokOSQVFTkV + Dw8WJBY5FRUkFRUgHQ4hLiAkJA8xICQtJA8gKxUVJBUPIDEgKyAHIBYPKw8WBiQHICUgGyAgICQWFhYP + JAYkFiAgICAgICAhIBYgMSslJS4gGxsyMSQkFS0rGyAbFiQVFQoVFSQPICAWFRUVBiQVDxYQIi4gDw8H + MQcWLSQgJCUgByAgDyQKFS0VFSQtDyQVJBUVIBMSIDEMDzEgMSAWMSAWFQ8PLQ8rJSAPFRYHIBYkDyQ5 + ChUkFSQVJBUkFQokJBoVDyQVFRUVCiQVChUKFQoVJBUVFTkVFTEkFg8xDzEgDCAgGyAgICAcIRAgFiAg + IDEPLRUkJCQkJBUVFRUVDysgDyQPJAoVFSQVBhM3IiEQICQPJCQkCzEPDy0HMSQ5KxUxDyAgISAgFSAg + JDEkDyAHICUxIBYgDyQtKw8xFRsrISEhECEhFiAxIDEHIBYPFRUVMQggBxUVFSQkFTkPLRUVJAoVBzEl + ICsPIBYPIDEVDyASIiIvECAPMQcyFg8gDzkHFS0rICQVDzkVFTkVCgoVOSQVFSQkFSQ5FRUPCAc5ICAL + JRoWIActKzEHJBYkICsVFRUVJBUkJBUVFRUkFRUVDxUVFSQVJBUVCiQVJAoVChUVChUVJA8gJSQVFiQM + DyQgEBAiLwchISUlIDEPIDIIKyQGLTEIDzkxIAYPMSAgBys5FSQVJBUVJCQkEg4dICAgICQVJA8kBhUP + KyAgBw8xJCQVFggrByUgIActIBEgJC0PORsrICsgByAlMRYrLQcgKyAgByAgLiAgMSQVFSQrMSAHKy0k + FRUkJBUKFRUVJBUVFTkHIBAlICUlDwckJBUkCCEhEA4iICQgByAHKxUkFSQGICAMJBYVFRUVJBUVJCQK + FRUKFQ8WFRUrFSsxAQcrICAgIAIrMQYbKzEHBxYrDzkVChUPDxUVChUkFRUkFTkVFQoVChUVChUVChUK + JAoVCiQVChUVLQYWJAcgIBAlIAcQECAQGw0QECEgFisILSQPFSQKFSQkDysxORU5FjkPDxU5KxYVFSQk + FSQhIiEgICsPMQ8PLSQkOSQkFjEkFSQkICsgFg8gFiArDBYxGxYkFRUkGyAgIDEgICARCDEIMRsxCCQg + FiAlESUgDy0gICAQICAaLSQkDw8VFRUVJCQVJCQPFiAgERARIRAgJBUkFRUlETEPISYuIBwgIC0PIBYk + JCsgICAgMQ8kKy0kFRUkFRU5FRUPMTEIMQ8HDxogESUgICAgByQlIQcgBisRJQcVJBUkFRUVCiQKFQoV + ChUKFRUkFRUKJBUKFRUKFRUkFRUVChU5FSQ5FQYxICAhESUhMQggEDEgIA8PKw8tFhYgOTkVJBUVMQ8g + CBUVFQ8PFjkWJA8rJCQVFRUVFg0iLiAgIDEgJA8kDyQgFQ8VICAgLhAHFiAxDysgIBsPICQkJCQWFiQV + JBYuFisgISArLSQVJBUVFQgcISEhIRAlIRARECAgICUgJBUxGyQKFSAMOSAkJCQxJCsRJQcxMRY5FjEP + LRUQECAhMiEmIBYkCysbJSAGDysgJBYgCCQkFjEgMTEPKysgJSAVKxUkKxslICARMQcQJSAgJRwgKyAt + Fg8yKw8WDyQVFRUVFQokFSQVJC0VORUKFQoVJAoVChUVFSQVFSQKFQoVFjEkFRYbFiAgBiQkOQcPJBUV + MSAhIDEkFRUkFSQkJCQPKxYgJC0kOSAxDyQgIDkVJDkWJC0RLxIgIBAlIAc5Dw8VFTkkKyAgFiAgDCQH + ETEkByQWKyAMICAxEQ8kORYgJCAgICEhIBUVFRU5FRUVFiAQIRIvISAxIDEgICAgICAxGiAxFSQ5IAcl + CBYxDw8kICAuBw8kCyARKxUVFS0iHh4eHSEHJCAHMiAHKwYtBzExJTkPLREQETIJIRsgETEbFRUkKyAW + ECAlMSUgKxYrBxAgGg8HKxUrBgcxJCQVFQoVJBUkFRUaIBYWFSQVFSQVFRUVFSQVJBUVFRUVFRUVJA8l + ECQVFRUPKw8kFRUVIBYgFiQxDxYVLRYkIBYxBhYWIC0WMSAWKxYVJCsWIBElBgcWDy0VDyEvIRwgIA8W + DxUtKxYrFhsgIRMMKyAHMSAWIBYWIC4QJSEQIDElFhsIFiUJISIiFistFSQkJBU5JCQgISIQIhAWDy0Q + ECAQHCEvISAQEA8PJC0xLSAxDyQVJA8kEC4hICAIKxUVFSQVCiQeIiEWLQ8gIAc5BxUWCCsgByAgFRU5 + JCAQJhAVJBUVFTklICUQIRwvFyAgBwctLQwxFiAgFS4WKy0GJBU5ChUVJBUVFQ8WICsHDyQVOQ8VFRUK + FQoVFRUVJBU5FRUKFSQkDyAPFQoVFQ8WLRUKFSQWIRAWFRUkFQ8VICsbFistOSUgKw8gECAxDzEgECAx + DzExDysWJDkQIh0OEyAWJC0rICAHICAgKw8kICAxFiQkByArByEQIBEQECUHMRsrMTEgIRAgMQcPFRUP + LQ8WCCQVICAPICAxCCsPKy0uHTASDRAbJC8QGysWCDErBwYxGxUVLRUHIAcrJAYtJBYkFRUkFQckFRUr + LSQtDyQgOSUQBiAtFQoVFTEgECAVFRUKFRUQMQcgBiQPJBYlICArFjEgDBYrJDEHOSArKzEVFRUkFRUV + JAYVOQ8tJAoVFSQkJBUVJBUkJBUVChUVJBUPORUVFSQVFjExJDErByQkFRUVDyQxICAVGy4rFRslISE1 + ByA5BzEgIActJAcgECAlMSsIICAWGxYPJA4iMDMQECQWIBAxMSsHFSQkFSQHIBYWGysgIBshEi8hLhEx + DxYgDwgrIA8gMRYbMRY5FisbGjErLSQVJDkVFiAtICAhIiIQLSQKFRUQLzItKw8CICAlICskFSstBisg + Dw8lKw8gJDkVFQoVLRUVFRUPKyQHDyAgIBYkFRUVFSQlEyAkOQoVFRUVMQ8GJDEVFSQkJAcHIBYlMSEP + MRYPFRYWDw8kFRUVFSQkDzkVDyQVChUKFQokChUkFRUPDyQtFSQVFRU5JCQVORUVFRsWDwwbMQcxDxUV + FRUVICsbKw8LICAxDyEQISAxICUHFjErDxYgISEgICAgFiArIDEtJCQkIRAgESAkByAgJRAgICAPFg8t + DwcgJAckCCAHECAXEhIQESQtJBYkLSUgKyAbKw8gDyQkFg8gICAkFTkVDyAxECEhEhAIFQoKFRUKFQkS + IRsxMSAxICAgIDkWCCsPICstMQ8gKy0GFRUVJCQPLQ8kMRsWMRYVMSQGFhsVJCQkISAPFRUkFS0xLRUV + JCQkFQ8WFRUVGyUQICQHJBYHICsgBzEVFTkkBiQGIBUVBhUVFSQVChUVFQoVFSQkBy0VFRUVOSQkDysk + DxUkJAoVFSAkLSsICCstLRUtMREgJSAWMSAQICAkBiAQLisgMSAgByAxGwcgMQcxIDEgJQ8PLQ8kFRw5 + ICAgIA8PGyAgJTEHJCAkFisgKyAxMTEPKwYWESQPLSQVJCQPIBYxICAxKwoVKyAHOQ85FQY5FSQVFRUP + ESAhISQVFQoVFRUKFSQ5HiUhECAHJSAhEBAlBxYWICUHJQ8HKw8PJBU5JBUVISAgIBYVJA8kMRYPJRsr + IBYHFiAWJCQkFi0rFiAVFRUPFjkWKw8VORYVDysVFiAWEAcxBysVFRUkFTkVFRUkGg8rMSQkBhU5FQoV + FSQILTEkJBUVFRUVFQ8PJBUtJBUVFSQPDxUVDysPBystJAclIBAgGzEgJRwlESUrIBAyIAsWByAHIBYk + JBUxBzEgFi0HKxYrJBUKFRUgECAlKyAgIDEWICUtByAPMSAHBw8rORUGETkkJCQWDw8xLSsgDzEgMRUP + IBsrDxUPJBUVFRUVJBU5DyAQIS4tJBUkKxUkFSQVDxAiLxAgICAQECEgMTEgIDEgEBAgJSAWJBUkFSQV + FSESJhElLRUxFg8MMSQWIDEgDyAgORUbIDEuBxsgJCsPKxsWGyAkKzEIJBU5FjEHFiAPKzEkMSAtFQgK + KxYGLSQxFQ8LFjEWFQoVJBUVJBUkFQoVFTkVJC0WORUVFjEPFRUGJAIkKyAgJRwVChUVMSAtKxYxDyQx + IAcRLiAxDyQPMSArLSsPFjEPBxYgMSArICARICQVFQoVJBEgESAaICstJC0kFiQgMS0rJSAgCA8VOSQV + FRUxLSsgJSAgICAgBxUVKxYPMTEHORUtJBUkLSsWJA8WGyQHFSQtBxstOQ8kJCQPIiIuECAgJSETECAP + KwcgIBEQIAcgIBYtBw8xJCstMCEvIBYkJBUtBgcgKzEkJCQgKw8VBiArCCsWKw8WLQsPFisWMQcgCy0W + JAgxFiAxDw8WKy0aJC0rBy0kFRYkFRYVDzkIJBUkChUKJBUKFQoVFSQKFRUkFSQLCCQkKyAWFiAgMSAW + ICAGFSQVFTkHICAbJCQVJAo5DxYHDxYgMSAgByAgKxsWJDEPFg8gIAcrJSAVORUkFSQkJCUPLSQVBjEV + FS0VJBUVFS0PKzErICQVJDkPLRYgIC4RIDEgFSQWISAgFQ8kIRwWKxYxIAcPIBUkORUKFRUkFSQLFRUK + FQoVFSAiIi8RICAPECUHIQcuBzEgKyAgFiAxMTExMRYgBiAiEAcQICAgBysPICAPIDECJAgHMRYkLRYg + DyQkFRYkFiQHIAsPFjkVBiQKFQgxBysxJBYWJC0VDwcWFQYrDw8kLRUVFRUVFRUVFRUVCiQKFSQkFRUK + FSQVOSsGLS0gECEhIRAcETEVJBUVFRUVJBUVKxYHJBUkJBUVJCAkIBAWESAgDyAlMS0WJCArByUgECAx + FRUKFRUVFTEtLQ8VOSQVDysPBystJA8kJA8gDy0WICsPFSsbIRAvIRAgCzkgIBExFSQHJSEgICEgICUR + ECsgJAYVJC0PFSQKFQoVFRU5FQoVEA4iISAlKzEkGysQMSsVFRYbKwcxBwwHJQcgFiQGMTEbFSsVJCQP + ERYgICsELSAlIDEHFhYkByArCBYPIDEgMSArDxUVFQoVFSQVJA8gICAWJDEVJAcxJCAkMRU5FhUVFRUk + FRUVFSQKFQ8kFRUKFRU5FRUVFSQPFRUPIDERMQctJBUKFRUVFRUVFSQbMQcgITIgJS0kMSAxFjkGLTEg + ECElGyAHMSAgECUhIBEgICQkFRUKJAoVGyQVBgsWLQ8tKxsIKyAlDxUkOQskFg8gORUPJTEyMRYGMREl + IC4xBisgLhAlECARJSAgIC4gByUPLRUkFSQkJCA5FjEPJBUVCiQGEhIlIA8PFRUPDwcPFgYxMSAgJSAu + ICAhIAcrLSQTIiEgICUQECUtFjEPFRUgISsWFjEbMSQKMSsbJBUkJCsWMQ8tFQokFSsrBg8rFhYxJAsP + JRYxBhYHJBUVBiQkORUtFS0VJDkPOSQVJAo5FRUVDwYVFSQHFRUKFRUVChUKFQoVFQoVFRUtJBsrJAYk + FisgERULICAHLSQGORYbJi8iCSUgFgsQESAgKyArFiAkOSQkFRUVJA8VLTErJDErDwsWDzEHJCAWFSQP + BhYWDwsVJAgbBzEgMTEgESEWFRUgIRAgICAgICExIBAMECAgDyQ5FSQkBiAxFjEgIBYrJBUVFRUQISEu + Fi0WMSArBzElICsgICEQIRAgDwgGDxUkFRIiISAgMSAgJRYkFiQlECAWJC0xBxYgLRYtFiAxFg8PFSQV + FRUVFRUkFhEgBzEVFSQlICQxByQVFRUtJBUVFRUVJA8kFRUkFRUVFTkVFSQVOQ8kFiAxFS0kOQoKChUK + FRUKChUKMSQVFRUVDw8rMQYWDxUkOQckFSQVJCAuECINIBYgMSAgJSAgICAWLSsIFRUtJCQVFQ85FS0k + LRUVBjEkJCQPJBYtOSAaDzEgJDExIDEVFQ8gJCUlMRAWJBUPIBAMEBAhJSAkFiAWICAyEDkkFSQkDyQW + LSAHLisgIBYbFRUVLSIvISEQGyAHIBYgGyAgECEhIQcrDysrFTkVFQoVAzMQESUkCAcgICAlIAcgMQcV + JBYxISArDxYgDzkkFSQVDwoVFRUPBxAgDCAPJCQVBjkHECAlIDEgDxUtJCQVFSQVORUPKyQkORUVFSAg + KxYWLiEQKy0PFRUVFSQVORUVFRUVOQ8PJBUkFS0HIA8kBzkPDwskDyQWDxwiHiIhEC0hISAWMSAPMQ8H + KwcgISQtJCQkFSQKJCQVDxUWFiQkFhUtJBYbKw8gKy0bJSAgICAPFRY5FQ8tCC0PLS0gDyQaGyAxESUr + ICAgISEGICQPJC0WDyQxFRUVLQchJREQFjIgKxYPEBIQJCQVGyAQIAwQITEWBhUkDyAgICQPFiQVCgot + BzEgGystFiIQESA5CBYtFhYHIAcxJQ8VDxYWFRU5FTkVLSsxDzErMQg5FRUkFSQVFSQPJQMlBysxKy0G + OSQkFRUVOQ8VFRUkJAgPGzEIMQcRJSAWKxUVFQoVFRUVFRUkFRUVFTkVFRUVJCAxFjkGFRUkDzkgICES + IBEkJC0QIhIvJi4xKwclMRsgIBwVKw8kFSQkFRUVFTkWLQ8gIBYPDxUkFiAgECARJRYgICUgICQVJCQV + FRUkJBUkIBwgLRUGICQHEA8WJBUKLTEVICAlMTEkDyQkMRYHIBAgIREWBCAtFRUVJBU5BysgECAtJBYg + JBUkJSEQESAHKxskChUVFRUIJgwIFQo5ICsgKzEWFhEhIDEkGw8xGjkVLRokFSQVJCQkDxYHDyQVFSQV + ChUVFTkVBiQgIAcPBw8VJBUWBxUkFRUVChUVFRU5FRUVFQ8tKw8rICAgMRYWORUWLS0VJBskJBUPDxYG + ORUVJAgkORUVORUkDyIhFRUKFRUkGyQREBEHDyAuIA8WKyAgJC0kLSAgDxU5FRUPKyUgKwcWMSsgICAr + ECAxJBYkFSQPLSAxDzEVFRUVFSQVFSsgEBA5JCQgLSAxMSAVFhYgKw8RIC0tFiQWIBAQJREhECUgMRAl + MQ8kFQokDw8gECAQJSArFQcgIBAQICUHIAcWFRUPCiQxEQ8tFRUVCg8HEBAgLRUxFjEgICsHOQ8kFQct + FSQVFSQVDxUkORUkJBUVFTkrFQ8VFQoVFSQPOSQlJCQPJC0rFSQVJBUVOQYkFSQVJBUkFS0VDzEHKwck + BgoVJCArJSA5FRUKFSQWJBUVJAokFRUkFSQVFiEhJCQVJBUVFRUVFSQkMSAhByQPMQ8WESAGMSUxMQ8g + Fg8WBwcgICAlIBEgJRAhICAhISAHDw85OQctFg8kDzkkDw8kFRUVICAgICAkFhAgIAcPJCAgDw8MMSAM + JSAgESAgICAmISEgIBAgESAPFjkVJA8rICAgECAgFhsgITMcIRAQICAQICAgKzEHICskKxUPCiQrIDEP + FhUVCg8IIQwgMQ8HMRUVJBUVFSQVBiQkFg8WFRUVFRUWFQ8kJCQ5JA8VGysVDwYkJBYWJAskFQoVFRUV + FSQkFRUVJCQVFTEWICAgFiArLRYgICAIJBUPFSQxFjkkJC0kFQ8tICQPICEhCDkVFRUVFTkkFSQVJA8g + ICAPMSEgJRsVJCAtIAc5DzkgIDEIIBAhICAhECARCyQPICEhEDIrFhUVJBUVDy0kMSQ5DyQ5DyQPICEg + JDEPERYkBy0gKxUkICQHICAgEDIhECAQJRAcICEzISAgFhYIKzEgIBArFiAgFhElERIJMCIRFg8gKyAr + JSAQBwctFg8gKy0HIBskKw8kCiQkIBYIKwYVFiQVFTkKBg8kKyQrIC0VFSQVLRYWKyAlBzEaJAoKJBUV + KxU5JBUtLQg5FQoVFRUrCBYxFRUkFRUVJCQgISAQICEgICAhISAWJCQVORUxFhYGJCQkFTkVDy0rLRAS + CSQVFRUkJAYkKy4gJS4lICQVJBYkFgsgMS0bFg8gLRYWDyQHJRYHMSsGGjEgJBUVJCQbERAQEC0kJCQV + LSQkJBYkFRUPKzEGMRYxDzExJS4gICAgFSQtJBUHICsPBjEHGyAlEBAgFS0QMyAOLyEgJSAhJhAgICAx + MSAgByQHJRERECEhICQHIC4QIDIgKw8WICUhBxYrBiQWDzEgIDEVLQ8WIDkVMSQPMSsrDw8xCBYkFTkP + JBYxICAHLRUkFQoVFRUKJBUKFQoVChUKFSQVFRUtFjEkBisWORUVChUVDwcgEBAvIRAQIBEkJBUVFRUP + Dy0kJAY5FRUVJBUVDzEhICQVJCAtBysxDy0lICEhICA5JAYGMRsxICQWDzkgFhUPFQ8gMRYtJAgVJCAQ + JDEPJBUPFiAxJQ8xBzEPFg8lLhAbJDExICAPJBUPJCAgICEgIC0tJCQPKyA5IBAgKw8HMSsHICAgDyAW + ICEwIhIQIBAhERYQIBYgIBErGzEHJDkVFRUHKyAxMSQHMiAhECAMICAQIBAgFisPJCAgKwcPKxUkICQk + DwggJBUHJCQPKyQ5FRUGFRUWFgcrFRUkChUVFRUkChUKFQoVFSQKFRUVFSQVFQ8GJBUGJBUkFRUVFRUV + DyAxEBEbDxUVFRUKFRUVJBUVFjkkFSQPLSAkKwghEDkVBiQHMRsgKzEkDxYFIRAgICQxDxYgJSAbJAIW + JCAgICUgIBYgKxYkFSAgFRUkKzEkDyQVFRsHMQgGKxwrIBEhISQ5BhUVLSQ5DzEgEBExJBUkFjEgMSAg + ByAgECAlMQcgISE5BhUVJAYPCy4hIiEhByQkJREhLiUrBxUkJAYVFSQVJA8xDwYkLRUgBxAgMSAQMiEg + ICAgIC0PLSUuIBYPIA8PICQ5DxYGICQVLQoVFQokFTkPIDExBiQVFSQVFTkVFRUVFSQVJBUVFRUKFSQV + CyQrICUtFg8VJAYVORUkORUVJAoVFQokChUKFSQKFRUVKw8kDzkVFS0PMTEQMxAkFSQ5ICUgICAgJQc5 + FQ8gISURMSQgJTEgJSAgLiAHICQtJCAxByAPMRUHKw85DxstJCQPFRYrBiQVJC0gICArJBUKChUVFSQV + JBY5ICAgFRUKJDEgDyQhICUVJCQQICAWICEFFRUVChUkKyAQIC4QIAcVICAgEBAQICQ5FgY5FQYPFRUk + DyQkFRUPJDkGMREQIRMkLREQHSIiIjAjHiIgKxYWKy0kFhUkOSAgFisxORUkKw8kFhAHFRUWFhYkFRUK + FQokFQoVFRUVFQoVJBUkFSQ5DxEPGxUkLSQWOQcPFRUVChUKFQoVFRUKORUVFS0PJC0VFiQVFSQVJAYg + ISAGFSQtFggGLSstIA8kCCQkICElICAlIA8gJRwgJRAlJSsPBxYgICArIDEgICAPDw8rMQcrJDkgDw8k + IBYQESUgORUKFSQPORUrIA8PFi05FRUVFSQPMSQbGiAkMRUxLTEkBisKFRUKDzkxICAPMRUQIhAgIC0r + IA8tCDEWDwcrDzEPKxUVJCQgOS0VJBUkIAsWDxYWFhYlICUhISIOHxAPJAYkLQ8HJA8kFRUgJREgCBYW + BwcWDyAhJSQWKyAkORUkFRUVFQoVJBUKFRUVGg8rDysVByQkFRUPFSQVBg8kOQoVCiQVJCQVFQoVFSQP + JA8rDyQWJCQVJC0gDystIREVFTkkFiAWORUPJCQ5FSQVMQ8PDyQkDysWCA8gIBAgERAHMTkIIBAgECUb + Kw8rGysHBw8lLiAHJBUxICAhISExBhUVFSQrGyUuIQctFjkVCgoVOQ8kDyQGICAlICQPFgcWFhYPJC0r + ICAMEBEWIDEPFhAvISEhByQWESsgKyAgFg8xKy0VOQcgIBYrDyQkDw85Fgc5LQgxIA8rDyURIBE5FRUG + FhYWJCQkJAoVByQxKwgxICAxLiUxByQWICUgFiQVJCQkChUPJBUVORUVOQcWLQYtByAVFQoVFS0rDzkV + FRUVFQoVChUkFg8kJCAWFi0WDyAPBi0kJAYVIC0WISIlJCQkMTEgIA8kJA8VFRUVFSQVMSQWFjkPORUk + BisgMSAgICAlIBElECUQIDEHMQ8WLSQWGwchLiAxMS8NHCEgDyQkJBYxICAQICArJBUVFRUkJA8gJSQr + MRYgICAgICQIJCAgEBAmECAgISUQJhwWOQokISUHEDEHJBYlERAQKw8VDwcPKw8rLgcgBwYPJDkVFS0k + BhU5JBUxICAPORUKCgokCiQgJSAPECQVORYPFSQrICsxICUIDzkgECUhICAMFRUVFSQVFSQrFRUkGxYk + DysWKwglFhUVJCQgFhUVFRUVChUVChUKJCAxICAHICQPJCQkFSsVFRUPFRUrICEPDyQVOQYHBiskFQgg + KyQVJCQkOQ8rDyQHBxYVFRUGMREhISEQJSAgIBAQICAQIDEHICsPMRYgESEWGxUWICAgESEyICAQICUQ + ECAPBxUPDyQtICQWJA8gICAgIBASLyArMSAHMSEgJAcWJBYgICALFiQkFRUGJC0kICAkDyAxICUbKyQP + KxYPIBEyICsxKxYVFSQVDyQrFRUbDy0VFRUVFRUVFRUVLQcgFiAtFiQPJCQgIAwVJBUGJBUVChUtByAW + ORYWBiQVFRUkIA8VJBUVBzEHGyAWLSQtJAYPJAg5JBU5FSQkChUkFSQVLQ8kJA8gIActFQ85FQoVFTkP + LhEWFRUkJA8rJCQGMRYxICUxByQWDw8WCCAWICAVORUPJBUPMx4iMxwgDysgIRAuICALKyAgFgcIKxUV + FRUkOQYgICARIBAQJTEgITMiLyAgISEyECAxIBUkIC8QFiUgKwcIIDEWICAWMRYtFiUgFhElICAgJBUV + JBUkESAgMSsPECAQJTErICAgDysgECAgICAgJBUkJC0PORUVJBUkFQoVFTEHMSQVFQYVFRUWKw8rLQcl + ECAgLRUrLSstFRUKFSQVJCQPOQcgKw8tFQ8kFRUVJBUVFQY5DyQVFQoKFSQVChUVCiQKFRUVChUKFRU5 + FQokFQ8kFiQWDw8lFiQkGxYtJC0PJCsPDyQ5FQ8QISQRMSAgFjEMJBUPJCQGFRUVOSQVOQchEiEhERAb + ByUhECUgICAxJCAgJDEtIBYxBzk5FSQgEDMRHCEhEBshISIiHiIOIRAxETIgJS8RJSAgDw85JBogICAt + BzEgECAgHCUgIBAQIQ8gJBUkDysHJAYkFSQkCBogByAWORAgIBAxECAgKxUgICQPFSsgBhUVFRUkFRUg + EBEgJBUrFQ8xDxYPFSsgLhEgFRUkDwsPFQoVFRUVFSQkFQYkDyQVFjEVJBUkFSQkFRUVBiQVBiQkJBUV + ChUKFRUVJBUVFRUKFRUKFSQVFQoVJCAWOSQVCDEWICAkFRUVFS0kBzkVFSQgJC0lICUQJAcGLQ85FSQk + FRUVFRUVBxYPByAdLyEhEBAgESESISIhETEHMRYHFiUIDw8kChUKFTEQMyEhEiAPFRUEEBIiHjcdHCAQ + IRAQECAlETEHFg8tIAY5FistByAgECEPOQggMSExKxUWDyQVFSQkLQYVFQYtIBElICAgOQcRICAbMSAg + ICAPFjkPDzkVFRUVJBUkFiAhISAgLQ85DzkPJA8gBwwgFRUkFS0kFSQVJBUVOSQVFRUkJBUkFQ8kFRUV + FRUKFRUKFRU5AzkKFRUVChUkFRUkFSQkORUKFRUKChUVFRUVJCARIQ8VFSQtJCAkFSQVFSQkFjkWJBsr + DyAWDyAgIA8xFRUVFRUVCiQ5FQoVOSsgFjkPEBAQLSURFhUkLRAQECAgKwclJCAgKxYkJCQVJBUKFRsk + LgYxFRUKFQ8hIiImEiEuIBwgIBUxICUxJDEWKw8VJAYPMSAlECArFhUWFiAHByAgICsPOQ8WJBYkDyQk + Kw8gERAlIAcxICUgJSAgICArICsgJSQWJDkVDyQkICAPIRASISArFRUVDxUrFg8tJCQVChUkFRUPFQ8r + DxUKFRU5BhUVFRUkBhUVJBUkFSQkJBUVFRUVCiQKFSQVFRUkFRUVFSQVJCQKFRUVChU5JBUVDxUVJDkV + FSQVCgoVFQYWDzEHByAHJRsVFiAWISArBiQkMRUVChUKFQ8kDxUVJA8HFiQkDwgPMSs5FQYWESEQICUg + ByAgJSAGFi0VFQoVChUkDxUkDw8VFQokCActCCEiIiIQIDEtKwc5DxYgIAYWMQ8rIAckIRExFiArFiQg + Dy0yECAgBxYkMgcgKxUgFi0rMSAkGyskDyAvISEQIDEWECAgIBAgICsWICAlICUgFiQgBxAhFhUPKyAk + IA8VChUVChUKJBUkFRYPFi0KFSQVJBUkFSQVJBUkFRUVFSQHFRUVORUkChUVFRUkDyQkJBUPFSQVJBUk + FTkKJBUVFQ8VFRUVORUVChUKORUkDxYxFisPJDErDxYgFS0yECAgDxYgDxUVFTkVFRUGORUkORYkICQ5 + FQsrFgYPFiskJBUHMSAQISElESAHOSQkICQkJBUKFSQVFTkPORU5FSQKFSQPIR4wIhwtJBYcICQVJCAx + ICElIBYgDCAVECEhIBYlECAhJiERFjEIFgcgJSAgKxsWGxUgJBYgDzkgICERIAcgICAhEDExMQcHLTEg + IBAQERUVJDkVBxAxLiAgIDElOSQkFRUVFRUVORUkORUkCgoVJCQkFRUVFSQVFSQVFRYgMQ8PFg8kFSQV + FQ8VChUkJBUVJBUVFRUkFSQVJBUkJAYrORUVBg8kJCQVFRUkLSstBiAbFiAPIBYPIDERESArBzkLDzkV + JBUVFRUVJBUkDxYPDzExBistICArFjEgMSQbBysbKwgHIAcgJCQGECAHJBUkJA8VFRUKFQokFRUVFRUV + OQYgESEzExAgFhU5DwgtICAhEBwQICAHFSQHEBAQICAhIiIiIS4gICsgMSAuFhsWFTEWJCAhEQcrFRUP + JBYgLiElESUgICAkLSsGDyAtICAWFRUVFRYtIAcQIR0hBw8VFQokFRUkFRUVMQ8PJBUVGhUVJA8VJCQV + CiQVLQ85FjEHKxskIBUVDy0PORUVFRUkFSQkChUKFTkWIA8WJDEtDwgPJCQrISAgKxsrMQ8GDystKwYk + Bw8GJCQtKxYgGw8WCCQPGhUPFS0VFTEVJCQkDxUPFSQgIA85FiAWBzEIFiAkBiAgJTElOQYVJDEQLisV + BzkkJBUkFQokFRUVFRUVJBUVCjETDjAgICstKyArFjELByAhJSAgORYgDyAQECEQIRIQECEiEBYPIBYG + MRYtJBUgIA8WFhYPLiAKFQo5LiIQISEhECUgMQ8VChUVDysPKy0kFg8kLRYgFSISIBErFRUVFRUkFRUk + FSQVJA8VFSQkJBUVOQoVFRUVBiQkBhYVFiAgMQY5JA8VJBUVJBUkJDkKFRUVOSQGJCQGOQ8PJBU5FSQP + LSAhEyEWFQ8kKy0LFRUkJDkPFTkKFQggMSAlKw85JBUPFTkLJCQrFQoVFRUkFTkPFggPFiUhECAxKxUx + MRYWICAHIBYgICURJQcRIAckOQoPFRUVFi4uDyAkFRUVCiQVJCEiISAgICAgICAgIDkPJCAQISUuFisg + IAkTIiIQICQPDw85FSAkICAkJBUPMSAlISAhIRElORUkDwcQIhAQEBAvEAstDzEkJCQVJCQPMTExFiQg + KyAQMSAHIDkKFRUVFRUVORUPJBUVFRUVFSQVFRUVDw8GMSsgDxY5FhEgBxYkFgs5FRUVFRUVJBUKFRUV + FRUVFRUkFRUVORUkFSQPFSQkDyARGyArLQ8VJA8kJAokJBUVFQ8VIAcgHBsVFSQkJBUPOQgkFSQVFQoV + FRUVJCAxISAQJRAgIC0gIA8WFhEbFhsrIBExMQcPMSArDystFRUVLiAiIi8WFQoKFQoVCgoHISIvECAt + EBsgICAgGyUhECAgEBAPFgckFiEiMRUkJCQVFRUVFRYWBhU5JCAgECEJIiEhEBYkJBYgFiAQICURECAl + Kw8xByAtFhYIMSAWJBoHICAlIAY5FRUKFQotFSQVJBUVKyQkGjkVKw8aLSQkBisxJA8PMSQgFhAgFi0P + IA8xIA85FjEWLRUVJCQPLSQxLTkVFQoVFRUVFRUVLRUVFRUKFSQgBhUkDyQxFhUVBysPFQoKFRYQIR4h + JBUVJBUkFRUWDzkVDy0rLSQVJCAgISEiIS8vIC4HMSArMTEVFQ8gDxYgJSAgKyAgIDEgJSAxDxYmEBAg + BhUVJAoVFRUVFRUQDSEiIiAxMiAgESEgJAcgKyAgJDkkMRYELQ8VFRUVChUKFTkkJDkVDxUkFhAgICEQ + ISAgGyAxDzkPBxAgICAxESAlFiAPKyAxFgclESAgJCAQBxsgBiQkFRUkFRUVFRU5FRUVJBYPFg8tJCQG + FRUGFRU5JA8MFhElJCsVKw8rFRUVFg8xCDEkJBUVGhYxDysVFSQVFRUkFTkVJBUVFRUkFSQVFSQkDxUk + JCQtDxUPFTkVFRUPICIiISAgJBUVFRUVORUVDyQWDxYPLQ8gMREPEBAWFiAzICAgFg8kFRUkFTkPJAcW + JDEPMQ8kOQcuECElCCQkFTkkFRYkFiQ5ChUWGyAhITMwDg4zHCUxFRU5MQ8RMQcHMQckFSQWFQoVChUk + JC0VFQ8VFQoVDyAgMRAQIRMhMyEhIS4HISUhIQ0hISAgGyAlKyAgByAgByAlECAWICElJBYKFRUVFSQt + FgYPJBU5BistFisPKxYkFSQVJBUkDw8WGwcuIA8GLQcgDyQVFSAkLRUPBg8kFi0PBxYVFS0kBjkVFRUV + JBYVDzkkDwYVJCQkFRUkJAokFSQkLSQVFRUVMSEiIQckFQ8VFRUKFRUVChUtIA8rDystDzEWJBsWIR0Q + IRAQIDEgBwcrFQokFQ85DxUWJBUkFQ8rISEyCCQKFRUGICAQICAkKy0tFRUPKwcQIRMvIiEPBg8VDzkV + FSQPJCQkFRUWJCQ5FQoVOQoVFRU5FQo5FSQgIBEgLhAhECEhIiIhBw8PETEgIS8iMxcgICAgIBAgBjEQ + HSAxICAgIA85JBUKMS0WICQ5JBsHDyQWKw8WLS0PFS0VDzkPLSsgFhUPOQoVCystFQ8WIBAgFg8GKw8r + GxsrFiQVJA8VFRUPFggPFTEgKy0WFhYkFRUVCiQVFRUKFRUtChUKFQokDyATEDEkDy0aFTEtJDkkJC0r + FjkxGzEPKyAPDy0kIAcxERExICAgIS4tICQkFTkVFS0kIA8VJDkPFiERJBUVJBUkISUHIS8gDw8rICQx + LiAVKw8xEBEHJDkVJBUkDxUkFiUHIC0PLQcxFRUVChUVChUVChUVBgYVKyAgIBUkBxAiIiYiITkkFSQV + OS8iMB4eMxMgJCAQJSAQICsHMRAhESEPFSQgOSAxMQgkBhYkORYtFhYgKxYWJA8VJBUGFgcHIC4kBhUV + FTEIJBUbECAtFQ8rFiAtBhoVIA85Dy0kFRUWJBYrICAgICArByQtFi0kJCQVJCQVFSQVJBUVFRUVFSQg + MRsgITIQIAYkBwgkFhYgDwcgEQcxJRwgJBUVJBUVORUkGwYtICEiHjAuJCsVJCQkFg8kOQ8VDzkGJBUk + Gg8QIREWICUkISEWICQgDyArDy0PMRUkOQ8PDysbJDkPJCQHDysPKxUtDyQKFRUKJBUKFRUVOQ8kFS0l + Kw8kJA8xERAPCBEgBhUVFQoVERIiHh4wMw8WDyAgICAkICAQEQ8tJBYbICAgIAcrJBUkDxUGKw8rMQ8P + MQYxKxYHMQ8VJCAPKysVKy0kFSQVFRUkFRUrDyQ5KxUkDyQVFSsWFhYgIBAgByAEFjEHByARKw8kBhUV + JBUtFRUVJBUVJBUtFRUVFRUVOSQWERYWFhYrByAkByQxCCQrGyUgJTEtLSQWORYVJCQVJA8VICETIiAk + FRU5Dw85FRUkJBU5JDkPDwggICAQEBAhICEtICQHOTEWIAcrJCsPFRU5FSstFRUKFSQVFTEgICQVFSQL + ORUKFQoKJAo5DA8rDwckBi0VFRUkORUVFRUkFSQVFQoVJA8gMSESDiIhMSsgESElMSUhFiQkJBUkMSEv + ECAWJBUVIDEPMQ8xFSsPKxYxKwcbJQckLQ8WJAYtDwgkFRUKFRUKFRUHJSEgBxUVJAYtFRUVMSAxFiAg + ByArFTktIBAhJSAgFjEVJBUVJAYaFQY5DyQVFRU5JBUrDyQHIBYgLxMhICAgECAxCCArICAlMQggICAg + IBYkFhsVJA85FRUkByAPLRUVFRUVFSQVFRUVICsHKzErIBAQLiEgGzEPECIgMRYkICQgJQcuIA8PFSQW + Fg8PFRUkDxYPIBAGFRUVDw8VJCQVFRUkCC0xDy0WDyQkFSQVFRUVCiQKFRUVOSQVFSQVFQghIiIfHiIg + IBchByAgCDEVFSQVFQotEA4vHDIgIBYgFgckFQ8xDyAgBwglKw8gFisPJCQVJC0kFRUkJBU5FRUVFQgG + KyQHMQckJAYgDyQWICArFiA5JA8PByARICAlJAckFSQkFQoVJDkkFRUkFSQVJA8VGw8VMRUgISIeIiAl + ETIgEBAlIC0tCCAgFiAgFgcgMS05DwYxIA8VFRUrFQ8kJCQtFjEgFjEkJAYHICARICUrGyElJCQVFSQV + EBEgIDEHMQcQEAc5FSQPJC0VDy0kFiQgFhYxFjkkJDkkFSQkFQokFQokFRUVJDkVFRUVORUKFRUVJBUk + FSQkICQgFQ8xDw8HEA4eMCEQLyEHFhYgJCQVChUkFQ8lEjMJIBAQLiExDy0PKxYkLSsgICUlLQckORUV + FSQkFhYxFi0kBxYtMS0VKyAgKw8tFQorJCstJDEIDyQVFQsrLSsgDxYHIA8PMSQVFTkVJAoVJA8VJBUV + Fi0VFRUkLSsPKyArBw8POSQPMSAgICAVLRU5MRUPFSQVKw8WFhYkJC0KFSQPICAWJCAgFjEWFjEQICAW + KyAQIBsWICUGJBUVCiQHIBYgHCEQISAgIAUgFhUbFg8VFRUkFiAlICUgFiAPFSQVCiQPFiQVFRUKFRUK + FRUVFTkkFRUVORUVFg8kOTEWBxYuIBAgJBUkFTkVECINIBEQJS0PKw8VJBUVJBUVLSASISUgESUHICQW + KyAPIAsxBxAHGyQVJAoVChUPFiARJSAWIA8xDCQPKw8HBw8HFiQkFQsPCxoHKzEHJBUtDw8PFRU5LQsV + JA8VFRUKFRUVFRUVLRU5Dw8kJBUVMSAPJBYPLQ85JBUPMSACMSAkLSQkBg8tFhsxLRY5GxYkGxUVFSQW + MTkWORYWDzkIIC0lICARECAHJCQVKycVFQYVJBUVFTkHOSQkFRUPJSAyKwg5LSQxJBU5FSQtJBskIBAb + JBUVJBUVFSQVFiQVJBUKJBUkFSQKJC0kDxUkIDEgICAgISAhICAgORUKFQoVChUVGwcPByAgEBYgICAg + FgcxJCQ5ESEgOS0PDyQWCDEgKws5IBAgFg8VFRUVFRUkFQ8RKyAgDwskFiAgIBYgKyAVJDEkJA8WORUt + ICAgEDEgKw85FRUVFRUkDy0WDzkKFRUVChUVFSQVJA85CyAgJA8bJCQPKw8kDw8kJCAgICAWGxYrDxU5 + DzkVChUkFSQVCiQkChUPJA8LGw8xMRYWFhYWByAQLhAgJBUkGyAGFQokChUKJBUKFRUKChU5BjktBw8k + FiAxGyQVDxUVChUVFRUVMQ8VFSQVChUVLTEWDyQVFRUKFSQVJAYkJA8gFSQBMSAxECAQECUkJBUKFRUV + JBUkFRUVFRUWECEgISEvISAgDw8VFRUrIAcWOS0VDyQVChUPFRUGBhUVJBUkFSQVFRUkFSQVMSskIBAb + JA85ByAgGysIJAIWKxUkFgcaFSQtICAgBxUtDxYtICsPKxYIORUGORU5FRUVFRUVJC0VBi0kKwcVDyAg + IBYrGyQVBjkkICsgICUgFg8kFRU5FRUVFTEWDxUkFRY5FisGICArIDEPDw8rDyQxJAgxICAVJCQVFRUK + FRUKFQoVJBUVFSQVCjkPJCQtJBUkFjkVFRUKFQoVFQckJBUkFSQKJAckLRUkJA8kJBUVChUkFQY5Fhsk + LSQgICUQISETMRUKJBUKFRYPJCQkMSEiMhMwHiISMCIgOQ85FSQVDyArGwsxIDExFS0VKxYWKysxFiQV + Dw8aDxYkFSQHJCAgICsPFRUVCxYtFQsPFiAWICAPJQ8xGwYWKyAlIBsgKy0rByAWDy0kFRUkFRUVJCQV + CiQVFRUkJBUKDzkVKyAxJRAgIDEkLSsVBwcgICAxCDkVFSQPFiQVFSQgDyQKFSsxDyAuFjEbFhYgFjEW + Gw8xDyQxMSArJCAlJCsVJBUVCiQVCiQGFhUkFRUVFSQVFRU5FSQGJCQ5JBUVFQoVJBUVJA8tFRUkFSQk + FRUkFSQVJBUVFRUVFQYkFhUPMSAQMRYkFQoVFRUVJBYrDwcuEyIeHyofHx8YHx4OIhAxFRUVFRU5GyUk + FiAQIQcVFS0gMQgVFQYkFiQVFRU5FRUVFQcrIBYHFTkVFRUVJBU5FisPKxElKw8HKxYrCDEgDyQtJA8W + FhsWFjkVFSQkJCQKFQoVChUVFTEWMRYVFQYrDyQbJSARKxYkJBUPDzkgFiQPJDkVFQoPORYrLSAHMSQ5 + JBUVJA8WFRYWJBYkByAxICQWFQ8xByAHLiAgICAgLSQtFSQVCiQKFTkPFRUVFSQPJA8KJBUtMSQWFRUk + OTkkFRUGChUVFRUKFRUVFRUVFSQGJBUVJBUkFSQkDzEWMQ8WGyAgFRUVFRUPKwYgGyAgECEQEBISHiIS + DRMhEyEhLhUPJBUVFQ8PCA8gECAxDysVJDEVFRUVFSQVFTkKFRUkFRU5DysrIBYWBhUkFRUVFSsPJAcx + KwcxFhYHLRYPFRUkFRUPICQtKw8kFRUkFiUVJBUkFRUVJA8GOQQkJDkrDyQkGjEbICAgJBUtFSstJBUV + DxUVFRU5FQ8xIBAgJAoVDxU5FRUxDy0WJCQtFjEgIDkWDzEPFi0kICAhIS8RISArJA8PJCQkJBUPJDkP + CjkkIBU5DyQkJBsWLRYkBhYPJCQVFSQVJCQkFQoVFQ8kGzkVJBU5JBUVFSQVFTkHITEWIDEHICAxICAr + DyAlICUgIAggEBYRICsgJDkPFSQgBxA5JSsPOSQrBysgICEgFg8rLSQVFSQxJCQVJBUGORUrDxYPFhYR + IBYxJBUbFSQtBiQkBw8rIBYWIActKwc5FSQKFSQkJAoVDyAkFRUVFQ8KFRUkFRUVORUkORUVFQokJBUW + Dw8gJSAgICAWKwcbFhstJCsVFRUVFRUkLQ8kFiQ5FQoVFRUkBysHMSAWKxsWLSQPKxsrBxUkFiATISEQ + ICQxIAgWIDEgFiQxKxYWJCQVFSQ5JBUkJAYHKyAkLSQkLRUPOSQkJBUVFSQVFQ8tJBUWJA8PJBUhKxUk + FRUVDxYgHCAkICsgICARICQtMSAhECAWMSQHMREgICQVJBUkBiQHICAgFhUPICAgIC0WEDExICstCg8V + BxUVFRUWDwYPDysxFiAxJBYHETEkFSsVKw8VDzkPFiAHJBAgFgYVDxYkFSQVFRUVFSQVDxY5DzkVChUK + JBUVFRUVFRUVChUVBi0kFTExIBErICExLQ8PJA8VDCAbFjk5JBUVJBUKCi0PJBUkFTEKFRUbICAlMQ8x + JBU5DyAgICAWMSsRIDEVFRUkFQYkORwVICQgECAcMRYbKwYPJCQPFRUkJA8kDxYVFRUPJA8gFSQVChUk + FRU5JBUgICQgKxUGDy0kFgYkBhUkBisgICAQECAgICAxFgcgFg8WMQ8VICAlICUgFRUVFQokJAcPMSck + LSQgDysgMRshIAcPFSQHKyQkDxULLQ8tKxUPBy4gEBAgJCQPFhYxDyQtJAYWIDEgKy0WDzEPKxYgFRoV + FRUkOQ8kDysPFgcWFRUVFQoVFS0PFg8PORUVFSQkBhU5ByAuERAWIBY5JBUVJC05ICArDxUVFRUVChUV + FTkVFRUPFTkVFRUkBw8HFRYkFggrFiQgKxYbIBYVFSQKFRUVOQchICAQIRAzBxYgFjkkOS0WLSsHDzEb + FhYtKyQkFTkVJAckFRUkFQ8VFRUVFRUVDxUPKysPKwg5JCsuNiEuICAgJSAHKzErIBAuICAgISAVDw8k + Dy0gGw8VFQoVFRU5FiAWFhUVFRUVBg8rECIuIBUHIA8GFRU5JBUKFQoVJCAHJTEVFRUVFTkVByQxChUx + JA8xBiAWKyAlBzEQMQs5FhUtDwwaMRYgFiAgFTkVLSQVFSQkFSQtJBUVFS0PFSQkFQYtIBYtJCQgDxUk + OQoVFRUPCC0WOQ8kFRUVChUVFRUkLSQVFRUkFSQWIBAlIC0WDyAkIA8PJSAkChUVFRUVFRUtFhAhICUP + BjkPBiskDxYIKyAtMRUPKyAPJBsxDxUkDxY5DxUVJCQVJBUkFRUKFRUVDyAgICQkFiEdEBIiHiIhIQct + ICAgMRArDzkVFSQbICQVFSQVJAo5JC0VFSQKFQ8WIRErFSAHDzEWLSQgIiIhKwoVJBUKFRUKFSQVFSQr + CCQPDxUxFRUGFSAPFTkVDw8PKxYkIAYxBzEHMQ8VFg8VDyQgIAYVDyQVDxUVFSQVFSQVFRUkFRUVJBUV + OSQVORUkJBYkFSQVJAYrDw8kCiQVJBUkBiQkJBUVOSQVFRUgORUVOQ8VFRUVJBY5FiArJCQrICskMSA5 + FSQKFQo5FRUGORYgFg8PJBUkFjEgIBUtJSAkJA8PIC0xJBY5IC0kBiQkFRU5FSQPJA8PFQ85JBUKJCsH + LRUGKxUkIBAgDxEhHRAhECAgMQcPFSQVJA8lFjEIJCQVFTkVChUkFSQVFRUPMSUQLiUQIDEHORUKJAcR + DTkVFRUkFQokFSQgFg8WFRUVFTEVDxUVFRUVFRUkDys5Dy0LFRYWDysgFQcgKyA5JBUWDysPORUkJCQV + ChUVJCAWIBYtFjkVFRUVFSQKFRUVFS0RICQVJBUVLRUVFRUVChUKFRUPMQ8kFRUKFTkGDysPJA8HOQYk + ChUkDwwxICAxIA8WGwcWJCQVFRUVFRUtFRUKFRUkFSQGFRUtFSQVDxYcJSAlJA8rByAgJTEPJBUVChUV + FQoVFSQkJBUVJA8VFRUVFRUVJC0VFTkkFQoKFRYHJCARJSAlLRYkIDIRECAgKy0rDyQPFRUVFQ8VFSQk + LRYgBxAQICEhICQVJBUVMSAWFSQVFRUVFRUVJBU5DwoVJBUkFhY5DxU5Fi0VDzEWDysGOSAkBxYgFjEH + JA8PFRUVORUGJBUVFQokJBUKORUPMRYgKw8WJBUkBiQkFTkVFRUWFTkVFRUVJBUVORUVFSQKJAo5FQgr + IDEkDyQkFTkgIBUkFRUVFRUKFRUPDxsgIA8WHBAhHBYtKxUVJA8VJCQkJBUVFRUkFS0WFSQkJCQkJCQg + MSAgMSAlBw8tFRU5ChUKFQoVFQoVFRUVChUtMSQVFQoVJBUVJA8kFRUkFSQKFSQVFTkHLiUhIBAhECUg + ICAlICQVIDEkChUxIDEgFiQPDzkkIBEHBystJA8xDzEPECEPDxUVFRUVFQoVFSQkFQoVFS0rDxoWFQ8k + FQ8kDysHBxYgIAw5FTkHORUVJBUPFQYkKy0VFQoVChUtJBUVFQ8GOSAgBzEgDzkKFSQKFRUkFSQkGxUk + Gi0VJA8PJDkVFSQVFSQbJSUxJBUVFRUtBiQgFS05FQoVJBUkLRYlICEQISEXIRYkDxU5Dy0tFRUWERYt + JBUWDysPJCsPFSQVFQYkIC4hISEgByAkFRUVChUVFRUKFSQVFSQVJBUVFSAgICQVFRUVDxUxFiQVFRUK + FQoVJCAlKyAgFhYtDxsgICsbICAgGyQuORUkDyAFMQ8WFiQkFSAgMjEPBhYlECQVJBUPIh0hIBY5FRU5 + FSQVFQYVChUPLRYVLSsrDyQxFiAgIDEkFiQtMQYgIAY5FSQkFTkPBw8kFRU5FRUVFQ8kFTkkFg8WIA8k + FRUKFRUVFQo5FRUVFRUVDyQkJBU5FRUVJAskDw8xOQcgDy0VCiQVFSQgDyAVFSQVFRUKFRUPORsPJCAP + LSQkFSQVDyQVGiQgLgckFg85DyQIMSAxOSQVIDk5FRUGJAckDxUkFRUKFRUVCgo5FRUVJAoVFRUkFQYV + IDEuMRUkJCUgFg8kJBUVFRUkFQggLQwgEDkVBhoPICEHIREhLyYHEC4PLQ8rLQcxLTEGFQ85FhEhEDEg + JC0VChUVFQokHiEPFQoVBhUVFSskFRUVJCsGFQcPCCQVFRYrDxUlBzEgJAcrBjkVJAYVBhYWJCAPFSQV + FSQVFSQVOQ8WBjkPJDkVJCQPFQoVORUVCjkkJBUPKw8HOQYkJCQxJA85ICsgBxUVORYrJCQVFSQVFSQ5 + FRUVBhYPFSQVFSQVJBUVJBUVChUVCiQkOSQkJBsVMSArFhUkJCsHBxUPICsxFRUkFRUkFSQVFQokFRUP + FTkVChUkFRUkFRUVFRUVORUVFQcxBy0VJCAGJBU5FRUVFTkkFgcrDxUVJSstFSsWLiIwEhIQJAchIQgr + LRYrMQIrGzEVFSQVMSAHBzkPJBUrORUVJBUxDxUkFRUPJBU5BhUtFSQVDzElJCQVLRYPBjkWDy0VDyAP + DyQVFSQVJBUtBhYkJCQVBhUkFRUxFSQGOQ8VChUVFSQGORUVFRUkFTkPDxUVFS0bKw8kJCQkJC0LCyAg + DyQVChUVLQYVJAoVFQokChUKJCArIA8VCgoVChUkJBUKJBUVChUVFRYPFSQKFRUVLQ8WDwggFSQtKyQP + BiQGJBUkFRUVFQoVFRU5FQoVCiQVCiQVJAY5JCQkFRUKFQoxGyQVFSQVJBUVJAo5MSQVFQ85DyQVJDkg + Fg8kGxASIS0VCiQVEB0yLRY5ByAbICArFS0POQYrIA8kFgwPLRYkFRUVCi0VFRU5FRYVFgsWJA8aJA8V + Dw8VJCQPOSsPGhUVFRUkDxUkCiQVChUVJA8kLSQVDxU5Fg8kKxUKJBUVFSQVORUVJBUVOQoVDxUkLhUk + JDkVFRUkOQgkFS0rGyskLRUVChUKFRUVFSQVFRUVFQokFRUgIDEkFRUVChUkFSQVJBUVFSQVFRYtFRUK + FQokBiQxLSsxFTkIMQc5FSQ5FRUVFQokFRUVFSQkChUVChUVJBUkFSQVFQYWGxUVJBUVFRUVFRUVFRUk + JBUkGw8WKyAPJAckChUGIQcrIDkPFRUKFQoKFRUhEiExBxsgJTElLiArFgcPDyU5DCAtMTErDyQVJBUk + DxYWDxUVJBUrGysGORUxJCQkJAcxFg8WDy0WJBUVORUVFRUVChUVFSQbJBUVJCQVDw8kLRUVJBUVChUk + FQ8kFRUVJBU5FTkkDyAVFRUkORUkByQVJCQVJBUtFRUKFSQVFRUkJBUVFTkVChUVFRUVFiAHDyAkFRUK + FSQVFSAkFQoVJC0PFSQKFRUKFSQVFQ8PJA8VDyQkFRUVJCQ5DxUVFQoVORUkJBUKFRUKJAoVFRUkFRU5 + DyQkChUKJBUKDy0VFSQ5FQ8VFRUxCC0VJA85FTkVChUbMSQWJAoVChUVFRUVFh4gIRAxICAgIRAQICAW + FjEgByAPFjEPLSQVJCQkFSEgICAkJBUVFQ8kDxUWJBUVBjkPDy0VJBUPKy0VFQcrLRUKFRUKFTkkFQYV + FRUVORUVCw8kFRoPFhsrLRYtFSAxLQ8WFQ8kBy4VJBUVBSAPMS0kFRUkGxYkFRUkFQoVOS0VFTEPFQYP + JBUVFSQkFiEgJS0gLRUKFQoVChUkJCAkJDEkCiQVFRUKFQoVChUkFSQVJBUkFTkVFQoVFRUtFRUVFRUV + JBUKJAoVFRU5JBUkFSQVFRUkFRUKFRUKFTkVLSQKFTkVFSQkFRUVFRUVFRUVChUVFSEhICA5FSQVFSsk + FS0QEi8QICURECEQICArICAgJRAlMSEHKw8VFRUkJBUTISEhIDEPFhUVFRUkJBsVFSQVFRUVFQ8kJBU5 + Dy0VBiQVFQoVChUVFTkgOSQkFRUKFS0VFTkWLRUPKwcrCCsgFhYWICQkISAhChUKJBU5ITEkDw8VBjkk + FjkPFRUVJBUVJBYkFiskJCQVORUWFiAhIREgICs5FQoVJBUPFiQkGyQVFRU5FRUkFSQVFRUVFRUkFRUV + FRUkDzEkJBUVDxAkFRU5FRUVFRUVJBUkFRUkFRUVJBUkFSQVChUkFRUKFRUVChUVDzktFRUVCgoVChUK + FSQVCiQVISEhIS4bMRsIKwoVJCIiLiEIICAQEhAHFg8gICARECAHICAWGysxLRUPKzAhIRsHMTkWFRUk + FRUVChUVFSQtJBUVJBUKFRUkDyQ5FRU5FRUKFSQkByQkFRUKFRUVFRUVFistDw8kICAgICAWDw8tICES + JAoVFRUVJBUkChU5FRUkDyQGJA8kJDkgJAsgICQPFRUVFSQGJCAhJg8rICAkFQokCiQtJBskFSQVJBUK + FRUVFRUVFS0kDyQkFRUVChUkFjkkJCQPMRUVETEVFSQVJBUkFQ8kFRUKJBUkFRUVFRUkJCQKFSQVFQoV + FSQVChUVFQYVFTkkFRUKJAoVChUVChUVJBAhIg4wFSQVFRUbIiImHCAgKyUxIBAgMQcxIBYgIBYxIDEg + JCUrIA8gIjEHMSUgIC0rJBUKFQoVFSQKFQokFRUVFRUVFSQKFQoKFRUtFRUVJBUVChUtOSQkOSsWJA8t + JAcrIBAQJiAVJCQkJBUkFRUKFQoKJBUKFRUVKy0PFTkVFQ8PDxYtDxY5ICAtJA8kFSQVORURIAcxEBEP + ORUVFSQVJBU5ChUVFQ8kCiQVFRUkFRUVDzkVFRUVORUVLQ8VICAPIA8kFSQgJA8kFRUGJBUkFRUVJBUV + FRUKJCQVFQoVFRUVFRUVMQ8VFRU5FRUkFRUVFTkVFRUVFRUVJBUKFQokFRUWEA8VFS0PFQcOIhAgJQct + Dy0kEDEPFRUrGysHICsgDCAgIA8VBhYHICARFjEPDwwgDwYVJBUVJBUkFSQkFQoVLSQVFRUVJBUkJCQV + FRUKFRUVFQctFg8PIBYxIDEgByAlHBAIJBUWLi4KFQoVFRUVChUKFRUVJAgkJBUkFTkVOQ8kKxYkMQcx + ICAlJCArJCsPIS0QICAxJBUKFSQWMQ8kFRUVFSQ5FRUkLS0xICsGJBUVJC0VJCQkOSQVJBUVFRUKFRUK + MREhICQkLi8hLi4QJBUWJBUrLRUVChUKFSQVFRU5Dw8VFg8VFRUVOSQtFQoVFRUVJBUPMRUKJBUVChUK + ChUtFRUGKyQKFSYdICAkFhoVDyAIFisPIBYgJSUgESAgEBsHMTEgIQw5FiAPFRUgICQtJBUKJBUkFSQV + LSQVFRUVJBUkDxUVFTkaICQVChUKORUVFQ8xFistDy0MLSQgMRUVFQo5Gw8LFRUkChY5JBUVChUVGxYg + FTkkFSQVFRUVOQ8xIAcWFg83ICAlICAHICEgByAkICQVJCQPJC0kFSQVORUkJBU5JCQaLS0GOQoVFSQP + JBUVJBUVFQoVChUkChUKFQo5EA0iLyESIh4iITIvICAkIBUVFRUKFQoVFTkVFS0rMQcgKyQVJAoVFRUK + FQo5ASQrLSsPFhUVChUKJBUVFRUVJCAWJBUVECYhMRYPLSArFhYgICArICAcIRAlMRYHKyAWIBYgIAck + KxYRITEWCy0VFRUKFSQVFSQVKxU5JA8kFRUVJCQkByQGFSQKFRUVFRUKFRUGFRoVDyQVFQoVChUkFRUk + JDkKFQo5DzEVCi0VJBUVFQ8WFTkPKxYVJA8IJSQVOSQgIBYgLSQHORAkFTkVJCQkFSQkJBUVDzkkJA8W + DxUVFRUgDxUkBhUVJBUkJBUkFRUVChUVFQoKFRUVFRUVFRUbFhAhBw8RIR0QDSIvEiAHLRUkFRUVChUV + FQokFi0lICAVFRUVFQoVJBUVFS0GFhYGJA8kFSQVFQ8kFRUtFhYWJBUVJAYQHSEhIQ8gByAxICUgICAh + JiEgBw8rKyAQESAkKwclICAgJQcgECQGFSQGFRUkJBUKFQ8VJBUkFSQVFS0rIDEWFRUKFQokFSQkLRUV + JC0VJCQkFSQVJBUVFQoVJAoVFRUVDysPJDkkJDEVFTkPJAgrICAtFjkrDyQkFRUPJAYPJBUVJBYgFRUV + ChUKJCQVJCQVChUVJCQVLSQ5ChUKJC0kFRUkFRUkFRUVFRUVKxUVCiQkJCQGFSQ5FSQKFRUVJBUKJBUW + BzkIMQckFSQkFRUVORUKJBUVFS0PMQg5FRUVFRUkChUkFRUVJDkWDzkkORUVBg8rJA8rFhYbFhU5FRUV + OQcTJQYkFSAgEDEHECEgFgYVJBYgIAcrIA8lIC05Bw0hICAkFg8xJA85JBUkFRU5FQokFSQIFSQVFRYW + CCQHGzkVFRUVCgoVFQ85JAYkFS0kFRUVJBUVChUkChUVFQoVFTkPMSQPFSQPFRUVFSAlIBAlMQ8PDxUk + FRUVFRUVLQYkJC0gMRUKChUKFRUVKzEPJBUVChUKJBUVChUVFRUkICskLRUVJBUKFQoVOS0gJA8kFSQk + JDEkFRUVFQokJBUVChUKFSQKFSQVMRsrLSQWJAYVFRUKFTkVFRUVFS0gDyQ5JBUkFRUkCgYPDzEVFRUV + CiQxDyAWIA8tFRUkFRUKFSQVFTkVOQcrLhAgGyskICQVJCAQECAPCgYxIQcHFRUtBysgIDkgCyAWFRU5 + ChUVChUkFQoVFTkVLSQtJCQkFTkVFSQVJBUVChUVFRU5ChUVFSQVBiQkFTkVFRUVJBU5DzkkJBYgFTkV + FTkkFiAQJSEQICAgFg8VFRUVOQYkORUkJBUPKy0KFRUVJAoVOQgtFSskFQoVFRUKChUVORUVBhUIICsx + FQoVORUkLRYPFi0VFQokJCAgBzEkFQoVChUKCiQKFRUKFQoVFSQPMQ8VLRYgKxUKFRUVFQoVJAokLSQ5 + DyQPFRUVJCQrOSsVFRUKFTkPJCsWDyAHFRUVCgokJCQVLQsVFRUVBg8xISUgKxUHICAhECUgFSQ5IAc5 + FRUKFQYgEwwgFhUbFhUkBhUVJBUVChUVDyQVJBUPFRUVChUKFRUVJA8kFQoVJAoVChUKFQoVFTkVFQoV + ChUkICsVChUPDxUtLSQVFRUkByAxICAbDzEHFTkVDxUkFRU5JA8kFSQrBy4VFQokFRUVFSQVKy0PFSQ5 + JCQVFRUVJAcxOTkrLQ8HFjkVFRUVJCQWOSQWJDkVChUVMSQWBhUVFSQKFRUVCiQKFQokJAYtFSQkFRUt + ICAxJA8tByQVChUVChUVKw8WGxYtBysxBw8PJAYlJAsrJAYPGyQkFSQkFRUVFRUHFRYtJBUKFRUkDyQg + MQcrICEhJRwQMSUWJRYVFhUkJBU5IBYHJBUKFRUGFRUkFSQVFTkVFRUVFRUVJBUKFRUKFRUkFRUVFSQV + FRUVFSQVFSQVJBUVFRUVFRUVJA8PJCQPJCUgMSUtGiQWGyUgDzkVFRU5DyQkJDkVFQoVFRUxICAgLi8h + JBUVFRUVJDkHMQ8kBjkkDyAxDy0KOSQkFiAgJCQxJBYPJCQkFQ8tJA8gJBUVDzkgKwctLSQ5FRUVFQoV + ChUVFRUKFQokChUVJBUkFQ8xCDEGOS05FRUKJBUKFRskDzkPFS0PLQc5FRogICAtFiQPOQoVFTkVFRUG + JCQbKw8HFhUVDzkVJCQLDxUgESANIiIwIAccBxs5DysgFisgICsGORUWFRUxMRUVFSQkFRUVFTkVJBUK + FRUKFQoVOSQGICArLSQVChUVFSQVChUVFRUVFRUPJBYgMSAxIA8kFSAgFjEIFiAgMSsgBhUVCiQKFRU5 + By0PFSskJA8gLRYgICEhFRUKJBUVOQYkDw8kJCQkDysPFQ8VDxYkFhEgFiAWJAggKy0gLRUVJA8xJAYk + DysPFQ8VFSQPJBUkChUkJAoVFRUVFRUVJBUkFSQPFRUVDyQVJBsPLRUVChUKJAoVChUKFSQVFQoVFRUk + JCUkDxUtFQoVFRUVFSQVOQ8HJQ8WJC0kORUWFQ8rDysWDxULLRARECERJSUMDxYHICAQByAtJBUbDzEH + JQ8VJAoVFSQVFSQVFRUVJCQkFRU5FRUVICQRIAcVJBUkJDkPICs5DxUVFSAgMSAgLxMhJCQ5GzEkDyAl + ICsPBxAgFSstFQoVChUKJA8WBjkgJCsrICsgICEQMSQVFQ85JCQrDzEkJBUVFRsxFRUVJCQbByUgISEc + ISAVLREQMhAxIDEgFhskFSQtJDExKy0VFTkVFRUVJCQkDzkaLRUGFRUVFSQVFSQkJCQxFSQ5JBUVChUK + FRUVCiQVFQMVFSQVFSAkICUkFhUkFRUVJBUVFRUVDxYkLRUVOQcVFRUkJCQKFS0VDxU5DyQkFQoVMSAh + ISAWICUQJSUHFhYkFisgByAkFgoVFQokJC0VFSQVJCQVFSQVKwgVJAgVDxUkDxUkBisPJBYtAistJDEh + LzEHLiQGBi0WDxotICAkFiAgJBU5BjkVJBUkJBUVJAoVJCQGFiQgBw8PECAtFRUVFTkWDyQkICAPFQYP + Fi0kJBskJBUVJCQ5CCQCISEuFhYxBAcRIRMQOSQ5FSQVFRUkBw8VFRUGJA8rDyQHMSAWJCQkORUkFQYL + FgYWFQ8PFhYWBw8rFRUkBhYPJBUVFTkVFRUkDyQVDyAgEBYVJBUkFSQGFTkWFisbIRAVFSQVFRUkFRUk + ORUVJDkVFSQrJA8kJBUPBxAxJSAcECAQICAlIC0PLS4gIA8PKzkVJBUVJBUVJBUkChUGLSQVORUVFSQV + FSQVFTEHMTEkFS0gDyAHDAcbOQYPJBUVJCQPBxAgMREdJTEWFSQVDyQVFRUVFRUVFRUGJDEHOQ8kIDkV + FQoVChUVORUVDyQkORUVJBUxICAxJBUkOQoVCiQKJBUQIRwPKyQkLRYVFRUKJBUkJCQxBy0kFRUVJCQG + LRYtLg8kJBUkJA8WDyAxMTEWJA8rDyQlLRYHJRElBzkPMSAVFRUbMTkVFTkVBisgIDExIDEPORUVORYP + IA8xFgc5FRUkFSQVDyQPFRUVFhYVFSQkFRUVFQ85BisPIBEQISEbFiUQLyIiIjAqHhIgFg8VCy0VFRUV + JCQVOSQ5JBUPDxUKJAoVFRUVOQYkMSAPMRYPKwcgICAVFRUrJC0kFS0gIS8hMRsrIAUQDzkPJDEbORUk + OQY5JBUKLTEWFiQVORUVChUkFRUkDwYkFRUxIBYkJDkPOSQtFSQPJBUVFRUVFQoVLSESLy0VFRUVJBUK + FQoVFQ8tDw8VFSQKFSQVFSQVFQY5FRUGJCQaDzElICUbICUxICAWMRYbMSAgJRAxByAlJA8kMSAbFgoV + JC0gISUQIAckFSQVJBYPIBUVDxYkFRUkFRUVBjEkFSsVJDkVJDkWFhYWJCQkFRUPFhUPKxYkFiQgIBAh + IRIiHxAkBgYrDzEkFSQVFRUkJBYPFRUVFTkVFRUVFRUtFRUVJCQVFRUGOQ8GKw8rDxokJC0WDyAQNyIh + ISQPBiAgISAlICAHJBUkJA8WJAYPJA8xBzkPLSQKFRUKFQoVLSQkIBYkJA8kDyAPFRUVFSQkDy0VJCQV + FRUVFQoVByEhIAgVJBUKJAoVFTkVJAYkJAoVFTkVFTkVFRUkFRUVJCstIDEWDzERFhYgISAgByQgIAcW + EB0gICARESAkFRUxECs5FRUkJA8kLQ8WCCsVBhYbIRAVCjkVFRUkFRUVFSsgDxU5BzEGJCQVBiQ5FRUk + JBUVOSQtFiAtDzEgICsPKyAyERYtFRUVLRYWFg8WFS0kBjkgKzEWOQ8VFRUKFQYkKwckJBUPJDEVDw8V + JA8gDzEgJSAxIBYuIhIQDxUVFSQHISYQECAgKyAWFjEWKyAWJDEVFSQWMRYPJBUKFRUVFSsgICAtIA8V + JDkkJCQkDxUVJCsPFi0VFTkPOSQKFQo5BzkkChUKFRU5JA8KJBUVORUkJBUKFRUVFSQPJBUkKyAgBxUH + MTExFQ85ByQGFSQVJBYxISAaICshITIQIBUPJA8VJBUKFQokFQoVLSQPLSsbEhAkFRUVJCQKKwYkFTkP + KxYGJCQHJA8WKzkVDCAVAQcrJBUkFSQPFRUPJCQgMSAbDxUVCgokFRUgIDErLhUVJA8VFgcxDxYkFQoV + ChUkIBUPMQ8kICUPMSsVFRUaLSsPIAcPBiQgECEVFRUKJAoVFQ8RJBAWDxsWLQgkDw8kJDEIFSQkDw85 + JBUVFTkkMQ8xFhAlDCQkORUVDyQgFTktJCQPMS0rGxUkDyskORUVChUKFRUVJBsrFistJCQkChUkFRUV + FSQPFRs5FRUVJAcgMSAPFiAgKyAxCBYgFg8VFQ8gDxYgFSAgMhEPDw8rICAHLRUVFRUVFRUkFRUVFggW + IQ8tFSQVJBUVFg8rLSQWFQc5KwcgICArBxYPCCQVJCAgIAgVFSQkFjkkORUIOQgVFSQVFRUVFSQVCCAH + IAcxJCQPKwogDyQtJCQkFRU5BzkWFRUPDyQPKwcPJDkVBiQPKyA5JBUWHBwkFQoVFQoVChUKIA8VFRUV + ORUkFi0kMQcVFTkGJBUkFRUVJCAVJBUkIBYtBhskJBUkJDkkDzkkFRUkFQcHLRYkDzkPFQ8VFRUkFRUV + JC4MCCAcGyQVJBUVFRUkBjkkORYkFRU5JCQHKxYPKyAgBSAPBhYxICArFRU5FQYkLSQgIQckJDkVFSAQ + ICsxFg85ChUKFQokICArERAkFQoVFRUVJCQgFhUWIDEWFgcPFiAxIAcaORUVCiQkFiQWJBUPJCQPFRUV + ORUVJAoVFRYbFiQVFRUVFRUrLQ8WKyAgIAckFRUWFSQkFQ8HDyAkFjExMQ8tKy0kBiArJA8PDxUgISAK + FSQVFQoVFQoVFRUVJDkVFRUKOQ8kFg8xJDkkFQoVFRUVORUPFSQPMSQkFSsVFRUVFSQVFSQkDyQVFRUP + LSQrLRUVFSQPOQ8VFRUkDzEHOQ85JBU5JBUGJBUPKyQkFRUkBxsVFSQVOQ8bISEgJCArMRUGICUrMQgr + FhU5FRUkFRUVJBUVBiQVJAY5ByQgKxUVJAoVFRUVIBEVChUkDyQkDyQIKy0GKyAKFSQgKzEHICAVJCsG + OQYgICAHICAxIA8tDysbFRUKJBUVFSQgIRAtJBUtFSQgDxYrJA8gECEgFQ8kFhUkLRYVMSQWICAgMSAx + CxYPBiQkIBYPJDkrGyQkFSQVFTkKFQoVOQ85MSQVFSQVFRUVMQcPJA8kFRUVFRUkFRUkFgg5Kw8PFSQt + FSQVJBUVFS0kORYWFjEtFisIFg8WJCQVJCQPGystIDEPFiQVFRUkFSAkMSs5JCQVDyQVJBUVORUKJBUG + KyAHICUPDw8rJSEgBxYWLQ8PFSQrFRUVJBUkFRUkFTkVFSsILRUVChUkFSQVFjEVCiQVFSQgKw8rFRYr + JCArLSAHJRAHJBUPJSAkFRUxByAkFiAPJAoVJC0rDzkVFRUkFRUtKyAhEBEgKxYkJDkPBiQgMQcxFRU5 + DzkIFRUtJBUVDxAgMRYtFiQtKw85FQgxMRYHICAVFQoVChUVORUVChUkDyEuLg8VLRUKJBsxLTkHFQ8V + FTkPOSQVLSsPDy0rDyQtORUtJDkVJCQWBwc5IDkWJC0WICs5GzEkLRUHFTEgESAgORUkFQ85KyQkDzEP + By0PJBUVFSQkDxUkORUVFgcgFiAgMSUgJSAIICAkFSsgFhUkBhUkLRYtDzkrFRYPFhYgKyAxFg8LFRUV + DwcVFQoVChUkCBYrICUbFgcPBy0VLRUtJBUVJCAtFRUVDxUVBjkVFRUVFRUrGw8WJCQkBiQxFgcgECEm + ECAtFRUVJBUWGxUbJBUVBhYWORUkDyAPFiQHICA5ByAgFiQkFRUxDzEuIBctOQoVFSQKFSQVORUKJBUQ + DiIiLSA5JBUVFRUPFQYkORUkDyQVFhYtLSsWDxY5DxUVFSQkFg8gFjEgMQ8PFg8HKxsPDysgFiQkOSAg + KyAxFRUVFRUVJA8tBwYRISIOLzEPFQ8WOQ8kBg8kKy0xDyQQBxYgIBw5FRUVJAYtFi0WDw8tFhYkDysV + DxU5GiAgISAQECAWJCQkDxAQFQoVFSQVFQcgECAVFSQgKwYVFRUKFRUVORU5JBUVChUVFRUKFSQKFQoV + DxYWJC0WFiAgICUtCA8gBxAQFhUPFiAkMQ8VCiQVJBUkLRUVJCstMSAlIDEVFRUVISEWDzEWJBYHFhwh + EBUkFSQVFRUKFQoVFRUKCBMwHh8zHBYkFSQkJBU5Dw8PJBUkFTkPFisgICsgDxUKJBUkFS0kDzkPIBwx + IDEkJC0HJTEgIA8rCCQkICAPJCQVFQYVJBUVFSQ5FRUVEB4eOi4gJAcrMSQWMSAgFg8gFSQ5IBAQFgok + CiQkDyQkJC0kDw85CCAHIA8aDwchISUhECAlECAxICArFQokBgckFQcxISUxFjkHJSAVChUKFQoVOQoV + FQokCiQVORUKFRUKFRUVORUGORUVFRsxJRARJRUVORUPICURMhEgIBYyKyQVChUVLSQVDyAgEBYIGyQk + ChUKFQ8HIDEgIS4xDyAhIRYVFS0kJCQkFSQVFSQVFRUkEBMeHiEuLQ8VFRUKFSQxKxUVJCQPJCAHJSAH + LRUVFQYkDyQVJCQVJBUkFiAlICAxICAxFisVJC0VFRUtFTkkICQxJDkPORUKFSQVFRUCEB4eHCUuICAP + DxYgKwgVOSQkByAQLiQVOTEPAzkWFS0WMSsbFRUxIDEkFRUVLSQPIA8xICAREBYgFRUkJCAgCDkVFSQP + JCAgBxUVJBUKFSQVFRU5FRUVFRU5FQ8VORUKFQokFRUVFRUPJBUkCCsbICAWFRUkGg8xICQQIR0TCBYk + FRUKFRUkFS0kMS0kMRUVFRU5JCQVJC0PDyQPFjEvICQKDzEPJBU5Fi0WICArLSQVChUVLSYiIi8tDyQV + JBUPDwckJCAHKyAtKxsrLQ85FSQkIBU5DyQkDyQ5FRUgICEhITEHBw8PLSQVOQoVFQ8WFS0WJA8kFRUk + FQoVJC0xLRUQEh4fHh8pHiYcIDEVFRUkFiQxGxUVKyArLQcPJAYkKxsWIBUkBxwvIC0VFSQKJBUkICQx + ISArIBUrBxYkFhYyGxUkCiQQLyAVFRUKJAoVFSQVJBUVFRUWBg8VFQ8VFRUVFRUkFQoVFRUVFRUtJBUP + OQ8rDyQPMQ8gFSIiMiAPFSQVJBUVFRUPLTkVDyQPCgokDyQICyskJAoVFQ8RECQPJBUEOQckFiQLLSAt + FisPJDkKFSQIEBMvJSQkDzkVLRoxORYgIBwQMhAgICArLSQPLRUkDxYVJBUIJBUkFQ8gAyQWBiskOSQP + ORUkFSQkLSQVJCUQIBUVFiAxJBUrGyQPFSQVFRUHIRIeIRYkFRUPJA8yBxUtDxsWFSsxDyAtKw8kOSAV + CiQiHgcPKyQVJBUKJAggICEQLhEgCCAlIBEhESAWFSQkByEhJRYGFRUVFSQVDxYPLRUkFiQ5DxYkMRUk + FQYkFRUVORUGJBUkKxYkJCQPMSArLSsgKyAlByAPICQKFRUVJBUkFSQVFQoVOSQkJCAgIDEIDyQkJBU5 + DxUVFSQWFjEWDxYxJBYkFS0PICQVFQoKFRUuIh0gMQ8WJA8PBwcxIBAQIS8gMQcHIBYHKxUVCjkVOQ8P + MSArLS0kDzkPOSQtJBUGJCsGFRUVFQctFQcgIBYbFRUVLSA5ICAKFQoVFRUKFRUkEC8hFhU5MQ8xFiUg + FSsVJC0IICsxJC0PORYgFRUtHiEgKxUtDxUkFRUVOQ8gHBAQISUgECEiECEhGiQrIBsPERAgJBUVFSQk + FRUtJBUrLRUVFRU5BgYkLSQVJCQVChUVJBUkFS0PKxYHMSArBhUHLiAQICQxBiQKFQoGFRUVFRUVFQoV + JBUkLRYgIRYrMRAuLjEtJCsVFSQgIBEkLSAgCCAWJDEVFTkVFSQVFQokFSEiIiEPKy05KyQ5JCUuIREW + LSQkJBYRIDEkJBUVJBUkMSQtDw8kGhUkKw8WDyQVKzkGJDkVFRUkICAgKyArLQ8kFRUVBwcVJBUVChUK + JBUVDyQQECAgByslByAkIC0kChUGFjExCBUVJBUPLSQrESIhDxYkJBYlJA8kFSQVJBU5Dy4QECAWICAQ + IC4gGxYWKw8HECUgJBUkFSQkDxUVDxU5FSQVFRUkFRUtJA8kJBUKFRUVJBUkFiAgDwclESUgKyAxByAg + JBUVJBUkORUVJCQKFQoVChUKChUgIRARLiEvIREWBxUkFRUgJCQVBisgECUQMSAPJCQkJDEPJAoVFQoV + EB44ECAWJBUVFRsxGxUkFSQVLRUkDxUPFSskJA8HDwYVJBUrMQgtFQ85DyArIC0rJCQVFRU5FSQbOQ8H + ICsPDzEPDyQ5JCQVOSQkFSQkFRUVICEhLyAxESAVJCQBMSQtKyAHDxYxJDEPMRYtDw8gICsbByARICAk + FSQkJCQVFSsHICAhISAtJSAQJSEvLjEQLhwhECAWBiQGFjkVJBoVFSskJAYVFSQVJBUWDyQVJBUkFRUk + FRUxFiAxICAQECAWICErIBUVFRUkFRUbBhUkFQokChUVJBUHByExICARIBUVChUPFQoVChUVFRUtFiUc + DCAxICQPDyQrFiQVChUVFRUGEh8dIC8yMRUVFQoVFRUVDysgMSQkJAclECAxJC0kJCQtLQ8kFRUVFRUk + IBYPBy0PDxU5FSQPMSQkMQ8kJCQWJTEuFRUkJA8WBzkVFQ8kFSQgIiEgMQcWJBUPIDkgFg8HDyQQIBAH + KxskLSQtFS0gIBYkByAgIBYkDxUVFRUxMRwQIBAhCSEGMQchEyUHFQcQICAhIS0kKyQKFSsWDxskDw8k + KxUkBzklICsVFRUPDyQPFRUkJCAgBxYQLyAgICARICQ5JBUVKy0rFjkWBiQVFRUVFRUkICQgCCQVChUk + FTkgOQg5FSQVJA85DysbICAWFi0WMSQgEC4tFRUkFSQKFQoWIjceHi8VCgoVFQoVGyQgIBAgICUgESEx + JCAWORUkDyQkJDkkJBYWFQsgMRAlMQ8kJBUkOSAbJBUkFSAgJA8HICQkFSQxMSAVByQkFSQkFggWGwcW + JDEWKyAgFiAxMTklICAQICAkMQ8GDyQbHCAkMSAkICUkGyQVFTkVDw8WFiAlECUgFisQICsgICQtFRU5 + Lw4iDiAPFRUgFiUVFSQkDw8WIDElGystFTkkFSQVLSQPMRYLDyAcJSQHKy8hCSEIFQ8gOQcxDw8tFSQ5 + DyQkJCARIS4hDzkVFSQVChUVFRUVFRUVFQ8PFSQtByQkGyQWJC0tICUHMSQVFQoVFQokFRESCBIOKDEk + FSQkJBUHICAgISAgIAcCICAHJA8aFi0PFSQWCC0tMSArJSAxByAPOQ8kFRUkJBUkDxUPOQYkORUkJBUI + ICAgMTEkJBYkFQcxJAc5ICAQESAgESEWIAcgDzkVDyQbECAkJDkRIh4vICAkICQPFiQ5JBYVDyQWOQ8P + OSARJRwgICAWByArFhUVChUgEiIOLyAPFhUVFRUVFSQHFiAgECUIFQ8VFRUVFRUkBiQPOSArDyAVICAQ + ESQkDysgICAgOQ8VDw8VJC0gECAgIRAPJBUVFQoVChUVJBUKFSQVFhYkCDEHJBUkFRUVLSQkBjkPLgc5 + FSQVJBUVFRUKFRUKFSEQORYtJBUkLSQxByEdECAxOSAlMRYIGy0rLTEuJA8rICAgICAgICAWJBUkJBUV + FRUVFSs5FSQWBxYPJBUtFRUIByAbFg85FRU5JCQxBysgJQcxICUgFjEgFiQVJDEkJCshJBUVJR4eDhMQ + IBYgKxsWJBYtJBYtFTkVFQwgISEQISAhICsWECAWGxUVJCAgExIiISsVChUVCiQWMQcHIA8PJCQkFQoV + ChUVFSQkDw8GDystORYQMSQVLRUVIBAyFg8kFSQ5FQYPORUlECAtChUKCgoVFRUkJCQVJDkxDzkHMSQH + JCQKFSQVJA8rFRUVFSQPDw8VChUVJBUkFQoVJBUKICAGFRU5FSQVFRUIIRImESUgDxEHJTErGyAHLRYx + FiAlICsIFQc5LRUKFSQGORUVFTkPDyQWByEbJCQkJBUkFiAgKxYkDw8tJA8bByAxGysuICAkBysgJSAb + FhUVFSQIGxUVFTkHECEQISEhIActKw8WIBYxBzEGJA8gMSAHDysgFhoHICAgJCQVFSQVORMSIh4eIBYV + OSQ5CDkELRU5ChUVCgokFSQVJBUVFSQVJCQkFRUVFRUVFRUVFRUPFS0VFhUVDxUVORYPDzkKFRUKFRUk + ChUPJBUVDxYPFSQWBiQWMS0VFRUkOQ8xLhwxJBUVLRYkORUVJCQVDzk5HBYVChUtJBUkFRUKFQoVMRAQ + ECEgORUkOTkPGy0WFRUkCCQPJBUtFTkkFhYPFRU5JBUVFQoVMSsgMy0kFTkVFRUVOSAPFhYtJAcWFRUV + DysgECsWGyElFg8gByAgKzEkDxYHMRUVFRUkFS0PGzEQEy4xJBYgIDEQICUPFiQVJDEIFiQgFSQgJCQW + Kw8WLTEHFg8rLQcQIh4vBxYkFRUVFRUKFQoVChUVFRUVJBUVFQoVFSQVFRYVFRU5FTkVJCQVORUPJA8P + JCstJCQPFiQKFRUKFRUVFRUkJCQPMSAxDysPJCQWIDkGJCQtKyAgICAlBwc5CiQtFiQkJCQVMSAgJRUc + ETkKFQoVFSQkJBUkJCAgLSAPOSQkFRUVFRUkDy0kJBUkDzkVFRUVFQg5MQ8VFSQVFTkkDw8gIAcgFhYW + JAsPJCQrIC0PGiAgMSQ5DwcPMSAgLSsxCBYgKyAxICAtDyQgMSAVFRU5Dw8KJBUgISEmLg8xMSUgJREg + MSQ5LQYGMQUWICAgICAlFjkkKwcgIDEHFRUVLRUQIiExJBUkFQoVFQoVFRUkJBUVJCQVFSQVFSQVFSQG + Dy0rFRUPFgY5Gg8rFiAkJS4gJS0kJBUVChUKFQo5FQoVFRUkLTEHLRYWMSAhISAWORYxICAQFgcPJCAP + FjkVJCAxDyAkFQ8kJBsVBhArJCQkJAcPMQ85DyQ5FRUVFRUVFRUKFRUVFTkkFSQVORUPJCQkDxYxDyAg + JCQVFRUKGysPKw8rLQ8POQgxLSsPICAxFQ8gMSUgByQxMTEHOSAPJBYtIA8gIA8WKyQHICAVJBUPDxU5 + FQoVLhAQESIhECAgLhElICAWFRUVJCQVOSQQBxAgJBYHDyAHORUgFiQGChUVFQYIFg8VFSQVChUVFRU5 + FRUkFRUKJBUPJBUVCgotJBUkDwYrBy0rBiQLICUhIBAiECAWFiQKFRUKJCQVFRUVCjkkIBYPDxUbMSAx + GyQGFRUkDBslICsVORUrICQVJA8kDysPLTkVFRUVFSQxMiAxIC0gIDEPJBUVCiQkFSQVFSQPOSQtJDkV + FSQVFSQkFiAgIDEgJCQkJRsgJBUVFSsbFiAWDxYVORUrDyQIISEhICAWJActDyQVICAgMSUWIBYxKwgr + MRY5BiAxMTEPORU5Fi0VFQoVORUhHCAQISEgIDEMICAgMSQVOQoVFQ8VKyAxFRYRFhYVFRUWDysgFisL + FRUVChUVFRUVFRU5FTkPJBUKFRUPFRUVJCQVChUVJAo5FSQxLQcrMSQkIBAhIBARICARIDkbFRUKFSQP + JDEVChUVJC0bJCQVFQYtFRUVChU5DyAPIC0PFSQVJA8kJA8GMSQtByQWFQoKCgoVFREhLyIwLy4QIDEk + FRUkDxUVFTkPJBUPFiQkFRUVFSQVLSQGMSAWLRUVFQ8tFi0kLSQPJCQkJBYrDxUPDzEWIBAVHCArDyAW + JBUVOQIPDwcgGxoPLSAlJQckDw8PECAkJAokFiAkFRUVJBUVDyEhJSAdMxAgICElMRYHJBUVJDEgKy0V + JBYHICsgFg8kICsVBysgICAWOSQgMiIgFhUWAiQPFRUkFSQVOQoVJBUkFSQVFSQVChUbIBExFSQPIBAl + MQcQJCAbMSAHFSQWLSQkDzEIJBUVDyQkFSQVJCQkJBUVChUVJBUVFRUkJCstJBUVFRUkJBsgBzEWDzkk + FRUVChUQLw4eDiITICsHLSQkFSQkJCQkJCQVDyQVJBUVDxUPJA8kFRUPLQ8kFTkVDzEWDw8xDzEPByAg + LiAtDzkgHBMgMQogFjkgJDEVFQ85BystECUgICUhIS0WMQ8rICAPDyQkDyAVJBUVFRUVJBUhIRAuDyAg + EBEgIAMgOSQkDxYgJQcgICAgJQgPJA8xDCAWIBUPBiQ5FSAhIg4fKh8dICAgCyQVFRUGFQoVFSQVChUk + JAoVChUVFiAhJSQWJCAgGxUtLSQgLSQPJBUPOQgtMSskJDkkDyQVFSQVJCQVORU5FRUVLSQkOQoVFRUP + DxYPFSQVJCAhDyQgMQcPOQ8VJBUKDyEgICQVCiAgMS0tJBUVJRskFRUkLRUVFRUVOSsbJBsrLRUVJCsk + ORUGJCQVICQkFS05BiQlEC8iIiIeKh4iERARIDEIMQ85JBUVDw8bJRExICAREyUWIA8lBysbMSQWICAr + JAogGxUVFRUVDxARIiEQICAgEDIgKw8kMQ85FQYkJBAxICQ5JBYgIBEkDxYrCzkKFQ8VFhEQDSIOIiEH + FiQkJBUVORUkFSQVJC0VFRUVChUVJBUVJCUgByArByQVFSQVJBUkFRU5FRUVFQYVJBUVFTkKFRU5FRUV + FSQPFRUkJBUGFRUVOSQtIDkgOSstJCQPFhAxDyAuKw8rJAckFSQKFRUKFSQVISEQJSAVOS0hMSQkFSQk + JCQkFSQPJCQPMQ8VFQ8kIA8WJBUVLRYrLSQ5BysWICAQISENIh8QDxUVOSEhMRsrFgglKzkPKyAgJSAx + ECAPDzEgMSAgBysPIBYkBjkVJCAxLQoVChU5DxAhISAgIDEgERElByA5FhUVFhU5FhUkFQY5FSQGFRUk + Dy0VJBUVORUgFhEgKxskFS0kCw85JC0VJBUVFRUWJCQPJCQKFSAGFRUPIBAgICAkJBUVJBUkFSQVFRUK + JDEkLSQVDwYVFRUVFRUkDzkkJC0WDwYkOSQVFRUVDysPFgcWJA8VLSQgMQgrICAgLS0bFiQVFSQ5DxU5 + DyEiIi4HORUVIC8WFSQkDyAhLiAgFjkkFjEVFTkPICAkFiQPJA8kGyQVJA8tIDExChYgMhEWORUKChUW + ITIQICArICAHFi0QEBwgFg85Cg8xBxEgIDEPIDkVFRUkDzELDyAVChUKFQo5EzAiLyAQECUgJS0WFRUk + ICArFg8WFSQVFQYVOSQ5DxoVFRUVBxYIJBY5ECAlDyQVFSAtFg8PFQoGJBUkDyURMSsIMSArETEPMSAg + ISEuIA8tGyAgORYVJAoVJBUPFhUkLSQPJBU5JCQkJCQVDyArJCQVOQoVChUkFTkPICsgJA8VLSQVLQ8x + ICAgDyArJC0WFRUKJBYVFTkPESEQMRUVJBYRLjEgMSQkJAcgJBUVFSQWLRYPCy4gJQgrBiQ5FSQkFSQV + JCQVIDEgCC0VFQoVJBUVJAcRECUgICArDxYgMRAzISQVFTkkJA8rLSsbKxUPDzkVDxYgMSQPJDkVFQoV + JBUGISIhHCAgByAkJCQGFjEgICQxFRUVOSQrBxUWFhY5JBUtDystFSQWICAgIDEVCiQVFRsrFQ8VORUP + FiQbJC0PKyAQIDEPIBEdMyEOHSIeIjcRICAkFRUkChUkIDkKJBUPJBUPDxYxByAPFgcgGxUkFRU5FSQV + FRUKFSQxICUgJBUVCisgLiAPFiQgGxYWKy05FSQVJCQkJBUQES8kJCQkBxwQBw8rFS05FSQVJC0kJBY5 + DyAREDEWOS0rFRUVFSQkJDkVGzkIFRUVFRUKFRUkChUVDyQgIAcgLiEhMgcHIAcbFRUVBistIBUVFSQt + KxYkFhsxIC0kJCsPIBUVFQokFRUWJRAhECAxFg8xOSQVJA8gBhU5DysIMSQVDw8kFgYVJCAPKw8VJA8r + GyAPFiQVFRUkDzExFg8PJBUVFRUrDw8hIA8VJBUQIRISIhIOIiIhIDEIORUVFQ85FjkkLSQVFiAkFhYg + ICAHJC0kFRUVBiQVFQYkFRUVFSQPBwcxMQ8kORUVICsWJDkPMQ8tJDEPKyQVCiQVJBUVJCQGBxEgMRsr + IDkkLS0GJAskJA8kJCUgBw8rIBAgICUgFg8kJCQtDxUVFRUVFSQKFRUgGysPFRUVFRUkDxYtECEhISEu + MRU5JCQVJC0gICQPDyQtBzEkLRUrByAQJSAPFhUPJDkVFQoVDyAgECEhISEgMSAlCCQVKyQGDwcxDwck + DzEaDyskLRYVFQ8xFiAPFRU5FSQtDxUkBi0rFRU5FjkVFQoVFS0gKwckChUKFQoPIA8bJDkPFSQVFRUk + FS0PDwcWBiQkJA8WIDElESUxDxUVFRUVFTkkFRUkJCQxFRUVLSQWDw8kFg8kFSQPJCQPJBYVDw8WKyAk + FSQkFSQkJBUKFTkgIAkyLi0WFiQWJCQkGxYWIAcgKy0QICAgECARFg8kICAPJA8kIBUkFSQVFRU5ByEl + GyQVOQokFTEPIBAQIRcTIRYVFRUtLTEgEBAWFTEWJBYIJA8gDyAgERAcIDEPFRUPFSQVFSQkLTEcMhAh + ECAgJC0WJAYVFRUkFiAkMRUkDxUkDxUVJC0rDxAlKxUVJBUKFRUVJBUVFQYPFg8PFiQPMQ8PJRsVFQok + FQoVChUkFQoVCiQVChUkFTkGKxYxJCQVJCQVIDERICARIAcrFRU5JA8WFiQtFTkWDxYPFiQVOSQxJRsW + KzkVLSQPFRUPIAcxJSAxByAHICQrJBUKFQoVFTkkDyIiLxAgLSQkDyAgESAuECAgIDEHISAlICAlICAH + JBUWDw8PFRUVJBUVJBYRIRAuICAgIDErICAlEBEgISIIFQoVFhYgICAgKy0gDwgxJBUrFisgByUgISAH + JCQtKyAtFhUVJBUkFQYkLhAhIBYWJBU5Fi0rGy0VJAYPFjkPJBUVLRYPByAWDxY5Dw8VFRUVJBUVJCQ5 + FjEPFiAgMSAhIRwlJBUVFSQVFSQKFQokChUVChUVDyQkOQ8PFi0PFSQkJBUHIRAgIRAgOQ8kJDEkLTkI + Kw8rBjkVDzkkDxUHJCArIA8PFSQkCw8gMTEtIBAgIDkxKyAgICUPJCQVCgoKFRUhDh4eODAwMDcgKzEr + ByAhEDEbKyAgICAgMSAgMSAgIDEWOSQkFQYkMRYgKxAhEhAgJSERFgcgICEXIDEWJBUVJAcWETERBzEH + Kw8rLSQVCCAgKyA5IAcgFjEHICAQMS0rFiAVORUkFgcgIBAhIDEHDyQGFhYrIA8rIBYWKy0kMRYxFiAr + FjkHJBUxGyQKFSAlOSAPJA8WOQ8WJSAxICAgIAcWJCsIMQ8kFRUVFRUKCiQVFSQkDxYWIBYkKw8VFRUx + FhYgITIgDw8kFiQkBxYWJSAkDyQkFSQVFiQxFjEgIAc5FjkPMSA5Fg8tDyQHKyQWDw8QECERIAckFRUV + FRU5JBsQEh4OHhIXIAIHGzEgJBYWJAggISEyIS0gKxAgIDElICUkIDEgICAlLQgPIAcQISEgICEhHCYh + ESEgJA8xOSAPOSQVFSQtKy0xDyQrIBYrICAgBw8WOQ8kDysIICAlICArDxUVFTkgECUgIS8QIRYaFhYb + ESAWICAxDw8VFgcHDxUkLRUVDyAxKy4WFTkkIAclCCsxJA8VICAgBw8kFiAgJBsHJSAgKxUVJAoKFSQV + FQ8xIDEHBw8VLRU5DxYkORYVORwPFRUtFS0gFjkPJA8tCzkkFjkkFTkPJA8kFgcxJSAgJDEQECAxDy0l + DzkbICArDyAkMisPIDEkFRUVFRUVFS0cETEkFSQ5ICskDxYPIA8kMREhESUxBwcgEBAxICAHDysgICUQ + ESUVFTkVJAcREDMSECEhECAPFjkVJA8WJCQPJCQVOQ8tICsPICAcICAxJDEgMQ8kFRUgIBYgEBwQFg8V + JBUbIBAcEBAhECArJRwxMRYPICAWDxUVJBUVMSQWFhUkKyEvEAcQIQ8PJC0xDyAxCCQGJC0GEC4hICAH + KxUVFSQPICAtFg8VJBUVFSAgKyAgIBUVDyQIDwskIBYPDw8rCgoVChUPDysPMSAVJA8kBjkWJA8VJC0V + FRUkBhsVDyAgIDEgIBYgJBUgDDEgMSQkFgcgMSsIMSAgDxUKFQoVJBUVFSQGJCQbByQgIREWMSQVKyQP + IC4hEC4QICAbKzEPJAg5ICAgFhUVFQs5FjEHECEdIiArGyQVFRU5JCAHIDkVChUkIA8IMQwgJQcxIBYk + FS0kFTkPKyQ5ICAWLQ8rICQWJCQaICAgJRAQICAHEBEtFRUVFSQVFQYxIBYgETExFi4hEhAbJC8hGysW + CDErBxUgORUVORUHIAcrJAYtFS05FRUVOQckFRUKJAYVMRAhICAgMTEPGg8kMQ85DysgFRUkFRUVFRUt + BxExFjEkMRYHCDErFSQGFSQVFRUVJBUxESAlIDIhIBYWJA8gIAcgBzEHJA8PJCARJRY5JAoVChUKFRUV + Fi0lMSAxCxYxDyAgChUKDyAiISYhIRAyIA85FRUVBjkVDzkPFg8kDw8LIBUiIiURDxUkFRUkDyQPDwcP + JCQVJAo5DCA5BysxBxACOSQtBg8CIA8PFg85FQ8WICUgIQckDyQxEBEgISEQMiQkBzkkFRUkFTkPKwcW + JQcHBRAhDyQVChUQLyUtKw8CICAlIBYkFRY5BisgDw8gKxYgJCQVFQoVLRUVFRUVFQ8xJRElMQcQICAH + LRYLLQcxJCQVFRU5FSQkJBUVFRUgIDEWFjkgBy0kDyQxBiQVFRUVFQ8RJSERMiAgOSQVJC0gICAtJCQ5 + FQYVFSAREBUxFQoVFRUkLQgrICAlES8gECEQIA8kJCQgEBMREBAhIRAHDyQHJCQWFSQkJDExFiQxLS0x + EAcgDyAkChUkFg8gDzkkKw85FSQ5JCQIFQ8bDxYPOSQGKyQrICAgJTExFhYtKyAuECAQFhUWIBAgECEQ + ECAHIDEVFTkVChUkFiAgIC0gJTEgFQoVChUKFQkiIRsxMSAxICARICsxCBYPICsxMQ8gKy0PFSQVFSQP + LRYkFjkWFg8gMRElETEgICsPJBYrIA8VJAoVJA8gMSArLSQVFRUPIDkWICAkCzkHDyQkFRUKFSQkFhsa + Fg8gEBAlJBUkKyAkFQ8PFSQVJC0gIBAQISAyIDEgJCQkDyAgJRAQISIhIRELJAYgKwgyECAlJRElICAa + MSAWORYWGwcgFiQVICAlISAkMRUkChUKOSQtJAYVFTEgFQ8VFRUVMRYWKyQtJA8WMQ8gICAxMREgFiQg + DxYWISUgECAlGxUkICAxLiARKwcHJA8VFQ8WGwskJAcQJRwWJAoVFRUVJCQkHiUhECAHJSAhJSElCAcr + ICUHIA8HKw8PFRUkJBUVISAgIBYVDzkPKw8HIC4gJRYgIDEgIAIkJAoVFSQVOSAWBwcxFSQtFQglITEg + FiQVJAcxDyQ5FRUVCjkkDw8lKzEgByAgDzEIJCUkJA85GxYVFSAQHDEGJDEHMS4PKw8kDy0gESAhISEQ + IDEgLRYkFgcQEBEgMSAlICAWIBYgKxYgJRElESsgIAcWIBUkFRUVDxUVJCQVJCAQIC0kORUVJA8bICAr + JAs5JAc5IBAxJSAlFhYgFhYPOQchCCQgISEgLSskFRU5FSA5JDkVDxY5DysxIAwgIRAPJBUkDxUkFRUk + DxAiLxAgICAQExAgICsgIDEgEBAgJSAWJDkVJA85CiEdJhElOQYWFgglMSQWIBExByAQICA5JBUVLSQx + Dw8rDzkkLSQkJDEWIBUVJA8tDyQPORYPDyQkFRUVCCQgFi4uIS4gKy0VECA5IAcrBystJBUVFQoVChUK + FRUbMSAWMSAlFiURFyETEC8QISEuMRAlESEzHCEgICAgIA8xICAWICAgECAgByAQMSAVJBUVFRUVMQck + FSQgIBUVFRUGLSsWKyAQICQVFRUPFiAHIBwRIA8xJAc5FQ8kKyAWICAlEBYPLRUVFQoPDw8VDyQGMQcg + FiAgFiQtFSQPMRYbOQ8kJBUPIiIuECAgJSETIQcWJCUbJREQIAcgIBYtBy0rJCQxIiEvIBYkJBU5Bgcg + KzEkJCQlJC0VCgoVFSQPKw85FRUVFQ8HICQLDxUPFjEkDxU5Bw8rMQcrJBUVJBUlESEhECEvHSEgFjEg + IBYgICAgICUxJAoVFQokJBUVJDkgECAgICARICAhIRAhISIiEAgkGxAgIBAiLzMcJSUxICURIBYWECEP + KyAuESAkJBUVFTkxOSAPFQ8HICQWKw8kJBYPIAcWGxYbJBU5JDkGJCAQEA8tJBUkFRUVFQ8gMQctKwcr + LSsKFSQVGysVFS0kGg8rByUgFg8kFRU5FSQPFRUVChUVCjEOIi8RICAPMgMxECAgBzEgKyAgFjEgKyAr + IBYgDyASEAcQICAgBxYkICAPIDEHJAgWDxUVOQ8VByAgDxUPFRUVMTEkDyQ5JA8PLRUVFSQ5Dw8rIA8t + FSQPCCUgICYNISYdDi8gLyEhIi8hEBAQEC4WMSskLQ8kMQ8kJAgxECAxJTEGFQ8mIiIhMyExFRUVFS0h + Ih4eHjMTIA8IECAQICUVFQ8QISEhDwYPIDkHIAcWJC0kFjEkLSAgDCAgICQxDyQPFRUVJAcVORYWKyAg + JBUVJBUVFTkkICAPKxYgIAcVFRUVDyAgDyQPFg8gICARICQPFRUkBhUVCgoKFRU5ChUkEA4iISAlKxY5 + LRYQMSQVFQ8gKwcgBwwHJQcgDxUGLTEbFSsVJBUkEQcgICsEDyAlICsGJCQkGyAgKzErMSQVLRUWDxYk + FRU5FRUVFSQkBisPMS0kKwYkJCQtEA8bMRATIjAOHx4eIiISISEvISEhISARBxoPLSQ5JBUVCBUlIA8P + JDkLGyAHCw8RMS0VFQoVFSASIh4eDiIxFhYgICAgFhUxECAPDy0kMSAgICAkMRUVDw8kBisgICEhIBYk + JBUkKzEPMSUgJBUxMQgtFRUVJBUkMQ8VFRUVMREhJSAbJA8PDysQICsHJSQgKyEhMiExFQ8gJDEkDyAx + LTEPJBUVFQokEhIlIA8kBhUPJAcPFgstMSAxICAuICAhIAw5LSQTIiEuICAQISUtFjEPFRUgHBYxFjEP + FjElIQcuECAxKw8kBzkWMRUkFSQWJBYgFhsPKyArByAxJCQVDy0KJBUVFSQVBzEIFgUhIBMNISERLhEu + IC0gFSQkIDEgMTEgLTEgFhYPJBUkORUKJBUVFRUVCiQkICAhIiIiITEkIBAyESAWEC0kFSQVFSAQMyEl + DyQVFSsgKyAgJTkPDysgICQVFQ8HIBAgFSQWDyQkFSQkJCQkCyQkFgYkFRUkBxAmIg4iIS0WDyAgIDEV + ICAhESQPDyQgICAgICsbFTEgIBYkJBUVChUhIRAgFi0rICArBzElJSsgICEQIRAgDwgGDxUVFRIiISAl + IAcgJRYkFiQlISAWKw8PJCAgMS0kICAxDwYVJBUVJBUPKw8rOSAxJDErIBsHBzEgJSAPJCQVChUKChUV + CiQVFSQVFRUPOQ8kFRUrFhYrDyQWDw8xEA8PFTEgICUQECUbKw8VJBUVFSQ5FRUkFRUPISIOHh4zICAQ + ECAxIDErJBUkChUKLRAiHSEyICUxIA8TMTEGFiQbFggrMRshMiEhICAPBysWFTkPFRUkJA8rFSstKwY5 + FS0gESESHSIhMSsgEBAyICUQBxUVORUVMREmISAPFiACJSQgIAcxJBUVJA4vISEQGzEWIBYgGyAgECEh + IQcrFisrFTkVFQoVAyYQESAkCAcgICAlIAcgMQcVJCUgIBYVJBsHJCQkLSsPDyQWLTEtECAgFhYPDyQW + JAcxDzkHKy0VChUKFRUkChUKCiQVCiQVJAoVCjkHICAxIBYxESEhIDExBzkkFi4gJRAgIDItDxUVJDkk + JBYtKw8VFi0BByEOHjAhESAgJSAWICQVFRUVJBU5JQ0vISAQESAhICAkMTkgCw85IBATECYQLhAPOTkG + LRUWFSQWFRUkLRYgBzEPCyQkJBYhIiIfHjMgIBAhByAgIA8kFRUVJAoxEDAdMhEgMSAQJRElMSAgFg8k + EBIQJC0VGzEQIAwQITEHFRUkFhsgICQWFiQkChUtICsgICstFhIQESAkCBYtKzEtBSUkDxUkDystFg8W + LSsgJA8WICAgFiAgJBYxJDkkJA8WDzEWChUKFRUVFSQVFRUVChUVFSQVFRUVDxogIBEhISEHLSsgFg8L + BiQQICA5GzEHGiQPJCAPFiAWICAhICQVORUkJBEiEjIQIRwgDyAkFSQVFSQVFRsgHhcgIBARByAHKxYg + FjkxFiAgJS4QESAVFRUPFRYWJCQtKw8PJA8VBiQHKy0PFRUPJA8HEBIeIiEQLyEHFhYxMRUkChUVJCQl + JiIvIBAgLiEgECUgFiAgJBUVORUVBzEQJSAtKw8xJBUWMSEQECAIKxsVFRUKFRUIJgcIJBUkIDEgKzEW + FiAQEC4PICAPOQ8WDysIOQ8VDyAxMSskDzkPICUxByAGFS0kJBUPFRUVORU5FSQkFRUKFRUVFRUVFTkk + DyQVOQchHSAuKy0HIA8kIDEgJDEVFRYkIC0WMRsrIBAgECAgIA8kCgoVFQoVBA8HJAcgIBAWIBsgMRYH + OSQkJCAQIDE5JA8kDy0rGyAHLSArICQHOSsPJBUVFhU5DzErByArDws5JCQ5FQ8kFi0kMRYkFSQkES8S + EBEQIC0PByQkJBUVJBUVIBEiJiAgMhAgISAgAiUQKw8VFRUkJDkHIBEQJSAPFQcgIBAQICAMIAcWFRUP + FRUxIA8xFRUKFRUHEBEgLRUIIBwxEAYVFRY5BzkVFRUkFSQVBg8PDxUVJBUIBhYkDyQkJC0kJBUVCiQI + KxYPFjEPOQ8VByUxEDEgEDE5GysgIAcuEBMvJSAlICEQIDEgJDEPOQ8gKyAlEBElIRAgJCQVFRUVChUk + FRUKFRUVBxAhICEvISEgIA8kJBUVICAIFiAPJBUPJAsQICUgIAcWJAYVMSsPFSQPFSQPBgYPBzEkDxUV + BhUVFSQVJC0GMQYxICsVDwwkByUgIRYxByArGxYtJBUkIBwHLSQPKwgxICAgMSAHLSQVLQcLMSAgECAg + KyAgISYcIRAQICARIDEgJDEHIBYVJBUPCiQtIDEPFhUVFSsgFhUVFTkkDxUkBiQVOQ8tMSQVFTEkFQo5 + FSQrJBUkFRUVFRUVFTkPDyUgJTELIDErMRsgICURICAgECURICAHISEhLi8hECEQIDkgDxUgMSAgESUW + LSAgEBAhEjEKCgoVChUPDys5JCAhMzIhMDAOIjAiLg8PORUVJCQgFhYPMSUbMSAgKxEgDysPLSQkFSQG + ICUWJAokJDkVORUVDxYtJCQGOQoVFSQkFSQPJAgxBjE5ICUxFhYIICAgJTEPJCQkFRUkFiQGOQ8WFQY5 + FTEbKw8WMSsgMSEgKzEgFhElEQ0TMCIRFi0HKyAWICUQByAtFhYgKzEHIBYkKw8kCiQbJCQtFSQkLRUk + FjEPFSQkFhYlJBUkBhUPJCQWIBEbIDEWLRYkFSQkJDkPMSAgERYHIBsrBw8IMSARMSAgFggkFTkkLRUP + CDEIFjEWKwcxIBYgECAQLRYgECAPJBUVFRUVJDkWKw8WICEiDh8ZHx8fHx4eDiIhKxUVFRUVFSAbFhYg + JSEhESQGORUbJBUGORUGJDEHIBUVFRUVFRUVFSQkJCQxFSQWDw8PFjEHJBUkFSQPFgcPFi0kKyAVJBYV + FhYxBy0WLQYVFRYkLRUKFRUkJCQkJA8PByAkByAgJCUgBzkHJSAQIRAhICQIJSAQIDIHKw8PJSAhFgc5 + Bg8WDzExJBUVDysVFQ8tJAYtJDEPJA8bETEuBzE5KxYlIBAuJTEWMSAgJCAWOQ8kFi0WICAkMSskOSQV + JBUgJCAgIDkkFRUVChUkFRUVJAcxGyUgBxEgMSURJSAkByAgIBUKChUkDxYBIDEgICEhEBASIg4iIgkS + FxMQISAGJBUVFSQtFg8kICEQIBY5FRUrIBYbKxUVORYlGysWFhYrDxUkFRUVJAYkDw8HLTErBxEQJBUV + FRUkFg8kFiQVFhY5FQ85JDEgORYkJAskMSQLFiQkJBUkFRUVJCQVJBUkFRUVFiAIMRYHJA8VFRUHKyAg + DyQlIDIhECAMICAQJSUgKxYrDysgICAtMQcgFiAkFRUgJA8kJC0VJDEHCDkVDxUgIBsHDwcgIDEgECAx + MQ8PKxYrDzkHMQcgDwcrLRUVLRYQBzkVFSQVFSQVFRUVJDkkDxYgICAgKw8gIBAgCDExAjEgJRsgKw8r + ICAQICAIJREPESArGyQkJC0VICAgLSAxJBYkJAgrICAQIDEVDyQVJDkPFRUkDxYHJBYgIAsgJTEkFRUk + FSQkFRsrLQcgIBAQIAYVFRUkJA8lICAPFiAkDyQrDxYgByQVJA85Fg8VJC0VFiQkDyQkFSQVFRUVChUK + FQokFiQIORYVFRUkFQ8PKy0VJA8gBxAgMSAQIS4RICAgIDEPICAQKxsWFgcrLRYtKxU5JBYVKzEHJCQV + DxUVMQIrMSstDwcQERAlICAWDzkPFSQGJBUVESUgIAwkFSQkDxUkFSQVOTEkIBYtFg8GJC0gKyArICAg + IAcgICUxLTExIBExJSAWICAxHBAgKw8tBysRJSAWFSQKFRUtCCUgMQ8VFiAlICAxFhwrLSAWICAPFS0P + LSsPMSAQIDEgICUgIBUVKw8gFg8VFg8rGyAgJAY5FTkVJBYWIBEQFjkWDwcWIBYxBxYVJBYrDw8xBzEV + JCQPLSQVORUkJBUPFRUVJBUkFS0VFSQPFi0kFRU5JA8kJAYkFTkWMREQISEPMREQHTMvECEhISAxBzEb + DyAgKzEbBiQVDyQPFi0kJCsxLRsxIBEWFSQkORUxDyQPDyQWJA8xOSQGFi0kJRYbKzkVFQoVJCQPFg8x + BzkPKyArIA8kBwIPMS0kICQtKyAgIDEgISAlMSAxGyQHJRYWFiAkFSAgICAgMRUVFRUKFSQIFiAgOQ8k + Gy0PIDEgIS4HIC0rJBUPKw8LIAcPIAcgICAQIBYHORUaFS0kJDkVFRU5JCQVCisVJBUPICAyLRUVORU5 + FTEgKzkkOSsbJCsHFiQPMRYPFQ8rFQ8VBiQWORUkFSQVFSQVJC0VJBUkGi0VJCQHLSsVBiQPDxUxFiQH + FiQyMSUQIDElDyQbFS0VORYkFg8PKw8GMSQxJBUkByAgIBAlIDEPJBUVFRUKFRU5FRUgIBYxMRUxLSQW + IC0lIA8VFS0VFQ8gKw8kFQ8kICAgIDEWIC0gFhUPFRUkFggQByAgBxAgCDExFiUlLiAbLTIgJA8VLSsb + IBsPFRUVChUkJA8xIBYVFRUaFSQGFhAiLiAPDwcxBw8xJCAWMSUIJSArMRotKzEIJBUVFQ8WDxUkCgoV + FQYPKyAgJRA5FQoVDw8rDxYCLRYHMQcMICUgIDEWDyQPFiQkBjkPJDEPBxUVJCQVFSQkJA8VFTEgDyQk + JBUVICAgMTkVFS0VJAgtJBYgBzEPFhYPLRUVFSQVJAYWJQ8VDzErIC4gICAkOQ8xICsbIAcrJC0kMRUV + JBUkFRYgBzEgFhYkBzElKy0rBwcrJAokFSQWICAlDyArDzkHKxYkByQPJCQ5JBUPFi0WORUgIS8rGyUg + IBYgByQGFRUgDyArFRUVJDkKJC0PFSQVChUHICUgKw8xCA8gMSQPICIiIi8QIA8xBy4WDzEIOQc5DwsP + Fg8HKwcWFTkPJCArJBUVFRU5ByAgIDEkFQoVFRogIBsxESUkDysGMREgERYGBhotFjkVLSQVFRUVJDEP + KyQkCiQPFRUkOSAgFjEWFSQPFTElBxUVFRUKFSQVFhYgJBUPKyAgMRUVChUkJCQPOQ8xJDkPByArDzEk + FisHICAgFistJDkHFg8kLQg5BxYxKw8WFTEgDzEIJQ8WIAcHDyQVFRUkJC0WDzExBiAPBxwlJRsWJAYk + DxYxIBUPFQoVFSAHICUxDyAgDxUVJCQxIAcxCCQVFSQVFRUVFRUkFRUVOQcgECAgJSArByQVChUIECEh + DiIgJCAMIAgrDyQVFRUWJA8rFgcgKxsWBxYHFhskFSQGJAYPBysPFQoVFRUbMRAQJSAgMRYxDzExFi0V + OSsPGiQIJBUVFRUtJAstMQsWFiQVChU5DyAxICAlJCAWDzEgDzkVChUKFRUPJCQtJCAlKwcWIA8VFSQV + CgokJBYPJA8VFS0kIBYkJA8uLiEHLSsHCAcWMQ8kLRYkFRUtJCA5LRYxKw8rIAcWOQ8kMTEVOQ8rDwYk + JCUgJBYkLQ8WByAWDxUkJCQtGw8PJBUVCiQPKyAIIBAgJSAPOSUgIRAxIBotJCQPDxUVFRUkJBUkJA8k + ICAQERAhISA5FSQVJCARFg8hJiAgHAcgDxYtFg8rMSAlICAxIAcrBy0kDzkHICAgKw8rFiQVFRUVDxYg + MSAgICAgJSEQKxYkFiQVFRUVLSQVFQoVFSstKwskFQ8tKxsWJCQVDyQPCCQlICUxFistDyQVFRUVJCAx + DzEHFgcgLgcxDxYPJBUVChUWLRY5DyQVJBUkFjkWJBYQISAkFiQVFjExIBYkFg8xLSQWJCQWFiQPDyQV + IActLRYWICAlICAgIDExMQcIJSAgFiQPKwgPICQkJBUkFSsWOQ8VDyQkOQY5KxAhISEhISAQIRElICAg + JSAkFTEbJAoVIAwtIA8kMRYkKxEgByAkFjkWMRY5JBAQICEyISYgMSQWDzEgCzEgJRElIBYlICskFhYH + MTYxIAcgIC0xIDEgJS0xMQgrBxAhICATISEgByQVFRUkFRUVORUVFS0WCA8tDyQVBy0WDy0PJBUkKyAH + Gw8HICAWDzEVDzkWDzErIBY5ByQVMSsIFg8tKw8tJBUkCA8gFiQkFSQrDxYgECAhECAhICAWJCQgDxY5 + LRUPFRUWBzEHDwcHMSQtKy0WMQckIBYgICAHIBErDxUkJSAxFg8tMTEkFisxDyQPMRoPIAcrBzERIA8V + DwstLiEhEhAhIBsgICAgICAgIDEaIDEVOSQgFiUIKw8kLRUgJTIHDw8LIBAPFRUVLRIeHh4dIQckIBYy + JSAlEBAmMhAlDwcgAiArDwcWICUQECAgMSAxEBAQEA8xFi0tJAYxJBYMICAgISArDxYkJBUGJCQPJC0r + FhUPMRU5FjEWJDEHICAgMRUrFiAQIBYPLRYWICQWCCUbFiAxMQcgJS0rDysbGhUPLRYWMSAgICQGDzkW + ICUQISEhICArICQGJBUtBhUVJDkkICsgJDktKxUkFQ8kFhUPBzEPFTkbJSAxFjkkFQ8kBhU5FRUgJCAP + ICQxKyAHICQgLSAlFSQkDw8kDysQDSEiIQ8rFhAQIBAcEC8hIBAhDyQkLTEbMTEIJBUkLQ8RMiEgMQc5 + FSQVFRUKOR4iIRY5DyAgFiARICUWBwcQICAgEBAxICAWGxYbEBAyESUWByUgICAgBw8WJBUtFRUVLSUQ + IRcQIBUPMQ8kKzEIORYVFgY5DxUkFggWJAglICUQGyExICAQISElGyUkDwcPIDEWICEhJSARJSArIBYc + FiQkICQPJCAgJSQWMSUrICUbFRUVJDEWIAcgFRUkFQokICsWLRElBxUPICAxFiQkFQ8gORUkMQgWLSs5 + Bg8WIDkkDxUPJC0kDxUVFRUPDw8kJCQkFRYrGyAGFRU5MRYkIDEgJSAHLQ8kMS4dMBISEBskIRAbFiQg + FjEICzEbFRUrFQcxBxYkBisVFjkVFRUVFg8VBhUPKwglICAgLSAgIBAQJTEgISEQORYPJREgFiAWGyAH + GyUgMSAlIA8kChUVCiQPMSAgIQcWGxUkLQ8PJCsPORUrByQVMSQkDyAxIBARLQ8WICslESEgICAgLiAW + MRYgDyAkIAclLSsIGxYkFgctLSQVFQcgIC0WIA4RICAgFhUkORUkGy0gJBUVFRUkDyAbEBAgKw8rIBYg + ICAxBzErCCAPFSsgJCQPDxU5DxYuFS0kFggkFiQkJBUxKzEgMSQkJDkPDzEkJDkrBw8QIA8lHAckICsg + ICEiEhAtFQoVFRAvMjEPJAIxICAgKyQVDzkGFiAtJCAtFi0PJBUkFRU5FRUVJCAgJCUHIAwkJSUhECAg + ECEXECAgMQ8xCDEkBysVKwYkDwsgESAkFRUKJBUVFRUVCCUgKxUVJCsLJBYbBhYPBw8PDyQVDyQWGwct + ICQkFSEgICsHFiUQHBwrFRYgKw8WDxUPJBYkMQgxICQkICQtDy0WJBUkCxYgFisgIDkkFSQkChUVFRUV + JBUPLy4gMSArFg8GOQ8kFhYkICsPLRUWJDEgJC0WIBokFSQkFgsVFS0kDy0gBxYgDyAgMRYHFiQkFiQk + FRUkGyskIDkPJCAxIAcxBxAhEysVFQoVChUVCSIhBzEgICAgJSAgLRYIFiQgKxYgKyAWMSQVFRUkDw8x + DxYgFiUHMSAxIAcPIAcHIBElECAlMQcgKxYHLg8PLQ85FRUkByUgDxUVFRUVKzkPJDEkETEPDwcPLRYt + KxYkMSstFRU5FRUkJAo5JAoVFRUIFiQkFRslIBAhIC0WJDEHORUkFTEaDyQWKxAxDyQPFSQHOS0VDwcx + ICAHICQWDzEPJBUVFQoVJBUVIBMeDiEXGyAxDxYPDzEkFiAgJSQkJBYgIBYVFTkgECAkLRUkJBUkKyAr + MSQ5ByAxGzEIOSAtFjkPFTkVMRYHICAWFRUPIAckCBYHFhYPFQoVFRUVJA8iLiEhBzElICEQISUWBysg + JQcgJAcPFiQGFSQkFRUhIDExDxYPJCUlIDEkMRUWIDEQESARECAgMQYVLRARKxYrFiQkDyAQJSsxJCQG + OSQWMSAgJQsgKw8tKxYWJCQPBgsPFRUKFRUVFRUVFRUVFQokJDkGFTkWIActIAcWJCAgLQgVFRUWDy0W + FiAHBzkVFTkWIAcVFTkxByArDzEgDyQGGhUkFS0VJBUVFSQPEBIeHiElIDEgMQgkIBYHMQ8WDyAgIAc5 + FRUPBxAgFiQkICAgDxYtFQ8VFQ85CxU5FSQkFSQVFSQkDwcPFiAhORY5LSAgFjkIOQgtJCQPFS0VFTkW + ESYvESAgIBAQECAgICAlByAhECAlMQgkJBU5DxUVISAgJCQkKyUgIAcWJA8PKxslCSUxKyAQJRwrFRYx + JRAgEAcxICURIBwgETEgKzEVDyAiEAcxByAkFhYxDw8VKy0kFRUVDyQkJA8kFSQVJBUVJBUVFQ8rDyQW + DxY5ICAWFiQKJCQtMQcWIDkgJBUkJCQPByArFRUkDzEgGxYtJDkkLSQVFSQkKxsrGxYxGiUgECEdISEg + Bw8rBxYMIAcrLRYtKw8KMSQtKyAlMQ8PKy0kFTkkJCQ5FRUkBiQWFSQVFTkVDxUPKzE5FjEgECAxBysH + LSskFRUVKxU5JA8rLRYVJBsWFiAlICUxICAgIA8kIDElIBAgICUgFjkWBzkWICAlJQIlBzEgDDEPFisl + ByAHMTEgDyARJRAHIBsWFhAlISURKyAgDw8HISUlIA8kKxshETEHIBAlICQWFiQ5FSQVFS0kFRUVFSQk + FRUkFRUVJBUVCiQVDy0kFjkgIBAgIDkkFTkWByAgICUgOQgtJSUbKy4HLRYgKyAWKw8kFQ8kKxYgJBUt + JA8VCysgIBsPOQgSIiYiIi8gLi4rICAgByAWDw8kOSQPByAQESAWLSAVFRUVFRUPDyQVFSQxIBUVFRUV + JCQxFS0PIC4xESAHIS0gIAcgDxUkFRUtBwsbJCsbJA8rIA8rJCAkBzEIKxUrICQIICsHLhEWMSAgICQx + BysgMSAgMRElICsgIDkgECEQIBwgDwUlERAhISEQIDkgICAWICAgIDExMRYPIAgxKyAMISAPDyAhECAg + DzkVFSQVFRUVFS0VFRUVJBUPFRUkFSQ5FSQVFRUrCDEWICAgESsrDxYPDzEgBw8gDxYVFRsHMSAWIDEg + ICAgByAHMQ8kFQ8bKw8gJCQPJAYgESEkChUKFTEiHiIwMwcDECAWICEWOQ8xJAoVJCAgICAhLzEkJBUk + LRYtOSQrLQ8xGxUkFRUPJDEkDyQPBysyMjEgDxU5FSQrLSQVOSQVOSQkFhYIKyAMBhUkLQ8kDyAHKyAg + ICAFJSAPFiAgJQ8LLSQVFRUPBxYgICAlICUgICUgJRAQJS4QFiQkICQgMSArBw8xFhsHIBoPJTEgIC0G + OQ8VFRUkByAkJCQPFg8IFiQGFSQVLSQkFiQkJCs5JBUkOSQtJBsxFRYtCiQ5Dy4xFiQPMSAGDzkPKwgW + JCAkFSQVJCUPJAgHFSAWIBUxJSQVOQcrMTExJRElJCArJBYuISEWFRUVJAoVERISEQwVKw8WEBAkMQck + BhUKFQ8rBxAQMhAkFSQPKw8rCBYbDysgIDkkBg85FiAgKy0kKyAgIQgHORUkJBUVDyskBg8kDyQVDyAx + JSARIDEWFSQVJBUkFQ8VECAhMSQWKwcxOQ8rDxUVFSQVJCsbIDEgIBElECAIOQcgDwYkDyQVFRUVFRUV + By0rDzEVKw8xDyAgICArDxUVJCQkICAHFRUVFQotFS0VJBUtJA8PLQ8PMQ8VFRUkDw8WCyQgES0GKy0V + FSQPJAcxMQcxOQ8WGzEkIA8VLQ8kJSAkFisxDzEkBi0WIBsVJBYgICEQESUgIBAQIRAhISErDzkVLSs5 + FRUVFSQVGyA5IDEkFQgxFiQkORUVDzkVOQgkORYrLRYgJRAxJSAPGxUVFTkkDyQPIBYrDzEPLSAkFSQk + FhYtLTEPLSQkFSQVFSsQLhslFiAgICAGJBUVFRUkLRYWMQYWIC0rBxYxICAkFRUVFRUPKw8gByUgETEV + FRUkLRUVFSQkJCsPOQ8bFRUVFRYPIBYWFRUQJTEPLRUVFSQkMSsPOSQkJAoVChUKFRUGDzErFhoxJCQk + FSQPJAs5DxYtGhYrDw8rMQ8WOQcgORYxIA8xByAxDzkkJBYkMS0WJA8GJC0VCyQWLRYkJCQWMSUcJRAR + JSAlECAQECElBw8IICAHHCEkCiQ5GyQgJRAgBzkWJCAPFRUPORUPFRUVOQ8PDw8rIDEPMQ81KxYkFSQV + FiQkFSstDzEPKyAWJDkPIBEyEREgDxYVJBUVFSQxLiYhIBEhIDEWJCQVFTkxIBYrJCQHJCAHBxYcIRAr + FhYxDxYPFi0PKwgkICsVCiQkFRUKJBUVFRUVFRUrFjEWDyUPMSAgFg8xJRYgIBYxGyQVFg8xDyAVOSQV + ChUKFSQVORYkLQgtFRUkFRUVFSQkDyQPFg8POSsxFi0HORYkCw8PDxUkFRUPJBUVJAY5FRYIKwYrDzkr + IC0xJAglICUkGwcgEAcxMQcxICAuIBAgIC0kKysgFhUVCiQVChUKFQ8tJA8kDw8xKy0VFQ8rGxYVChUk + JQgxICAVDyQxJAggJCstFSQPFjEgIBYkDxU5FQ8kChUhIiI6NyE5Dw8VFSQVLRYgIBAxJRElICQPLQYW + IBA5ICAgICUHJCQcEBAyGyAgJQ8xJC0kFSQHMQcVFRUVCjkVDxUVFQotJCslDwcgICsgKxYHKyArDyUR + ECAuBxUxDyQxFhYVJBUVChUkFRUVDxUkDwoVFQYVDxUVFSQVDyQxFjEgKw8IJDEHJAYVIBY5FRUPORUP + JBUVKy0kBg8WMSQWIBYPCCQHKw8rICAgICUlEC0rDyQgIBYrIRAWLSsVOQcuIDEkChUVChUVFSQKJCAk + JSArJCArIDEgIBY5FSQkLSsxCCUHFjEGKwcxBy0HJA8xKzEbJRwWIBYPFRUtJCQkOQcHEBIOHyIxMQYW + LQ8tICUgICAQICA5KysxFRUVDxUQMQc5FQ8WIBAgJSACFjElICAWDzEgIBAgLSQKFRUVORYrFjEkKwcg + MRYWFjEHMQcgIActFg8bJSAhFjEVKwcgFhYgJBUVFSQVDyQkFRUkFSQVJBUVJBUVFTkVJCQPDxYgDwY5 + CxYHORUVFSQGJBUxByAgKyA5Dw8VJBY5ByQgFiAWMRUWICAgIC0HOQ8WCCUbMS0VFjEHGxUtFhUkFQgg + ICURDxUKFSQ5FRYkFSQKDzEgICAPICAWLRYkJDEIFiQGFiQPJCArLQ85FiArICsgIBEhICAkIDkxJCQW + FSQVFRUkORUVDxAeHh0hICsWJRElGyUgICARMgggOQ8VFSQkDxYkFSQ5JCAWOQ85FQYVFQYkJAcgDR4v + Ey4gKw8rFQ8gICArBw8rByAlMQ8gICsgKzExJAcrFiAgFiAHFgglMQYWJCAxORUkDyQWDzEkDyQVChUV + ORU5FRUGJCQVJAcgLSsWJA85FRUVOSstFSsgKyQWICAPKw8kIBYtFhYWICUgIDEgICsWMiQxFgwgMSA5 + DyQWMQcPJCQVJBUVFS0kFiEkORUVFRUVFRUkIC0VFRUKDxUIFRYgIAcxDzExFiA5JDkgBxYgDw8rDwcx + ICAgIBAgFyEgMRYRMSAWOSQtDxUVFRUVFRUVCBAeMC4gLjEuLyERJRAgJSAgFhUVKyAgFjErGyQVFQ8P + OSQVFRUVFRUkJDkkFRslDjAeMyAlIBYWKyUQICARJSAlECAlCwcHICAHJBYtFiAxFiAWJCAxICAgKzEW + IAcHFiAlDxYIFhUVFSQVFRUVFSQtKxUVJBUtFjEPBjkPFSQVJAckFhUWDyAPFRUtFiAgJSAtFhUxOSAg + IAsWDyQgIAcQGxYtDyAkJA8xJDEWICsIMSQVJBUkFjEPIBYVJDkVFSQrDzErKxskJBUVFTkgICUHICAk + CCUkIBYQIBEHORYkOSQWGyARMTEgIBElJBshMRUVDxYPFRU5FRUKFTkrLSQWERIfHx4fKSIzIREgJQcx + JCQPJC0gESAkIBYkBiQkMQ8VFRUVFTkPDyQGFSQ5CBASMA4dISAgESAHIRchMiAQEBAQIDElMSAWIBYI + JQ8gFg8VJBUWGyUxDDEWJCQrLTECMSAWDzEkOSQGJBUkFRUVFRUkFRUVJBUPMSQWKw8rMSUkDyAWLSsH + Ky0VFS0WLQcQJRYtDwsxFiQxICElICAgKxYgMQsrBxEgBzEgICsHMQ8VJCsWMQcuICQ5Dy0WLQctDyQH + IDEHIC4rICQVFQcxBxUVFTEPFiAkJSAxFQ8xLRYgLQ8gIBEgIDEtDyQKJBsVFSsgHCAVFQgxMSQkDyAP + ORUkFRUkCxATEi4hIRAgIBYPMRYVJDEHMQckFSQ5JCQVJDkkLSQVJDE5Fg8VFSQkMREzHx8iIRAlIRMh + IiAQEDElESUgFiAHKyArIC4gIDExLSQtGiAgIBYkCCUgMRYxJSAxMSsVDw8kMRUVDxUPORUVFSQkJBUk + FSAHIA8WIBYtFRYPKyAgMQ8rDxYkDysgMSAgKxYkJA8tByAdISElICAgFhYWGyAgICsHFhUVDysgFhYP + LSExIBYkFRUVDysVJCQPMRYHMiAhIDEgICQPOQ8KJDkVMSQgICArLSsPKwcxFRUkFRUVOQ8kFSQ5FRUg + OQogMQcWLRUVFRYbFiAxChUKFQoVFRUVFhAhESAhICEgJC0kJCQPMSAtFS0kDw8PCCQVJAEtDwYxFiQt + FRUkBg8rETAeHyovIRAlEBITICUHICAgICArMQ8HJRElECAgJCQbICAgFjEPGiAkLSQgICAhMi0PDysg + KwctKw85FQokJA8PFRUVFRUrDxYVFiQVJA8rFhYRLSsPMREgIA8VICAQEBExLRYVFSsWEBAhECsLMSAx + IBAgDyUxMSAxMRYgICsbKxYgByQtFQoKJBUPLSsGMQYxKy4WICAhMjElByQVJA8IFgcgLRAgIBYkDyAx + IDEVFTkkFRUVFRUVChUkFSAgIBYgMQ8rFRUVJAcxFRUkFQokFQoVFTkPECAgBzEkMRYkFSQPIDEPMSQk + MSsPOSQkFRU5IDErCDEgMSsgFRY5ByQxEBIeHzAhEBYVJAcHICAlJAcxIBYrICAHICAlMSAWKyAxIDEV + JCAkFiQkByAlEQcgKzkPICAVJA8VFRUVFQcgKw8VFRUVFSstICQPJC0gICAxFiQVByISLjErBwcxByEH + ICsPFSQVOQ8gKwcgECAlIAcrIDEIICUREDEuETEtFiAcFiQkFRUVJCQVFRUPDw8kKxsxBw8rIAcgICQV + JBsxFisgDyU5ByQkFiAvLyErLRUVFTktFhUVJBUkJCQ5LSQ5ByAWLS0gDyQkLSQkFSQkJBU5FRUVFQ8V + FSAkDxU5FQ8xCDExDysPIAcPORUKFRUkFQ8QJCAHFgcHOQ8VDxYtIAcgHSIfMC8PIBYtKwsPOQ8xICUV + DyAHKzErDxUgMSAgESUQMSAlIDEgKw8PFiQPIAcPKyArIBUVORUVFSQkJRExFiA5BjktECUgJSEhISUg + IA8WDyAQICAWGzEgJC0gBzEGMSAPFg8VOSAHJSAQJSAQIBUxFiAPICUgDC0HLRYkFjkkDxUVFRUkJCQV + FSsbKyQWFSQxByQtBjkkBiQyMSAIMTEgITEgLREhIhAxICAPKy0WDzkkFRUVJCQVDzEkJCAkFSQkKyAW + LhUVJA8xFg8kFRUkFSQVFjkkDyAWJCA5FiEWFg8tFhUkJBUkFQoVFRUtDxYgMSAgFhYgFi0rDyQHGxYu + ER4eIhAxICAkFSQPMSAgIDEQJRsHJBYWDyURICARJRElICUhDy0rORUkBiQxLS0PLQ8VFSQ5DyQVDxUV + IC0gFg8WESIiEyYSJhIQETEWMRAgJBUtFiAWICQkFjkgKxYaJREWDwotJCAhIRAQICAlGysxFiAPLQ8W + JBUPMSQPGhUVLQ8xORUPICAbBwcxFRUVOS0kJBUKChUWBzEgKw8WBw8VIBASKw8kByQWIS0HJBUVKw8P + JCQkJCQgICQVORUHIC0PICAkJBUkJCAxCxskJCQtJBEgFSstFi0WBw85FRUPDwYtOSQkFTkVJCQVKxYg + JQcrIDEgIDElFjEtKw8kJSAgEikfLyYgMSAVJAchGyUgICAlICAgKyAtDxElIDElEBAgECUgDyQVFRU5 + FSQGFSQVORUVBiQkFis5JDkGJDErICYTIh4wIiElKyAxICAgJSArFSQWIAYHJSAlICAgIBYrMSAkFRUH + ICAQECAgFhsgByQkFRYPOSQkOQYxJBsgGysPDzEkKwcxIDkxByQPOQYVChUVJBUkJCAQEC4HOS0kFSQ5 + JC05FRUVOQ8VORYkJC0WOSQPFRUVORUVFSQVJBUkFSQVFQ8kCCUgIC0rMQ8gBzEPJCQWICAkJBUWLRUt + MSQkORUIJQ8PFRUVDw8bMSAgIA8gIDEPICAgFhYkDw8PIA8uJh4qHiIhFhYgDxUgByArIBYlMSAHKxYk + LSAgDyAQEBAhECUPFhYkFRUKJDkVFSQPJCskFQcgBiQkFSQIIBEQIAURJQ8VFQclERYgECElDw8WDxUP + MQ8gEBAlMSAxIAcxFjEPKwcgIBAlJAcrFjExFRUxMQcVFRUgJBYkFQgWBisPIA8WORUVJCQkJBUVFRUV + ChUVByQPCDERJRYtFRUVKxYVBzktJAYVDw8PLRUkDw8VORU5FRUVCjkPJC0WFSAxFjkVJBUPICQWLTEg + KzEkKwggECAWIBY5Dy0rByQPJBUkFSQtJBUkJDkPGgcxICsPGg8WFiAgCxY5DxYkJBUtKyAQDiofOCAx + ICskKyAQICAgIAcWDzEgDysHJDkaMSAQISEhICEhIBYVJBUVJBUxJCUgJAcgDCQHMQ8PFjEhFiQVFQoV + JCQ5Dy0cECEPICAhLiAxFiQVFTERICAxBzExIBYbIS4uIRAHIDEIMSAgICAgETIPJBUPORYGFSAkFjkx + ByArLRUVFRUkJCskFRU5FSQkKyAVORUVFQoVFRUtICAgLSQPFiAVJA8rCCQkFSsVChUPBiQVJBUkJAYr + DyAQDw8kJA8WISAxJBUVIA8VGyQPORUVOQ8kDxUPICAxFRUKFTkVJBUVFRUVDy0PMSAgFi0xFgcPMTEC + DxUxFiQVJBUbKxsSDh8gJQclGwcgFiARAiAWIBYGJBYgDw8kKwwRICEhISsgByExICAbFiAPBzEIFiAg + HC0WOQY5DxYRIRUVJBUkJBUVJBYrDBYVICAhISIiISAPChUVICEQIBYIJSAhEBAlBy0VORUxMhAhISAr + IBArDxU5FiAkLSQLFiAgIDEgIBYtJDkVJBUPDzkVFQ8WICAkDxUkFRUVJCQPJSEhHSEyEBA5JC0kLRUH + FiAbORUVJCQkChUKFRYxGzMtDzkGJBUkFRAcHBYPJBUVJCQGJBUVJBUGMRYkIBwhGyQVDxUVJBUkFRUV + JCQkFi0rCBoPFg8lIA8kFSQWMTIIFgYVDxYgAiAlICAQIBYkJSAgEDElIBY5FhYgEDExFiQPKzEIJCAg + BxUWBwcgJRExDyskKw8QIREHJBUVFjEhDxUVFRUVJCQVFQ8PIAcgITMiHh4iHg43MCEVFRUQLyIvICUx + CCsbJBUkFQYkIBEHMQYVDyA5DzkWDyQkFRYVOSAgMSAWJA8kFRUVFRUrBjkkFTExICAxIDEVFTkVFTkr + IDkIFSQgIREgIAcrICsgMSEvIRYkFTkVFRUkJC0kICsgFhYrLSQkJDkVJiAkGys5JBY5JCQWMTkWOQc5 + DyArICQkOSQ5FRU5FTkkFTkVORUxBzkVOQcxICArFjkrIBEgKzEkLRU5DzExICsgIRErLSAgKyAgICAr + ICAxBTkPCDkWMRUVFSQVOSAkICQxKy05CCsHLQcgLyUrJCQkKyAgFQo5FRUkJCQkFSQrFisgKxEgEAcQ + IBAJEhIiLy0WCCIhEhMcFhUVFRUkFQo5FSQ5DyQVORYkFQoVKyAVMRUxICAWMQcxJC0VFTkVDy0PIBUk + FS0PCCUgISEQDyQVFS0HDw8VFRUVJCAuICEgCA8gICEiIQcgGw8VFQoVCi0PDw8PDw8PIAcPDxUVBhwg + LRUkDw8gFRUbICEtDyQVJCQPICAtDxUkFRU5DyQPBg8VFRUPDw8VDyQPIA8IICAPDy0PDxUPDxUVJBUV + DxAPIBAWDw8PByAgIC4gIA8gBzEkBhUKFRUPLRUVFRUVDw8PFQ8PFRUkDxAhISEbDw8kDw8IDxUkFRUV + JBUVFQokDw8bDw8VFQoVChUKFRUEBxAiHDIQEh0SIQ8bIC0VFRUPDxUkFSQgLg8PLQokDzEtGwYtDw8g + IQcPDw8VFRUPDw== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAJpJREFUOE+lU4EN + wCAIm/8fzcRZrKxuJi4hcUpL0VIu/dlivyz2Y9uBZqbDz3pIngBSIgATsSJpYADrov6+I85H7pAOAgdy + YiZGi6wiqgOMO1BEnAMSSdAq9eCqvwTcCt9DvE5vkVp7niwq8lqo+FWQ5WbANsF0+91YULn1EuxI9ocC + uxmOjRQkLD1bOvlDz8PJMDHjNERfU3gDvwxpp71FEQgAAAAASUVORK5CYII= + + + \ No newline at end of file diff --git a/Code/Chapter 29/Buttons/MainForm.vb b/Code/Chapter 29/Buttons/MainForm.vb new file mode 100644 index 0000000..8d8563d --- /dev/null +++ b/Code/Chapter 29/Buttons/MainForm.vb @@ -0,0 +1,34 @@ +Option Explicit On +Option Strict On + +Public Class MainForm + ' Hold the current text alignment + Private currAlignment As ContentAlignment = ContentAlignment.MiddleCenter + Private currEnumPos As Integer = 0 + + Private Sub btnStandard_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles btnStandard.Click + ' Get all possible values + ' of the ContentAlignment enum. + Dim values As Array = [Enum].GetValues(currAlignment.GetType()) + + ' Bump the current position in the enum. + ' & check for wrap around. + currEnumPos += 1 + If currEnumPos >= values.Length Then + currEnumPos = 0 + End If + + ' Bump the current enum value. + currAlignment = CType([Enum].Parse(currAlignment.GetType(), _ + values.GetValue(currEnumPos).ToString()), ContentAlignment) + btnStandard.TextAlign = currAlignment + + ' Paint enum value name on button. + btnStandard.Text = currAlignment.ToString() + + ' Now assign the location of the icon on + ' btnImage... + btnImage.ImageAlign = currAlignment + End Sub +End Class diff --git a/Code/Chapter 29/Buttons/My Project/Application.Designer.vb b/Code/Chapter 29/Buttons/My Project/Application.Designer.vb new file mode 100644 index 0000000..319ce3c --- /dev/null +++ b/Code/Chapter 29/Buttons/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.Buttons.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 29/Buttons/My Project/Application.myapp b/Code/Chapter 29/Buttons/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 29/Buttons/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 29/Buttons/My Project/AssemblyInfo.vb b/Code/Chapter 29/Buttons/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..5eb4f15 --- /dev/null +++ b/Code/Chapter 29/Buttons/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/Code/Chapter 29/Buttons/My Project/Resources.Designer.vb b/Code/Chapter 29/Buttons/My Project/Resources.Designer.vb new file mode 100644 index 0000000..d2372bd --- /dev/null +++ b/Code/Chapter 29/Buttons/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("Buttons.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/Code/Chapter 29/Buttons/My Project/Resources.resx b/Code/Chapter 29/Buttons/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 29/Buttons/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/Code/Chapter 29/Buttons/My Project/Settings.Designer.vb b/Code/Chapter 29/Buttons/My Project/Settings.Designer.vb new file mode 100644 index 0000000..48d8fc7 --- /dev/null +++ b/Code/Chapter 29/Buttons/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.Buttons.My.MySettings + Get + Return Global.Buttons.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 29/Buttons/My Project/Settings.settings b/Code/Chapter 29/Buttons/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 29/Buttons/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 29/CarConfig/CarConfig.sln b/Code/Chapter 29/CarConfig/CarConfig.sln new file mode 100644 index 0000000..a3d90c3 --- /dev/null +++ b/Code/Chapter 29/CarConfig/CarConfig.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CarConfig", "CarConfig.vbproj", "{74D47550-418A-4B12-9CEF-034D51FA834B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {74D47550-418A-4B12-9CEF-034D51FA834B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {74D47550-418A-4B12-9CEF-034D51FA834B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {74D47550-418A-4B12-9CEF-034D51FA834B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {74D47550-418A-4B12-9CEF-034D51FA834B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 29/CarConfig/CarConfig.suo b/Code/Chapter 29/CarConfig/CarConfig.suo new file mode 100644 index 0000000..e290f2b Binary files /dev/null and b/Code/Chapter 29/CarConfig/CarConfig.suo differ diff --git a/Code/Chapter 29/CarConfig/CarConfig.vbproj b/Code/Chapter 29/CarConfig/CarConfig.vbproj new file mode 100644 index 0000000..f03fd1e --- /dev/null +++ b/Code/Chapter 29/CarConfig/CarConfig.vbproj @@ -0,0 +1,111 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {74D47550-418A-4B12-9CEF-034D51FA834B} + WinExe + CarConfig.My.MyApplication + CarConfig + CarConfig + WindowsForms + + + 2.0 + + + + + true + full + true + true + bin\Debug\ + CarConfig.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + CarConfig.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + MainForm.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/Code/Chapter 29/CarConfig/CarConfig.vbproj.user b/Code/Chapter 29/CarConfig/CarConfig.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 29/CarConfig/CarConfig.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 29/CarConfig/MainForm.Designer.vb b/Code/Chapter 29/CarConfig/MainForm.Designer.vb new file mode 100644 index 0000000..0d0f1d5 --- /dev/null +++ b/Code/Chapter 29/CarConfig/MainForm.Designer.vb @@ -0,0 +1,257 @@ + _ +Partial Class MainForm + 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.label4 = New System.Windows.Forms.Label + Me.label2 = New System.Windows.Forms.Label + Me.radioPink = New System.Windows.Forms.RadioButton + Me.radioYellow = New System.Windows.Forms.RadioButton + Me.radioRed = New System.Windows.Forms.RadioButton + Me.radioGreen = New System.Windows.Forms.RadioButton + Me.infoLabel = New System.Windows.Forms.Label + Me.checkedBoxRadioOptions = New System.Windows.Forms.CheckedListBox + Me.btnOrder = New System.Windows.Forms.Button + Me.checkFloorMats = New System.Windows.Forms.CheckBox + Me.groupBoxColor = New System.Windows.Forms.GroupBox + Me.label3 = New System.Windows.Forms.Label + Me.carMakeList = New System.Windows.Forms.ListBox + Me.label5 = New System.Windows.Forms.Label + Me.monthCalendar = New System.Windows.Forms.MonthCalendar + Me.label1 = New System.Windows.Forms.Label + Me.comboSalesPerson = New System.Windows.Forms.ComboBox + Me.calendarTip = New System.Windows.Forms.ToolTip(Me.components) + Me.groupBoxColor.SuspendLayout() + Me.SuspendLayout() + ' + 'label4 + ' + Me.label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Bold) + Me.label4.Location = New System.Drawing.Point(9, 197) + Me.label4.Name = "label4" + Me.label4.Size = New System.Drawing.Size(208, 24) + Me.label4.TabIndex = 24 + Me.label4.Text = "Order Stats:" + ' + 'label2 + ' + Me.label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Bold) + Me.label2.Location = New System.Drawing.Point(157, 15) + Me.label2.Name = "label2" + Me.label2.Size = New System.Drawing.Size(144, 16) + Me.label2.TabIndex = 21 + Me.label2.Text = "Radio Options:" + ' + 'radioPink + ' + Me.radioPink.BackColor = System.Drawing.SystemColors.ControlLight + Me.radioPink.Location = New System.Drawing.Point(176, 24) + Me.radioPink.Name = "radioPink" + Me.radioPink.Size = New System.Drawing.Size(56, 23) + Me.radioPink.TabIndex = 3 + Me.radioPink.Text = "Pink" + Me.radioPink.UseVisualStyleBackColor = False + ' + 'radioYellow + ' + Me.radioYellow.BackColor = System.Drawing.SystemColors.ControlLight + Me.radioYellow.Location = New System.Drawing.Point(96, 24) + Me.radioYellow.Name = "radioYellow" + Me.radioYellow.Size = New System.Drawing.Size(56, 23) + Me.radioYellow.TabIndex = 1 + Me.radioYellow.Text = "Yellow" + Me.radioYellow.UseVisualStyleBackColor = False + ' + 'radioRed + ' + Me.radioRed.BackColor = System.Drawing.SystemColors.ControlLight + Me.radioRed.Location = New System.Drawing.Point(264, 24) + Me.radioRed.Name = "radioRed" + Me.radioRed.Size = New System.Drawing.Size(64, 23) + Me.radioRed.TabIndex = 2 + Me.radioRed.Text = "Red" + Me.radioRed.UseVisualStyleBackColor = False + ' + 'radioGreen + ' + Me.radioGreen.BackColor = System.Drawing.SystemColors.ControlLight + Me.radioGreen.Location = New System.Drawing.Point(16, 24) + Me.radioGreen.Name = "radioGreen" + Me.radioGreen.Size = New System.Drawing.Size(64, 23) + Me.radioGreen.TabIndex = 0 + Me.radioGreen.Text = "Green" + Me.radioGreen.UseVisualStyleBackColor = False + ' + 'infoLabel + ' + Me.infoLabel.BackColor = System.Drawing.Color.OldLace + Me.infoLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle + Me.infoLabel.Font = New System.Drawing.Font("Arial", 8.0!) + Me.infoLabel.Location = New System.Drawing.Point(10, 229) + Me.infoLabel.Name = "infoLabel" + Me.infoLabel.Size = New System.Drawing.Size(224, 200) + Me.infoLabel.TabIndex = 18 + ' + 'checkedBoxRadioOptions + ' + Me.checkedBoxRadioOptions.CheckOnClick = True + Me.checkedBoxRadioOptions.Cursor = System.Windows.Forms.Cursors.Hand + Me.checkedBoxRadioOptions.FormattingEnabled = True + Me.checkedBoxRadioOptions.Items.AddRange(New Object() {"Front Speakers", "8-Track Tape Player", "CD Player", "Cassette Player", "Rear Speakers", "Ultra Base Thumper"}) + Me.checkedBoxRadioOptions.Location = New System.Drawing.Point(159, 42) + Me.checkedBoxRadioOptions.Name = "checkedBoxRadioOptions" + Me.checkedBoxRadioOptions.Size = New System.Drawing.Size(157, 49) + Me.checkedBoxRadioOptions.TabIndex = 15 + ' + 'btnOrder + ' + Me.btnOrder.Location = New System.Drawing.Point(267, 407) + Me.btnOrder.Name = "btnOrder" + Me.btnOrder.Size = New System.Drawing.Size(120, 22) + Me.btnOrder.TabIndex = 19 + Me.btnOrder.Text = "Confirm Order" + ' + 'checkFloorMats + ' + Me.checkFloorMats.FlatStyle = System.Windows.Forms.FlatStyle.Popup + Me.checkFloorMats.Location = New System.Drawing.Point(10, 11) + Me.checkFloorMats.Name = "checkFloorMats" + Me.checkFloorMats.Size = New System.Drawing.Size(112, 24) + Me.checkFloorMats.TabIndex = 13 + Me.checkFloorMats.Text = "Extra Floor Mats" + ' + 'groupBoxColor + ' + Me.groupBoxColor.Controls.Add(Me.radioPink) + Me.groupBoxColor.Controls.Add(Me.radioYellow) + Me.groupBoxColor.Controls.Add(Me.radioRed) + Me.groupBoxColor.Controls.Add(Me.radioGreen) + Me.groupBoxColor.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.groupBoxColor.Location = New System.Drawing.Point(10, 116) + Me.groupBoxColor.Name = "groupBoxColor" + Me.groupBoxColor.Size = New System.Drawing.Size(435, 56) + Me.groupBoxColor.TabIndex = 17 + Me.groupBoxColor.TabStop = False + Me.groupBoxColor.Text = "Exterior Color" + ' + 'label3 + ' + Me.label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Bold) + Me.label3.Location = New System.Drawing.Point(333, 18) + Me.label3.Name = "label3" + Me.label3.Size = New System.Drawing.Size(112, 16) + Me.label3.TabIndex = 22 + Me.label3.Text = "Make:" + ' + 'carMakeList + ' + Me.carMakeList.FormattingEnabled = True + Me.carMakeList.Items.AddRange(New Object() {"BMW", "Caravan", "Ford", "Grand Am", "Jeep", "Jetta", "Saab", "Viper", "Yugo"}) + Me.carMakeList.Location = New System.Drawing.Point(333, 42) + Me.carMakeList.Name = "carMakeList" + Me.carMakeList.ScrollAlwaysVisible = True + Me.carMakeList.Size = New System.Drawing.Size(112, 56) + Me.carMakeList.Sorted = True + Me.carMakeList.TabIndex = 16 + ' + 'label5 + ' + Me.label5.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Bold) + Me.label5.Location = New System.Drawing.Point(265, 197) + Me.label5.Name = "label5" + Me.label5.Size = New System.Drawing.Size(184, 16) + Me.label5.TabIndex = 25 + Me.label5.Text = "Delivery Date:" + ' + 'monthCalendar + ' + Me.monthCalendar.Location = New System.Drawing.Point(267, 229) + Me.monthCalendar.Name = "monthCalendar" + Me.monthCalendar.TabIndex = 23 + Me.calendarTip.SetToolTip(Me.monthCalendar, "When do you want your car?") + ' + 'label1 + ' + Me.label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.label1.Location = New System.Drawing.Point(10, 52) + Me.label1.Name = "label1" + Me.label1.Size = New System.Drawing.Size(112, 24) + Me.label1.TabIndex = 20 + Me.label1.Text = "Sales Person" + ' + 'comboSalesPerson + ' + Me.comboSalesPerson.FormattingEnabled = True + Me.comboSalesPerson.Items.AddRange(New Object() {"Baby Ry-Ry", "Dan 'the Machine'", "Cowboy Dan", "Tom 'the Style' "}) + Me.comboSalesPerson.Location = New System.Drawing.Point(10, 76) + Me.comboSalesPerson.Name = "comboSalesPerson" + Me.comboSalesPerson.Size = New System.Drawing.Size(128, 21) + Me.comboSalesPerson.TabIndex = 14 + ' + 'calendarTip + ' + Me.calendarTip.IsBalloon = True + Me.calendarTip.ShowAlways = True + Me.calendarTip.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info + ' + 'z + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(517, 454) + Me.Controls.Add(Me.label5) + Me.Controls.Add(Me.label4) + Me.Controls.Add(Me.monthCalendar) + Me.Controls.Add(Me.label3) + Me.Controls.Add(Me.label2) + Me.Controls.Add(Me.label1) + Me.Controls.Add(Me.comboSalesPerson) + Me.Controls.Add(Me.carMakeList) + Me.Controls.Add(Me.infoLabel) + Me.Controls.Add(Me.checkedBoxRadioOptions) + Me.Controls.Add(Me.btnOrder) + Me.Controls.Add(Me.checkFloorMats) + Me.Controls.Add(Me.groupBoxColor) + Me.Name = "z" + Me.Text = "Buy a new car!" + Me.groupBoxColor.ResumeLayout(False) + Me.ResumeLayout(False) + + End Sub + Protected WithEvents label4 As System.Windows.Forms.Label + Protected WithEvents label2 As System.Windows.Forms.Label + Protected WithEvents radioPink As System.Windows.Forms.RadioButton + Protected WithEvents radioYellow As System.Windows.Forms.RadioButton + Protected WithEvents radioRed As System.Windows.Forms.RadioButton + Protected WithEvents radioGreen As System.Windows.Forms.RadioButton + Protected WithEvents infoLabel As System.Windows.Forms.Label + Protected WithEvents checkedBoxRadioOptions As System.Windows.Forms.CheckedListBox + Protected WithEvents btnOrder As System.Windows.Forms.Button + Protected WithEvents checkFloorMats As System.Windows.Forms.CheckBox + Protected WithEvents groupBoxColor As System.Windows.Forms.GroupBox + Protected WithEvents label3 As System.Windows.Forms.Label + Protected WithEvents carMakeList As System.Windows.Forms.ListBox + Protected WithEvents label5 As System.Windows.Forms.Label + Protected WithEvents monthCalendar As System.Windows.Forms.MonthCalendar + Protected WithEvents label1 As System.Windows.Forms.Label + Protected WithEvents comboSalesPerson As System.Windows.Forms.ComboBox + Private WithEvents calendarTip As System.Windows.Forms.ToolTip + +End Class diff --git a/Code/Chapter 29/CarConfig/MainForm.resx b/Code/Chapter 29/CarConfig/MainForm.resx new file mode 100644 index 0000000..77f2b25 --- /dev/null +++ b/Code/Chapter 29/CarConfig/MainForm.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/Code/Chapter 29/CarConfig/MainForm.vb b/Code/Chapter 29/CarConfig/MainForm.vb new file mode 100644 index 0000000..a0067cb --- /dev/null +++ b/Code/Chapter 29/CarConfig/MainForm.vb @@ -0,0 +1,84 @@ +Option Explicit On +Option Strict On + +Public Class MainForm + + Sub New() + ' This call is required by the Windows Form Designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call. + CenterToScreen() + End Sub + +#Region "Button Click logic" + Private Sub btnOrder_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles btnOrder.Click + ' Build a string to display information. + Dim orderInfo As String = "" + If comboSalesPerson.Text <> "" Then + orderInfo &= "Sales Person: " + comboSalesPerson.Text & Chr(10) + Else + orderInfo &= "You did not select a sales person!" & "" & Chr(10) + End If + If carMakeList.SelectedItem IsNot Nothing Then + orderInfo &= "Make: " & carMakeList.SelectedItem.ToString() & "" & Chr(10) + End If + If checkFloorMats.Checked Then + orderInfo &= "You want floor mats." & Chr(10) + End If + If radioRed.Checked Then + orderInfo &= "You want a red exterior." & Chr(10) + End If + If radioYellow.Checked Then + orderInfo &= "You want a yellow exterior." & Chr(10) + End If + If radioGreen.Checked Then + orderInfo &= "You want a green exterior." & Chr(10) + End If + If radioPink.Checked Then + orderInfo &= "Why do you want a PINK exterior?" & Chr(10) + End If + + orderInfo += "--------------------------------" & Chr(10) + For i As Integer = 0 To checkedBoxRadioOptions.Items.Count - 1 + ' For each item in the CheckedListBox... + ' Is the current item checked? + If checkedBoxRadioOptions.GetItemChecked(i) Then + ' Get text of current item. + orderInfo &= "Radio Item: " + orderInfo &= checkedBoxRadioOptions.Items(i).ToString() + orderInfo &= "" & Chr(10) & "" + End If + Next + orderInfo += "--------------------------------" & Chr(10) + + ' Get ship date. + Dim startD As DateTime = monthCalendar.SelectionStart + Dim endD As DateTime = monthCalendar.SelectionEnd + + ' Get correct string representation. + ' + Dim dateStartStr As String = startD.Date.ToShortDateString() + Dim dateEndStr As String = endD.Date.ToShortDateString() + If dateStartStr <> dateEndStr Then + orderInfo &= "Car will be sent between" & Chr(10) & dateStartStr & " and" & Chr(10) & dateEndStr + Else + orderInfo &= "Car will be sent on" & Chr(10) + dateStartStr + ' they picked a single date. + End If + ' Set order info. + infoLabel.Text = orderInfo + End Sub +#End Region + + Private Sub groupBoxColor_Enter(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles groupBoxColor.Enter + groupBoxColor.Text = "Exterior Color: You are in the group..." + End Sub + + Private Sub groupBoxColor_Leave(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles groupBoxColor.Leave + groupBoxColor.Text = "Exterior Color: Thanks for visiting the group..." + End Sub +End Class diff --git a/Code/Chapter 29/CarConfig/My Project/Application.Designer.vb b/Code/Chapter 29/CarConfig/My Project/Application.Designer.vb new file mode 100644 index 0000000..aa324ac --- /dev/null +++ b/Code/Chapter 29/CarConfig/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CarConfig.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 29/CarConfig/My Project/Application.myapp b/Code/Chapter 29/CarConfig/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 29/CarConfig/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 29/CarConfig/My Project/AssemblyInfo.vb b/Code/Chapter 29/CarConfig/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..9c27fa7 --- /dev/null +++ b/Code/Chapter 29/CarConfig/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/Code/Chapter 29/CarConfig/My Project/Resources.Designer.vb b/Code/Chapter 29/CarConfig/My Project/Resources.Designer.vb new file mode 100644 index 0000000..a2c8a3b --- /dev/null +++ b/Code/Chapter 29/CarConfig/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("CarConfig.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/Code/Chapter 29/CarConfig/My Project/Resources.resx b/Code/Chapter 29/CarConfig/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 29/CarConfig/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/Code/Chapter 29/CarConfig/My Project/Settings.Designer.vb b/Code/Chapter 29/CarConfig/My Project/Settings.Designer.vb new file mode 100644 index 0000000..954e7e1 --- /dev/null +++ b/Code/Chapter 29/CarConfig/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CarConfig.My.MySettings + Get + Return Global.CarConfig.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 29/CarConfig/My Project/Settings.settings b/Code/Chapter 29/CarConfig/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 29/CarConfig/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 29/CarConfig/UpgradeLog.XML b/Code/Chapter 29/CarConfig/UpgradeLog.XML new file mode 100644 index 0000000..c1c9945 --- /dev/null +++ b/Code/Chapter 29/CarConfig/UpgradeLog.XML @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 29/CarControlLibrary/AboutToBlow.bmp b/Code/Chapter 29/CarControlLibrary/AboutToBlow.bmp new file mode 100644 index 0000000..f9da539 Binary files /dev/null and b/Code/Chapter 29/CarControlLibrary/AboutToBlow.bmp differ diff --git a/Code/Chapter 29/CarControlLibrary/CarControl.Designer.vb b/Code/Chapter 29/CarControlLibrary/CarControl.Designer.vb new file mode 100644 index 0000000..bbbfd03 --- /dev/null +++ b/Code/Chapter 29/CarControlLibrary/CarControl.Designer.vb @@ -0,0 +1,67 @@ + _ +Partial Class CarControl + Inherits System.Windows.Forms.UserControl + + 'UserControl1 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(CarControl)) + Me.currentImage = New System.Windows.Forms.PictureBox + Me.imageTimer = New System.Windows.Forms.Timer(Me.components) + Me.carImages = New System.Windows.Forms.ImageList(Me.components) + CType(Me.currentImage, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'currentImage + ' + Me.currentImage.Location = New System.Drawing.Point(25, 50) + Me.currentImage.Name = "currentImage" + Me.currentImage.Size = New System.Drawing.Size(100, 50) + Me.currentImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage + Me.currentImage.TabIndex = 1 + Me.currentImage.TabStop = False + ' + 'imageTimer + ' + Me.imageTimer.Interval = 200 + ' + 'carImages + ' + Me.carImages.ImageStream = CType(resources.GetObject("carImages.ImageStream"), System.Windows.Forms.ImageListStreamer) + Me.carImages.TransparentColor = System.Drawing.Color.Transparent + Me.carImages.Images.SetKeyName(0, "Lemon1.bmp") + Me.carImages.Images.SetKeyName(1, "Lemon2.bmp") + Me.carImages.Images.SetKeyName(2, "Lemon3.bmp") + Me.carImages.Images.SetKeyName(3, "AboutToBlow.bmp") + Me.carImages.Images.SetKeyName(4, "EngineBlown.bmp") + ' + 'CarControl + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.Controls.Add(Me.currentImage) + Me.Name = "CarControl" + CType(Me.currentImage, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + + End Sub + Private WithEvents currentImage As System.Windows.Forms.PictureBox + Private WithEvents imageTimer As System.Windows.Forms.Timer + Private WithEvents carImages As System.Windows.Forms.ImageList + +End Class diff --git a/Code/Chapter 29/CarControlLibrary/CarControl.bmp b/Code/Chapter 29/CarControlLibrary/CarControl.bmp new file mode 100644 index 0000000..c25da69 Binary files /dev/null and b/Code/Chapter 29/CarControlLibrary/CarControl.bmp differ diff --git a/Code/Chapter 29/CarControlLibrary/CarControl.resx b/Code/Chapter 29/CarControlLibrary/CarControl.resx new file mode 100644 index 0000000..c5b4cc1 --- /dev/null +++ b/Code/Chapter 29/CarControlLibrary/CarControl.resx @@ -0,0 +1,253 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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, 13 + + + 127, 13 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w + LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 + ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD8 + GwAAAk1TRnQBSQFMAgEBBQEAAQkBAAEEAQABLwEAAS8BAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + AwABvAMAAV4DAAEBAQABCAUAAQgBRRgAAYACAAGAAwACgAEAAYADAAGAAQABgAEAAoACAAPAAQABwAHc + AcABAAHwAcoBpgEAATMFAAEzAQABMwEAATMBAAIzAgADFgEAAxwBAAMiAQADKQEAA1UBAANNAQADQgEA + AzkBAAGAAXwB/wEAAlAB/wEAAZMBAAHWAQAB/wHsAcwBAAHGAdYB7wEAAdYC5wEAAZABqQGtAgAB/wEz + AwABZgMAAZkDAAHMAgABMwMAAjMCAAEzAWYCAAEzAZkCAAEzAcwCAAEzAf8CAAFmAwABZgEzAgACZgIA + AWYBmQIAAWYBzAIAAWYB/wIAAZkDAAGZATMCAAGZAWYCAAKZAgABmQHMAgABmQH/AgABzAMAAcwBMwIA + AcwBZgIAAcwBmQIAAswCAAHMAf8CAAH/AWYCAAH/AZkCAAH/AcwBAAEzAf8CAAH/AQABMwEAATMBAAFm + AQABMwEAAZkBAAEzAQABzAEAATMBAAH/AQAB/wEzAgADMwEAAjMBZgEAAjMBmQEAAjMBzAEAAjMB/wEA + ATMBZgIAATMBZgEzAQABMwJmAQABMwFmAZkBAAEzAWYBzAEAATMBZgH/AQABMwGZAgABMwGZATMBAAEz + AZkBZgEAATMCmQEAATMBmQHMAQABMwGZAf8BAAEzAcwCAAEzAcwBMwEAATMBzAFmAQABMwHMAZkBAAEz + AswBAAEzAcwB/wEAATMB/wEzAQABMwH/AWYBAAEzAf8BmQEAATMB/wHMAQABMwL/AQABZgMAAWYBAAEz + AQABZgEAAWYBAAFmAQABmQEAAWYBAAHMAQABZgEAAf8BAAFmATMCAAFmAjMBAAFmATMBZgEAAWYBMwGZ + AQABZgEzAcwBAAFmATMB/wEAAmYCAAJmATMBAANmAQACZgGZAQACZgHMAQABZgGZAgABZgGZATMBAAFm + AZkBZgEAAWYCmQEAAWYBmQHMAQABZgGZAf8BAAFmAcwCAAFmAcwBMwEAAWYBzAGZAQABZgLMAQABZgHM + Af8BAAFmAf8CAAFmAf8BMwEAAWYB/wGZAQABZgH/AcwBAAHMAQAB/wEAAf8BAAHMAQACmQIAAZkBMwGZ + AQABmQEAAZkBAAGZAQABzAEAAZkDAAGZAjMBAAGZAQABZgEAAZkBMwHMAQABmQEAAf8BAAGZAWYCAAGZ + AWYBMwEAAZkBMwFmAQABmQFmAZkBAAGZAWYBzAEAAZkBMwH/AQACmQEzAQACmQFmAQADmQEAApkBzAEA + ApkB/wEAAZkBzAIAAZkBzAEzAQABZgHMAWYBAAGZAcwBmQEAAZkCzAEAAZkBzAH/AQABmQH/AgABmQH/ + ATMBAAGZAcwBZgEAAZkB/wGZAQABmQH/AcwBAAGZAv8BAAHMAwABmQEAATMBAAHMAQABZgEAAcwBAAGZ + AQABzAEAAcwBAAGZATMCAAHMAjMBAAHMATMBZgEAAcwBMwGZAQABzAEzAcwBAAHMATMB/wEAAcwBZgIA + AcwBZgEzAQABmQJmAQABzAFmAZkBAAHMAWYBzAEAAZkBZgH/AQABzAGZAgABzAGZATMBAAHMAZkBZgEA + AcwCmQEAAcwBmQHMAQABzAGZAf8BAALMAgACzAEzAQACzAFmAQACzAGZAQADzAEAAswB/wEAAcwB/wIA + AcwB/wEzAQABmQH/AWYBAAHMAf8BmQEAAcwB/wHMAQABzAL/AQABzAEAATMBAAH/AQABZgEAAf8BAAGZ + AQABzAEzAgAB/wIzAQAB/wEzAWYBAAH/ATMBmQEAAf8BMwHMAQAB/wEzAf8BAAH/AWYCAAH/AWYBMwEA + AcwCZgEAAf8BZgGZAQAB/wFmAcwBAAHMAWYB/wEAAf8BmQIAAf8BmQEzAQAB/wGZAWYBAAH/ApkBAAH/ + AZkBzAEAAf8BmQH/AQAB/wHMAgAB/wHMATMBAAH/AcwBZgEAAf8BzAGZAQAB/wLMAQAB/wHMAf8BAAL/ + ATMBAAHMAf8BZgEAAv8BmQEAAv8BzAEAAmYB/wEAAWYB/wFmAQABZgL/AQAB/wJmAQAB/wFmAf8BAAL/ + AWYBAAEhAQABpQEAA18BAAN3AQADhgEAA5YBAAPLAQADsgEAA9cBAAPdAQAD4wEAA+oBAAPxAQAD+AEA + AfAB+wH/AQABpAKgAQADgAMAAf8CAAH/AwAC/wEAAf8DAAH/AQAB/wEAAv8CAAP/AQAv7I0AL+yNAC/s + jQAv7I0AL+yNAC/sjQAG7AHtAewEbQHrAu0Q7ALtAewEbQHsAe0H7I0ABQcBvAHwAe8EAAFDAvAQBwLw + ARQEAAHvAfABvAYHjQAEBwG8Ae8IAAEVArwMBwK8ARQIAAHvAbwFB40ABAcB8wQAAQ4BEQQAARIB8wwH + AfIB6gQAAREBQwEOAwAB8QUHjQADBwG8Ae8DAAEOAW0B8AERAwABFQK8CgcCvAEUAwABEQG8Af8BbQEO + AgAB7wG8BAeNAAMHAfMDAAEOAW0C/wHwAUMDAAESAfMKBwHyAW0DAAERAbwD/wFtAQ4CAAHyBAeNAAMH + AfMDAAEQBP8BBwMAARIB8woHAfIBbQMAAe8F/wERAgAB8gQHjQADBwHzAwABDwEHAv8B8wHsAwABEgHz + CgcB8gFtAwAB7AHzA/8BBwEPAgAB8gQHjQADBwHyARMDAAEPAQcB8wHsBAABFQGSCuwBkgEUBAAB7AHz + Af8BBwEQAgABFAHxBAeNAAIHAZMBBwGUAQsBAAELAQABEAHsGAAB7AH3ARADAAHxBQeNAAEHAW8B+QEH + AvkBAQEgBgABDwFKDikBSgEQCAABEwHwBQeNAAFvARcB+QEHARcD+QEeAwABDwFtAXMB5Q77AeUBcwFt + AQ8EAAETAW0B8AYHjQABFwEHARcCbwL5ARcBbwNtAewBoAHlEPsB5QGgAXMEbQG8AfIHB40AAQcCbwEX + A/kBkwEbA6AB5RT7AeUDoAEbCQeNAAEHARcB+QFvAvkBFwEyAXkc+wJ5CAeNAAIHAW8BFwH5AW8BeQz7 + ATgCMgE4EPsBeQcHjQAEBwFvAQcBeQv7ATgEJgIyATgN+wFYBweNAAcHAnkJ+wEyAfkBLAEyA/kBMgv7 + AVgBeQgHjQADBwFvAQcBbwMHAnkG+wE4AiYBMgEmA/kBJgE4CfsBWAMHAW8GB40AAwcB+QEXAfkBBwEX + AW8BBwGZBvsBOAEsByYBOAn7AZkBBwFvAe8BbwYHjQADBwFvAfkBbwEXAfkBRwIHAXkG+wE4ATIBLAQm + ATIH+wEwATcBeQEHAm8BFwHvAW8BFwQHjQABBwMXAW8BFwP5AW8CBwJ5BfsBOAImASwB+QEmATgF+wEw + ASkBDgFzAW0B9wFHApMBBwJvBAeNAAEHAW8C+QEXA/kBbwGTBAcBeQT7ATgCMgEsATIBOAb7ASkCAAFD + AQ4B7QFHAZMBBwFvARcBBwEXAweNAAIHAW8B+QFvAfkBbwGTBwcCeQFYA/sCOAX7AVgBeQFRASICAAHq + ARAB7QJHAe8BkwH5Ae8B+QMHjQADBwH5AQcB+QIXCQcBmQp5AZkBBwEUAwABEQFtARIBIAFvAgcCRwFv + AweNAAMHAZMBBwH5ApMVBwJtAREBAAHqARABEQEOAW4BBwEXAUcBbwGTBAeNAAUHAZMXBwGSAe8BFAHq + ARIB6wEQAQAB7QEHAZMB+QGTBQeNAB4HAW0BDgEQAQ4BEAEOAQABEQH3AQcBkwYHjQABBwJHBAcB7wFH + ARcBkwFHARcBBwGTAUcBbw0HAfcBQwYAARABQwHwAvMEB40AAQcC+QMHAe8CRwKTAfkBRwEHAZMB+QEX + DgcB9wHtAREGAAHxAv8C9AIHjQABBwL5AwcBkwH5AUcBBwGTAfkBRwEHAZMB+QEXEAcBFQYAAfEE/wH0 + AQeNAAEHAvkDBwGTAfkBRwEHAZMB+QFHAQcBkwH5ARcQBwEVBgAB8QETAfMC/wG8AQeNAAEHAvkFRwGT + AQcBkwH5AUcBBwGTAvkERwFvCwcBFQYAARABAAEQAREDB40AAQcC+QSTAfkBRwEHAZMB+QFHAQcBkwH5 + AUcDkwFvAfkBbwoHAe8B9wERBgAB7QEOAe8CB40AAQcC+QMHAZMB+QFHAQcBkwH5AUcBBwGTAfkBFwMH + AW8B+QFvDAcB7wEQBAAB7QERAQABDgIHjQABBwL5AwcBkwH5AUcBBwGTAfkBRwEHAZMB+QEXAwcBbwH5 + AW8NBwHvARACAAHtAREDAAEOAQeNAAEHAvkDBwGTAfkBRwEHAZMB+QFHAQcBkwH5ARcDBwFvAfkBbwEH + AfEM/wHzAREBAAEOAZIB7wEOAQAB7wEHjQABBwb5AUcCBwGTAfkBRwEHAZMG+QHjEP8BQwEAAbwC/wEO + AQACB40AFAcB8BH/AfQBEQMOAfIDB40AGAcB8g//BweNAC8HjQD/7P/s/+z/7HLsAe0B7ARtAesC7RDs + Au0B7ARtAewB7Q3sAe0B7ARtAesC7RDsAu0B7ARtAewB7Q3sAe0B7ARtAesC7RDsAu0B7ARtAewB7Q3s + Ae0B7ARtAesC7RDsAu0B7ARtAewB7QfsBQcBvAHwAe8EAAFDAvAQBwLwARQEAAHvAfABvAsHAbwB8AHv + BAABQwLwEAcC8AEUBAAB7wHwAbwLBwG8AfAB7wQAAUMC8BAHAvABFAQAAe8B8AG8CwcBvAHwAe8EAAFD + AvAQBwLwARQEAAHvAfABvAoHAbwB7wgAARUCvAwHArwBFAgAAe8BvAkHAbwB7wgAARUCvAwHArwBFAgA + Ae8BvAkHAbwB7wgAARUCvAwHArwBFAgAAe8BvAkHAbwB7wgAARUCvAwHArwBFAgAAe8BvAkHAfMEAAEO + AREEAAESAfMMBwHyAeoEAAERAUMBDgMAAfEJBwHzBAABDgERBAABEgHzDAcB8gHqBAABEQFDAQ4DAAHx + CQcB8wQAAQ4BEQQAARIB8wwHAfIB6gQAAREBQwEOAwAB8QkHAfMEAAEOAREEAAESAfMMBwHyAeoEAAER + AUMBDgMAAfEIBwG8Ae8DAAEOAW0B8AERAwABFQK8CgcCvAEUAwABEQG8Af8BbQEOAgAB7wG8BwcBvAHv + AwABDgFtAfABEQMAARUCvAoHArwBFAMAAREBvAH/AW0BDgIAAe8BvAcHAbwB7wMAAQ4BbQHwAREDAAEV + ArwKBwK8ARQDAAERAbwB/wFtAQ4CAAHvAbwHBwG8Ae8DAAEOAW0B8AERAwABFQK8CgcCvAEUAwABEQG8 + Af8BbQEOAgAB7wG8BwcB8wMAAQ4BbQL/AfABQwMAARIB8woHAfIBbQMAAREBvAP/AW0BDgIAAfIHBwHz + AwABDgFtAv8B8AFDAwABEgHzCgcB8gFtAwABEQG8A/8BbQEOAgAB8gcHAfMDAAEOAW0C/wHwAUMDAAES + AfMKBwHyAW0DAAERAbwD/wFtAQ4CAAHyBwcB8wMAAQ4BbQL/AfABQwMAARIB8woHAfIBbQMAAREBvAP/ + AW0BDgIAAfIHBwHzAwABEAT/AQcDAAESAfMKBwHyAW0DAAHvBf8BEQIAAfIHBwHzAwABEAT/AQcDAAES + AfMKBwHyAW0DAAHvBf8BEQIAAfIHBwHzAwABEAT/AQcDAAESAfMKBwHyAW0DAAHvBf8BEQIAAfIHBwHz + AwABEAT/AQcDAAESAfMKBwHyAW0DAAHvBf8BEQIAAfIHBwHzAwABDwEHAv8B8wHsAwABEgHzCgcB8gFt + AwAB7AHzA/8BBwEPAgAB8gcHAfMDAAEPAQcC/wHzAewDAAESAfMKBwHyAW0DAAHsAfMD/wEHAQ8CAAHy + BwcB8wMAAQ8BBwL/AfMB7AMAARIB8woHAfIBbQMAAewB8wP/AQcBDwIAAfIHBwHzAwABDwEHAv8B8wHs + AwABEgHzCgcB8gFtAwAB7AHzA/8BBwEPAgAB8gcHAfIBEwMAAQ8BBwHzAewEAAEVAZIK7AGSARQEAAHs + AfMB/wEHARACAAEUAfEHBwHyARMDAAEPAQcB8wHsBAABFQGSCuwBkgEUBAAB7AHzAf8BBwEQAgABFAHx + BwcB8gETAwABDwEHAfMB7AQAARUBkgrsAZIBFAQAAewB8wH/AQcBEAIAARQB8QcHAfIBEwMAAQ8BBwHz + AewEAAEVAZIK7AGSARQEAAHsAfMB/wEHARACAAEUAfEIBwHzBAABEAHsGAAB7AH3ARADAAHxCQcB8wQA + ARAB7BgAAewB9wEQAwAB8QkHAfMEAAEQAewYAAHsAfcBEAMAAfEJBwHzBAABEAHsGAAB7AH3ARADAAHx + CQcB8QESCAABDwESDikBEgEQCAABEwHwCQcB8QESCAABDwFKDikBSgEQCAABEwHwCQcB8QESCAABDwFK + DikBSgEQCAABEwHwCQcB8QESCAABDwFKDikBSgEQCAABEwHwCgcB8QFtARIEAAEPAW0B7AGgDl4BoAFz + AW0BDwQAARMBbQHwCwcB8QFtARIEAAEPAW0BcwHlDvsB5QFzAW0BDwQAARMBbQHwCwcB8QFtARIEAAEP + AW0BcwHlDvsB5QFzAW0BDwQAARMBbQHwCwcB8QFtARIEAAEPAW0BcwHlDvsB5QFzAW0BDwQAARMBbQHw + DAcB8gHwBG0B7AKgEF4CoAHsBG0BvAHyDQcB8gHwBG0B7AGgAeUQ+wHlAaABcwRtAbwB8g0HAfIB8ARt + AewBoAHlEPsB5QGgAXMEbQG8AfINBwHyAfAEbQHsAaAB5RD7AeUBoAFzBG0BvAHyDwcBGwSgFF4EoAEb + EQcBGwOgAeUU+wHlA6ABGxEHARsDoAHlFPsB5QOgARsRBwEbA6AB5RT7AeUDoAEbDgcB7wHrAZkBeRxe + AXkBmQ0HAW0B6wJ5HPsCeQ8HAnkc+wJ5DwcCeRz7AnkMBwFtAeoBDgIDAVEdXgF5CQcCbQHqAQABIgH7 + AQMBMB37AXkNBwF5IPsBeQwHAe8B6yD7AXkKBwHvAQABDgESAQABDgEDAVEcXgF5CQcCAAESAQABDgEp + AQABIh37AVgNBwF5ATAf+wFYDAcBEgEOAQMBMB77ATAB6gHvCAcB7wEAAQ4BEgEAAQ4BAwFRGl4CeQoH + AgABEgQAAQ4BMBr7AVgBeQ0HA+oBMBz7AVgBeQkHAeoBbwFtAe8DAAEOAQMBMBn7ATACAwEOARIB6gHv + BgcB6gESAgABDgHqAQ4BbQFRGV4BeQwHAQABbQUAAQ4Bcxn7AVgOBwESAQ4BbQETAQ8BeQEwGfsBWAoH + AW8BbQEBAQABbwMAAQ4BbQFzGfsBIgESAQ4BAAETAQ4B7wYHAW0BAAFtAQABDgETAQ4BFAEiGV4BmQwH + AW0BEgQAAQ4B7AGZGfsBmQ0HARIBAAEOARMBDgFtARQBIhn7AZkKBwEBAW8CAAH5AwABDgISATAW+wEw + AQMBDgEUAW0BDgIAAe8HBwEOAe8BAAEOAeoCAAERAXkXXgF5DQcBEgFtAQABDgFtAQABEAIHAXkX+wF5 + DQcBEwQAAQ4BFAEOAW0BAxf7AXkLBwEAAW8CAAEeBQABDwFzFvsBNwEiAQACEgEOAQABbQHvBwcB7AHv + AQABDgESAusB7AEHAZkBeRJeAXkCmQ4HAesBBwFtAQ4BEgHrAewDBwJ5EvsBWAJ5DgcHAAEOARIB7AJ5 + EvsBWAJ5DAcB6wETAW0EAAEfAW0BAAERAQcCeQz7ATACKQE3ATABNwFYAnkB7AEPAe0BEAIAAfcKBwHr + AW0BDwYHAXkQXgF5AZkTBwHrAewHBwF5EPsBWAGZDwcBEwHrBwABEQMHAXkQ+wFYAZkOBwETAesBFwEf + AQABAQEAAR4BRAEfAewDBwF5C/sBAwIAAiIBUQGZAwcBEQHtARACAAH3CwcB7wHsBwcCmQF5Cl4BeQOZ + DwcCFAETDAcCeQFYCvsBWAJ5AZkPBwEUAewBBwHsAesEAAEPAewEBwJ5AVgK+wFYAnkBmQ8HAQABFAIe + AekBbwEAAQ4B7AGTBQcCeQFYB/sBMAEiAgABEwIRAZIDBwHsAe8BEAFtAewB7xYHDJkSBwIAAewBEw0H + AZkKeQGZEgcB7AEHARQBBwEVAgABDgLsBwcBmQp5AZkSBwLsAQAB7AFvARMB6wHpARcBbwcHAZkGeQFR + ASIDAAERAQ8BAAERAZIEBwHsAe82BwIAAQcBDiwHARUB7AEVAgABDgHsAxUB6iMHARUBRwHpAQcB7wHp + AQcCkwJvDQcB6gEUARUBEwFDAQABEgERAQAB7DwHAgABQwEAARQqBwEVAewBBwEOAewCAAFDAQABDwFt + AREjBwHsApMBFwEHAfkBRwEXAZMBFwGTDQcB9wHqAW0B6gEOAQABEAFtAewB7zwHA+wBDgHtKgcB7AEH + ARUB7AFDAgABDgHrARABkgERJgcBkwEHAvkBkwEHAZMPBwHqAQ8BbQHsAUMBAAHsMwcB8gbzBQcBQwER + AQ4rBwJDAewBQwHsAwABFAHsARQBkhgHAfIG8wUHAUcDBwH5AZMSBwHqAQACbQEOAQABEAHtAwcB8gbz + JgcB8gH0B/8C9AMHAgAB7SsHAQAB7QERAQABEQQAARQBkhcHAfIB9Af/AfQEBwGTAwcBkwHvARcRBwHv + Ae0B7wETAeoBQwFtAe8BBwHyAfQH/wL0IwcB8gv/AfQBBwERApIsBwGSAREGAAEPAZIXBwHyCv8DBwFH + BQcBRwH5ARcTBwLvAfcB7wEHAfIL/wH0IgcBvAH0Cv8BvAEHAZIXBwHxB/QB8A4HARACAAEOApIB7AEA + ARAYBwG8AfQJ/wMHAZMCBwJHAe8B+QKTEQcBbQHsBQcBvAH0Cv8BvAYHBPQB8xgHArwB9Ab/ArwYBwHx + AfQJ/wH0AbwMBwL3AZIBDgEHAvQB8AHxAfMYBwK8AfQG/wG8AvQEBwGTAfkB9AG9AvQB8xAHAu8BbQHs + BAcCvAH0Bv8CvAUHAvQF/wH0AfMZBwa8GQcB8Q3/AbwLBwIPARAB8QH0Bf8B9AHzGQcGvAEHArwDBwFH + AfQBvQX/AfQB8xAHAu8HBwa8BwcI/wH0IwcC9BQHAfIL/wHwDAcBAALvCP8B9CUHAZMI/wH0JQcK/wHz + IgcC/wH0FQcB8gf/AfEOBwHvAQcK/wHzJAcK/wHzJQcI/wH0DAcB8Q//AbwGBwP/AfQCBw3/AfIeBwj/ + AfQMBwHxD/8BvAkHCP8B9AwHAfEP/wG8CQcI/wH0CQcB8RX/BAcD/wIHD/8B8h0HCP8B9AkHAfEV/wcH + CP8B9AkHAfEV/wkHBP8B9AoHAfEX/wMHAv8CBxH/AfIeBwT/AfQKBwHxF/8IBwT/AfQKBwHxF/8bBwHy + D/8BvAsHAbwN/wHyMwcB8g//AbweBwHyD/8BvMIHAUIBTQE+BwABPgMAASgDAAG8AwABXgMAAQEBAAEB + BQAB0AEIFgAD//8A/wD/AP8A/wD/AP8A/wDZAAs= + + + \ No newline at end of file diff --git a/Code/Chapter 29/CarControlLibrary/CarControl.vb b/Code/Chapter 29/CarControlLibrary/CarControl.vb new file mode 100644 index 0000000..389da19 --- /dev/null +++ b/Code/Chapter 29/CarControlLibrary/CarControl.vb @@ -0,0 +1,141 @@ +Option Explicit On +Option Strict On + +Imports System.ComponentModel + +' Helper enum for images. +Public Enum AnimFrames + Lemon1 + Lemon2 + Lemon3 + AboutToBlow + EngineBlown +End Enum + + _ +Public Class CarControl + + Sub New() + ' This call is required by the Windows Form Designer. + InitializeComponent() + StretchBox() + End Sub + + ' State data. + Private currFrame As AnimFrames = AnimFrames.Lemon1 + Private currMaxFrame As AnimFrames = AnimFrames.Lemon3 + Private IsAnim As Boolean + Private currSp As Integer = 50 + Private maxSp As Integer = 100 + Private carPetName As String = "Lemon" + Private bottomRect As Rectangle = New Rectangle() + + ' Car events. + _ + Public Event AboutToBlow(ByVal msg As String) + + _ + Public Event BlewUp(ByVal msg As String) + + Private Sub StretchBox() + ' Configure picture box. + currentImage.Top = 0 + currentImage.Left = 0 + currentImage.Height = Me.Height - 50 + currentImage.Width = Me.Width + currentImage.Image = carImages.Images(CType(AnimFrames.Lemon1, Integer)) + ' Figure out size of bottom rect. + bottomRect.X = 0 + bottomRect.Y = Me.Height - 50 + bottomRect.Height = Me.Height - currentImage.Height + bottomRect.Width = Me.Width + End Sub + +#Region "Properties" + ' Used to configure the internal Timer type. + _ + Public Property Animate() As Boolean + Get + Return IsAnim + End Get + Set(ByVal value As Boolean) + IsAnim = value + imageTimer.Enabled = IsAnim + End Set + End Property + + ' Configure pet name. + _ + Public Property PetName() As String + Get + Return carPetName + End Get + Set(ByVal value As String) + carPetName = value + Invalidate() + End Set + End Property + + ' Adjust currSp and currMaxFrame, and fire our events. + _ + Public Property Speed() As Integer + Get + Return currSp + End Get + Set(ByVal value As Integer) + ' Within safe speed? + If currSp <= maxSp Then + currSp = value + currMaxFrame = AnimFrames.Lemon3 + End If + ' About to explode? + If (maxSp - currSp) <= 10 Then + + RaiseEvent AboutToBlow("Slow down dude!") + currMaxFrame = AnimFrames.AboutToBlow + End If + ' Maxed out? + If currSp >= maxSp Then + currSp = maxSp + RaiseEvent BlewUp("Ug...you're toast...") + currMaxFrame = AnimFrames.EngineBlown + End If + End Set + End Property +#End Region + +#Region "Event handlers" + Private Sub imageTimer_Tick(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles imageTimer.Tick + If IsAnim Then + currentImage.Image = carImages.Images(CType(currFrame, Integer)) + End If + ' Bump frame. + Dim nextFrame As Integer = (CType(currFrame, Integer)) + 1 + currFrame = CType(nextFrame, AnimFrames) + If currFrame > currMaxFrame Then + currFrame = AnimFrames.Lemon1 + End If + End Sub + + Private Sub CarControl_Paint(ByVal sender As System.Object, _ + ByVal e As System.Windows.Forms.PaintEventArgs) _ + Handles MyBase.Paint + ' Render the pet name on the bottom of the control. + Dim g As Graphics = e.Graphics + g.FillRectangle(Brushes.GreenYellow, bottomRect) + g.DrawString(PetName, New Font("Times New Roman", 15), Brushes.Black, bottomRect) + End Sub +#End Region + +End Class diff --git a/Code/Chapter 29/CarControlLibrary/CarControlLibrary.sln b/Code/Chapter 29/CarControlLibrary/CarControlLibrary.sln new file mode 100644 index 0000000..c8de34d --- /dev/null +++ b/Code/Chapter 29/CarControlLibrary/CarControlLibrary.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CarControlLibrary", "CarControlLibrary.vbproj", "{F743E575-44C3-47F2-9F52-F0671227CD81}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F743E575-44C3-47F2-9F52-F0671227CD81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F743E575-44C3-47F2-9F52-F0671227CD81}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F743E575-44C3-47F2-9F52-F0671227CD81}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F743E575-44C3-47F2-9F52-F0671227CD81}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 29/CarControlLibrary/CarControlLibrary.suo b/Code/Chapter 29/CarControlLibrary/CarControlLibrary.suo new file mode 100644 index 0000000..dac00f8 Binary files /dev/null and b/Code/Chapter 29/CarControlLibrary/CarControlLibrary.suo differ diff --git a/Code/Chapter 29/CarControlLibrary/CarControlLibrary.vbproj b/Code/Chapter 29/CarControlLibrary/CarControlLibrary.vbproj new file mode 100644 index 0000000..b6e52fe --- /dev/null +++ b/Code/Chapter 29/CarControlLibrary/CarControlLibrary.vbproj @@ -0,0 +1,170 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {F743E575-44C3-47F2-9F52-F0671227CD81} + Library + CarControlLibrary + CarControlLibrary + Windows + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + CarControlLibrary.xml + _MYFORMS=True + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + CarControlLibrary.xml + _MYFORMS=True + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + UserControl + + + CarControl.vb + + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + CarControl.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 29/CarControlLibrary/CarControlLibrary.vbproj.user b/Code/Chapter 29/CarControlLibrary/CarControlLibrary.vbproj.user new file mode 100644 index 0000000..1659b79 --- /dev/null +++ b/Code/Chapter 29/CarControlLibrary/CarControlLibrary.vbproj.user @@ -0,0 +1,17 @@ + + + ShowAllFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 29/CarControlLibrary/EngineBlown.bmp b/Code/Chapter 29/CarControlLibrary/EngineBlown.bmp new file mode 100644 index 0000000..950b48f Binary files /dev/null and b/Code/Chapter 29/CarControlLibrary/EngineBlown.bmp differ diff --git a/Code/Chapter 29/CarControlLibrary/Lemon1.bmp b/Code/Chapter 29/CarControlLibrary/Lemon1.bmp new file mode 100644 index 0000000..1903d13 Binary files /dev/null and b/Code/Chapter 29/CarControlLibrary/Lemon1.bmp differ diff --git a/Code/Chapter 29/CarControlLibrary/Lemon2.bmp b/Code/Chapter 29/CarControlLibrary/Lemon2.bmp new file mode 100644 index 0000000..c37ecfa Binary files /dev/null and b/Code/Chapter 29/CarControlLibrary/Lemon2.bmp differ diff --git a/Code/Chapter 29/CarControlLibrary/Lemon3.bmp b/Code/Chapter 29/CarControlLibrary/Lemon3.bmp new file mode 100644 index 0000000..87c7dbd Binary files /dev/null and b/Code/Chapter 29/CarControlLibrary/Lemon3.bmp differ diff --git a/Code/Chapter 29/CarControlLibrary/My Project/Application.Designer.vb b/Code/Chapter 29/CarControlLibrary/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 29/CarControlLibrary/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 29/CarControlLibrary/My Project/Application.myapp b/Code/Chapter 29/CarControlLibrary/My Project/Application.myapp new file mode 100644 index 0000000..758895d --- /dev/null +++ b/Code/Chapter 29/CarControlLibrary/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/Code/Chapter 29/CarControlLibrary/My Project/AssemblyInfo.vb b/Code/Chapter 29/CarControlLibrary/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..ab1a21d --- /dev/null +++ b/Code/Chapter 29/CarControlLibrary/My Project/AssemblyInfo.vb @@ -0,0 +1,34 @@ +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/Code/Chapter 29/CarControlLibrary/My Project/Resources.Designer.vb b/Code/Chapter 29/CarControlLibrary/My Project/Resources.Designer.vb new file mode 100644 index 0000000..296aaa4 --- /dev/null +++ b/Code/Chapter 29/CarControlLibrary/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("CarControlLibrary.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/Code/Chapter 29/CarControlLibrary/My Project/Resources.resx b/Code/Chapter 29/CarControlLibrary/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 29/CarControlLibrary/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/Code/Chapter 29/CarControlLibrary/My Project/Settings.Designer.vb b/Code/Chapter 29/CarControlLibrary/My Project/Settings.Designer.vb new file mode 100644 index 0000000..b48486f --- /dev/null +++ b/Code/Chapter 29/CarControlLibrary/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CarControlLibrary.My.MySettings + Get + Return Global.CarControlLibrary.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 29/CarControlLibrary/My Project/Settings.settings b/Code/Chapter 29/CarControlLibrary/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 29/CarControlLibrary/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 29/CarControlTestForm/CarControlTestForm.sln b/Code/Chapter 29/CarControlTestForm/CarControlTestForm.sln new file mode 100644 index 0000000..83fe86a --- /dev/null +++ b/Code/Chapter 29/CarControlTestForm/CarControlTestForm.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CarControlTestForm", "CarControlTestForm.vbproj", "{2EB0CD99-5EFC-439B-B928-5A645159E26F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2EB0CD99-5EFC-439B-B928-5A645159E26F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2EB0CD99-5EFC-439B-B928-5A645159E26F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2EB0CD99-5EFC-439B-B928-5A645159E26F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2EB0CD99-5EFC-439B-B928-5A645159E26F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 29/CarControlTestForm/CarControlTestForm.suo b/Code/Chapter 29/CarControlTestForm/CarControlTestForm.suo new file mode 100644 index 0000000..76f079b Binary files /dev/null and b/Code/Chapter 29/CarControlTestForm/CarControlTestForm.suo differ diff --git a/Code/Chapter 29/CarControlTestForm/CarControlTestForm.vbproj b/Code/Chapter 29/CarControlTestForm/CarControlTestForm.vbproj new file mode 100644 index 0000000..b69e58f --- /dev/null +++ b/Code/Chapter 29/CarControlTestForm/CarControlTestForm.vbproj @@ -0,0 +1,152 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {2EB0CD99-5EFC-439B-B928-5A645159E26F} + WinExe + CarControlTestForm.My.MyApplication + CarControlTestForm + CarControlTestForm + WindowsForms + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + CarControlTestForm.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + CarControlTestForm.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + False + ..\CarControlLibrary\bin\Debug\CarControlLibrary.dll + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + MainForm.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 29/CarControlTestForm/CarControlTestForm.vbproj.user b/Code/Chapter 29/CarControlTestForm/CarControlTestForm.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 29/CarControlTestForm/CarControlTestForm.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 29/CarControlTestForm/MainForm.Designer.vb b/Code/Chapter 29/CarControlTestForm/MainForm.Designer.vb new file mode 100644 index 0000000..030d321 --- /dev/null +++ b/Code/Chapter 29/CarControlTestForm/MainForm.Designer.vb @@ -0,0 +1,100 @@ + _ +Partial Class MainForm + 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.numericUpDownCarSpeed = New System.Windows.Forms.NumericUpDown + Me.lblEventData = New System.Windows.Forms.Label + Me.lblCurrentSpeed = New System.Windows.Forms.Label + Me.myCarControl = New CarControlLibrary.CarControl + CType(Me.numericUpDownCarSpeed, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'label1 + ' + Me.label1.AutoSize = True + Me.label1.Location = New System.Drawing.Point(179, 90) + Me.label1.Name = "label1" + Me.label1.Size = New System.Drawing.Size(73, 13) + Me.label1.TabIndex = 9 + Me.label1.Text = "Speed +/- 10 " + ' + 'numericUpDownCarSpeed + ' + Me.numericUpDownCarSpeed.Increment = New Decimal(New Integer() {10, 0, 0, 0}) + Me.numericUpDownCarSpeed.Location = New System.Drawing.Point(180, 116) + Me.numericUpDownCarSpeed.Maximum = New Decimal(New Integer() {300, 0, 0, 0}) + Me.numericUpDownCarSpeed.Name = "numericUpDownCarSpeed" + Me.numericUpDownCarSpeed.Size = New System.Drawing.Size(120, 20) + Me.numericUpDownCarSpeed.TabIndex = 8 + ' + 'lblEventData + ' + Me.lblEventData.AutoSize = True + Me.lblEventData.Location = New System.Drawing.Point(179, 53) + Me.lblEventData.Name = "lblEventData" + Me.lblEventData.Size = New System.Drawing.Size(64, 13) + Me.lblEventData.TabIndex = 7 + Me.lblEventData.Text = "Event Data:" + ' + 'lblCurrentSpeed + ' + Me.lblCurrentSpeed.AutoSize = True + Me.lblCurrentSpeed.Location = New System.Drawing.Point(179, 25) + Me.lblCurrentSpeed.Name = "lblCurrentSpeed" + Me.lblCurrentSpeed.Size = New System.Drawing.Size(78, 13) + Me.lblCurrentSpeed.TabIndex = 6 + Me.lblCurrentSpeed.Text = "Current Speed:" + ' + 'myCarControl + ' + Me.myCarControl.Animate = False + Me.myCarControl.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D + Me.myCarControl.Location = New System.Drawing.Point(12, 12) + Me.myCarControl.Name = "myCarControl" + Me.myCarControl.PetName = "Lemon" + Me.myCarControl.Size = New System.Drawing.Size(150, 150) + Me.myCarControl.Speed = 50 + Me.myCarControl.TabIndex = 5 + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(337, 182) + Me.Controls.Add(Me.label1) + Me.Controls.Add(Me.numericUpDownCarSpeed) + Me.Controls.Add(Me.lblEventData) + Me.Controls.Add(Me.lblCurrentSpeed) + Me.Controls.Add(Me.myCarControl) + Me.Name = "MainForm" + Me.Text = "CarControl Tester" + CType(Me.numericUpDownCarSpeed, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Private WithEvents label1 As System.Windows.Forms.Label + Private WithEvents numericUpDownCarSpeed As System.Windows.Forms.NumericUpDown + Private WithEvents lblEventData As System.Windows.Forms.Label + Private WithEvents lblCurrentSpeed As System.Windows.Forms.Label + Private WithEvents myCarControl As CarControlLibrary.CarControl + +End Class diff --git a/Code/Chapter 29/CarControlTestForm/MainForm.resx b/Code/Chapter 29/CarControlTestForm/MainForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 29/CarControlTestForm/MainForm.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/Code/Chapter 29/CarControlTestForm/MainForm.vb b/Code/Chapter 29/CarControlTestForm/MainForm.vb new file mode 100644 index 0000000..aa63cf0 --- /dev/null +++ b/Code/Chapter 29/CarControlTestForm/MainForm.vb @@ -0,0 +1,31 @@ +Option Explicit On +Option Strict On + +Public Class MainForm + Sub New() + ' This call is required by the Windows Form Designer. + InitializeComponent() + CenterToScreen() + + lblCurrentSpeed.Text = String.Format("Current Speed: {0} ", Me.myCarControl.Speed.ToString()) + numericUpDownCarSpeed.Value = myCarControl.Speed + + ' Configure the car control. + myCarControl.Animate = True + myCarControl.PetName = "Zippy" + End Sub + Private Sub myCarControl_AboutToBlow(ByVal msg As System.String) Handles myCarControl.AboutToBlow + lblEventData.Text = String.Format("Event Data: {0} ", msg) + End Sub + + Private Sub myCarControl_BlewUp(ByVal msg As System.String) Handles myCarControl.BlewUp + lblEventData.Text = String.Format("Event Data: {0} ", msg) + End Sub + + Private Sub numericUpDownCarSpeed_ValueChanged(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles numericUpDownCarSpeed.ValueChanged + ' Assume the min of this NumericUpDown is 0 and max is 300. + Me.myCarControl.Speed = CType(numericUpDownCarSpeed.Value, Integer) + lblCurrentSpeed.Text = String.Format("Current Speed: {0} ", Me.myCarControl.Speed.ToString()) + End Sub +End Class diff --git a/Code/Chapter 29/CarControlTestForm/My Project/Application.Designer.vb b/Code/Chapter 29/CarControlTestForm/My Project/Application.Designer.vb new file mode 100644 index 0000000..f312584 --- /dev/null +++ b/Code/Chapter 29/CarControlTestForm/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CarControlTestForm.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 29/CarControlTestForm/My Project/Application.myapp b/Code/Chapter 29/CarControlTestForm/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 29/CarControlTestForm/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 29/CarControlTestForm/My Project/AssemblyInfo.vb b/Code/Chapter 29/CarControlTestForm/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..816af5a --- /dev/null +++ b/Code/Chapter 29/CarControlTestForm/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/Code/Chapter 29/CarControlTestForm/My Project/Resources.Designer.vb b/Code/Chapter 29/CarControlTestForm/My Project/Resources.Designer.vb new file mode 100644 index 0000000..1c9e825 --- /dev/null +++ b/Code/Chapter 29/CarControlTestForm/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("CarControlTestForm.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/Code/Chapter 29/CarControlTestForm/My Project/Resources.resx b/Code/Chapter 29/CarControlTestForm/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 29/CarControlTestForm/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/Code/Chapter 29/CarControlTestForm/My Project/Settings.Designer.vb b/Code/Chapter 29/CarControlTestForm/My Project/Settings.Designer.vb new file mode 100644 index 0000000..257600e --- /dev/null +++ b/Code/Chapter 29/CarControlTestForm/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CarControlTestForm.My.MySettings + Get + Return Global.CarControlTestForm.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 29/CarControlTestForm/My Project/Settings.settings b/Code/Chapter 29/CarControlTestForm/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 29/CarControlTestForm/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 29/ControlsByHand/ControlsByHand.vb b/Code/Chapter 29/ControlsByHand/ControlsByHand.vb new file mode 100644 index 0000000..fac3ee7 --- /dev/null +++ b/Code/Chapter 29/ControlsByHand/ControlsByHand.vb @@ -0,0 +1,62 @@ +Option Explicit On +Option Strict On + +Imports System.Windows.Forms +Imports System.Drawing + + Class MainWindow + Inherits Form + ' Form widget member variables. + Private firstNameBox As New TextBox() + Private WithEvents btnShowControls As New Button() + + Public Sub New() + ' Configure Form. + Me.Text = "Simple Controls" + Me.Width = 300 + Me.Height = 200 + CenterToScreen() + + ' Add a new textbox to the Form. + firstNameBox.Text = "Hello" + firstNameBox.Size = New Size(150, 50) + firstNameBox.Location = New Point(10, 10) + Me.Controls.Add(firstNameBox) + + ' Add a new button to the Form. + btnShowControls.Text = "Click Me" + btnShowControls.Size = New Size(90, 30) + btnShowControls.Location = New Point(10, 70) + btnShowControls.BackColor = Color.DodgerBlue + Me.Controls.Add(btnShowControls) + End Sub + + ' Handle Button's Click event. + Private Sub btnShowControls_Clicked(ByVal sender As Object, ByVal e As EventArgs) Handles btnShowControls.Click + ' Call ToString() on each control in the + ' Form's Controls collection + Dim ctrlInfo As String = "" + For Each c As Control In Me.Controls + ctrlInfo += String.Format("Control: {0}" & Chr(10), c.ToString()) + Next + MessageBox.Show(ctrlInfo, "Controls on Form") + + ' Uncomment to test. + ' DisableAllButtons() + End Sub + + ' This method disables all buttons on the Form. + Private Sub DisableAllButtons() + For Each c As Control In Me.Controls + If TypeOf c Is Button Then + CType(c, Button).Enabled = False + End If + Next + End Sub + End Class + + Class Program + Public Shared Sub Main(ByVal args As String()) + Application.Run(New MainWindow()) + End Sub + End Class \ No newline at end of file diff --git a/Code/Chapter 29/ExoticControls/CarNode.bmp b/Code/Chapter 29/ExoticControls/CarNode.bmp new file mode 100644 index 0000000..c25da69 Binary files /dev/null and b/Code/Chapter 29/ExoticControls/CarNode.bmp differ diff --git a/Code/Chapter 29/ExoticControls/ExoticControls.sln b/Code/Chapter 29/ExoticControls/ExoticControls.sln new file mode 100644 index 0000000..d5f20e2 --- /dev/null +++ b/Code/Chapter 29/ExoticControls/ExoticControls.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ExoticControls", "ExoticControls.vbproj", "{9CE71325-3D2D-485E-86A2-74F7FC4257D4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9CE71325-3D2D-485E-86A2-74F7FC4257D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9CE71325-3D2D-485E-86A2-74F7FC4257D4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9CE71325-3D2D-485E-86A2-74F7FC4257D4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9CE71325-3D2D-485E-86A2-74F7FC4257D4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 29/ExoticControls/ExoticControls.suo b/Code/Chapter 29/ExoticControls/ExoticControls.suo new file mode 100644 index 0000000..7d3de76 Binary files /dev/null and b/Code/Chapter 29/ExoticControls/ExoticControls.suo differ diff --git a/Code/Chapter 29/ExoticControls/ExoticControls.vbproj b/Code/Chapter 29/ExoticControls/ExoticControls.vbproj new file mode 100644 index 0000000..9a0b072 --- /dev/null +++ b/Code/Chapter 29/ExoticControls/ExoticControls.vbproj @@ -0,0 +1,158 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {9CE71325-3D2D-485E-86A2-74F7FC4257D4} + WinExe + ExoticControls.My.MyApplication + ExoticControls + ExoticControls + WindowsForms + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + ExoticControls.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + ExoticControls.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + + Designer + MainForm.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + Always + + + + Always + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 29/ExoticControls/ExoticControls.vbproj.user b/Code/Chapter 29/ExoticControls/ExoticControls.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 29/ExoticControls/ExoticControls.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 29/ExoticControls/MainForm.Designer.vb b/Code/Chapter 29/ExoticControls/MainForm.Designer.vb new file mode 100644 index 0000000..8af285c --- /dev/null +++ b/Code/Chapter 29/ExoticControls/MainForm.Designer.vb @@ -0,0 +1,515 @@ + _ +Partial Class MainForm + 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(MainForm)) + Me.txtInput = New System.Windows.Forms.TextBox + Me.lblErrorInstructions = New System.Windows.Forms.Label + Me.pageErrorProvider = New System.Windows.Forms.TabPage + Me.btnValidate = New System.Windows.Forms.Button + Me.btnGetSelections = New System.Windows.Forms.Button + Me.lblNumericUpDown = New System.Windows.Forms.Label + Me.lblDomainUpDown = New System.Windows.Forms.Label + Me.numericUpDown = New System.Windows.Forms.NumericUpDown + Me.domainUpDown = New System.Windows.Forms.DomainUpDown + Me.pageTreeView = New System.Windows.Forms.TabPage + Me.lblNodeInfo = New System.Windows.Forms.Label + Me.treeViewCars = New System.Windows.Forms.TreeView + Me.myWebBrowser = New System.Windows.Forms.WebBrowser + Me.txtUrl = New System.Windows.Forms.TextBox + Me.lblURL = New System.Windows.Forms.Label + Me.btnGO = New System.Windows.Forms.Button + Me.pageWebBrowser = New System.Windows.Forms.TabPage + Me.tabControlExoticControls = New System.Windows.Forms.TabControl + Me.pageTrackBars = New System.Windows.Forms.TabPage + Me.pagePanels = New System.Windows.Forms.TabPage + Me.panelTextBoxes = New System.Windows.Forms.Panel + Me.lblInstructions = New System.Windows.Forms.Label + Me.txtUpperText = New System.Windows.Forms.TextBox + Me.txtNormalText = New System.Windows.Forms.TextBox + Me.btnHidePanel = New System.Windows.Forms.Button + Me.btnShowPanel = New System.Windows.Forms.Button + Me.pageUpDown = New System.Windows.Forms.TabPage + Me.lblCurrSel = New System.Windows.Forms.Label + Me.lblCurrColor = New System.Windows.Forms.Label + Me.blueTrackBar = New System.Windows.Forms.TrackBar + Me.lblBlue = New System.Windows.Forms.Label + Me.lblGreen = New System.Windows.Forms.Label + Me.greenTrackBar = New System.Windows.Forms.TrackBar + Me.redTrackBar = New System.Windows.Forms.TrackBar + Me.lblRed = New System.Windows.Forms.Label + Me.colorBox = New System.Windows.Forms.PictureBox + Me.imageListTreeView = New System.Windows.Forms.ImageList(Me.components) + Me.tooManyCharactersErrorProvider = New System.Windows.Forms.ErrorProvider(Me.components) + Me.pageErrorProvider.SuspendLayout() + CType(Me.numericUpDown, System.ComponentModel.ISupportInitialize).BeginInit() + Me.pageTreeView.SuspendLayout() + Me.pageWebBrowser.SuspendLayout() + Me.tabControlExoticControls.SuspendLayout() + Me.pageTrackBars.SuspendLayout() + Me.pagePanels.SuspendLayout() + Me.panelTextBoxes.SuspendLayout() + Me.pageUpDown.SuspendLayout() + CType(Me.blueTrackBar, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.greenTrackBar, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.redTrackBar, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.colorBox, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.tooManyCharactersErrorProvider, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'txtInput + ' + Me.txtInput.Location = New System.Drawing.Point(196, 72) + Me.txtInput.Name = "txtInput" + Me.txtInput.Size = New System.Drawing.Size(181, 20) + Me.txtInput.TabIndex = 3 + ' + 'lblErrorInstructions + ' + Me.lblErrorInstructions.Font = New System.Drawing.Font("Arial Black", 12.0!) + Me.lblErrorInstructions.Location = New System.Drawing.Point(45, 8) + Me.lblErrorInstructions.Name = "lblErrorInstructions" + Me.lblErrorInstructions.Size = New System.Drawing.Size(376, 56) + Me.lblErrorInstructions.TabIndex = 2 + Me.lblErrorInstructions.Text = "The following text box only allows 5 characters. Try to enter more..." + ' + 'pageErrorProvider + ' + Me.pageErrorProvider.Controls.Add(Me.txtInput) + Me.pageErrorProvider.Controls.Add(Me.lblErrorInstructions) + Me.pageErrorProvider.Controls.Add(Me.btnValidate) + Me.pageErrorProvider.Location = New System.Drawing.Point(4, 22) + Me.pageErrorProvider.Name = "pageErrorProvider" + Me.pageErrorProvider.Padding = New System.Windows.Forms.Padding(3) + Me.pageErrorProvider.Size = New System.Drawing.Size(636, 341) + Me.pageErrorProvider.TabIndex = 3 + Me.pageErrorProvider.Text = "Error Provider" + ' + 'btnValidate + ' + Me.btnValidate.Location = New System.Drawing.Point(53, 72) + Me.btnValidate.Name = "btnValidate" + Me.btnValidate.Size = New System.Drawing.Size(112, 32) + Me.btnValidate.TabIndex = 1 + Me.btnValidate.Text = "OK" + ' + 'btnGetSelections + ' + Me.btnGetSelections.Location = New System.Drawing.Point(53, 136) + Me.btnGetSelections.Name = "btnGetSelections" + Me.btnGetSelections.Size = New System.Drawing.Size(136, 24) + Me.btnGetSelections.TabIndex = 4 + Me.btnGetSelections.Text = "Get Current Selections" + ' + 'lblNumericUpDown + ' + Me.lblNumericUpDown.Font = New System.Drawing.Font("Verdana", 12.0!) + Me.lblNumericUpDown.Location = New System.Drawing.Point(45, 80) + Me.lblNumericUpDown.Name = "lblNumericUpDown" + Me.lblNumericUpDown.Size = New System.Drawing.Size(221, 32) + Me.lblNumericUpDown.TabIndex = 3 + Me.lblNumericUpDown.Text = "Numeric UpDown Control" + ' + 'lblDomainUpDown + ' + Me.lblDomainUpDown.Font = New System.Drawing.Font("Verdana", 12.0!) + Me.lblDomainUpDown.Location = New System.Drawing.Point(45, 24) + Me.lblDomainUpDown.Name = "lblDomainUpDown" + Me.lblDomainUpDown.Size = New System.Drawing.Size(221, 32) + Me.lblDomainUpDown.TabIndex = 2 + Me.lblDomainUpDown.Text = "Domain UpDown Control" + ' + 'numericUpDown + ' + Me.numericUpDown.Location = New System.Drawing.Point(272, 80) + Me.numericUpDown.Maximum = New Decimal(New Integer() {5000, 0, 0, 0}) + Me.numericUpDown.Name = "numericUpDown" + Me.numericUpDown.Size = New System.Drawing.Size(168, 20) + Me.numericUpDown.TabIndex = 1 + Me.numericUpDown.ThousandsSeparator = True + Me.numericUpDown.UpDownAlign = System.Windows.Forms.LeftRightAlignment.Left + ' + 'domainUpDown + ' + Me.domainUpDown.Items.Add("Another Selection") + Me.domainUpDown.Items.Add("Final Selection") + Me.domainUpDown.Items.Add("Selection One") + Me.domainUpDown.Items.Add("Third Selection") + Me.domainUpDown.Location = New System.Drawing.Point(272, 24) + Me.domainUpDown.Name = "domainUpDown" + Me.domainUpDown.Size = New System.Drawing.Size(168, 20) + Me.domainUpDown.Sorted = True + Me.domainUpDown.TabIndex = 0 + Me.domainUpDown.Text = "Some Item" + Me.domainUpDown.Wrap = True + ' + 'pageTreeView + ' + Me.pageTreeView.Controls.Add(Me.lblNodeInfo) + Me.pageTreeView.Controls.Add(Me.treeViewCars) + Me.pageTreeView.Location = New System.Drawing.Point(4, 22) + Me.pageTreeView.Name = "pageTreeView" + Me.pageTreeView.Padding = New System.Windows.Forms.Padding(3) + Me.pageTreeView.Size = New System.Drawing.Size(636, 341) + Me.pageTreeView.TabIndex = 4 + Me.pageTreeView.Text = "Tree View" + ' + 'lblNodeInfo + ' + Me.lblNodeInfo.AutoSize = True + Me.lblNodeInfo.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle + Me.lblNodeInfo.Location = New System.Drawing.Point(267, 6) + Me.lblNodeInfo.Name = "lblNodeInfo" + Me.lblNodeInfo.Size = New System.Drawing.Size(78, 15) + Me.lblNodeInfo.TabIndex = 1 + Me.lblNodeInfo.Text = "Tree View Info" + ' + 'treeViewCars + ' + Me.treeViewCars.ImageIndex = 0 + Me.treeViewCars.ImageList = Me.imageListTreeView + Me.treeViewCars.Location = New System.Drawing.Point(43, 6) + Me.treeViewCars.Name = "treeViewCars" + Me.treeViewCars.SelectedImageIndex = 0 + Me.treeViewCars.Size = New System.Drawing.Size(206, 251) + Me.treeViewCars.TabIndex = 0 + ' + 'myWebBrowser + ' + Me.myWebBrowser.Location = New System.Drawing.Point(45, 37) + Me.myWebBrowser.Name = "myWebBrowser" + Me.myWebBrowser.Size = New System.Drawing.Size(585, 298) + Me.myWebBrowser.TabIndex = 4 + ' + 'txtUrl + ' + Me.txtUrl.Location = New System.Drawing.Point(148, 7) + Me.txtUrl.Name = "txtUrl" + Me.txtUrl.Size = New System.Drawing.Size(248, 20) + Me.txtUrl.TabIndex = 1 + Me.txtUrl.Text = "http://www.intertechtraining.com" + ' + 'lblURL + ' + Me.lblURL.AutoSize = True + Me.lblURL.Location = New System.Drawing.Point(44, 7) + Me.lblURL.Name = "lblURL" + Me.lblURL.Size = New System.Drawing.Size(101, 13) + Me.lblURL.TabIndex = 0 + Me.lblURL.Text = "Please Enter a URL" + ' + 'btnGO + ' + Me.btnGO.Location = New System.Drawing.Point(403, 7) + Me.btnGO.Name = "btnGO" + Me.btnGO.Size = New System.Drawing.Size(46, 23) + Me.btnGO.TabIndex = 3 + Me.btnGO.Text = "Go!" + ' + 'pageWebBrowser + ' + Me.pageWebBrowser.Controls.Add(Me.btnGO) + Me.pageWebBrowser.Controls.Add(Me.myWebBrowser) + Me.pageWebBrowser.Controls.Add(Me.txtUrl) + Me.pageWebBrowser.Controls.Add(Me.lblURL) + Me.pageWebBrowser.Location = New System.Drawing.Point(4, 22) + Me.pageWebBrowser.Name = "pageWebBrowser" + Me.pageWebBrowser.Padding = New System.Windows.Forms.Padding(3) + Me.pageWebBrowser.Size = New System.Drawing.Size(636, 341) + Me.pageWebBrowser.TabIndex = 5 + Me.pageWebBrowser.Text = "Web Browser" + ' + 'tabControlExoticControls + ' + Me.tabControlExoticControls.Controls.Add(Me.pageTrackBars) + Me.tabControlExoticControls.Controls.Add(Me.pagePanels) + Me.tabControlExoticControls.Controls.Add(Me.pageUpDown) + Me.tabControlExoticControls.Controls.Add(Me.pageErrorProvider) + Me.tabControlExoticControls.Controls.Add(Me.pageTreeView) + Me.tabControlExoticControls.Controls.Add(Me.pageWebBrowser) + Me.tabControlExoticControls.Location = New System.Drawing.Point(11, 16) + Me.tabControlExoticControls.Name = "tabControlExoticControls" + Me.tabControlExoticControls.SelectedIndex = 0 + Me.tabControlExoticControls.Size = New System.Drawing.Size(644, 367) + Me.tabControlExoticControls.TabIndex = 1 + ' + 'pageTrackBars + ' + Me.pageTrackBars.Controls.Add(Me.lblGreen) + Me.pageTrackBars.Controls.Add(Me.lblRed) + Me.pageTrackBars.Controls.Add(Me.blueTrackBar) + Me.pageTrackBars.Controls.Add(Me.lblBlue) + Me.pageTrackBars.Controls.Add(Me.greenTrackBar) + Me.pageTrackBars.Controls.Add(Me.redTrackBar) + Me.pageTrackBars.Controls.Add(Me.lblCurrColor) + Me.pageTrackBars.Controls.Add(Me.colorBox) + Me.pageTrackBars.Location = New System.Drawing.Point(4, 22) + Me.pageTrackBars.Name = "pageTrackBars" + Me.pageTrackBars.Padding = New System.Windows.Forms.Padding(3) + Me.pageTrackBars.Size = New System.Drawing.Size(636, 341) + Me.pageTrackBars.TabIndex = 0 + Me.pageTrackBars.Text = "Track Bars" + ' + 'pagePanels + ' + Me.pagePanels.Controls.Add(Me.panelTextBoxes) + Me.pagePanels.Controls.Add(Me.btnHidePanel) + Me.pagePanels.Controls.Add(Me.btnShowPanel) + Me.pagePanels.Location = New System.Drawing.Point(4, 22) + Me.pagePanels.Name = "pagePanels" + Me.pagePanels.Padding = New System.Windows.Forms.Padding(3) + Me.pagePanels.Size = New System.Drawing.Size(636, 341) + Me.pagePanels.TabIndex = 1 + Me.pagePanels.Text = "Panels" + ' + 'panelTextBoxes + ' + Me.panelTextBoxes.Controls.Add(Me.lblInstructions) + Me.panelTextBoxes.Controls.Add(Me.txtUpperText) + Me.panelTextBoxes.Controls.Add(Me.txtNormalText) + Me.panelTextBoxes.Location = New System.Drawing.Point(148, 7) + Me.panelTextBoxes.Name = "panelTextBoxes" + Me.panelTextBoxes.Size = New System.Drawing.Size(294, 187) + Me.panelTextBoxes.TabIndex = 2 + ' + 'lblInstructions + ' + Me.lblInstructions.AutoSize = True + Me.lblInstructions.Location = New System.Drawing.Point(41, 9) + Me.lblInstructions.Name = "lblInstructions" + Me.lblInstructions.Size = New System.Drawing.Size(126, 13) + Me.lblInstructions.TabIndex = 2 + Me.lblInstructions.Text = "Enter Some Text below..." + ' + 'txtUpperText + ' + Me.txtUpperText.Location = New System.Drawing.Point(41, 59) + Me.txtUpperText.Name = "txtUpperText" + Me.txtUpperText.Size = New System.Drawing.Size(100, 20) + Me.txtUpperText.TabIndex = 1 + ' + 'txtNormalText + ' + Me.txtNormalText.Location = New System.Drawing.Point(40, 33) + Me.txtNormalText.Name = "txtNormalText" + Me.txtNormalText.Size = New System.Drawing.Size(101, 20) + Me.txtNormalText.TabIndex = 0 + ' + 'btnHidePanel + ' + Me.btnHidePanel.Location = New System.Drawing.Point(44, 37) + Me.btnHidePanel.Name = "btnHidePanel" + Me.btnHidePanel.Size = New System.Drawing.Size(75, 23) + Me.btnHidePanel.TabIndex = 1 + Me.btnHidePanel.Text = "Hide Panel" + ' + 'btnShowPanel + ' + Me.btnShowPanel.Location = New System.Drawing.Point(44, 7) + Me.btnShowPanel.Name = "btnShowPanel" + Me.btnShowPanel.Size = New System.Drawing.Size(75, 23) + Me.btnShowPanel.TabIndex = 0 + Me.btnShowPanel.Text = "Show Panel" + ' + 'pageUpDown + ' + Me.pageUpDown.Controls.Add(Me.lblCurrSel) + Me.pageUpDown.Controls.Add(Me.btnGetSelections) + Me.pageUpDown.Controls.Add(Me.lblNumericUpDown) + Me.pageUpDown.Controls.Add(Me.lblDomainUpDown) + Me.pageUpDown.Controls.Add(Me.numericUpDown) + Me.pageUpDown.Controls.Add(Me.domainUpDown) + Me.pageUpDown.Location = New System.Drawing.Point(4, 22) + Me.pageUpDown.Name = "pageUpDown" + Me.pageUpDown.Padding = New System.Windows.Forms.Padding(3) + Me.pageUpDown.Size = New System.Drawing.Size(636, 341) + Me.pageUpDown.TabIndex = 2 + Me.pageUpDown.Text = "Up Down Controls" + ' + 'lblCurrSel + ' + Me.lblCurrSel.BackColor = System.Drawing.Color.Linen + Me.lblCurrSel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle + Me.lblCurrSel.Location = New System.Drawing.Point(53, 180) + Me.lblCurrSel.Name = "lblCurrSel" + Me.lblCurrSel.Size = New System.Drawing.Size(256, 48) + Me.lblCurrSel.TabIndex = 5 + ' + 'lblCurrColor + ' + Me.lblCurrColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle + Me.lblCurrColor.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!) + Me.lblCurrColor.Location = New System.Drawing.Point(26, 220) + Me.lblCurrColor.Name = "lblCurrColor" + Me.lblCurrColor.Size = New System.Drawing.Size(392, 40) + Me.lblCurrColor.TabIndex = 17 + ' + 'blueTrackBar + ' + Me.blueTrackBar.Location = New System.Drawing.Point(100, 162) + Me.blueTrackBar.Maximum = 255 + Me.blueTrackBar.Name = "blueTrackBar" + Me.blueTrackBar.Size = New System.Drawing.Size(310, 45) + Me.blueTrackBar.TabIndex = 18 + Me.blueTrackBar.TickFrequency = 5 + Me.blueTrackBar.TickStyle = System.Windows.Forms.TickStyle.TopLeft + ' + 'lblBlue + ' + Me.lblBlue.Font = New System.Drawing.Font("Arial", 15.0!) + Me.lblBlue.Location = New System.Drawing.Point(22, 162) + Me.lblBlue.Name = "lblBlue" + Me.lblBlue.Size = New System.Drawing.Size(72, 32) + Me.lblBlue.TabIndex = 23 + Me.lblBlue.Text = "Blue:" + ' + 'lblGreen + ' + Me.lblGreen.Font = New System.Drawing.Font("Arial", 15.0!) + Me.lblGreen.Location = New System.Drawing.Point(22, 122) + Me.lblGreen.Name = "lblGreen" + Me.lblGreen.Size = New System.Drawing.Size(72, 32) + Me.lblGreen.TabIndex = 25 + Me.lblGreen.Text = "Green:" + ' + 'greenTrackBar + ' + Me.greenTrackBar.Location = New System.Drawing.Point(100, 122) + Me.greenTrackBar.Maximum = 255 + Me.greenTrackBar.Name = "greenTrackBar" + Me.greenTrackBar.Size = New System.Drawing.Size(310, 45) + Me.greenTrackBar.TabIndex = 20 + Me.greenTrackBar.TickFrequency = 5 + Me.greenTrackBar.TickStyle = System.Windows.Forms.TickStyle.TopLeft + ' + 'redTrackBar + ' + Me.redTrackBar.Location = New System.Drawing.Point(100, 82) + Me.redTrackBar.Maximum = 255 + Me.redTrackBar.Name = "redTrackBar" + Me.redTrackBar.Size = New System.Drawing.Size(310, 45) + Me.redTrackBar.TabIndex = 19 + Me.redTrackBar.TickFrequency = 5 + Me.redTrackBar.TickStyle = System.Windows.Forms.TickStyle.TopLeft + ' + 'lblRed + ' + Me.lblRed.Font = New System.Drawing.Font("Arial", 15.0!) + Me.lblRed.Location = New System.Drawing.Point(22, 77) + Me.lblRed.Name = "lblRed" + Me.lblRed.Size = New System.Drawing.Size(72, 32) + Me.lblRed.TabIndex = 24 + Me.lblRed.Text = "Red:" + ' + 'colorBox + ' + Me.colorBox.BackColor = System.Drawing.Color.Blue + Me.colorBox.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D + Me.colorBox.Location = New System.Drawing.Point(26, 18) + Me.colorBox.Name = "colorBox" + Me.colorBox.Size = New System.Drawing.Size(384, 56) + Me.colorBox.TabIndex = 16 + Me.colorBox.TabStop = False + ' + 'imageListTreeView + ' + Me.imageListTreeView.ImageStream = CType(resources.GetObject("imageListTreeView.ImageStream"), System.Windows.Forms.ImageListStreamer) + Me.imageListTreeView.TransparentColor = System.Drawing.Color.Transparent + Me.imageListTreeView.Images.SetKeyName(0, "CarNode.bmp") + Me.imageListTreeView.Images.SetKeyName(1, "SpeedNode.bmp") + Me.imageListTreeView.Images.SetKeyName(2, "RadioNode.bmp") + ' + 'tooManyCharactersErrorProvider + ' + Me.tooManyCharactersErrorProvider.BlinkRate = 500 + Me.tooManyCharactersErrorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.AlwaysBlink + Me.tooManyCharactersErrorProvider.ContainerControl = Me + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(678, 407) + Me.Controls.Add(Me.tabControlExoticControls) + Me.Name = "MainForm" + Me.Text = "Fun with Exotic Controls" + Me.pageErrorProvider.ResumeLayout(False) + Me.pageErrorProvider.PerformLayout() + CType(Me.numericUpDown, System.ComponentModel.ISupportInitialize).EndInit() + Me.pageTreeView.ResumeLayout(False) + Me.pageTreeView.PerformLayout() + Me.pageWebBrowser.ResumeLayout(False) + Me.pageWebBrowser.PerformLayout() + Me.tabControlExoticControls.ResumeLayout(False) + Me.pageTrackBars.ResumeLayout(False) + Me.pageTrackBars.PerformLayout() + Me.pagePanels.ResumeLayout(False) + Me.panelTextBoxes.ResumeLayout(False) + Me.panelTextBoxes.PerformLayout() + Me.pageUpDown.ResumeLayout(False) + CType(Me.blueTrackBar, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.greenTrackBar, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.redTrackBar, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.colorBox, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.tooManyCharactersErrorProvider, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + + End Sub + Private WithEvents txtInput As System.Windows.Forms.TextBox + Private WithEvents lblErrorInstructions As System.Windows.Forms.Label + Private WithEvents pageErrorProvider As System.Windows.Forms.TabPage + Private WithEvents btnValidate As System.Windows.Forms.Button + Private WithEvents btnGetSelections As System.Windows.Forms.Button + Private WithEvents lblNumericUpDown As System.Windows.Forms.Label + Private WithEvents lblDomainUpDown As System.Windows.Forms.Label + Private WithEvents numericUpDown As System.Windows.Forms.NumericUpDown + Private WithEvents domainUpDown As System.Windows.Forms.DomainUpDown + Private WithEvents pageTreeView As System.Windows.Forms.TabPage + Private WithEvents lblNodeInfo As System.Windows.Forms.Label + Private WithEvents treeViewCars As System.Windows.Forms.TreeView + Private WithEvents myWebBrowser As System.Windows.Forms.WebBrowser + Private WithEvents txtUrl As System.Windows.Forms.TextBox + Private WithEvents tabControlExoticControls As System.Windows.Forms.TabControl + Private WithEvents pageTrackBars As System.Windows.Forms.TabPage + Private WithEvents pagePanels As System.Windows.Forms.TabPage + Private WithEvents panelTextBoxes As System.Windows.Forms.Panel + Private WithEvents lblInstructions As System.Windows.Forms.Label + Private WithEvents txtUpperText As System.Windows.Forms.TextBox + Private WithEvents txtNormalText As System.Windows.Forms.TextBox + Private WithEvents btnHidePanel As System.Windows.Forms.Button + Private WithEvents btnShowPanel As System.Windows.Forms.Button + Private WithEvents pageUpDown As System.Windows.Forms.TabPage + Private WithEvents lblCurrSel As System.Windows.Forms.Label + Private WithEvents pageWebBrowser As System.Windows.Forms.TabPage + Private WithEvents btnGO As System.Windows.Forms.Button + Private WithEvents lblURL As System.Windows.Forms.Label + Private WithEvents lblGreen As System.Windows.Forms.Label + Private WithEvents lblRed As System.Windows.Forms.Label + Private WithEvents colorBox As System.Windows.Forms.PictureBox + Private WithEvents blueTrackBar As System.Windows.Forms.TrackBar + Private WithEvents lblCurrColor As System.Windows.Forms.Label + Private WithEvents lblBlue As System.Windows.Forms.Label + Private WithEvents redTrackBar As System.Windows.Forms.TrackBar + Private WithEvents greenTrackBar As System.Windows.Forms.TrackBar + Private WithEvents imageListTreeView As System.Windows.Forms.ImageList + Private WithEvents tooManyCharactersErrorProvider As System.Windows.Forms.ErrorProvider + +End Class diff --git a/Code/Chapter 29/ExoticControls/MainForm.resx b/Code/Chapter 29/ExoticControls/MainForm.resx new file mode 100644 index 0000000..41dc37f --- /dev/null +++ b/Code/Chapter 29/ExoticControls/MainForm.resx @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 16, 11 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w + LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 + ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACy + CAAAAk1TRnQBSQFMAgEBAwEAAQQBAAEEAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA + AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 + AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA + AWYDAAGZAwABzAIAATMDAAIzAgABMwFmAgABMwGZAgABMwHMAgABMwH/AgABZgMAAWYBMwIAAmYCAAFm + AZkCAAFmAcwCAAFmAf8CAAGZAwABmQEzAgABmQFmAgACmQIAAZkBzAIAAZkB/wIAAcwDAAHMATMCAAHM + AWYCAAHMAZkCAALMAgABzAH/AgAB/wFmAgAB/wGZAgAB/wHMAQABMwH/AgAB/wEAATMBAAEzAQABZgEA + ATMBAAGZAQABMwEAAcwBAAEzAQAB/wEAAf8BMwIAAzMBAAIzAWYBAAIzAZkBAAIzAcwBAAIzAf8BAAEz + AWYCAAEzAWYBMwEAATMCZgEAATMBZgGZAQABMwFmAcwBAAEzAWYB/wEAATMBmQIAATMBmQEzAQABMwGZ + AWYBAAEzApkBAAEzAZkBzAEAATMBmQH/AQABMwHMAgABMwHMATMBAAEzAcwBZgEAATMBzAGZAQABMwLM + AQABMwHMAf8BAAEzAf8BMwEAATMB/wFmAQABMwH/AZkBAAEzAf8BzAEAATMC/wEAAWYDAAFmAQABMwEA + AWYBAAFmAQABZgEAAZkBAAFmAQABzAEAAWYBAAH/AQABZgEzAgABZgIzAQABZgEzAWYBAAFmATMBmQEA + AWYBMwHMAQABZgEzAf8BAAJmAgACZgEzAQADZgEAAmYBmQEAAmYBzAEAAWYBmQIAAWYBmQEzAQABZgGZ + AWYBAAFmApkBAAFmAZkBzAEAAWYBmQH/AQABZgHMAgABZgHMATMBAAFmAcwBmQEAAWYCzAEAAWYBzAH/ + AQABZgH/AgABZgH/ATMBAAFmAf8BmQEAAWYB/wHMAQABzAEAAf8BAAH/AQABzAEAApkCAAGZATMBmQEA + AZkBAAGZAQABmQEAAcwBAAGZAwABmQIzAQABmQEAAWYBAAGZATMBzAEAAZkBAAH/AQABmQFmAgABmQFm + ATMBAAGZATMBZgEAAZkBZgGZAQABmQFmAcwBAAGZATMB/wEAApkBMwEAApkBZgEAA5kBAAKZAcwBAAKZ + Af8BAAGZAcwCAAGZAcwBMwEAAWYBzAFmAQABmQHMAZkBAAGZAswBAAGZAcwB/wEAAZkB/wIAAZkB/wEz + AQABmQHMAWYBAAGZAf8BmQEAAZkB/wHMAQABmQL/AQABzAMAAZkBAAEzAQABzAEAAWYBAAHMAQABmQEA + AcwBAAHMAQABmQEzAgABzAIzAQABzAEzAWYBAAHMATMBmQEAAcwBMwHMAQABzAEzAf8BAAHMAWYCAAHM + AWYBMwEAAZkCZgEAAcwBZgGZAQABzAFmAcwBAAGZAWYB/wEAAcwBmQIAAcwBmQEzAQABzAGZAWYBAAHM + ApkBAAHMAZkBzAEAAcwBmQH/AQACzAIAAswBMwEAAswBZgEAAswBmQEAA8wBAALMAf8BAAHMAf8CAAHM + Af8BMwEAAZkB/wFmAQABzAH/AZkBAAHMAf8BzAEAAcwC/wEAAcwBAAEzAQAB/wEAAWYBAAH/AQABmQEA + AcwBMwIAAf8CMwEAAf8BMwFmAQAB/wEzAZkBAAH/ATMBzAEAAf8BMwH/AQAB/wFmAgAB/wFmATMBAAHM + AmYBAAH/AWYBmQEAAf8BZgHMAQABzAFmAf8BAAH/AZkCAAH/AZkBMwEAAf8BmQFmAQAB/wKZAQAB/wGZ + AcwBAAH/AZkB/wEAAf8BzAIAAf8BzAEzAQAB/wHMAWYBAAH/AcwBmQEAAf8CzAEAAf8BzAH/AQAC/wEz + AQABzAH/AWYBAAL/AZkBAAL/AcwBAAJmAf8BAAFmAf8BZgEAAWYC/wEAAf8CZgEAAf8BZgH/AQAC/wFm + AQABIQEAAaUBAANfAQADdwEAA4YBAAOWAQADywEAA7IBAAPXAQAD3QEAA+MBAAPqAQAD8QEAA/gBAAHw + AfsB/wEAAaQCoAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8BAAL/AgAD/wEABF4C/wZeAv8CXhD/ + EA4QAANeAf8CAAH/BF4B/wIAAf8BXgX/BtUF/xAOEAACXgH/BAAB/wJeAf8EAAX/CNUE/xAOEAACXgH/ + BAAB/wJeAf8EAAP/BEAE1QRAAv8BDg76AQ4QAANeAf8CAAT/AV4B/wIAAf8BXgH/AkAC1QJAAtUCQALV + AkAB/wEODvoBDhAAAl4E/wSIBP8CXgH/BNUCQAbVAkAB/wEOAvsBDgL7AQ4C+wEOAvsBDgL7AQ4QAAFe + Af8MiAH/AV4B/wTVAkAG1QJAAf8BDgL7AQ4C+wEOAvsBDgL7AQ4C+wEOEAAB/w6IAv8CQALVAkAC1QJA + AtUCQAH/AQ4C+wEOAvsBDgL7AQ4C+wEOAvsBDhAAAf8OiAL/BUAD1QVAAdUB/wQOAvsBDgL7AQ4C+wQO + EAAB/w6IAv8CQAbVAkAE1QH/BA4C+wEOAvsBDgL7BA4QAAFeAf8MiAH/AV4B/wJABtUCQATVAf8EDgL7 + AQ4C+wcOEAACXgT/BIgE/wJeAf8CQAbVAkAD1QL/Bw4C+wcOEAAGXgT/Bl4B/wZAAtUGQAH/EA4QABBe + BP8I1QT/EA4QABBeBf8G1QX/EA4QABBeEP8QDhAAAUIBTQE+BwABPgMAASgDAAFAAwABEAMAAQEBAAEB + BQABgBcAA/+BAAs= + + + + 146, 15 + + \ No newline at end of file diff --git a/Code/Chapter 29/ExoticControls/MainForm.vb b/Code/Chapter 29/ExoticControls/MainForm.vb new file mode 100644 index 0000000..8bf1715 --- /dev/null +++ b/Code/Chapter 29/ExoticControls/MainForm.vb @@ -0,0 +1,143 @@ +Option Explicit On +Option Strict On + +Public Class MainForm + + ' Create a new generic List to hold the Car objects. + Private listCars As List(Of Car) = New List(Of Car)() + + Sub New() + ' This call is required by the Windows Form Designer. + InitializeComponent() + + CenterToScreen() + ' Set initial position of each slider. + redTrackBar.Value = 100 + greenTrackBar.Value = 255 + blueTrackBar.Value = 0 + UpdateColor() + + ' Fill List(Of T) and build TreeView. + Dim offset As Double = 0.5 + For x As Integer = 0 To 99 + listCars.Add(New Car(String.Format("Car {0} ", x), 10 + x)) + offset += 0.5 + listCars(x).r = New Radio(89 + offset) + Next + BuildCarTreeView() + End Sub + +#Region "Track Bar stuff" + Private Sub redTrackBar_Scroll(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles redTrackBar.Scroll + UpdateColor() + End Sub + + Private Sub greenTrackBar_Scroll(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles greenTrackBar.Scroll + UpdateColor() + End Sub + + Private Sub blueTrackBar_Scroll(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles blueTrackBar.Scroll + UpdateColor() + End Sub + + Private Sub UpdateColor() + ' Get the new color based on track bars. + Dim c As Color = Color.FromArgb(redTrackBar.Value, greenTrackBar.Value, blueTrackBar.Value) + ' Change the color in the PictureBox. + colorBox.BackColor = c + ' Set color label. + lblCurrColor.Text = String.Format("Current color is: (R:{0}, G:{1}, B:{2})", _ + redTrackBar.Value, greenTrackBar.Value, blueTrackBar.Value) + End Sub +#End Region + +#Region "Panel Stuff" + Private Sub btnShowPanel_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles btnShowPanel.Click + panelTextBoxes.Visible = True + End Sub + + Private Sub btnHidePanel_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles btnHidePanel.Click + panelTextBoxes.Visible = False + End Sub + + Private Sub txtNormalText_TextChanged(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles txtNormalText.TextChanged + txtUpperText.Text = txtNormalText.Text.ToUpper() + End Sub +#End Region + +#Region "Up / Down Stuff" + Private Sub btnGetSelections_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles btnGetSelections.Click + ' Get info from updowns... + lblCurrSel.Text = _ + String.Format("String: {0}" & Chr(13) & "Number: {1}", _ + domainUpDown.Text, numericUpDown.Value) + End Sub +#End Region + +#Region "Error Provider Stuff" + Private Sub txtInput_Validating(ByVal sender As System.Object, _ + ByVal e As System.ComponentModel.CancelEventArgs) Handles txtInput.Validating + ' Check if the text length is greater than 5. + If txtInput.Text.Length > 5 Then + tooManyCharactersErrorProvider.SetError(txtInput, "Can't be greater than 5!") + Else + tooManyCharactersErrorProvider.SetError(txtInput, "") + ' Things are OK, don't show anything. + End If + End Sub +#End Region + +#Region "Build the treeview!" + Sub BuildCarTreeView() + ' Don’t repaint the TreeView until all the nodes have been created. + treeViewCars.BeginUpdate() + ' Clear the TreeView each time the method is called. + treeViewCars.Nodes.Clear() + ' Add a root TreeNode for each Car object in the List(Of T). + For Each c As Car In listCars + ' Add the current Car as a top-most node. + treeViewCars.Nodes.Add(New TreeNode(c.petName, 0, 0)) + ' Now, get the Car you just added to build + ' two sub-nodes based on the speed and + ' internal Radio object. + treeViewCars.Nodes(listCars.IndexOf(c)).Nodes.Add(New _ + TreeNode(String.Format("Speed: {0}", c.currSp.ToString()), 1, 1)) + treeViewCars.Nodes(listCars.IndexOf(c)).Nodes.Add(New _ + TreeNode(String.Format("Favorite Station: {0} FM", c.r.favoriteStation), 2, 2)) + Next + ' Now paint the TreeView. + treeViewCars.EndUpdate() + End Sub + + Private Sub treeViewCars_AfterSelect(ByVal sender As System.Object, _ + ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles treeViewCars.AfterSelect + Dim nodeInfo As String = "" + ' Build info about selected node. + nodeInfo = String.Format("You selected: {0}" & Chr(10) & "", e.Node.Text) + If e.Node.Parent IsNot Nothing Then + nodeInfo += String.Format("Parent Node: {0}" & Chr(10) & "", e.Node.Parent.Text) + End If + If e.Node.NextNode IsNot Nothing Then + nodeInfo += String.Format("Next Node: {0}", e.Node.NextNode.Text) + End If + ' Show info and highlight node. + lblNodeInfo.Text = nodeInfo + e.Node.BackColor = Color.AliceBlue + End Sub +#End Region + +#Region "Web stuff" + Private Sub btnGO_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGO.Click + ' Set URL based on value within page's TextBox control. + myWebBrowser.Url = New System.Uri(txtUrl.Text) + End Sub +#End Region + +End Class diff --git a/Code/Chapter 29/ExoticControls/My Project/Application.Designer.vb b/Code/Chapter 29/ExoticControls/My Project/Application.Designer.vb new file mode 100644 index 0000000..c7d1e90 --- /dev/null +++ b/Code/Chapter 29/ExoticControls/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.ExoticControls.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 29/ExoticControls/My Project/Application.myapp b/Code/Chapter 29/ExoticControls/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 29/ExoticControls/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 29/ExoticControls/My Project/AssemblyInfo.vb b/Code/Chapter 29/ExoticControls/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..2d397d8 --- /dev/null +++ b/Code/Chapter 29/ExoticControls/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/Code/Chapter 29/ExoticControls/My Project/Resources.Designer.vb b/Code/Chapter 29/ExoticControls/My Project/Resources.Designer.vb new file mode 100644 index 0000000..36f8cfa --- /dev/null +++ b/Code/Chapter 29/ExoticControls/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("ExoticControls.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/Code/Chapter 29/ExoticControls/My Project/Resources.resx b/Code/Chapter 29/ExoticControls/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 29/ExoticControls/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/Code/Chapter 29/ExoticControls/My Project/Settings.Designer.vb b/Code/Chapter 29/ExoticControls/My Project/Settings.Designer.vb new file mode 100644 index 0000000..c8c75ae --- /dev/null +++ b/Code/Chapter 29/ExoticControls/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.ExoticControls.My.MySettings + Get + Return Global.ExoticControls.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 29/ExoticControls/My Project/Settings.settings b/Code/Chapter 29/ExoticControls/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 29/ExoticControls/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 29/ExoticControls/RadioNode.bmp b/Code/Chapter 29/ExoticControls/RadioNode.bmp new file mode 100644 index 0000000..5fedf65 Binary files /dev/null and b/Code/Chapter 29/ExoticControls/RadioNode.bmp differ diff --git a/Code/Chapter 29/ExoticControls/SimpleCar.vb b/Code/Chapter 29/ExoticControls/SimpleCar.vb new file mode 100644 index 0000000..aa79f59 --- /dev/null +++ b/Code/Chapter 29/ExoticControls/SimpleCar.vb @@ -0,0 +1,19 @@ +Option Explicit On +Option Strict On + +Class Car + Public Sub New(ByVal pn As String, ByVal cs As Integer) + petName = pn + currSp = cs + End Sub + Public petName As String + Public currSp As Integer + Public r As Radio +End Class + +Class Radio + Public favoriteStation As Double + Public Sub New(ByVal station As Double) + favoriteStation = station + End Sub +End Class \ No newline at end of file diff --git a/Code/Chapter 29/ExoticControls/SpeedNode.bmp b/Code/Chapter 29/ExoticControls/SpeedNode.bmp new file mode 100644 index 0000000..12b0416 Binary files /dev/null and b/Code/Chapter 29/ExoticControls/SpeedNode.bmp differ diff --git a/Code/Chapter 29/LabelsAndTextBoxes/LabelsAndTextBoxes.sln b/Code/Chapter 29/LabelsAndTextBoxes/LabelsAndTextBoxes.sln new file mode 100644 index 0000000..c50b271 --- /dev/null +++ b/Code/Chapter 29/LabelsAndTextBoxes/LabelsAndTextBoxes.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "LabelsAndTextBoxes", "LabelsAndTextBoxes.vbproj", "{B488DD23-C8AF-4E1C-9AE8-637CCE0C7B62}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B488DD23-C8AF-4E1C-9AE8-637CCE0C7B62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B488DD23-C8AF-4E1C-9AE8-637CCE0C7B62}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B488DD23-C8AF-4E1C-9AE8-637CCE0C7B62}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B488DD23-C8AF-4E1C-9AE8-637CCE0C7B62}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 29/LabelsAndTextBoxes/LabelsAndTextBoxes.suo b/Code/Chapter 29/LabelsAndTextBoxes/LabelsAndTextBoxes.suo new file mode 100644 index 0000000..6bf2538 Binary files /dev/null and b/Code/Chapter 29/LabelsAndTextBoxes/LabelsAndTextBoxes.suo differ diff --git a/Code/Chapter 29/LabelsAndTextBoxes/LabelsAndTextBoxes.vbproj b/Code/Chapter 29/LabelsAndTextBoxes/LabelsAndTextBoxes.vbproj new file mode 100644 index 0000000..7f866da --- /dev/null +++ b/Code/Chapter 29/LabelsAndTextBoxes/LabelsAndTextBoxes.vbproj @@ -0,0 +1,148 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {B488DD23-C8AF-4E1C-9AE8-637CCE0C7B62} + WinExe + LabelsAndTextBoxes.My.MyApplication + LabelsAndTextBoxes + LabelsAndTextBoxes + WindowsForms + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + LabelsAndTextBoxes.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + LabelsAndTextBoxes.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + MainForm.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 29/LabelsAndTextBoxes/LabelsAndTextBoxes.vbproj.user b/Code/Chapter 29/LabelsAndTextBoxes/LabelsAndTextBoxes.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 29/LabelsAndTextBoxes/LabelsAndTextBoxes.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 29/LabelsAndTextBoxes/MainForm.Designer.vb b/Code/Chapter 29/LabelsAndTextBoxes/MainForm.Designer.vb new file mode 100644 index 0000000..087783d --- /dev/null +++ b/Code/Chapter 29/LabelsAndTextBoxes/MainForm.Designer.vb @@ -0,0 +1,142 @@ + _ +Partial Class MainForm + 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.txtMaskedTextBox = New System.Windows.Forms.MaskedTextBox + Me.lblMaskedTextBox = New System.Windows.Forms.Label + Me.btnDisplayData = New System.Windows.Forms.Button + Me.txtUpperCase = New System.Windows.Forms.TextBox + Me.lblUpperCaseOnly = New System.Windows.Forms.Label + Me.txtMultiline = New System.Windows.Forms.TextBox + Me.lblMultiline = New System.Windows.Forms.Label + Me.txtPassword = New System.Windows.Forms.TextBox + Me.lblPassword = New System.Windows.Forms.Label + Me.SuspendLayout() + ' + 'txtMaskedTextBox + ' + Me.txtMaskedTextBox.BeepOnError = True + Me.txtMaskedTextBox.CausesValidation = False + Me.txtMaskedTextBox.Location = New System.Drawing.Point(132, 223) + Me.txtMaskedTextBox.Mask = "(999) 000-0000" + Me.txtMaskedTextBox.Name = "txtMaskedTextBox" + Me.txtMaskedTextBox.Size = New System.Drawing.Size(220, 20) + Me.txtMaskedTextBox.TabIndex = 17 + ' + 'lblMaskedTextBox + ' + Me.lblMaskedTextBox.AutoSize = True + Me.lblMaskedTextBox.Location = New System.Drawing.Point(22, 223) + Me.lblMaskedTextBox.Name = "lblMaskedTextBox" + Me.lblMaskedTextBox.Size = New System.Drawing.Size(87, 13) + Me.lblMaskedTextBox.TabIndex = 16 + Me.lblMaskedTextBox.Text = "Mas&ked TextBox" + ' + 'btnDisplayData + ' + Me.btnDisplayData.Location = New System.Drawing.Point(264, 260) + Me.btnDisplayData.Name = "btnDisplayData" + Me.btnDisplayData.Size = New System.Drawing.Size(88, 23) + Me.btnDisplayData.TabIndex = 15 + Me.btnDisplayData.Text = "Display Data" + ' + 'txtUpperCase + ' + Me.txtUpperCase.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper + Me.txtUpperCase.Location = New System.Drawing.Point(132, 181) + Me.txtUpperCase.Name = "txtUpperCase" + Me.txtUpperCase.Size = New System.Drawing.Size(220, 20) + Me.txtUpperCase.TabIndex = 14 + ' + 'lblUpperCaseOnly + ' + Me.lblUpperCaseOnly.AutoSize = True + Me.lblUpperCaseOnly.Location = New System.Drawing.Point(22, 181) + Me.lblUpperCaseOnly.Name = "lblUpperCaseOnly" + Me.lblUpperCaseOnly.Size = New System.Drawing.Size(86, 13) + Me.lblUpperCaseOnly.TabIndex = 13 + Me.lblUpperCaseOnly.Text = "&Uppercase Only:" + ' + 'txtMultiline + ' + Me.txtMultiline.Location = New System.Drawing.Point(132, 104) + Me.txtMultiline.Multiline = True + Me.txtMultiline.Name = "txtMultiline" + Me.txtMultiline.ScrollBars = System.Windows.Forms.ScrollBars.Vertical + Me.txtMultiline.Size = New System.Drawing.Size(220, 52) + Me.txtMultiline.TabIndex = 12 + ' + 'lblMultiline + ' + Me.lblMultiline.AutoSize = True + Me.lblMultiline.Location = New System.Drawing.Point(21, 104) + Me.lblMultiline.Name = "lblMultiline" + Me.lblMultiline.Size = New System.Drawing.Size(90, 13) + Me.lblMultiline.TabIndex = 11 + Me.lblMultiline.Text = "&Multiline TextBox:" + ' + 'txtPassword + ' + Me.txtPassword.Location = New System.Drawing.Point(132, 67) + Me.txtPassword.Name = "txtPassword" + Me.txtPassword.PasswordChar = Global.Microsoft.VisualBasic.ChrW(42) + Me.txtPassword.Size = New System.Drawing.Size(220, 20) + Me.txtPassword.TabIndex = 10 + ' + 'lblPassword + ' + Me.lblPassword.AutoSize = True + Me.lblPassword.Location = New System.Drawing.Point(20, 67) + Me.lblPassword.Name = "lblPassword" + Me.lblPassword.Size = New System.Drawing.Size(98, 13) + Me.lblPassword.TabIndex = 9 + Me.lblPassword.Text = "&Password TextBox:" + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(364, 295) + Me.Controls.Add(Me.txtMaskedTextBox) + Me.Controls.Add(Me.lblMaskedTextBox) + Me.Controls.Add(Me.btnDisplayData) + Me.Controls.Add(Me.txtUpperCase) + Me.Controls.Add(Me.lblUpperCaseOnly) + Me.Controls.Add(Me.txtMultiline) + Me.Controls.Add(Me.lblMultiline) + Me.Controls.Add(Me.txtPassword) + Me.Controls.Add(Me.lblPassword) + Me.Name = "MainForm" + Me.Text = "Fun with Labels and TextBoxes" + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Private WithEvents txtMaskedTextBox As System.Windows.Forms.MaskedTextBox + Private WithEvents lblMaskedTextBox As System.Windows.Forms.Label + Private WithEvents btnDisplayData As System.Windows.Forms.Button + Private WithEvents txtUpperCase As System.Windows.Forms.TextBox + Private WithEvents lblUpperCaseOnly As System.Windows.Forms.Label + Private WithEvents txtMultiline As System.Windows.Forms.TextBox + Private WithEvents lblMultiline As System.Windows.Forms.Label + Private WithEvents txtPassword As System.Windows.Forms.TextBox + Private WithEvents lblPassword As System.Windows.Forms.Label + +End Class diff --git a/Code/Chapter 29/LabelsAndTextBoxes/MainForm.resx b/Code/Chapter 29/LabelsAndTextBoxes/MainForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 29/LabelsAndTextBoxes/MainForm.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/Code/Chapter 29/LabelsAndTextBoxes/MainForm.vb b/Code/Chapter 29/LabelsAndTextBoxes/MainForm.vb new file mode 100644 index 0000000..e45a3c6 --- /dev/null +++ b/Code/Chapter 29/LabelsAndTextBoxes/MainForm.vb @@ -0,0 +1,43 @@ +Option Explicit On +Option Strict On + +Public Class MainForm + Sub New() + ' This call is required by the Windows Form Designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call. + CreateLabelControl() + CenterToScreen() + End Sub + + Private Sub CreateLabelControl() + ' Create and configure a Label. + Dim lblInstructions As New Label() + lblInstructions.Name = "lblInstructions" + lblInstructions.Text = "Please enter values in all the text boxes" + lblInstructions.Font = New Font("Times New Roman", 10, FontStyle.Bold) + lblInstructions.AutoSize = True + lblInstructions.Location = New System.Drawing.Point(16, 13) + lblInstructions.Size = New System.Drawing.Size(240, 16) + ' Add to Form's controls collection. + Me.Controls.Add(lblInstructions) + End Sub + + Private Sub btnDisplayData_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles btnDisplayData.Click + ' Get data from all the text boxes. + Dim textBoxData As String = "" + textBoxData &= String.Format("MultiLine: {0}" & Chr(10), txtMultiline.Text) + textBoxData &= String.Format("Password: {0}" & Chr(10), txtPassword.Text) + textBoxData &= String.Format("Uppercase: {0}" & Chr(10), txtUpperCase.Text) + textBoxData &= String.Format("Masked: {0}" & Chr(10), txtMaskedTextBox.Text) + ' Display all the data. + MessageBox.Show(textBoxData, "Here is the data in your TextBoxes") + End Sub + + Private Sub txtMaskedTextBox_MaskInputRejected(ByVal sender As System.Object, _ + ByVal e As System.Windows.Forms.MaskInputRejectedEventArgs) Handles txtMaskedTextBox.MaskInputRejected + Me.Text = String.Format("Error: {0}", e.RejectionHint) + End Sub +End Class diff --git a/Code/Chapter 29/LabelsAndTextBoxes/My Project/Application.Designer.vb b/Code/Chapter 29/LabelsAndTextBoxes/My Project/Application.Designer.vb new file mode 100644 index 0000000..61a8ebf --- /dev/null +++ b/Code/Chapter 29/LabelsAndTextBoxes/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.LabelsAndTextBoxes.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 29/LabelsAndTextBoxes/My Project/Application.myapp b/Code/Chapter 29/LabelsAndTextBoxes/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 29/LabelsAndTextBoxes/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 29/LabelsAndTextBoxes/My Project/AssemblyInfo.vb b/Code/Chapter 29/LabelsAndTextBoxes/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..35a3b3e --- /dev/null +++ b/Code/Chapter 29/LabelsAndTextBoxes/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/Code/Chapter 29/LabelsAndTextBoxes/My Project/Resources.Designer.vb b/Code/Chapter 29/LabelsAndTextBoxes/My Project/Resources.Designer.vb new file mode 100644 index 0000000..c832fd3 --- /dev/null +++ b/Code/Chapter 29/LabelsAndTextBoxes/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("LabelsAndTextBoxes.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/Code/Chapter 29/LabelsAndTextBoxes/My Project/Resources.resx b/Code/Chapter 29/LabelsAndTextBoxes/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 29/LabelsAndTextBoxes/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/Code/Chapter 29/LabelsAndTextBoxes/My Project/Settings.Designer.vb b/Code/Chapter 29/LabelsAndTextBoxes/My Project/Settings.Designer.vb new file mode 100644 index 0000000..a9d2ce4 --- /dev/null +++ b/Code/Chapter 29/LabelsAndTextBoxes/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.LabelsAndTextBoxes.My.MySettings + Get + Return Global.LabelsAndTextBoxes.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 29/LabelsAndTextBoxes/My Project/Settings.settings b/Code/Chapter 29/LabelsAndTextBoxes/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 29/LabelsAndTextBoxes/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 29/SimpleModalDialog/ItalicUserMessageDialog.Designer.vb b/Code/Chapter 29/SimpleModalDialog/ItalicUserMessageDialog.Designer.vb new file mode 100644 index 0000000..48cce52 --- /dev/null +++ b/Code/Chapter 29/SimpleModalDialog/ItalicUserMessageDialog.Designer.vb @@ -0,0 +1,49 @@ + _ +Partial Class ItalicUserMessageDialog + Inherits SimpleModalDialog.UserMessageDialog + + '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.checkBoxItalic = New System.Windows.Forms.CheckBox + Me.SuspendLayout() + ' + 'checkBoxItalic + ' + Me.checkBoxItalic.AutoSize = True + Me.checkBoxItalic.Location = New System.Drawing.Point(14, 84) + Me.checkBoxItalic.Name = "checkBoxItalic" + Me.checkBoxItalic.Size = New System.Drawing.Size(54, 17) + Me.checkBoxItalic.TabIndex = 8 + Me.checkBoxItalic.Text = "Italic?" + Me.checkBoxItalic.UseVisualStyleBackColor = True + ' + 'ItalicUserMessageDialog + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.ClientSize = New System.Drawing.Size(364, 137) + Me.Controls.Add(Me.checkBoxItalic) + Me.Name = "ItalicUserMessageDialog" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent + Me.Controls.SetChildIndex(Me.checkBoxItalic, 0) + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents checkBoxItalic As System.Windows.Forms.CheckBox + +End Class diff --git a/Code/Chapter 29/SimpleModalDialog/ItalicUserMessageDialog.resx b/Code/Chapter 29/SimpleModalDialog/ItalicUserMessageDialog.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 29/SimpleModalDialog/ItalicUserMessageDialog.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/Code/Chapter 29/SimpleModalDialog/ItalicUserMessageDialog.vb b/Code/Chapter 29/SimpleModalDialog/ItalicUserMessageDialog.vb new file mode 100644 index 0000000..5ddce3c --- /dev/null +++ b/Code/Chapter 29/SimpleModalDialog/ItalicUserMessageDialog.vb @@ -0,0 +1,13 @@ +Option Explicit On +Option Strict On + +Public Class ItalicUserMessageDialog + Public Property Italic() As Boolean + Get + Return checkBoxItalic.Checked + End Get + Set(ByVal value As Boolean) + checkBoxItalic.Checked = value + End Set + End Property +End Class diff --git a/Code/Chapter 29/SimpleModalDialog/MainForm.Designer.vb b/Code/Chapter 29/SimpleModalDialog/MainForm.Designer.vb new file mode 100644 index 0000000..7f6086e --- /dev/null +++ b/Code/Chapter 29/SimpleModalDialog/MainForm.Designer.vb @@ -0,0 +1,85 @@ + _ +Partial Class MainForm + 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.toolsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.configureToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.exitToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.menuStrip1 = New System.Windows.Forms.MenuStrip + Me.fileToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem + Me.menuStrip1.SuspendLayout() + Me.SuspendLayout() + ' + 'toolsToolStripMenuItem + ' + Me.toolsToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.configureToolStripMenuItem}) + Me.toolsToolStripMenuItem.Name = "toolsToolStripMenuItem" + Me.toolsToolStripMenuItem.Size = New System.Drawing.Size(44, 20) + Me.toolsToolStripMenuItem.Text = "&Tools" + ' + 'configureToolStripMenuItem + ' + Me.configureToolStripMenuItem.Name = "configureToolStripMenuItem" + Me.configureToolStripMenuItem.Size = New System.Drawing.Size(152, 22) + Me.configureToolStripMenuItem.Text = "&Configure" + ' + 'exitToolStripMenuItem + ' + Me.exitToolStripMenuItem.Name = "exitToolStripMenuItem" + Me.exitToolStripMenuItem.Size = New System.Drawing.Size(152, 22) + Me.exitToolStripMenuItem.Text = "E&xit" + ' + 'menuStrip1 + ' + Me.menuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.fileToolStripMenuItem, Me.toolsToolStripMenuItem}) + Me.menuStrip1.Location = New System.Drawing.Point(0, 0) + Me.menuStrip1.Name = "menuStrip1" + Me.menuStrip1.Size = New System.Drawing.Size(368, 24) + Me.menuStrip1.TabIndex = 1 + Me.menuStrip1.Text = "menuStrip1" + ' + 'fileToolStripMenuItem + ' + Me.fileToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.exitToolStripMenuItem}) + Me.fileToolStripMenuItem.Name = "fileToolStripMenuItem" + Me.fileToolStripMenuItem.Size = New System.Drawing.Size(35, 20) + Me.fileToolStripMenuItem.Text = "&File" + ' + 'MainForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(368, 169) + Me.Controls.Add(Me.menuStrip1) + Me.Name = "MainForm" + Me.Text = "Enter your Message and I will paint it..." + Me.menuStrip1.ResumeLayout(False) + Me.menuStrip1.PerformLayout() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Private WithEvents toolsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Private WithEvents configureToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Private WithEvents exitToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Private WithEvents menuStrip1 As System.Windows.Forms.MenuStrip + Private WithEvents fileToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + +End Class diff --git a/Code/Chapter 29/SimpleModalDialog/MainForm.resx b/Code/Chapter 29/SimpleModalDialog/MainForm.resx new file mode 100644 index 0000000..541af56 --- /dev/null +++ b/Code/Chapter 29/SimpleModalDialog/MainForm.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/Code/Chapter 29/SimpleModalDialog/MainForm.vb b/Code/Chapter 29/SimpleModalDialog/MainForm.vb new file mode 100644 index 0000000..cc861d8 --- /dev/null +++ b/Code/Chapter 29/SimpleModalDialog/MainForm.vb @@ -0,0 +1,50 @@ +Option Explicit On +Option Strict On + +Public Class MainForm + Private userMessage As String = "Default Message" + Private textIsItalic As Boolean = False + + Sub New() + + ' This call is required by the Windows Form Designer. + InitializeComponent() + CenterToScreen() + ' Add any initialization after the InitializeComponent() call. + + End Sub + Private Sub configureToolStripMenuItem_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles configureToolStripMenuItem.Click + Dim dlg As ItalicUserMessageDialog = New ItalicUserMessageDialog() + dlg.Message = userMessage + dlg.Italic = textIsItalic + + ' If user clicked OK button, render his message. + If Windows.Forms.DialogResult.OK = dlg.ShowDialog() Then + userMessage = dlg.Message + textIsItalic = dlg.Italic + Invalidate() + End If + + ' Have dialog clean up internal widgets now, rather + ' than when the GC destroys the object. + dlg.Dispose() + End Sub + + Private Sub exitToolStripMenuItem_Click(ByVal sender As System.Object, _ + ByVal e As System.EventArgs) Handles exitToolStripMenuItem.Click + Application.Exit() + End Sub + + Private Sub MainForm_Paint(ByVal sender As System.Object, _ + ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint + Dim g As Graphics = e.Graphics + Dim f As Font = Nothing + If textIsItalic Then + f = New Font("Times New Roman", 24, FontStyle.Italic) + Else + f = New Font("Times New Roman", 24) + End If + g.DrawString(userMessage, f, Brushes.DarkBlue, 50, 50) + End Sub +End Class diff --git a/Code/Chapter 29/SimpleModalDialog/My Project/Application.Designer.vb b/Code/Chapter 29/SimpleModalDialog/My Project/Application.Designer.vb new file mode 100644 index 0000000..e6a2676 --- /dev/null +++ b/Code/Chapter 29/SimpleModalDialog/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SimpleModalDialog.MainForm + End Sub + End Class +End Namespace diff --git a/Code/Chapter 29/SimpleModalDialog/My Project/Application.myapp b/Code/Chapter 29/SimpleModalDialog/My Project/Application.myapp new file mode 100644 index 0000000..27659f2 --- /dev/null +++ b/Code/Chapter 29/SimpleModalDialog/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + MainForm + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Code/Chapter 29/SimpleModalDialog/My Project/AssemblyInfo.vb b/Code/Chapter 29/SimpleModalDialog/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..7749604 --- /dev/null +++ b/Code/Chapter 29/SimpleModalDialog/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/Code/Chapter 29/SimpleModalDialog/My Project/Resources.Designer.vb b/Code/Chapter 29/SimpleModalDialog/My Project/Resources.Designer.vb new file mode 100644 index 0000000..7fbe27d --- /dev/null +++ b/Code/Chapter 29/SimpleModalDialog/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("SimpleModalDialog.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/Code/Chapter 29/SimpleModalDialog/My Project/Resources.resx b/Code/Chapter 29/SimpleModalDialog/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 29/SimpleModalDialog/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/Code/Chapter 29/SimpleModalDialog/My Project/Settings.Designer.vb b/Code/Chapter 29/SimpleModalDialog/My Project/Settings.Designer.vb new file mode 100644 index 0000000..41f5bba --- /dev/null +++ b/Code/Chapter 29/SimpleModalDialog/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SimpleModalDialog.My.MySettings + Get + Return Global.SimpleModalDialog.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 29/SimpleModalDialog/My Project/Settings.settings b/Code/Chapter 29/SimpleModalDialog/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 29/SimpleModalDialog/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 29/SimpleModalDialog/SimpleModalDialog.sln b/Code/Chapter 29/SimpleModalDialog/SimpleModalDialog.sln new file mode 100644 index 0000000..437eb42 --- /dev/null +++ b/Code/Chapter 29/SimpleModalDialog/SimpleModalDialog.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SimpleModalDialog", "SimpleModalDialog.vbproj", "{6B06FBA1-B420-4555-B095-DA954B7DA670}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6B06FBA1-B420-4555-B095-DA954B7DA670}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6B06FBA1-B420-4555-B095-DA954B7DA670}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6B06FBA1-B420-4555-B095-DA954B7DA670}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6B06FBA1-B420-4555-B095-DA954B7DA670}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 29/SimpleModalDialog/SimpleModalDialog.suo b/Code/Chapter 29/SimpleModalDialog/SimpleModalDialog.suo new file mode 100644 index 0000000..8f3d584 Binary files /dev/null and b/Code/Chapter 29/SimpleModalDialog/SimpleModalDialog.suo differ diff --git a/Code/Chapter 29/SimpleModalDialog/SimpleModalDialog.vbproj b/Code/Chapter 29/SimpleModalDialog/SimpleModalDialog.vbproj new file mode 100644 index 0000000..fda4d34 --- /dev/null +++ b/Code/Chapter 29/SimpleModalDialog/SimpleModalDialog.vbproj @@ -0,0 +1,168 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {6B06FBA1-B420-4555-B095-DA954B7DA670} + WinExe + SimpleModalDialog.My.MyApplication + SimpleModalDialog + SimpleModalDialog + WindowsForms + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + SimpleModalDialog.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SimpleModalDialog.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + ItalicUserMessageDialog.vb + + + Form + + + Form + + + MainForm.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + UserMessageDialog.vb + + + Form + + + + + Designer + ItalicUserMessageDialog.vb + + + Designer + MainForm.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + Designer + UserMessageDialog.vb + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 29/SimpleModalDialog/SimpleModalDialog.vbproj.user b/Code/Chapter 29/SimpleModalDialog/SimpleModalDialog.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 29/SimpleModalDialog/SimpleModalDialog.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 29/SimpleModalDialog/UserMessageDialog.Designer.vb b/Code/Chapter 29/SimpleModalDialog/UserMessageDialog.Designer.vb new file mode 100644 index 0000000..2bf1852 --- /dev/null +++ b/Code/Chapter 29/SimpleModalDialog/UserMessageDialog.Designer.vb @@ -0,0 +1,85 @@ + _ +Partial Class UserMessageDialog + 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.txtUserInput = New System.Windows.Forms.TextBox + Me.label1 = New System.Windows.Forms.Label + Me.btnOK = New System.Windows.Forms.Button + Me.btnCancel = New System.Windows.Forms.Button + Me.SuspendLayout() + ' + 'txtUserInput + ' + Me.txtUserInput.Location = New System.Drawing.Point(12, 41) + Me.txtUserInput.Name = "txtUserInput" + Me.txtUserInput.Size = New System.Drawing.Size(325, 20) + Me.txtUserInput.TabIndex = 7 + ' + 'label1 + ' + Me.label1.AutoSize = True + Me.label1.Location = New System.Drawing.Point(11, 15) + Me.label1.Name = "label1" + Me.label1.Size = New System.Drawing.Size(136, 13) + Me.label1.TabIndex = 6 + Me.label1.Text = "Please Enter your Message" + ' + 'btnOK + ' + Me.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK + Me.btnOK.Location = New System.Drawing.Point(181, 79) + Me.btnOK.Name = "btnOK" + Me.btnOK.Size = New System.Drawing.Size(75, 23) + Me.btnOK.TabIndex = 5 + Me.btnOK.Text = "OK" + ' + 'btnCancel + ' + Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel + Me.btnCancel.Location = New System.Drawing.Point(262, 79) + Me.btnCancel.Name = "btnCancel" + Me.btnCancel.Size = New System.Drawing.Size(75, 23) + Me.btnCancel.TabIndex = 4 + Me.btnCancel.Text = "Cancel" + ' + 'UserMessageDialog + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(364, 137) + Me.Controls.Add(Me.txtUserInput) + Me.Controls.Add(Me.label1) + Me.Controls.Add(Me.btnOK) + Me.Controls.Add(Me.btnCancel) + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "UserMessageDialog" + Me.ShowInTaskbar = False + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent + Me.Text = "UserMessageDialog" + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Private WithEvents txtUserInput As System.Windows.Forms.TextBox + Private WithEvents label1 As System.Windows.Forms.Label + Private WithEvents btnOK As System.Windows.Forms.Button + Private WithEvents btnCancel As System.Windows.Forms.Button +End Class diff --git a/Code/Chapter 29/SimpleModalDialog/UserMessageDialog.resx b/Code/Chapter 29/SimpleModalDialog/UserMessageDialog.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Code/Chapter 29/SimpleModalDialog/UserMessageDialog.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/Code/Chapter 29/SimpleModalDialog/UserMessageDialog.vb b/Code/Chapter 29/SimpleModalDialog/UserMessageDialog.vb new file mode 100644 index 0000000..2f38931 --- /dev/null +++ b/Code/Chapter 29/SimpleModalDialog/UserMessageDialog.vb @@ -0,0 +1,13 @@ +Option Explicit On +Option Strict On + +Public Class UserMessageDialog + Public Property Message() As String + Get + Return txtUserInput.Text + End Get + Set(ByVal value As String) + txtUserInput.Text = value + End Set + End Property +End Class \ No newline at end of file diff --git a/Code/Chapter 3/BasicConsoleIO/BasicConsoleIO.sln b/Code/Chapter 3/BasicConsoleIO/BasicConsoleIO.sln new file mode 100644 index 0000000..54ac495 --- /dev/null +++ b/Code/Chapter 3/BasicConsoleIO/BasicConsoleIO.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "BasicConsoleIO", "BasicConsoleIO.vbproj", "{756FA64A-E8FF-44ED-B3C4-DCA0B28D8EF0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {756FA64A-E8FF-44ED-B3C4-DCA0B28D8EF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {756FA64A-E8FF-44ED-B3C4-DCA0B28D8EF0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {756FA64A-E8FF-44ED-B3C4-DCA0B28D8EF0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {756FA64A-E8FF-44ED-B3C4-DCA0B28D8EF0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 3/BasicConsoleIO/BasicConsoleIO.suo b/Code/Chapter 3/BasicConsoleIO/BasicConsoleIO.suo new file mode 100644 index 0000000..46c2a52 Binary files /dev/null and b/Code/Chapter 3/BasicConsoleIO/BasicConsoleIO.suo differ diff --git a/Code/Chapter 3/BasicConsoleIO/BasicConsoleIO.vbproj b/Code/Chapter 3/BasicConsoleIO/BasicConsoleIO.vbproj new file mode 100644 index 0000000..c02dbee --- /dev/null +++ b/Code/Chapter 3/BasicConsoleIO/BasicConsoleIO.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {756FA64A-E8FF-44ED-B3C4-DCA0B28D8EF0} + Exe + BasicConsoleIO.Program + BasicConsoleIO + BasicConsoleIO + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + BasicConsoleIO.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + BasicConsoleIO.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 3/BasicConsoleIO/BasicConsoleIO.vbproj.user b/Code/Chapter 3/BasicConsoleIO/BasicConsoleIO.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 3/BasicConsoleIO/BasicConsoleIO.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 3/BasicConsoleIO/My Project/Application.Designer.vb b/Code/Chapter 3/BasicConsoleIO/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 3/BasicConsoleIO/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 3/BasicConsoleIO/My Project/Application.myapp b/Code/Chapter 3/BasicConsoleIO/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 3/BasicConsoleIO/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 3/BasicConsoleIO/My Project/AssemblyInfo.vb b/Code/Chapter 3/BasicConsoleIO/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..cbc3150 --- /dev/null +++ b/Code/Chapter 3/BasicConsoleIO/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/Code/Chapter 3/BasicConsoleIO/My Project/Resources.Designer.vb b/Code/Chapter 3/BasicConsoleIO/My Project/Resources.Designer.vb new file mode 100644 index 0000000..aa7d99d --- /dev/null +++ b/Code/Chapter 3/BasicConsoleIO/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("BasicConsoleIO.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/Code/Chapter 3/BasicConsoleIO/My Project/Resources.resx b/Code/Chapter 3/BasicConsoleIO/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 3/BasicConsoleIO/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/Code/Chapter 3/BasicConsoleIO/My Project/Settings.Designer.vb b/Code/Chapter 3/BasicConsoleIO/My Project/Settings.Designer.vb new file mode 100644 index 0000000..10a92d0 --- /dev/null +++ b/Code/Chapter 3/BasicConsoleIO/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.BasicConsoleIO.My.MySettings + Get + Return Global.BasicConsoleIO.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 3/BasicConsoleIO/My Project/Settings.settings b/Code/Chapter 3/BasicConsoleIO/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 3/BasicConsoleIO/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 3/BasicConsoleIO/Program.vb b/Code/Chapter 3/BasicConsoleIO/Program.vb new file mode 100644 index 0000000..3979721 --- /dev/null +++ b/Code/Chapter 3/BasicConsoleIO/Program.vb @@ -0,0 +1,44 @@ +Module Program + + Sub Main() + Console.WriteLine("***** Fun with Console IO *****") + ' Echo some information to the console. + Console.Write("Enter your name: ") + Dim s As String = Console.ReadLine() + Console.WriteLine("Hello, {0}", s) + Console.Write("Enter your age: ") + s = Console.ReadLine() + Console.WriteLine("You are {0} years old", s) + + ' Specify string placeholders and values to use at + ' runtime. + Dim theInt As Integer = 90 + Dim theDouble As Double = 9.99 + Dim theBool As Boolean = True + Console.WriteLine("Value of theInt: {0}", theInt) + Console.WriteLine("theDouble is {0} and theBool is {1}.", _ + theDouble, theBool) + + ' John says... + Console.WriteLine("{0}, Number {0}, Number {0}", 9) + + ' Prints: 20, 10, 30 + Console.WriteLine("{1}, {0}, {2}", 10, 20, 30) + + ' Various formatting options. + Console.WriteLine("C format: {0:C}", 99989.987) + Console.WriteLine("D9 format: {0:D9}", 99999) + Console.WriteLine("E format: {0:E}", 99999.76543) + Console.WriteLine("F3 format: {0:F3}", 99999.9999) + Console.WriteLine("N format: {0:N}", 99999) + Console.WriteLine("X format: {0:X}", 99999) + Console.WriteLine("x format: {0:x}", 99999) + + ' Use the shared String.Format() method to build a new string. + Dim formatStr As String + formatStr = _ + String.Format("Don't you wish you had {0:C} in your account?", 99989.987) + Console.WriteLine(formatStr) + End Sub + +End Module diff --git a/Code/Chapter 3/BasicDataTypes/BasicDataTypes.sln b/Code/Chapter 3/BasicDataTypes/BasicDataTypes.sln new file mode 100644 index 0000000..ac7f57b --- /dev/null +++ b/Code/Chapter 3/BasicDataTypes/BasicDataTypes.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "BasicDataTypes", "BasicDataTypes.vbproj", "{4A5BA9A5-CBB8-467B-96D7-6AC2337B5109}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4A5BA9A5-CBB8-467B-96D7-6AC2337B5109}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4A5BA9A5-CBB8-467B-96D7-6AC2337B5109}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4A5BA9A5-CBB8-467B-96D7-6AC2337B5109}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4A5BA9A5-CBB8-467B-96D7-6AC2337B5109}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 3/BasicDataTypes/BasicDataTypes.suo b/Code/Chapter 3/BasicDataTypes/BasicDataTypes.suo new file mode 100644 index 0000000..fd82e0f Binary files /dev/null and b/Code/Chapter 3/BasicDataTypes/BasicDataTypes.suo differ diff --git a/Code/Chapter 3/BasicDataTypes/BasicDataTypes.vbproj b/Code/Chapter 3/BasicDataTypes/BasicDataTypes.vbproj new file mode 100644 index 0000000..7711865 --- /dev/null +++ b/Code/Chapter 3/BasicDataTypes/BasicDataTypes.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {4A5BA9A5-CBB8-467B-96D7-6AC2337B5109} + Exe + BasicDataTypes.Program + BasicDataTypes + BasicDataTypes + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + BasicDataTypes.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + BasicDataTypes.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 3/BasicDataTypes/BasicDataTypes.vbproj.user b/Code/Chapter 3/BasicDataTypes/BasicDataTypes.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 3/BasicDataTypes/BasicDataTypes.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 3/BasicDataTypes/My Project/Application.Designer.vb b/Code/Chapter 3/BasicDataTypes/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 3/BasicDataTypes/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 3/BasicDataTypes/My Project/Application.myapp b/Code/Chapter 3/BasicDataTypes/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 3/BasicDataTypes/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 3/BasicDataTypes/My Project/AssemblyInfo.vb b/Code/Chapter 3/BasicDataTypes/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..7971ff6 --- /dev/null +++ b/Code/Chapter 3/BasicDataTypes/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/Code/Chapter 3/BasicDataTypes/My Project/Resources.Designer.vb b/Code/Chapter 3/BasicDataTypes/My Project/Resources.Designer.vb new file mode 100644 index 0000000..f4a6bbf --- /dev/null +++ b/Code/Chapter 3/BasicDataTypes/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("BasicDataTypes.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/Code/Chapter 3/BasicDataTypes/My Project/Resources.resx b/Code/Chapter 3/BasicDataTypes/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 3/BasicDataTypes/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/Code/Chapter 3/BasicDataTypes/My Project/Settings.Designer.vb b/Code/Chapter 3/BasicDataTypes/My Project/Settings.Designer.vb new file mode 100644 index 0000000..d71911f --- /dev/null +++ b/Code/Chapter 3/BasicDataTypes/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.BasicDataTypes.My.MySettings + Get + Return Global.BasicDataTypes.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 3/BasicDataTypes/My Project/Settings.settings b/Code/Chapter 3/BasicDataTypes/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 3/BasicDataTypes/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 3/BasicDataTypes/Program.vb b/Code/Chapter 3/BasicDataTypes/Program.vb new file mode 100644 index 0000000..c0d2726 --- /dev/null +++ b/Code/Chapter 3/BasicDataTypes/Program.vb @@ -0,0 +1,41 @@ +Module Program + Sub Main() + Console.WriteLine("***** Fun with Data Types *****") + ' Fun with basic data types. + Console.WriteLine("Max of Integer: {0}", Integer.MaxValue) + Console.WriteLine("Min of Integer: {0}", Integer.MinValue) + Console.WriteLine("Max of Double: {0}", Double.MaxValue) + Console.WriteLine("Min of Double: {0}", Double.MinValue) + Console.WriteLine("Double.Epsilon: {0}", Double.Epsilon) + Console.WriteLine("Double.PositiveInfinity: {0}", _ + Double.PositiveInfinity) + Console.WriteLine("Double.NegativeInfinity: {0}", _ + Double.NegativeInfinity) + Console.WriteLine("Boolean.FalseString: {0}", Boolean.FalseString) + Console.WriteLine("Boolean.TrueString: {0}", Boolean.TrueString) + Console.WriteLine() + + ' Fun with System.Char. + Dim myChar As Char = "a"c + Console.WriteLine("Char.IsDigit('a'): {0}", Char.IsDigit(myChar)) + Console.WriteLine("Char.IsLetter('a'): {0}", Char.IsLetter(myChar)) + Console.WriteLine("Char.IsWhiteSpace('Hello There', 5): {0}", _ + Char.IsWhiteSpace("Hello There", 5)) + Console.WriteLine("Char.IsWhiteSpace('Hello There', 6): {0}", _ + Char.IsWhiteSpace("Hello There", 6)) + Console.WriteLine("Char.IsPunctuation('?'): {0}", _ + Char.IsPunctuation("?"c)) + Console.WriteLine() + + ' Fun with parsing + Dim b As Boolean = Boolean.Parse("True") + Console.WriteLine("Value of myBool: {0}", b) + Dim d As Double = Double.Parse("99.884") + Console.WriteLine("Value of myDbl: {0}", d) + Dim i As Integer = Integer.Parse("8") + Console.WriteLine("Value of myInt: {0}", i) + Dim c As Char = Char.Parse("w") + Console.WriteLine("Value of myChar: {0}", c) + + End Sub +End Module diff --git a/Code/Chapter 3/FunWithMain/FunWithMain.sln b/Code/Chapter 3/FunWithMain/FunWithMain.sln new file mode 100644 index 0000000..d44724a --- /dev/null +++ b/Code/Chapter 3/FunWithMain/FunWithMain.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "FunWithMain", "FunWithMain.vbproj", "{A453D688-6088-4E4E-8893-F18246512BC4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A453D688-6088-4E4E-8893-F18246512BC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A453D688-6088-4E4E-8893-F18246512BC4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A453D688-6088-4E4E-8893-F18246512BC4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A453D688-6088-4E4E-8893-F18246512BC4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 3/FunWithMain/FunWithMain.suo b/Code/Chapter 3/FunWithMain/FunWithMain.suo new file mode 100644 index 0000000..3d01551 Binary files /dev/null and b/Code/Chapter 3/FunWithMain/FunWithMain.suo differ diff --git a/Code/Chapter 3/FunWithMain/FunWithMain.vbproj b/Code/Chapter 3/FunWithMain/FunWithMain.vbproj new file mode 100644 index 0000000..2a35b71 --- /dev/null +++ b/Code/Chapter 3/FunWithMain/FunWithMain.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {A453D688-6088-4E4E-8893-F18246512BC4} + Exe + FunWithMain.Program + FunWithMain + FunWithMain + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + FunWithMain.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + FunWithMain.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 3/FunWithMain/FunWithMain.vbproj.user b/Code/Chapter 3/FunWithMain/FunWithMain.vbproj.user new file mode 100644 index 0000000..2cf9117 --- /dev/null +++ b/Code/Chapter 3/FunWithMain/FunWithMain.vbproj.user @@ -0,0 +1,23 @@ + + + /arg1 -godmode -anotherArg + + + -test + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 3/FunWithMain/My Project/Application.Designer.vb b/Code/Chapter 3/FunWithMain/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 3/FunWithMain/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 3/FunWithMain/My Project/Application.myapp b/Code/Chapter 3/FunWithMain/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 3/FunWithMain/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 3/FunWithMain/My Project/AssemblyInfo.vb b/Code/Chapter 3/FunWithMain/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..2e3c388 --- /dev/null +++ b/Code/Chapter 3/FunWithMain/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/Code/Chapter 3/FunWithMain/My Project/Resources.Designer.vb b/Code/Chapter 3/FunWithMain/My Project/Resources.Designer.vb new file mode 100644 index 0000000..71f93ac --- /dev/null +++ b/Code/Chapter 3/FunWithMain/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("FunWithMain.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/Code/Chapter 3/FunWithMain/My Project/Resources.resx b/Code/Chapter 3/FunWithMain/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 3/FunWithMain/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/Code/Chapter 3/FunWithMain/My Project/Settings.Designer.vb b/Code/Chapter 3/FunWithMain/My Project/Settings.Designer.vb new file mode 100644 index 0000000..f676585 --- /dev/null +++ b/Code/Chapter 3/FunWithMain/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.FunWithMain.My.MySettings + Get + Return Global.FunWithMain.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 3/FunWithMain/My Project/Settings.settings b/Code/Chapter 3/FunWithMain/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 3/FunWithMain/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 3/FunWithMain/Program.vb b/Code/Chapter 3/FunWithMain/Program.vb new file mode 100644 index 0000000..a74f9c1 --- /dev/null +++ b/Code/Chapter 3/FunWithMain/Program.vb @@ -0,0 +1,27 @@ +' Note: I have specified start up arguments using the +' My Project editor (see Ch.3 for details). + +Class Program + Shared Function Main(ByVal args As String()) As Integer + Console.WriteLine("***** Fun with Main() *****") + Dim s As String + For Each s In args + Console.WriteLine("Arg: {0}", s) + Next + + ' OS running this app? + Console.WriteLine("Current OS: {0}", Environment.OSVersion) + + ' List the drives on this machine. + Dim drives As String() = Environment.GetLogicalDrives() + Dim d As String + For Each d In drives + Console.WriteLine("You have a drive named {0}.", d) + Next + + ' Which version of the .NET platform is running this app? + Console.WriteLine("Executing version of .NET: {0}", _ + Environment.Version) + Return 0 + End Function +End Class diff --git a/Code/Chapter 3/FunWithModules/FunWithModules.sln b/Code/Chapter 3/FunWithModules/FunWithModules.sln new file mode 100644 index 0000000..84e43dd --- /dev/null +++ b/Code/Chapter 3/FunWithModules/FunWithModules.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "FunWithModules", "FunWithModules.vbproj", "{DE804A9E-A08E-4E7F-8812-BE344D437326}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DE804A9E-A08E-4E7F-8812-BE344D437326}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DE804A9E-A08E-4E7F-8812-BE344D437326}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DE804A9E-A08E-4E7F-8812-BE344D437326}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DE804A9E-A08E-4E7F-8812-BE344D437326}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 3/FunWithModules/FunWithModules.suo b/Code/Chapter 3/FunWithModules/FunWithModules.suo new file mode 100644 index 0000000..261d620 Binary files /dev/null and b/Code/Chapter 3/FunWithModules/FunWithModules.suo differ diff --git a/Code/Chapter 3/FunWithModules/FunWithModules.vbproj b/Code/Chapter 3/FunWithModules/FunWithModules.vbproj new file mode 100644 index 0000000..23162e8 --- /dev/null +++ b/Code/Chapter 3/FunWithModules/FunWithModules.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {DE804A9E-A08E-4E7F-8812-BE344D437326} + Exe + FunWithModules.Program + FunWithModules + FunWithModules + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + FunWithModules.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + FunWithModules.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 3/FunWithModules/FunWithModules.vbproj.user b/Code/Chapter 3/FunWithModules/FunWithModules.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 3/FunWithModules/FunWithModules.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 3/FunWithModules/My Project/Application.Designer.vb b/Code/Chapter 3/FunWithModules/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 3/FunWithModules/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 3/FunWithModules/My Project/Application.myapp b/Code/Chapter 3/FunWithModules/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 3/FunWithModules/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 3/FunWithModules/My Project/AssemblyInfo.vb b/Code/Chapter 3/FunWithModules/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..971dc82 --- /dev/null +++ b/Code/Chapter 3/FunWithModules/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/Code/Chapter 3/FunWithModules/My Project/Resources.Designer.vb b/Code/Chapter 3/FunWithModules/My Project/Resources.Designer.vb new file mode 100644 index 0000000..994c6c2 --- /dev/null +++ b/Code/Chapter 3/FunWithModules/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("FunWithModules.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/Code/Chapter 3/FunWithModules/My Project/Resources.resx b/Code/Chapter 3/FunWithModules/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 3/FunWithModules/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/Code/Chapter 3/FunWithModules/My Project/Settings.Designer.vb b/Code/Chapter 3/FunWithModules/My Project/Settings.Designer.vb new file mode 100644 index 0000000..39c8c31 --- /dev/null +++ b/Code/Chapter 3/FunWithModules/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.FunWithModules.My.MySettings + Get + Return Global.FunWithModules.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 3/FunWithModules/My Project/Settings.settings b/Code/Chapter 3/FunWithModules/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 3/FunWithModules/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 3/FunWithModules/Program.vb b/Code/Chapter 3/FunWithModules/Program.vb new file mode 100644 index 0000000..548b855 --- /dev/null +++ b/Code/Chapter 3/FunWithModules/Program.vb @@ -0,0 +1,69 @@ +Module Program + Sub Main() + ' Show banner. + DisplayBanner() + + ' Get user name and say howdy. + GreetUser() + + ' Add some numbers. + Console.WriteLine("10 + 10 is {0}.", Add(10, 10)) + + ' Subtract some numbers + ' (module prefix optional) + Console.WriteLine("10 - 10 is {0}.", MyMathModule.Subtract(10, 10)) + + ' Nope! Error, can't allocated modules! + ' Dim m As New Module1() + + ' Set userName and call second form of GreetUser(). + UserName = "Fred" + MyModule.GreetUser() + Console.ReadLine() + + End Sub + +#Region "Helper methods" + Sub DisplayBanner() + ' Get the current color of the console text. + Dim currColor As ConsoleColor = Console.ForegroundColor + + ' Set text color to yellow. + Console.ForegroundColor = ConsoleColor.Yellow + Console.WriteLine("******* Welcome to FunWithModules *******") + Console.WriteLine("This simple program illustrates the role") + Console.WriteLine("of the Module type.") + Console.WriteLine("*****************************************") + + ' Reset to previous color of your console text. + Console.ForegroundColor = currColor + Console.WriteLine() + End Sub + + Sub GreetUser() + Dim userName As String + Console.Write("Please enter your name: ") + userName = Console.ReadLine() + Console.WriteLine("Hello there {0}. Nice to meet ya.", userName) + End Sub +#End Region + +End Module + +#Region "Extra Modules" +Module MyModule + Public UserName As String + Public Sub GreetUser() + Console.WriteLine("Hello, {0}.", UserName) + End Sub +End Module + +Module MyMathModule + Function Add(ByVal x As Integer, ByVal y As Integer) As Integer + Return x + y + End Function + Function Subtract(ByVal x As Integer, ByVal y As Integer) As Integer + Return x - y + End Function +End Module +#End Region \ No newline at end of file diff --git a/Code/Chapter 3/FunWithStrings/FunWithStrings.sln b/Code/Chapter 3/FunWithStrings/FunWithStrings.sln new file mode 100644 index 0000000..015cec2 --- /dev/null +++ b/Code/Chapter 3/FunWithStrings/FunWithStrings.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "FunWithStrings", "FunWithStrings.vbproj", "{2DDEB4C5-6F8A-4837-BA94-DA1B472FCE65}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2DDEB4C5-6F8A-4837-BA94-DA1B472FCE65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2DDEB4C5-6F8A-4837-BA94-DA1B472FCE65}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2DDEB4C5-6F8A-4837-BA94-DA1B472FCE65}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2DDEB4C5-6F8A-4837-BA94-DA1B472FCE65}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 3/FunWithStrings/FunWithStrings.suo b/Code/Chapter 3/FunWithStrings/FunWithStrings.suo new file mode 100644 index 0000000..de16dc5 Binary files /dev/null and b/Code/Chapter 3/FunWithStrings/FunWithStrings.suo differ diff --git a/Code/Chapter 3/FunWithStrings/FunWithStrings.vbproj b/Code/Chapter 3/FunWithStrings/FunWithStrings.vbproj new file mode 100644 index 0000000..3be4689 --- /dev/null +++ b/Code/Chapter 3/FunWithStrings/FunWithStrings.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {2DDEB4C5-6F8A-4837-BA94-DA1B472FCE65} + Exe + FunWithStrings.Program + FunWithStrings + FunWithStrings + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + FunWithStrings.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + FunWithStrings.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 3/FunWithStrings/FunWithStrings.vbproj.user b/Code/Chapter 3/FunWithStrings/FunWithStrings.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 3/FunWithStrings/FunWithStrings.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 3/FunWithStrings/My Project/Application.Designer.vb b/Code/Chapter 3/FunWithStrings/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 3/FunWithStrings/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 3/FunWithStrings/My Project/Application.myapp b/Code/Chapter 3/FunWithStrings/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 3/FunWithStrings/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 3/FunWithStrings/My Project/AssemblyInfo.vb b/Code/Chapter 3/FunWithStrings/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..b9b212a --- /dev/null +++ b/Code/Chapter 3/FunWithStrings/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/Code/Chapter 3/FunWithStrings/My Project/Resources.Designer.vb b/Code/Chapter 3/FunWithStrings/My Project/Resources.Designer.vb new file mode 100644 index 0000000..c7c4fd5 --- /dev/null +++ b/Code/Chapter 3/FunWithStrings/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("FunWithStrings.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/Code/Chapter 3/FunWithStrings/My Project/Resources.resx b/Code/Chapter 3/FunWithStrings/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 3/FunWithStrings/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/Code/Chapter 3/FunWithStrings/My Project/Settings.Designer.vb b/Code/Chapter 3/FunWithStrings/My Project/Settings.Designer.vb new file mode 100644 index 0000000..94360d4 --- /dev/null +++ b/Code/Chapter 3/FunWithStrings/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.FunWithStrings.My.MySettings + Get + Return Global.FunWithStrings.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 3/FunWithStrings/My Project/Settings.settings b/Code/Chapter 3/FunWithStrings/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 3/FunWithStrings/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 3/FunWithStrings/Program.vb b/Code/Chapter 3/FunWithStrings/Program.vb new file mode 100644 index 0000000..387c625 --- /dev/null +++ b/Code/Chapter 3/FunWithStrings/Program.vb @@ -0,0 +1,72 @@ +Imports System.Text ' StringBuilder lives here! + +Module Program + Sub Main() + Console.WriteLine("***** Fun with Strings *****") + Console.WriteLine() + + Dim firstName As String = "June" + Console.WriteLine("Value of firstName: {0}", firstName) + Console.WriteLine("firstName has {0} characters.", firstName.Length) + Console.WriteLine("firstName in uppercase: {0}", firstName.ToUpper()) + Console.WriteLine("firstName in lowercase: {0}", firstName.ToLower()) + + Console.WriteLine() + + Dim myValue As Integer = 3456787 + + Console.WriteLine("Hex vaule of myValue is: {0:X}", myValue) + Console.WriteLine("Currency value of myValue is: {0:C}", myValue) + + Console.WriteLine() + + Dim s1 As String = "Programming the " + Dim s2 As String = "PsychoDrill (PTP)" + Dim s3 As String = String.Concat(s1, s2) + s3 &= vbLf & "was a great industral project." + Console.WriteLine(s3) + + Console.WriteLine() + + Dim strA As String = "Hello!" + Dim strB As String = "Yo!" + ' False! + Console.WriteLine("strA = strB?: {0}", strA = strB) + strB = "HELLO!" + ' False! + Console.WriteLine("strA = strB?: {0}", strA = strB) + strB = "Hello!" + ' True! + Console.WriteLine("strA = strB?: {0}", strA = strB) + + Console.WriteLine() + + ' Set initial string value + Dim initialString As String = "This is my string." + Console.WriteLine("Initial value: {0}", initialString) + + ' Uppercase the initialString? + Dim upperString As String = initialString.ToUpper() + Console.WriteLine("Upper case copy: {0}", upperString) + + ' Nope! initialString is in the same format! + Console.WriteLine("Initial value: {0}", initialString) + + Console.WriteLine() + + 'Dim strObjA As String = "String A reporting." + 'strObjA = "This is a new string" + + ' Use the StringBuilder. + Dim sb As New StringBuilder("**** Fantastic Games ****") + sb.Append(vbLf) + sb.AppendLine("Half Life 2") + sb.AppendLine("Beyond Good and Evil") + sb.AppendLine("Deus Ex 1 and 2") + sb.Append("System Shock") + sb.Replace("2", "Deus Ex: Invisible War") + Console.WriteLine(sb) + Console.WriteLine("sb has {0} chars.", sb.Length) + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 3/TypeConversions/My Project/Application.Designer.vb b/Code/Chapter 3/TypeConversions/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 3/TypeConversions/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 3/TypeConversions/My Project/Application.myapp b/Code/Chapter 3/TypeConversions/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 3/TypeConversions/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 3/TypeConversions/My Project/AssemblyInfo.vb b/Code/Chapter 3/TypeConversions/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..59eb1af --- /dev/null +++ b/Code/Chapter 3/TypeConversions/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/Code/Chapter 3/TypeConversions/My Project/Resources.Designer.vb b/Code/Chapter 3/TypeConversions/My Project/Resources.Designer.vb new file mode 100644 index 0000000..2c8a4ce --- /dev/null +++ b/Code/Chapter 3/TypeConversions/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("TypeConversions.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/Code/Chapter 3/TypeConversions/My Project/Resources.resx b/Code/Chapter 3/TypeConversions/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 3/TypeConversions/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/Code/Chapter 3/TypeConversions/My Project/Settings.Designer.vb b/Code/Chapter 3/TypeConversions/My Project/Settings.Designer.vb new file mode 100644 index 0000000..9539dcf --- /dev/null +++ b/Code/Chapter 3/TypeConversions/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.TypeConversions.My.MySettings + Get + Return Global.TypeConversions.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 3/TypeConversions/My Project/Settings.settings b/Code/Chapter 3/TypeConversions/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 3/TypeConversions/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 3/TypeConversions/Program.vb b/Code/Chapter 3/TypeConversions/Program.vb new file mode 100644 index 0000000..cd2e4de --- /dev/null +++ b/Code/Chapter 3/TypeConversions/Program.vb @@ -0,0 +1,25 @@ +' Option directives must be the very first code statements in a *.vb file! +Option Strict On + +Module Program + Sub Main() + Console.WriteLine("***** The Amazing Addition Program *****") + Dim a As Short = 9 + Dim b As Short = 10 + ' Nope...Dim answer As Short = Add(a, b) + Dim answer As Integer = Add(a, b) + Console.WriteLine("a + b = {0}", answer) + + Dim myByte As Byte + Dim myInt As Integer = 200 + myByte = CByte(myInt) + myByte = CType(myInt, Byte) + myByte = Convert.ToByte(myInt) + Console.WriteLine("Value of myByte: {0}", myByte) + + End Sub + + Function Add(ByVal x As Integer, ByVal y As Integer) As Integer + Return x + y + End Function +End Module diff --git a/Code/Chapter 3/TypeConversions/TypeConversions.sln b/Code/Chapter 3/TypeConversions/TypeConversions.sln new file mode 100644 index 0000000..b6f5b41 --- /dev/null +++ b/Code/Chapter 3/TypeConversions/TypeConversions.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TypeConversions", "TypeConversions.vbproj", "{A0DF5133-8279-4092-B998-95F05C019D75}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A0DF5133-8279-4092-B998-95F05C019D75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A0DF5133-8279-4092-B998-95F05C019D75}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A0DF5133-8279-4092-B998-95F05C019D75}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A0DF5133-8279-4092-B998-95F05C019D75}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 3/TypeConversions/TypeConversions.suo b/Code/Chapter 3/TypeConversions/TypeConversions.suo new file mode 100644 index 0000000..d86df7a Binary files /dev/null and b/Code/Chapter 3/TypeConversions/TypeConversions.suo differ diff --git a/Code/Chapter 3/TypeConversions/TypeConversions.vbproj b/Code/Chapter 3/TypeConversions/TypeConversions.vbproj new file mode 100644 index 0000000..49fa677 --- /dev/null +++ b/Code/Chapter 3/TypeConversions/TypeConversions.vbproj @@ -0,0 +1,139 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {A0DF5133-8279-4092-B998-95F05C019D75} + Exe + TypeConversions.Program + TypeConversions + TypeConversions + Console + On + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + TypeConversions.xml + + + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + + + pdbonly + false + true + true + bin\Release\ + TypeConversions.xml + + + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 3/TypeConversions/TypeConversions.vbproj.user b/Code/Chapter 3/TypeConversions/TypeConversions.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 3/TypeConversions/TypeConversions.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 30/CodeBehindXamlApp/MainWindow.xaml b/Code/Chapter 30/CodeBehindXamlApp/MainWindow.xaml new file mode 100644 index 0000000..aeb24a3 --- /dev/null +++ b/Code/Chapter 30/CodeBehindXamlApp/MainWindow.xaml @@ -0,0 +1,12 @@ + + + + + + diff --git a/Code/Chapter 30/CodeBehindXamlApp/MainWindow.xaml.vb b/Code/Chapter 30/CodeBehindXamlApp/MainWindow.xaml.vb new file mode 100644 index 0000000..72829e3 --- /dev/null +++ b/Code/Chapter 30/CodeBehindXamlApp/MainWindow.xaml.vb @@ -0,0 +1,21 @@ +' MainWindow.xaml.vb +Imports System +Imports System.Windows +Imports System.Windows.Controls + +Namespace SimpleXamlApp + Public Partial Class MainWindow + Inherits Window + Public Sub New() + ' Remember! This method is defined + ' within the generated MainWindow.g.vb file. + InitializeComponent() + End Sub + + Private Sub btnExitApp_Clicked(ByVal sender As Object, _ + ByVal e As RoutedEventArgs) + ' Get a handle to the current application and shut it down. + Application.Current.Shutdown() + End Sub + End Class +End Namespace diff --git a/Code/Chapter 30/CodeBehindXamlApp/MyApp.xaml b/Code/Chapter 30/CodeBehindXamlApp/MyApp.xaml new file mode 100644 index 0000000..0859eea --- /dev/null +++ b/Code/Chapter 30/CodeBehindXamlApp/MyApp.xaml @@ -0,0 +1,8 @@ + + + diff --git a/Code/Chapter 30/CodeBehindXamlApp/MyApp.xaml.vb b/Code/Chapter 30/CodeBehindXamlApp/MyApp.xaml.vb new file mode 100644 index 0000000..b313d9f --- /dev/null +++ b/Code/Chapter 30/CodeBehindXamlApp/MyApp.xaml.vb @@ -0,0 +1,13 @@ +' MyApp.xaml.vb +Imports System +Imports System.Windows +Imports System.Windows.Controls + +Namespace SimpleXamlApp + Public Partial Class MyApp + Inherits Application + Private Sub AppExit(ByVal sender As Object, ByVal e As ExitEventArgs) + MessageBox.Show("App has exited") + End Sub + End Class +End Namespace diff --git a/Code/Chapter 30/CodeBehindXamlApp/SimpleXamlApp.vbproj b/Code/Chapter 30/CodeBehindXamlApp/SimpleXamlApp.vbproj new file mode 100644 index 0000000..3630518 --- /dev/null +++ b/Code/Chapter 30/CodeBehindXamlApp/SimpleXamlApp.vbproj @@ -0,0 +1,22 @@ + + + SimpleXamlApp + SimpleXamlApp + winexe + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 30/SimpleWPFApp/SimpleWPFApp.vb b/Code/Chapter 30/SimpleWPFApp/SimpleWPFApp.vb new file mode 100644 index 0000000..f6b980c --- /dev/null +++ b/Code/Chapter 30/SimpleWPFApp/SimpleWPFApp.vb @@ -0,0 +1,62 @@ +' A simple WPF application, written without XAML or Visual Studio. +Imports System +Imports System.Windows +Imports System.Windows.Controls + +' In this first example, we are defining a single class type to +' represent the application itself and the main window. +Class MyWPFApp + Inherits Application + + _ + Shared Sub Main() + ' Handle the Startup and Exit events, and then run the application. + Dim app As New MyWPFApp() + AddHandler app.Startup, AddressOf AppStartUp + AddHandler app.Exit, AddressOf AppExit + + ' Fires the Startup event. + app.Run() + End Sub + + Shared Sub AppExit(ByVal sender As Object, ByVal e As ExitEventArgs) + MessageBox.Show("App has exited") + End Sub + + Shared Sub AppStartUp(ByVal sender As Object, ByVal e As StartupEventArgs) + ' Create a MainWindow object. + Dim wnd As new MainWindow("My better WPF App!", 200, 300) + End Sub + +End Class + +Class MainWindow + Inherits Window + ' Our UI element. + Private btnExitApp As New Button() + + Public Sub New(ByVal windowTitle As String, ByVal height As Integer, _ + ByVal width As Integer) + ' Configure button and set the child control. + AddHandler btnExitApp.Click, AddressOf btnExitApp_Clicked + btnExitApp.Content = "Exit Application" + btnExitApp.Height = 25 + btnExitApp.Width = 100 + + ' Set the content of this window to a single button. + Me.AddChild(btnExitApp) + + ' Configure the window. + Me.Title = windowTitle + Me.WindowStartupLocation = WindowStartupLocation.CenterScreen + Me.Height = height + Me.Width = width + Me.Show() + End Sub + + Sub btnExitApp_Clicked(ByVal sender As Object, ByVal e As RoutedEventArgs) + ' Get a handle to the current application and shut it down. + Application.Current.Shutdown() + End Sub +End Class + diff --git a/Code/Chapter 30/SimpleWPFApp/build.rsp b/Code/Chapter 30/SimpleWPFApp/build.rsp new file mode 100644 index 0000000..4961de7 --- /dev/null +++ b/Code/Chapter 30/SimpleWPFApp/build.rsp @@ -0,0 +1,8 @@ +# build.rsp +# +/target:winexe +/out:SimpleWPFApp.exe +/r:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\WindowsBase.dll" +/r:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationCore.dll" +/r:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll" +*.vb diff --git a/Code/Chapter 30/SimpleWPFAppRevisited/SimpleWPFApp.vb b/Code/Chapter 30/SimpleWPFAppRevisited/SimpleWPFApp.vb new file mode 100644 index 0000000..ecc1304 --- /dev/null +++ b/Code/Chapter 30/SimpleWPFAppRevisited/SimpleWPFApp.vb @@ -0,0 +1,126 @@ +' A simple WPF application, written without XAML. +Imports System +Imports System.Windows +Imports System.Windows.Controls + +' In this first example, we are defining a single class type to +' represent the application itself and the main window. +Public Class MyWPFApp + Inherits Application + _ + Public Shared Sub Main() + ' Handle the Startup and Exit events, and then run the application. + Dim app As New MyWPFApp() + AddHandler app.Startup, AddressOf AppStartUp + AddHandler app.Exit, AddressOf AppExit + ' Fires the Startup event. + app.Run() + End Sub + + Shared Sub AppExit(ByVal sender As Object, ByVal e As ExitEventArgs) + MessageBox.Show("App has exited") + End Sub + + Shared Sub AppStartUp(ByVal sender As Object, ByVal e As StartupEventArgs) + ' Check the incoming command-line arguments and see if they + ' specified a flag for /GODMODE. + Application.Current.Properties("GodMode") = False + For Each arg As String In e.Args + If arg.ToLower() = "/godmode" Then + Application.Current.Properties("GodMode") = True + Exit For + End If + Next + + ' Create a MainWindow object. + Dim wnd As New MainWindow("My better WPF App!", 200, 300) + End Sub + +End Class + +Class MainWindow + Inherits Window + Private btnExitApp As New Button() + + ' This string will document which events fire, and when. + Private lifeTimeData As String = String.Empty + + Protected Sub MainWindow_Activated(ByVal sender As Object, ByVal e As EventArgs) + lifeTimeData &= "Activate Event Fired!" & vbLf + End Sub + Protected Sub MainWindow_Deactivated(ByVal sender As Object, ByVal e As EventArgs) + lifeTimeData &= "Deactivated Event Fired!" & vbLf + End Sub + Protected Sub MainWindow_Loaded(ByVal sender As Object, ByVal e As EventArgs) + lifeTimeData &= "Loaded Event Fired!" & vbLf + End Sub + + Protected Sub MainWindow_Closing(ByVal sender As Object, _ + ByVal e As System.ComponentModel.CancelEventArgs) + lifeTimeData &= "Closing Event Fired!" & vbLf + + ' See if the user really wants to shut down this window. + Dim msg As String = "Do you want to close without saving?" + Dim result As MessageBoxResult = MessageBox.Show(msg, _ + "My App", MessageBoxButton.YesNo, MessageBoxImage.Warning) + If result = MessageBoxResult.No Then + ' If user doesn't want to close, cancel closure. + e.Cancel = True + End If + End Sub + + Protected Sub MainWindow_MouseMove(ByVal sender As Object, _ + ByVal e As System.Windows.Input.MouseEventArgs) + ' Set the title of the window to the current X,Y of the mouse. + Me.Title = e.GetPosition(Me).ToString() + End Sub + + Protected Sub MainWindow_Closed(ByVal sender As Object, ByVal e As EventArgs) + lifeTimeData &= "Closed Event Fired!" & vbLf + MessageBox.Show(lifeTimeData) + End Sub + + Protected Sub MainWindow_KeyUp(ByVal sender As Object, _ + ByVal e As System.Windows.Input. KeyEventArgs) + ' Display keypress. + Me.Title = e.Key.ToString() + End Sub + + Public Sub New(ByVal windowTitle As String, ByVal height As Integer, _ + ByVal width As Integer) + ' Rig up events. + AddHandler Me.Activated, AddressOf MainWindow_Activated + AddHandler Me.Deactivated, AddressOf MainWindow_Deactivated + AddHandler btnExitApp.Click, AddressOf btnExitApp_Clicked + AddHandler Me.Closing, AddressOf MainWindow_Closing + AddHandler Me.Closed, AddressOf MainWindow_Closed + AddHandler Me.MouseMove, AddressOf MainWindow_MouseMove + AddHandler Me.KeyUp, AddressOf MainWindow_KeyUp + + ' Configure button and set the child control. + btnExitApp.Content = "Exit Application" + btnExitApp.Height = 25 + btnExitApp.Width = 100 + + ' Set the content of this window to a single button. + Me.AddChild(btnExitApp) + + ' Configure the window. + Me.Title = windowTitle + Me.WindowStartupLocation = WindowStartupLocation.CenterScreen + Me.Height = height + Me.Width = width + Me.Show() + End Sub + + Sub btnExitApp_Clicked(ByVal sender As Object, ByVal e As RoutedEventArgs) + ' Did user enable /godmode? + If CBool(Application.Current.Properties("GodMode")) Then + MessageBox.Show("Cheater!") + End If + + ' Get a handle to the current application and shut it down. + ' Application.Current.Shutdown() + Me.Close() + End Sub +End Class diff --git a/Code/Chapter 30/SimpleWPFAppRevisited/build.rsp b/Code/Chapter 30/SimpleWPFAppRevisited/build.rsp new file mode 100644 index 0000000..4961de7 --- /dev/null +++ b/Code/Chapter 30/SimpleWPFAppRevisited/build.rsp @@ -0,0 +1,8 @@ +# build.rsp +# +/target:winexe +/out:SimpleWPFApp.exe +/r:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\WindowsBase.dll" +/r:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationCore.dll" +/r:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll" +*.vb diff --git a/Code/Chapter 30/SimpleXamlApp/MainWindow.xaml b/Code/Chapter 30/SimpleXamlApp/MainWindow.xaml new file mode 100644 index 0000000..40dd2fd --- /dev/null +++ b/Code/Chapter 30/SimpleXamlApp/MainWindow.xaml @@ -0,0 +1,22 @@ + + + + + + + + + + + diff --git a/Code/Chapter 30/SimpleXamlApp/MyApp.xaml b/Code/Chapter 30/SimpleXamlApp/MyApp.xaml new file mode 100644 index 0000000..4f2d7b5 --- /dev/null +++ b/Code/Chapter 30/SimpleXamlApp/MyApp.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/Code/Chapter 30/SimpleXamlApp/SimpleXamlApp.vbproj b/Code/Chapter 30/SimpleXamlApp/SimpleXamlApp.vbproj new file mode 100644 index 0000000..86f5ed0 --- /dev/null +++ b/Code/Chapter 30/SimpleXamlApp/SimpleXamlApp.vbproj @@ -0,0 +1,31 @@ + + + SimpleXamlApp + SimpleXamlApp + winexe + v3.0 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + + + 2.0 + + + + + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + + \ No newline at end of file diff --git a/Code/Chapter 30/SimpleXamlPad/SimpleXamlPad.sln b/Code/Chapter 30/SimpleXamlPad/SimpleXamlPad.sln new file mode 100644 index 0000000..8c6a9d6 --- /dev/null +++ b/Code/Chapter 30/SimpleXamlPad/SimpleXamlPad.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SimpleXamlPad", "SimpleXamlPad\SimpleXamlPad.vbproj", "{6A2390B6-3664-4F7D-844C-18598589A1E3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6A2390B6-3664-4F7D-844C-18598589A1E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6A2390B6-3664-4F7D-844C-18598589A1E3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6A2390B6-3664-4F7D-844C-18598589A1E3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6A2390B6-3664-4F7D-844C-18598589A1E3}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 30/SimpleXamlPad/SimpleXamlPad.suo b/Code/Chapter 30/SimpleXamlPad/SimpleXamlPad.suo new file mode 100644 index 0000000..158e37a Binary files /dev/null and b/Code/Chapter 30/SimpleXamlPad/SimpleXamlPad.suo differ diff --git a/Code/Chapter 30/SimpleXamlPad/SimpleXamlPad/Application.xaml b/Code/Chapter 30/SimpleXamlPad/SimpleXamlPad/Application.xaml new file mode 100644 index 0000000..ff7991a --- /dev/null +++ b/Code/Chapter 30/SimpleXamlPad/SimpleXamlPad/Application.xaml @@ -0,0 +1,8 @@ + + + + + diff --git a/Code/Chapter 30/SimpleXamlPad/SimpleXamlPad/Application.xaml.vb b/Code/Chapter 30/SimpleXamlPad/SimpleXamlPad/Application.xaml.vb new file mode 100644 index 0000000..084cbe9 --- /dev/null +++ b/Code/Chapter 30/SimpleXamlPad/SimpleXamlPad/Application.xaml.vb @@ -0,0 +1,6 @@ +Class Application + + ' Application-level events, such as Startup, Exit, and DispatcherUnhandledException + ' can be handled in this file. + +End Class diff --git a/Code/Chapter 30/SimpleXamlPad/SimpleXamlPad/MainWindow.xaml b/Code/Chapter 30/SimpleXamlPad/SimpleXamlPad/MainWindow.xaml new file mode 100644 index 0000000..7dfe622 --- /dev/null +++ b/Code/Chapter 30/SimpleXamlPad/SimpleXamlPad/MainWindow.xaml @@ -0,0 +1,21 @@ + + + + + + + + diff --git a/Code/Chapter 31/ControlReview/MainWindow.xaml.vb b/Code/Chapter 31/ControlReview/MainWindow.xaml.vb new file mode 100644 index 0000000..f1aeadf --- /dev/null +++ b/Code/Chapter 31/ControlReview/MainWindow.xaml.vb @@ -0,0 +1,15 @@ +Class MainWindow + Sub New() + InitializeComponent() + ' Change FontSize of Label. + lblInstructions.FontSize = 14 + End Sub + + Private Sub btnPurchaseOptions_Click(ByVal sender As System.Object, _ + ByVal e As System.Windows.RoutedEventArgs) Handles btnPurchaseOptions.Click + MessageBox.Show("Button has been clicked") + End Sub + +End Class + + diff --git a/Code/Chapter 31/ControlReview/My Project/AssemblyInfo.vb b/Code/Chapter 31/ControlReview/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..1224aa6 --- /dev/null +++ b/Code/Chapter 31/ControlReview/My Project/AssemblyInfo.vb @@ -0,0 +1,59 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices +Imports System.Globalization +Imports System.Resources +Imports System.Windows + +' 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 + + + + + + + + + +'In order to begin building localizable applications, set +'CultureYouAreCodingWith in your .vbproj file +'inside a . For example, if you are using US english +'in your source files, set the to "en-US". Then uncomment the +'NeutralResourceLanguage attribute below. Update the "en-US" in the line +'below to match the UICulture setting in the project file. + +' + + +'The ThemeInfo attribute describes where any theme specific and generic resource dictionaries can be found. +'1st parameter: where theme specific resource dictionaries are located +'(used if a resource is not found in the page, +' or application resource dictionaries) + +'2nd parameter: where the generic resource dictionary is located +'(used if a resource is not found in the page, +'app, and any theme specific resource dictionaries) + + + + +'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/Code/Chapter 31/ControlReview/My Project/MyExtensions/MyWpfExtension.vb b/Code/Chapter 31/ControlReview/My Project/MyExtensions/MyWpfExtension.vb new file mode 100644 index 0000000..739db0e --- /dev/null +++ b/Code/Chapter 31/ControlReview/My Project/MyExtensions/MyWpfExtension.vb @@ -0,0 +1,121 @@ +#If _MyType <> "Empty" Then + +Namespace My + ''' + ''' Module used to define the properties that are available in the My Namespace for WPF + ''' + ''' + _ + Module MyWpfExtension + Private s_Computer As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Devices.Computer) + Private s_User As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.ApplicationServices.User) + Private s_Windows As New ThreadSafeObjectProvider(Of MyWindows) + Private s_Log As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Logging.Log) + ''' + ''' Returns the application object for the running application + ''' + _ + Friend ReadOnly Property Application() As Application + Get + Return Global.System.Windows.Application.Current + End Get + End Property + ''' + ''' Returns information about the host computer. + ''' + _ + Friend ReadOnly Property Computer() As Global.Microsoft.VisualBasic.Devices.Computer + Get + Return s_Computer.GetInstance() + End Get + End Property + ''' + ''' Returns information for the current user. If you wish to run the application with the current + ''' Windows user credentials, call My.User.InitializeWithWindowsUser(). + ''' + _ + Friend ReadOnly Property User() As Global.Microsoft.VisualBasic.ApplicationServices.User + Get + Return s_User.GetInstance() + End Get + End Property + ''' + ''' Returns the application log. The listeners can be configured by the application's configuration file. + ''' + _ + Friend ReadOnly Property Log() As Global.Microsoft.VisualBasic.Logging.Log + Get + Return s_Log.GetInstance() + End Get + End Property + + ''' + ''' Returns the collection of Windows defined in the project. + ''' + _ + Friend ReadOnly Property Windows() As MyWindows + _ + Get + Return s_Windows.GetInstance() + End Get + End Property + _ + _ + Friend NotInheritable Class MyWindows + _ + Private Shared Function Create__Instance__(Of T As {New, Global.System.Windows.Window})(ByVal Instance As T) As T + If Instance Is Nothing Then + If s_WindowBeingCreated IsNot Nothing Then + If s_WindowBeingCreated.ContainsKey(GetType(T)) = True Then + Throw New Global.System.InvalidOperationException("The window cannot be accessed via My.Windows from the Window constructor.") + End If + Else + s_WindowBeingCreated = New Global.System.Collections.Hashtable() + End If + s_WindowBeingCreated.Add(GetType(T), Nothing) + Return New T() + s_WindowBeingCreated.Remove(GetType(T)) + Else + Return Instance + End If + End Function + _ + _ + Private Sub Dispose__Instance__(Of T As Global.System.Windows.Window)(ByRef instance As T) + instance = Nothing + End Sub + _ + _ + Public Sub New() + MyBase.New() + End Sub + Private Shared s_WindowBeingCreated As Global.System.Collections.Hashtable + Public Overrides Function Equals(ByVal o As Object) As Boolean + Return MyBase.Equals(o) + End Function + Public Overrides Function GetHashCode() As Integer + Return MyBase.GetHashCode + End Function + _ + _ + Friend Overloads Function [GetType]() As Global.System.Type + Return GetType(MyWindows) + End Function + Public Overrides Function ToString() As String + Return MyBase.ToString + End Function + End Class + End Module +End Namespace +Partial Class Application + Inherits Global.System.Windows.Application + _ + _ + Friend ReadOnly Property Info() As Global.Microsoft.VisualBasic.ApplicationServices.AssemblyInfo + _ + Get + Return New Global.Microsoft.VisualBasic.ApplicationServices.AssemblyInfo(Global.System.Reflection.Assembly.GetExecutingAssembly()) + End Get + End Property +End Class +#End If \ No newline at end of file diff --git a/Code/Chapter 31/ControlReview/My Project/Resources.Designer.vb b/Code/Chapter 31/ControlReview/My Project/Resources.Designer.vb new file mode 100644 index 0000000..e4a5560 --- /dev/null +++ b/Code/Chapter 31/ControlReview/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:$clrversion$ +' +' 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("$safeprojectname$.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/Code/Chapter 31/ControlReview/My Project/Resources.resx b/Code/Chapter 31/ControlReview/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 31/ControlReview/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/Code/Chapter 31/ControlReview/My Project/Settings.Designer.vb b/Code/Chapter 31/ControlReview/My Project/Settings.Designer.vb new file mode 100644 index 0000000..8fcd7d7 --- /dev/null +++ b/Code/Chapter 31/ControlReview/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.ControlReview.My.MySettings + Get + Return Global.ControlReview.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 31/ControlReview/My Project/Settings.settings b/Code/Chapter 31/ControlReview/My Project/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/Code/Chapter 31/ControlReview/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 31/CustomSpinButtonApp/Application.xaml b/Code/Chapter 31/CustomSpinButtonApp/Application.xaml new file mode 100644 index 0000000..ff7991a --- /dev/null +++ b/Code/Chapter 31/CustomSpinButtonApp/Application.xaml @@ -0,0 +1,8 @@ + + + + + diff --git a/Code/Chapter 31/CustomSpinButtonApp/Application.xaml.vb b/Code/Chapter 31/CustomSpinButtonApp/Application.xaml.vb new file mode 100644 index 0000000..084cbe9 --- /dev/null +++ b/Code/Chapter 31/CustomSpinButtonApp/Application.xaml.vb @@ -0,0 +1,6 @@ +Class Application + + ' Application-level events, such as Startup, Exit, and DispatcherUnhandledException + ' can be handled in this file. + +End Class diff --git a/Code/Chapter 31/CustomSpinButtonApp/CustomSpinButtonApp.sln b/Code/Chapter 31/CustomSpinButtonApp/CustomSpinButtonApp.sln new file mode 100644 index 0000000..18bff55 --- /dev/null +++ b/Code/Chapter 31/CustomSpinButtonApp/CustomSpinButtonApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CustomSpinButtonApp", "CustomSpinButtonApp.vbproj", "{0A433A1D-0A60-45ED-B590-0FA448FBB6BD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0A433A1D-0A60-45ED-B590-0FA448FBB6BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0A433A1D-0A60-45ED-B590-0FA448FBB6BD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0A433A1D-0A60-45ED-B590-0FA448FBB6BD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0A433A1D-0A60-45ED-B590-0FA448FBB6BD}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 31/CustomSpinButtonApp/CustomSpinButtonApp.suo b/Code/Chapter 31/CustomSpinButtonApp/CustomSpinButtonApp.suo new file mode 100644 index 0000000..7ef6248 Binary files /dev/null and b/Code/Chapter 31/CustomSpinButtonApp/CustomSpinButtonApp.suo differ diff --git a/Code/Chapter 31/CustomSpinButtonApp/CustomSpinButtonApp.vbproj b/Code/Chapter 31/CustomSpinButtonApp/CustomSpinButtonApp.vbproj new file mode 100644 index 0000000..ff3a320 --- /dev/null +++ b/Code/Chapter 31/CustomSpinButtonApp/CustomSpinButtonApp.vbproj @@ -0,0 +1,127 @@ + + + Debug + AnyCPU + {0A433A1D-0A60-45ED-B590-0FA448FBB6BD} + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + WinExe + CustomSpinButtonApp + CustomSpinButtonApp + v3.5 + Custom + On + Binary + Off + On + + + true + full + true + true + true + bin\Debug\ + CustomSpinButtonApp.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + false + false + true + false + true + bin\Release\ + CustomSpinButtonApp.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + + 3.5 + + + 3.5 + + + 3.5 + + + 3.0 + + + 3.0 + + + 3.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Application.xaml + Code + + + MainWindow.xaml + Code + + + + + + + + + + + + + + + + + + + + + + + Code + + + Microsoft.VisualBasic.WPF.MyExtension + 1.0.0.0 + + + True + True + Resources.resx + + + True + Settings.settings + True + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + SettingsSingleFileGenerator + Settings.Designer.vb + + + + + \ No newline at end of file diff --git a/Code/Chapter 31/CustomSpinButtonApp/MainWindow.xaml b/Code/Chapter 31/CustomSpinButtonApp/MainWindow.xaml new file mode 100644 index 0000000..722d948 --- /dev/null +++ b/Code/Chapter 31/CustomSpinButtonApp/MainWindow.xaml @@ -0,0 +1,21 @@ + + + + + + + + diff --git a/Code/Chapter 31/CustomSpinButtonApp/MainWindow.xaml.vb b/Code/Chapter 31/CustomSpinButtonApp/MainWindow.xaml.vb new file mode 100644 index 0000000..0ff71c4 --- /dev/null +++ b/Code/Chapter 31/CustomSpinButtonApp/MainWindow.xaml.vb @@ -0,0 +1,19 @@ +Class MainWindow + Private currValue As Integer = 0 + + Public Sub New() + InitializeComponent() + lblCurrentValue.Content = currValue + End Sub + Protected Sub repeatAddValueButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) + ' Add 1 to the current value and show in label. + currValue += 1 + lblCurrentValue.Content = currValue + End Sub + + Protected Sub repeatRemoveValueButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) + ' Subtract 1 from the current value and show in label. + currValue -= 1 + lblCurrentValue.Content = currValue + End Sub +End Class diff --git a/Code/Chapter 31/CustomSpinButtonApp/My Project/AssemblyInfo.vb b/Code/Chapter 31/CustomSpinButtonApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..1dbccbc --- /dev/null +++ b/Code/Chapter 31/CustomSpinButtonApp/My Project/AssemblyInfo.vb @@ -0,0 +1,59 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices +Imports System.Globalization +Imports System.Resources +Imports System.Windows + +' 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 + + + + + + + + + +'In order to begin building localizable applications, set +'CultureYouAreCodingWith in your .vbproj file +'inside a . For example, if you are using US english +'in your source files, set the to "en-US". Then uncomment the +'NeutralResourceLanguage attribute below. Update the "en-US" in the line +'below to match the UICulture setting in the project file. + +' + + +'The ThemeInfo attribute describes where any theme specific and generic resource dictionaries can be found. +'1st parameter: where theme specific resource dictionaries are located +'(used if a resource is not found in the page, +' or application resource dictionaries) + +'2nd parameter: where the generic resource dictionary is located +'(used if a resource is not found in the page, +'app, and any theme specific resource dictionaries) + + + + +'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/Code/Chapter 31/CustomSpinButtonApp/My Project/MyExtensions/MyWpfExtension.vb b/Code/Chapter 31/CustomSpinButtonApp/My Project/MyExtensions/MyWpfExtension.vb new file mode 100644 index 0000000..739db0e --- /dev/null +++ b/Code/Chapter 31/CustomSpinButtonApp/My Project/MyExtensions/MyWpfExtension.vb @@ -0,0 +1,121 @@ +#If _MyType <> "Empty" Then + +Namespace My + ''' + ''' Module used to define the properties that are available in the My Namespace for WPF + ''' + ''' + _ + Module MyWpfExtension + Private s_Computer As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Devices.Computer) + Private s_User As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.ApplicationServices.User) + Private s_Windows As New ThreadSafeObjectProvider(Of MyWindows) + Private s_Log As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Logging.Log) + ''' + ''' Returns the application object for the running application + ''' + _ + Friend ReadOnly Property Application() As Application + Get + Return Global.System.Windows.Application.Current + End Get + End Property + ''' + ''' Returns information about the host computer. + ''' + _ + Friend ReadOnly Property Computer() As Global.Microsoft.VisualBasic.Devices.Computer + Get + Return s_Computer.GetInstance() + End Get + End Property + ''' + ''' Returns information for the current user. If you wish to run the application with the current + ''' Windows user credentials, call My.User.InitializeWithWindowsUser(). + ''' + _ + Friend ReadOnly Property User() As Global.Microsoft.VisualBasic.ApplicationServices.User + Get + Return s_User.GetInstance() + End Get + End Property + ''' + ''' Returns the application log. The listeners can be configured by the application's configuration file. + ''' + _ + Friend ReadOnly Property Log() As Global.Microsoft.VisualBasic.Logging.Log + Get + Return s_Log.GetInstance() + End Get + End Property + + ''' + ''' Returns the collection of Windows defined in the project. + ''' + _ + Friend ReadOnly Property Windows() As MyWindows + _ + Get + Return s_Windows.GetInstance() + End Get + End Property + _ + _ + Friend NotInheritable Class MyWindows + _ + Private Shared Function Create__Instance__(Of T As {New, Global.System.Windows.Window})(ByVal Instance As T) As T + If Instance Is Nothing Then + If s_WindowBeingCreated IsNot Nothing Then + If s_WindowBeingCreated.ContainsKey(GetType(T)) = True Then + Throw New Global.System.InvalidOperationException("The window cannot be accessed via My.Windows from the Window constructor.") + End If + Else + s_WindowBeingCreated = New Global.System.Collections.Hashtable() + End If + s_WindowBeingCreated.Add(GetType(T), Nothing) + Return New T() + s_WindowBeingCreated.Remove(GetType(T)) + Else + Return Instance + End If + End Function + _ + _ + Private Sub Dispose__Instance__(Of T As Global.System.Windows.Window)(ByRef instance As T) + instance = Nothing + End Sub + _ + _ + Public Sub New() + MyBase.New() + End Sub + Private Shared s_WindowBeingCreated As Global.System.Collections.Hashtable + Public Overrides Function Equals(ByVal o As Object) As Boolean + Return MyBase.Equals(o) + End Function + Public Overrides Function GetHashCode() As Integer + Return MyBase.GetHashCode + End Function + _ + _ + Friend Overloads Function [GetType]() As Global.System.Type + Return GetType(MyWindows) + End Function + Public Overrides Function ToString() As String + Return MyBase.ToString + End Function + End Class + End Module +End Namespace +Partial Class Application + Inherits Global.System.Windows.Application + _ + _ + Friend ReadOnly Property Info() As Global.Microsoft.VisualBasic.ApplicationServices.AssemblyInfo + _ + Get + Return New Global.Microsoft.VisualBasic.ApplicationServices.AssemblyInfo(Global.System.Reflection.Assembly.GetExecutingAssembly()) + End Get + End Property +End Class +#End If \ No newline at end of file diff --git a/Code/Chapter 31/CustomSpinButtonApp/My Project/Resources.Designer.vb b/Code/Chapter 31/CustomSpinButtonApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..e4a5560 --- /dev/null +++ b/Code/Chapter 31/CustomSpinButtonApp/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:$clrversion$ +' +' 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("$safeprojectname$.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/Code/Chapter 31/CustomSpinButtonApp/My Project/Resources.resx b/Code/Chapter 31/CustomSpinButtonApp/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 31/CustomSpinButtonApp/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/Code/Chapter 31/CustomSpinButtonApp/My Project/Settings.Designer.vb b/Code/Chapter 31/CustomSpinButtonApp/My Project/Settings.Designer.vb new file mode 100644 index 0000000..5e16fb1 --- /dev/null +++ b/Code/Chapter 31/CustomSpinButtonApp/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CustomSpinButtonApp.My.MySettings + Get + Return Global.CustomSpinButtonApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 31/CustomSpinButtonApp/My Project/Settings.settings b/Code/Chapter 31/CustomSpinButtonApp/My Project/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/Code/Chapter 31/CustomSpinButtonApp/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 31/GridWithSplitter.xaml b/Code/Chapter 31/GridWithSplitter.xaml new file mode 100644 index 0000000..ce36114 --- /dev/null +++ b/Code/Chapter 31/GridWithSplitter.xaml @@ -0,0 +1,22 @@ + + + + + + + + + + + diff --git a/Code/Chapter 31/ListControls/Application.xaml b/Code/Chapter 31/ListControls/Application.xaml new file mode 100644 index 0000000..ff7991a --- /dev/null +++ b/Code/Chapter 31/ListControls/Application.xaml @@ -0,0 +1,8 @@ + + + + + diff --git a/Code/Chapter 31/ListControls/Application.xaml.vb b/Code/Chapter 31/ListControls/Application.xaml.vb new file mode 100644 index 0000000..084cbe9 --- /dev/null +++ b/Code/Chapter 31/ListControls/Application.xaml.vb @@ -0,0 +1,6 @@ +Class Application + + ' Application-level events, such as Startup, Exit, and DispatcherUnhandledException + ' can be handled in this file. + +End Class diff --git a/Code/Chapter 31/ListControls/ListControls.sln b/Code/Chapter 31/ListControls/ListControls.sln new file mode 100644 index 0000000..94a8561 --- /dev/null +++ b/Code/Chapter 31/ListControls/ListControls.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ListControls", "ListControls.vbproj", "{ECB266C7-A870-4FAC-B675-55B6ED740DB7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {ECB266C7-A870-4FAC-B675-55B6ED740DB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ECB266C7-A870-4FAC-B675-55B6ED740DB7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ECB266C7-A870-4FAC-B675-55B6ED740DB7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ECB266C7-A870-4FAC-B675-55B6ED740DB7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 31/ListControls/ListControls.suo b/Code/Chapter 31/ListControls/ListControls.suo new file mode 100644 index 0000000..669c089 Binary files /dev/null and b/Code/Chapter 31/ListControls/ListControls.suo differ diff --git a/Code/Chapter 31/ListControls/ListControls.vbproj b/Code/Chapter 31/ListControls/ListControls.vbproj new file mode 100644 index 0000000..6214cf2 --- /dev/null +++ b/Code/Chapter 31/ListControls/ListControls.vbproj @@ -0,0 +1,127 @@ + + + Debug + AnyCPU + {ECB266C7-A870-4FAC-B675-55B6ED740DB7} + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + WinExe + ListControls + ListControls + v3.5 + Custom + On + Binary + Off + On + + + true + full + true + true + true + bin\Debug\ + ListControls.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + false + false + true + false + true + bin\Release\ + ListControls.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + + 3.5 + + + 3.5 + + + 3.5 + + + 3.0 + + + 3.0 + + + 3.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Application.xaml + Code + + + MainWindow.xaml + Code + + + + + + + + + + + + + + + + + + + + + + + Code + + + Microsoft.VisualBasic.WPF.MyExtension + 1.0.0.0 + + + True + True + Resources.resx + + + True + Settings.settings + True + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + SettingsSingleFileGenerator + Settings.Designer.vb + + + + + \ No newline at end of file diff --git a/Code/Chapter 31/ListControls/MainWindow.xaml b/Code/Chapter 31/ListControls/MainWindow.xaml new file mode 100644 index 0000000..c50a097 --- /dev/null +++ b/Code/Chapter 31/ListControls/MainWindow.xaml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 31/ListControls/MainWindow.xaml.vb b/Code/Chapter 31/ListControls/MainWindow.xaml.vb new file mode 100644 index 0000000..3f9f7cf --- /dev/null +++ b/Code/Chapter 31/ListControls/MainWindow.xaml.vb @@ -0,0 +1,38 @@ +Class MainWindow + + Public Sub New() + InitializeComponent() + + FillListBox() + End Sub + + Private Sub FillListBox() + ' Add items to the list box. + lstVideoGameConsoles.Items.Add("Microsoft XBox 360") + lstVideoGameConsoles.Items.Add("Sony Playstation 3") + lstVideoGameConsoles.Items.Add("Nintendo Wii") + lstVideoGameConsoles.Items.Add("Sony PSP") + lstVideoGameConsoles.Items.Add("Nintendo DS") + End Sub + + Private Sub btnGetGameSystem_Click(ByVal sender As System.Object, _ + ByVal e As System.Windows.RoutedEventArgs) + Dim data As String = String.Empty + data &= String.Format("SelectedIndex = {0}" & vbLf, _ + lstVideoGameConsoles.SelectedIndex) + data &= String.Format("SelectedItem = {0}" & vbLf, _ + lstVideoGameConsoles.SelectedItem) + data &= String.Format("SelectedValue = {0}" & vbLf, _ + lstVideoGameConsoles.SelectedValue) + MessageBox.Show(data, "Your Game Info") + End Sub + + Protected Sub btnGetColor_Click(ByVal sender As Object, ByVal args As RoutedEventArgs) + Dim data As String = String.Empty + data &= String.Format("SelectedIndex = {0}" & vbLf, lstColors.SelectedIndex) + data &= String.Format("SelectedItem = {0}" & vbLf, lstColors.SelectedItem) + data &= String.Format("SelectedValue = {0}", _ + TryCast(lstColors.Items(lstColors.SelectedIndex), StackPanel).Tag) + MessageBox.Show(data, "Your Color Info") + End Sub +End Class diff --git a/Code/Chapter 31/ListControls/My Project/AssemblyInfo.vb b/Code/Chapter 31/ListControls/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..b10af42 --- /dev/null +++ b/Code/Chapter 31/ListControls/My Project/AssemblyInfo.vb @@ -0,0 +1,59 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices +Imports System.Globalization +Imports System.Resources +Imports System.Windows + +' 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 + + + + + + + + + +'In order to begin building localizable applications, set +'CultureYouAreCodingWith in your .vbproj file +'inside a . For example, if you are using US english +'in your source files, set the to "en-US". Then uncomment the +'NeutralResourceLanguage attribute below. Update the "en-US" in the line +'below to match the UICulture setting in the project file. + +' + + +'The ThemeInfo attribute describes where any theme specific and generic resource dictionaries can be found. +'1st parameter: where theme specific resource dictionaries are located +'(used if a resource is not found in the page, +' or application resource dictionaries) + +'2nd parameter: where the generic resource dictionary is located +'(used if a resource is not found in the page, +'app, and any theme specific resource dictionaries) + + + + +'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/Code/Chapter 31/ListControls/My Project/MyExtensions/MyWpfExtension.vb b/Code/Chapter 31/ListControls/My Project/MyExtensions/MyWpfExtension.vb new file mode 100644 index 0000000..739db0e --- /dev/null +++ b/Code/Chapter 31/ListControls/My Project/MyExtensions/MyWpfExtension.vb @@ -0,0 +1,121 @@ +#If _MyType <> "Empty" Then + +Namespace My + ''' + ''' Module used to define the properties that are available in the My Namespace for WPF + ''' + ''' + _ + Module MyWpfExtension + Private s_Computer As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Devices.Computer) + Private s_User As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.ApplicationServices.User) + Private s_Windows As New ThreadSafeObjectProvider(Of MyWindows) + Private s_Log As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Logging.Log) + ''' + ''' Returns the application object for the running application + ''' + _ + Friend ReadOnly Property Application() As Application + Get + Return Global.System.Windows.Application.Current + End Get + End Property + ''' + ''' Returns information about the host computer. + ''' + _ + Friend ReadOnly Property Computer() As Global.Microsoft.VisualBasic.Devices.Computer + Get + Return s_Computer.GetInstance() + End Get + End Property + ''' + ''' Returns information for the current user. If you wish to run the application with the current + ''' Windows user credentials, call My.User.InitializeWithWindowsUser(). + ''' + _ + Friend ReadOnly Property User() As Global.Microsoft.VisualBasic.ApplicationServices.User + Get + Return s_User.GetInstance() + End Get + End Property + ''' + ''' Returns the application log. The listeners can be configured by the application's configuration file. + ''' + _ + Friend ReadOnly Property Log() As Global.Microsoft.VisualBasic.Logging.Log + Get + Return s_Log.GetInstance() + End Get + End Property + + ''' + ''' Returns the collection of Windows defined in the project. + ''' + _ + Friend ReadOnly Property Windows() As MyWindows + _ + Get + Return s_Windows.GetInstance() + End Get + End Property + _ + _ + Friend NotInheritable Class MyWindows + _ + Private Shared Function Create__Instance__(Of T As {New, Global.System.Windows.Window})(ByVal Instance As T) As T + If Instance Is Nothing Then + If s_WindowBeingCreated IsNot Nothing Then + If s_WindowBeingCreated.ContainsKey(GetType(T)) = True Then + Throw New Global.System.InvalidOperationException("The window cannot be accessed via My.Windows from the Window constructor.") + End If + Else + s_WindowBeingCreated = New Global.System.Collections.Hashtable() + End If + s_WindowBeingCreated.Add(GetType(T), Nothing) + Return New T() + s_WindowBeingCreated.Remove(GetType(T)) + Else + Return Instance + End If + End Function + _ + _ + Private Sub Dispose__Instance__(Of T As Global.System.Windows.Window)(ByRef instance As T) + instance = Nothing + End Sub + _ + _ + Public Sub New() + MyBase.New() + End Sub + Private Shared s_WindowBeingCreated As Global.System.Collections.Hashtable + Public Overrides Function Equals(ByVal o As Object) As Boolean + Return MyBase.Equals(o) + End Function + Public Overrides Function GetHashCode() As Integer + Return MyBase.GetHashCode + End Function + _ + _ + Friend Overloads Function [GetType]() As Global.System.Type + Return GetType(MyWindows) + End Function + Public Overrides Function ToString() As String + Return MyBase.ToString + End Function + End Class + End Module +End Namespace +Partial Class Application + Inherits Global.System.Windows.Application + _ + _ + Friend ReadOnly Property Info() As Global.Microsoft.VisualBasic.ApplicationServices.AssemblyInfo + _ + Get + Return New Global.Microsoft.VisualBasic.ApplicationServices.AssemblyInfo(Global.System.Reflection.Assembly.GetExecutingAssembly()) + End Get + End Property +End Class +#End If \ No newline at end of file diff --git a/Code/Chapter 31/ListControls/My Project/Resources.Designer.vb b/Code/Chapter 31/ListControls/My Project/Resources.Designer.vb new file mode 100644 index 0000000..e4a5560 --- /dev/null +++ b/Code/Chapter 31/ListControls/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:$clrversion$ +' +' 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("$safeprojectname$.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/Code/Chapter 31/ListControls/My Project/Resources.resx b/Code/Chapter 31/ListControls/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 31/ListControls/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/Code/Chapter 31/ListControls/My Project/Settings.Designer.vb b/Code/Chapter 31/ListControls/My Project/Settings.Designer.vb new file mode 100644 index 0000000..4f400fc --- /dev/null +++ b/Code/Chapter 31/ListControls/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.ListControls.My.MySettings + Get + Return Global.ListControls.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 31/ListControls/My Project/Settings.settings b/Code/Chapter 31/ListControls/My Project/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/Code/Chapter 31/ListControls/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 31/MySpellChecker/Application.xaml b/Code/Chapter 31/MySpellChecker/Application.xaml new file mode 100644 index 0000000..ff7991a --- /dev/null +++ b/Code/Chapter 31/MySpellChecker/Application.xaml @@ -0,0 +1,8 @@ + + + + + diff --git a/Code/Chapter 31/MySpellChecker/Application.xaml.vb b/Code/Chapter 31/MySpellChecker/Application.xaml.vb new file mode 100644 index 0000000..084cbe9 --- /dev/null +++ b/Code/Chapter 31/MySpellChecker/Application.xaml.vb @@ -0,0 +1,6 @@ +Class Application + + ' Application-level events, such as Startup, Exit, and DispatcherUnhandledException + ' can be handled in this file. + +End Class diff --git a/Code/Chapter 31/MySpellChecker/MainWindow.xaml b/Code/Chapter 31/MySpellChecker/MainWindow.xaml new file mode 100644 index 0000000..f8d47f1 --- /dev/null +++ b/Code/Chapter 31/MySpellChecker/MainWindow.xaml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 31/SimpleDataBinding/Application.xaml b/Code/Chapter 31/SimpleDataBinding/Application.xaml new file mode 100644 index 0000000..ff7991a --- /dev/null +++ b/Code/Chapter 31/SimpleDataBinding/Application.xaml @@ -0,0 +1,8 @@ + + + + + diff --git a/Code/Chapter 31/SimpleDataBinding/Application.xaml.vb b/Code/Chapter 31/SimpleDataBinding/Application.xaml.vb new file mode 100644 index 0000000..084cbe9 --- /dev/null +++ b/Code/Chapter 31/SimpleDataBinding/Application.xaml.vb @@ -0,0 +1,6 @@ +Class Application + + ' Application-level events, such as Startup, Exit, and DispatcherUnhandledException + ' can be handled in this file. + +End Class diff --git a/Code/Chapter 31/SimpleDataBinding/MainWindow.xaml b/Code/Chapter 31/SimpleDataBinding/MainWindow.xaml new file mode 100644 index 0000000..488915d --- /dev/null +++ b/Code/Chapter 31/SimpleDataBinding/MainWindow.xaml @@ -0,0 +1,32 @@ + + + + + + + + + + + + diff --git a/Code/Chapter 31/SimpleGrid.xaml b/Code/Chapter 31/SimpleGrid.xaml new file mode 100644 index 0000000..35b076b --- /dev/null +++ b/Code/Chapter 31/SimpleGrid.xaml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 31/SimpleStackPanel.xaml b/Code/Chapter 31/SimpleStackPanel.xaml new file mode 100644 index 0000000..d1e1184 --- /dev/null +++ b/Code/Chapter 31/SimpleStackPanel.xaml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/Code/Chapter 31/SimpleWrapPanel.xaml b/Code/Chapter 31/SimpleWrapPanel.xaml new file mode 100644 index 0000000..991e1a9 --- /dev/null +++ b/Code/Chapter 31/SimpleWrapPanel.xaml @@ -0,0 +1,17 @@ + + + + + + + + + + + + diff --git a/Code/Chapter 31/TextControls/Application.xaml b/Code/Chapter 31/TextControls/Application.xaml new file mode 100644 index 0000000..ff7991a --- /dev/null +++ b/Code/Chapter 31/TextControls/Application.xaml @@ -0,0 +1,8 @@ + + + + + diff --git a/Code/Chapter 31/TextControls/Application.xaml.vb b/Code/Chapter 31/TextControls/Application.xaml.vb new file mode 100644 index 0000000..084cbe9 --- /dev/null +++ b/Code/Chapter 31/TextControls/Application.xaml.vb @@ -0,0 +1,6 @@ +Class Application + + ' Application-level events, such as Startup, Exit, and DispatcherUnhandledException + ' can be handled in this file. + +End Class diff --git a/Code/Chapter 31/TextControls/MainWindow.xaml b/Code/Chapter 31/TextControls/MainWindow.xaml new file mode 100644 index 0000000..f75f3eb --- /dev/null +++ b/Code/Chapter 31/TextControls/MainWindow.xaml @@ -0,0 +1,18 @@ + + + + + + + + + + diff --git a/Code/Chapter 31/WPFControlEvents/MainWindow.xaml.vb b/Code/Chapter 31/WPFControlEvents/MainWindow.xaml.vb new file mode 100644 index 0000000..a170d90 --- /dev/null +++ b/Code/Chapter 31/WPFControlEvents/MainWindow.xaml.vb @@ -0,0 +1,28 @@ +Class MainWindow + ' This is used to hold data on the mouse-related + ' activity. + Private mouseActivityOuterEllipse As String = String.Empty + + Public Sub New() + InitializeComponent() + End Sub + + Public Sub btnClickMe_Clicked(ByVal sender As Object, ByVal e As RoutedEventArgs) + ' Show the final string. + mouseActivityOuterEllipse &= "Button Click event fired!" & vbLf + MessageBox.Show(mouseActivityOuterEllipse) + + ' Clear string for next test. + mouseActivityOuterEllipse = String.Empty + End Sub + + Public Sub outerEllipse_MouseDown(ByVal sender As Object, ByVal e As RoutedEventArgs) + ' Add data to string. + mouseActivityOuterEllipse &= "MouseDown event fired!" & vbLf + End Sub + + Public Sub outerEllipse_PreviewMouseDown(ByVal sender As Object, ByVal e As RoutedEventArgs) + ' Add data to string. + mouseActivityOuterEllipse = "PreviewMouseDown event fired!" & vbLf + End Sub +End Class diff --git a/Code/Chapter 31/WPFControlEvents/My Project/AssemblyInfo.vb b/Code/Chapter 31/WPFControlEvents/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..897849f --- /dev/null +++ b/Code/Chapter 31/WPFControlEvents/My Project/AssemblyInfo.vb @@ -0,0 +1,59 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices +Imports System.Globalization +Imports System.Resources +Imports System.Windows + +' 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 + + + + + + + + + +'In order to begin building localizable applications, set +'CultureYouAreCodingWith in your .vbproj file +'inside a . For example, if you are using US english +'in your source files, set the to "en-US". Then uncomment the +'NeutralResourceLanguage attribute below. Update the "en-US" in the line +'below to match the UICulture setting in the project file. + +' + + +'The ThemeInfo attribute describes where any theme specific and generic resource dictionaries can be found. +'1st parameter: where theme specific resource dictionaries are located +'(used if a resource is not found in the page, +' or application resource dictionaries) + +'2nd parameter: where the generic resource dictionary is located +'(used if a resource is not found in the page, +'app, and any theme specific resource dictionaries) + + + + +'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/Code/Chapter 31/WPFControlEvents/My Project/MyExtensions/MyWpfExtension.vb b/Code/Chapter 31/WPFControlEvents/My Project/MyExtensions/MyWpfExtension.vb new file mode 100644 index 0000000..739db0e --- /dev/null +++ b/Code/Chapter 31/WPFControlEvents/My Project/MyExtensions/MyWpfExtension.vb @@ -0,0 +1,121 @@ +#If _MyType <> "Empty" Then + +Namespace My + ''' + ''' Module used to define the properties that are available in the My Namespace for WPF + ''' + ''' + _ + Module MyWpfExtension + Private s_Computer As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Devices.Computer) + Private s_User As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.ApplicationServices.User) + Private s_Windows As New ThreadSafeObjectProvider(Of MyWindows) + Private s_Log As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Logging.Log) + ''' + ''' Returns the application object for the running application + ''' + _ + Friend ReadOnly Property Application() As Application + Get + Return Global.System.Windows.Application.Current + End Get + End Property + ''' + ''' Returns information about the host computer. + ''' + _ + Friend ReadOnly Property Computer() As Global.Microsoft.VisualBasic.Devices.Computer + Get + Return s_Computer.GetInstance() + End Get + End Property + ''' + ''' Returns information for the current user. If you wish to run the application with the current + ''' Windows user credentials, call My.User.InitializeWithWindowsUser(). + ''' + _ + Friend ReadOnly Property User() As Global.Microsoft.VisualBasic.ApplicationServices.User + Get + Return s_User.GetInstance() + End Get + End Property + ''' + ''' Returns the application log. The listeners can be configured by the application's configuration file. + ''' + _ + Friend ReadOnly Property Log() As Global.Microsoft.VisualBasic.Logging.Log + Get + Return s_Log.GetInstance() + End Get + End Property + + ''' + ''' Returns the collection of Windows defined in the project. + ''' + _ + Friend ReadOnly Property Windows() As MyWindows + _ + Get + Return s_Windows.GetInstance() + End Get + End Property + _ + _ + Friend NotInheritable Class MyWindows + _ + Private Shared Function Create__Instance__(Of T As {New, Global.System.Windows.Window})(ByVal Instance As T) As T + If Instance Is Nothing Then + If s_WindowBeingCreated IsNot Nothing Then + If s_WindowBeingCreated.ContainsKey(GetType(T)) = True Then + Throw New Global.System.InvalidOperationException("The window cannot be accessed via My.Windows from the Window constructor.") + End If + Else + s_WindowBeingCreated = New Global.System.Collections.Hashtable() + End If + s_WindowBeingCreated.Add(GetType(T), Nothing) + Return New T() + s_WindowBeingCreated.Remove(GetType(T)) + Else + Return Instance + End If + End Function + _ + _ + Private Sub Dispose__Instance__(Of T As Global.System.Windows.Window)(ByRef instance As T) + instance = Nothing + End Sub + _ + _ + Public Sub New() + MyBase.New() + End Sub + Private Shared s_WindowBeingCreated As Global.System.Collections.Hashtable + Public Overrides Function Equals(ByVal o As Object) As Boolean + Return MyBase.Equals(o) + End Function + Public Overrides Function GetHashCode() As Integer + Return MyBase.GetHashCode + End Function + _ + _ + Friend Overloads Function [GetType]() As Global.System.Type + Return GetType(MyWindows) + End Function + Public Overrides Function ToString() As String + Return MyBase.ToString + End Function + End Class + End Module +End Namespace +Partial Class Application + Inherits Global.System.Windows.Application + _ + _ + Friend ReadOnly Property Info() As Global.Microsoft.VisualBasic.ApplicationServices.AssemblyInfo + _ + Get + Return New Global.Microsoft.VisualBasic.ApplicationServices.AssemblyInfo(Global.System.Reflection.Assembly.GetExecutingAssembly()) + End Get + End Property +End Class +#End If \ No newline at end of file diff --git a/Code/Chapter 31/WPFControlEvents/My Project/Resources.Designer.vb b/Code/Chapter 31/WPFControlEvents/My Project/Resources.Designer.vb new file mode 100644 index 0000000..e4a5560 --- /dev/null +++ b/Code/Chapter 31/WPFControlEvents/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:$clrversion$ +' +' 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("$safeprojectname$.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/Code/Chapter 31/WPFControlEvents/My Project/Resources.resx b/Code/Chapter 31/WPFControlEvents/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 31/WPFControlEvents/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/Code/Chapter 31/WPFControlEvents/My Project/Settings.Designer.vb b/Code/Chapter 31/WPFControlEvents/My Project/Settings.Designer.vb new file mode 100644 index 0000000..3fed39c --- /dev/null +++ b/Code/Chapter 31/WPFControlEvents/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.WPFControlEvents.My.MySettings + Get + Return Global.WPFControlEvents.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 31/WPFControlEvents/My Project/Settings.settings b/Code/Chapter 31/WPFControlEvents/My Project/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/Code/Chapter 31/WPFControlEvents/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 31/WPFControlEvents/WPFControlEvents.sln b/Code/Chapter 31/WPFControlEvents/WPFControlEvents.sln new file mode 100644 index 0000000..572191e --- /dev/null +++ b/Code/Chapter 31/WPFControlEvents/WPFControlEvents.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "WPFControlEvents", "WPFControlEvents.vbproj", "{3EADE6A1-9E5B-4DAA-AC8B-271D59AF3E83}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3EADE6A1-9E5B-4DAA-AC8B-271D59AF3E83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3EADE6A1-9E5B-4DAA-AC8B-271D59AF3E83}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3EADE6A1-9E5B-4DAA-AC8B-271D59AF3E83}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3EADE6A1-9E5B-4DAA-AC8B-271D59AF3E83}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 31/WPFControlEvents/WPFControlEvents.suo b/Code/Chapter 31/WPFControlEvents/WPFControlEvents.suo new file mode 100644 index 0000000..53b6bc4 Binary files /dev/null and b/Code/Chapter 31/WPFControlEvents/WPFControlEvents.suo differ diff --git a/Code/Chapter 31/WPFControlEvents/WPFControlEvents.vbproj b/Code/Chapter 31/WPFControlEvents/WPFControlEvents.vbproj new file mode 100644 index 0000000..06b32c3 --- /dev/null +++ b/Code/Chapter 31/WPFControlEvents/WPFControlEvents.vbproj @@ -0,0 +1,127 @@ + + + Debug + AnyCPU + {3EADE6A1-9E5B-4DAA-AC8B-271D59AF3E83} + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + WinExe + WPFControlEvents + WPFControlEvents + v3.5 + Custom + On + Binary + Off + On + + + true + full + true + true + true + bin\Debug\ + WPFControlEvents.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + false + false + true + false + true + bin\Release\ + WPFControlEvents.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + + 3.5 + + + 3.5 + + + 3.5 + + + 3.0 + + + 3.0 + + + 3.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Application.xaml + Code + + + MainWindow.xaml + Code + + + + + + + + + + + + + + + + + + + + + + + Code + + + Microsoft.VisualBasic.WPF.MyExtension + 1.0.0.0 + + + True + True + Resources.resx + + + True + Settings.settings + True + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + SettingsSingleFileGenerator + Settings.Designer.vb + + + + + \ No newline at end of file diff --git a/Code/Chapter 31/WindowFrame.xaml b/Code/Chapter 31/WindowFrame.xaml new file mode 100644 index 0000000..348ae4e --- /dev/null +++ b/Code/Chapter 31/WindowFrame.xaml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + Ready + + + + + + + + + + + + + + + + + + Desktop markup? I like it! + + + diff --git a/Code/Chapter 32/AnimatedButtonWithDiscreteKeyFrames.xaml b/Code/Chapter 32/AnimatedButtonWithDiscreteKeyFrames.xaml new file mode 100644 index 0000000..f856208 --- /dev/null +++ b/Code/Chapter 32/AnimatedButtonWithDiscreteKeyFrames.xaml @@ -0,0 +1,24 @@ + + + + + diff --git a/Code/Chapter 32/AnimatedLabel/AnimatedLabel.sln b/Code/Chapter 32/AnimatedLabel/AnimatedLabel.sln new file mode 100644 index 0000000..0c6473b --- /dev/null +++ b/Code/Chapter 32/AnimatedLabel/AnimatedLabel.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AnimatedLabel", "AnimatedLabel.vbproj", "{797FCF17-2C8A-4710-896F-8E04F354F5D8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {797FCF17-2C8A-4710-896F-8E04F354F5D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {797FCF17-2C8A-4710-896F-8E04F354F5D8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {797FCF17-2C8A-4710-896F-8E04F354F5D8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {797FCF17-2C8A-4710-896F-8E04F354F5D8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 32/AnimatedLabel/AnimatedLabel.suo b/Code/Chapter 32/AnimatedLabel/AnimatedLabel.suo new file mode 100644 index 0000000..f147378 Binary files /dev/null and b/Code/Chapter 32/AnimatedLabel/AnimatedLabel.suo differ diff --git a/Code/Chapter 32/AnimatedLabel/AnimatedLabel.vbproj b/Code/Chapter 32/AnimatedLabel/AnimatedLabel.vbproj new file mode 100644 index 0000000..3466a47 --- /dev/null +++ b/Code/Chapter 32/AnimatedLabel/AnimatedLabel.vbproj @@ -0,0 +1,127 @@ + + + Debug + AnyCPU + {797FCF17-2C8A-4710-896F-8E04F354F5D8} + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + WinExe + AnimatedLabel + AnimatedLabel + v3.5 + Custom + On + Binary + Off + On + + + true + full + true + true + true + bin\Debug\ + AnimatedLabel.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + false + false + true + false + true + bin\Release\ + AnimatedLabel.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + + 3.5 + + + 3.5 + + + 3.5 + + + 3.0 + + + 3.0 + + + 3.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Application.xaml + Code + + + MainWindow.xaml + Code + + + + + + + + + + + + + + + + + + + + + + + Code + + + Microsoft.VisualBasic.WPF.MyExtension + 1.0.0.0 + + + True + True + Resources.resx + + + True + Settings.settings + True + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + SettingsSingleFileGenerator + Settings.Designer.vb + + + + + \ No newline at end of file diff --git a/Code/Chapter 32/AnimatedLabel/Application.xaml b/Code/Chapter 32/AnimatedLabel/Application.xaml new file mode 100644 index 0000000..ff7991a --- /dev/null +++ b/Code/Chapter 32/AnimatedLabel/Application.xaml @@ -0,0 +1,8 @@ + + + + + diff --git a/Code/Chapter 32/AnimatedLabel/Application.xaml.vb b/Code/Chapter 32/AnimatedLabel/Application.xaml.vb new file mode 100644 index 0000000..084cbe9 --- /dev/null +++ b/Code/Chapter 32/AnimatedLabel/Application.xaml.vb @@ -0,0 +1,6 @@ +Class Application + + ' Application-level events, such as Startup, Exit, and DispatcherUnhandledException + ' can be handled in this file. + +End Class diff --git a/Code/Chapter 32/AnimatedLabel/MainWindow.xaml b/Code/Chapter 32/AnimatedLabel/MainWindow.xaml new file mode 100644 index 0000000..4e92492 --- /dev/null +++ b/Code/Chapter 32/AnimatedLabel/MainWindow.xaml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + diff --git a/Code/Chapter 32/ControlTemplates/MainWindow.xaml.vb b/Code/Chapter 32/ControlTemplates/MainWindow.xaml.vb new file mode 100644 index 0000000..62292b8 --- /dev/null +++ b/Code/Chapter 32/ControlTemplates/MainWindow.xaml.vb @@ -0,0 +1,5 @@ +Class MainWindow + Private Sub myButton_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) + MessageBox.Show("Clicked!") + End Sub +End Class diff --git a/Code/Chapter 32/ControlTemplates/My Project/AssemblyInfo.vb b/Code/Chapter 32/ControlTemplates/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..1924e1f --- /dev/null +++ b/Code/Chapter 32/ControlTemplates/My Project/AssemblyInfo.vb @@ -0,0 +1,59 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices +Imports System.Globalization +Imports System.Resources +Imports System.Windows + +' 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 + + + + + + + + + +'In order to begin building localizable applications, set +'CultureYouAreCodingWith in your .vbproj file +'inside a . For example, if you are using US english +'in your source files, set the to "en-US". Then uncomment the +'NeutralResourceLanguage attribute below. Update the "en-US" in the line +'below to match the UICulture setting in the project file. + +' + + +'The ThemeInfo attribute describes where any theme specific and generic resource dictionaries can be found. +'1st parameter: where theme specific resource dictionaries are located +'(used if a resource is not found in the page, +' or application resource dictionaries) + +'2nd parameter: where the generic resource dictionary is located +'(used if a resource is not found in the page, +'app, and any theme specific resource dictionaries) + + + + +'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/Code/Chapter 32/ControlTemplates/My Project/MyExtensions/MyWpfExtension.vb b/Code/Chapter 32/ControlTemplates/My Project/MyExtensions/MyWpfExtension.vb new file mode 100644 index 0000000..739db0e --- /dev/null +++ b/Code/Chapter 32/ControlTemplates/My Project/MyExtensions/MyWpfExtension.vb @@ -0,0 +1,121 @@ +#If _MyType <> "Empty" Then + +Namespace My + ''' + ''' Module used to define the properties that are available in the My Namespace for WPF + ''' + ''' + _ + Module MyWpfExtension + Private s_Computer As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Devices.Computer) + Private s_User As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.ApplicationServices.User) + Private s_Windows As New ThreadSafeObjectProvider(Of MyWindows) + Private s_Log As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Logging.Log) + ''' + ''' Returns the application object for the running application + ''' + _ + Friend ReadOnly Property Application() As Application + Get + Return Global.System.Windows.Application.Current + End Get + End Property + ''' + ''' Returns information about the host computer. + ''' + _ + Friend ReadOnly Property Computer() As Global.Microsoft.VisualBasic.Devices.Computer + Get + Return s_Computer.GetInstance() + End Get + End Property + ''' + ''' Returns information for the current user. If you wish to run the application with the current + ''' Windows user credentials, call My.User.InitializeWithWindowsUser(). + ''' + _ + Friend ReadOnly Property User() As Global.Microsoft.VisualBasic.ApplicationServices.User + Get + Return s_User.GetInstance() + End Get + End Property + ''' + ''' Returns the application log. The listeners can be configured by the application's configuration file. + ''' + _ + Friend ReadOnly Property Log() As Global.Microsoft.VisualBasic.Logging.Log + Get + Return s_Log.GetInstance() + End Get + End Property + + ''' + ''' Returns the collection of Windows defined in the project. + ''' + _ + Friend ReadOnly Property Windows() As MyWindows + _ + Get + Return s_Windows.GetInstance() + End Get + End Property + _ + _ + Friend NotInheritable Class MyWindows + _ + Private Shared Function Create__Instance__(Of T As {New, Global.System.Windows.Window})(ByVal Instance As T) As T + If Instance Is Nothing Then + If s_WindowBeingCreated IsNot Nothing Then + If s_WindowBeingCreated.ContainsKey(GetType(T)) = True Then + Throw New Global.System.InvalidOperationException("The window cannot be accessed via My.Windows from the Window constructor.") + End If + Else + s_WindowBeingCreated = New Global.System.Collections.Hashtable() + End If + s_WindowBeingCreated.Add(GetType(T), Nothing) + Return New T() + s_WindowBeingCreated.Remove(GetType(T)) + Else + Return Instance + End If + End Function + _ + _ + Private Sub Dispose__Instance__(Of T As Global.System.Windows.Window)(ByRef instance As T) + instance = Nothing + End Sub + _ + _ + Public Sub New() + MyBase.New() + End Sub + Private Shared s_WindowBeingCreated As Global.System.Collections.Hashtable + Public Overrides Function Equals(ByVal o As Object) As Boolean + Return MyBase.Equals(o) + End Function + Public Overrides Function GetHashCode() As Integer + Return MyBase.GetHashCode + End Function + _ + _ + Friend Overloads Function [GetType]() As Global.System.Type + Return GetType(MyWindows) + End Function + Public Overrides Function ToString() As String + Return MyBase.ToString + End Function + End Class + End Module +End Namespace +Partial Class Application + Inherits Global.System.Windows.Application + _ + _ + Friend ReadOnly Property Info() As Global.Microsoft.VisualBasic.ApplicationServices.AssemblyInfo + _ + Get + Return New Global.Microsoft.VisualBasic.ApplicationServices.AssemblyInfo(Global.System.Reflection.Assembly.GetExecutingAssembly()) + End Get + End Property +End Class +#End If \ No newline at end of file diff --git a/Code/Chapter 32/ControlTemplates/My Project/Resources.Designer.vb b/Code/Chapter 32/ControlTemplates/My Project/Resources.Designer.vb new file mode 100644 index 0000000..e4a5560 --- /dev/null +++ b/Code/Chapter 32/ControlTemplates/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:$clrversion$ +' +' 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("$safeprojectname$.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/Code/Chapter 32/ControlTemplates/My Project/Resources.resx b/Code/Chapter 32/ControlTemplates/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 32/ControlTemplates/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/Code/Chapter 32/ControlTemplates/My Project/Settings.Designer.vb b/Code/Chapter 32/ControlTemplates/My Project/Settings.Designer.vb new file mode 100644 index 0000000..99e5c67 --- /dev/null +++ b/Code/Chapter 32/ControlTemplates/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.ControlTemplates.My.MySettings + Get + Return Global.ControlTemplates.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 32/ControlTemplates/My Project/Settings.settings b/Code/Chapter 32/ControlTemplates/My Project/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/Code/Chapter 32/ControlTemplates/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 32/FunWithBrushes.xaml b/Code/Chapter 32/FunWithBrushes.xaml new file mode 100644 index 0000000..e7959ad --- /dev/null +++ b/Code/Chapter 32/FunWithBrushes.xaml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 32/FunWithDrawingGeometries.xaml b/Code/Chapter 32/FunWithDrawingGeometries.xaml new file mode 100644 index 0000000..1301345 --- /dev/null +++ b/Code/Chapter 32/FunWithDrawingGeometries.xaml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 32/FunWithResources/Application.xaml b/Code/Chapter 32/FunWithResources/Application.xaml new file mode 100644 index 0000000..ff7991a --- /dev/null +++ b/Code/Chapter 32/FunWithResources/Application.xaml @@ -0,0 +1,8 @@ + + + + + diff --git a/Code/Chapter 32/FunWithResources/Application.xaml.vb b/Code/Chapter 32/FunWithResources/Application.xaml.vb new file mode 100644 index 0000000..084cbe9 --- /dev/null +++ b/Code/Chapter 32/FunWithResources/Application.xaml.vb @@ -0,0 +1,6 @@ +Class Application + + ' Application-level events, such as Startup, Exit, and DispatcherUnhandledException + ' can be handled in this file. + +End Class diff --git a/Code/Chapter 32/FunWithResources/FunWithResources.sln b/Code/Chapter 32/FunWithResources/FunWithResources.sln new file mode 100644 index 0000000..6db0504 --- /dev/null +++ b/Code/Chapter 32/FunWithResources/FunWithResources.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "FunWithResources", "FunWithResources.vbproj", "{7175A265-C078-44EB-A977-3302E45579A6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7175A265-C078-44EB-A977-3302E45579A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7175A265-C078-44EB-A977-3302E45579A6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7175A265-C078-44EB-A977-3302E45579A6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7175A265-C078-44EB-A977-3302E45579A6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 32/FunWithResources/FunWithResources.suo b/Code/Chapter 32/FunWithResources/FunWithResources.suo new file mode 100644 index 0000000..fbcef4c Binary files /dev/null and b/Code/Chapter 32/FunWithResources/FunWithResources.suo differ diff --git a/Code/Chapter 32/FunWithResources/FunWithResources.vbproj b/Code/Chapter 32/FunWithResources/FunWithResources.vbproj new file mode 100644 index 0000000..b9eeb8f --- /dev/null +++ b/Code/Chapter 32/FunWithResources/FunWithResources.vbproj @@ -0,0 +1,130 @@ + + + Debug + AnyCPU + {7175A265-C078-44EB-A977-3302E45579A6} + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + WinExe + FunWithResources + FunWithResources + v3.5 + Custom + On + Binary + Off + On + + + true + full + true + true + true + bin\Debug\ + FunWithResources.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + false + false + true + false + true + bin\Release\ + FunWithResources.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + + 3.5 + + + 3.5 + + + 3.5 + + + 3.0 + + + 3.0 + + + 3.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Application.xaml + Code + + + MainWindow.xaml + Code + + + + + + + + + + + + + + + + + + + + + + + Code + + + Microsoft.VisualBasic.WPF.MyExtension + 1.0.0.0 + + + True + True + Resources.resx + + + True + Settings.settings + True + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + SettingsSingleFileGenerator + Settings.Designer.vb + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 32/FunWithResources/IntertechBlue.gif b/Code/Chapter 32/FunWithResources/IntertechBlue.gif new file mode 100644 index 0000000..5dcd330 Binary files /dev/null and b/Code/Chapter 32/FunWithResources/IntertechBlue.gif differ diff --git a/Code/Chapter 32/FunWithResources/MainWindow.xaml b/Code/Chapter 32/FunWithResources/MainWindow.xaml new file mode 100644 index 0000000..4b3a343 --- /dev/null +++ b/Code/Chapter 32/FunWithResources/MainWindow.xaml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 32/Gooseberry0007.JPG b/Code/Chapter 32/Gooseberry0007.JPG new file mode 100644 index 0000000..4367474 Binary files /dev/null and b/Code/Chapter 32/Gooseberry0007.JPG differ diff --git a/Code/Chapter 32/IntertechBlue.gif b/Code/Chapter 32/IntertechBlue.gif new file mode 100644 index 0000000..5dcd330 Binary files /dev/null and b/Code/Chapter 32/IntertechBlue.gif differ diff --git a/Code/Chapter 32/SpinButtonWithLinearKeyFrames.xaml b/Code/Chapter 32/SpinButtonWithLinearKeyFrames.xaml new file mode 100644 index 0000000..f56d0d9 --- /dev/null +++ b/Code/Chapter 32/SpinButtonWithLinearKeyFrames.xaml @@ -0,0 +1,29 @@ + + + + + \ No newline at end of file diff --git a/Code/Chapter 32/StyleWithTriggers.xaml b/Code/Chapter 32/StyleWithTriggers.xaml new file mode 100644 index 0000000..fe917ba --- /dev/null +++ b/Code/Chapter 32/StyleWithTriggers.xaml @@ -0,0 +1,30 @@ + + + + + + + + + + + + diff --git a/Code/Chapter 32/StylesAtRuntime/Application.xaml b/Code/Chapter 32/StylesAtRuntime/Application.xaml new file mode 100644 index 0000000..ff7991a --- /dev/null +++ b/Code/Chapter 32/StylesAtRuntime/Application.xaml @@ -0,0 +1,8 @@ + + + + + diff --git a/Code/Chapter 32/StylesAtRuntime/Application.xaml.vb b/Code/Chapter 32/StylesAtRuntime/Application.xaml.vb new file mode 100644 index 0000000..084cbe9 --- /dev/null +++ b/Code/Chapter 32/StylesAtRuntime/Application.xaml.vb @@ -0,0 +1,6 @@ +Class Application + + ' Application-level events, such as Startup, Exit, and DispatcherUnhandledException + ' can be handled in this file. + +End Class diff --git a/Code/Chapter 32/StylesAtRuntime/MainWindow.xaml b/Code/Chapter 32/StylesAtRuntime/MainWindow.xaml new file mode 100644 index 0000000..4354076 --- /dev/null +++ b/Code/Chapter 32/StylesAtRuntime/MainWindow.xaml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + Please select a style for the button on the right. + + + + + + + diff --git a/Code/Chapter 32/StylesAtRuntime/MainWindow.xaml.vb b/Code/Chapter 32/StylesAtRuntime/MainWindow.xaml.vb new file mode 100644 index 0000000..4830a69 --- /dev/null +++ b/Code/Chapter 32/StylesAtRuntime/MainWindow.xaml.vb @@ -0,0 +1,19 @@ +Class MainWindow + Public Sub New() + InitializeComponent() + + ' Add items to our list box. + lstStyles.Items.Add("TiltStyle") + lstStyles.Items.Add("GreenStyle") + lstStyles.Items.Add("MouseOverStyle") + End Sub + + Private Sub lstStyles_Changed(ByVal sender As System.Object, _ + ByVal e As System.Windows.Controls.SelectionChangedEventArgs) + ' Get the selected style name from the list box. + Dim currStyle As System.Windows.Style = DirectCast(FindResource(lstStyles.SelectedValue), System.Windows.Style) + + ' Set the style of the button type. + Me.btnMouseOverStyle.Style = currStyle + End Sub +End Class diff --git a/Code/Chapter 32/StylesAtRuntime/My Project/AssemblyInfo.vb b/Code/Chapter 32/StylesAtRuntime/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..dc95fbe --- /dev/null +++ b/Code/Chapter 32/StylesAtRuntime/My Project/AssemblyInfo.vb @@ -0,0 +1,59 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices +Imports System.Globalization +Imports System.Resources +Imports System.Windows + +' 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 + + + + + + + + + +'In order to begin building localizable applications, set +'CultureYouAreCodingWith in your .vbproj file +'inside a . For example, if you are using US english +'in your source files, set the to "en-US". Then uncomment the +'NeutralResourceLanguage attribute below. Update the "en-US" in the line +'below to match the UICulture setting in the project file. + +' + + +'The ThemeInfo attribute describes where any theme specific and generic resource dictionaries can be found. +'1st parameter: where theme specific resource dictionaries are located +'(used if a resource is not found in the page, +' or application resource dictionaries) + +'2nd parameter: where the generic resource dictionary is located +'(used if a resource is not found in the page, +'app, and any theme specific resource dictionaries) + + + + +'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/Code/Chapter 32/StylesAtRuntime/My Project/MyExtensions/MyWpfExtension.vb b/Code/Chapter 32/StylesAtRuntime/My Project/MyExtensions/MyWpfExtension.vb new file mode 100644 index 0000000..739db0e --- /dev/null +++ b/Code/Chapter 32/StylesAtRuntime/My Project/MyExtensions/MyWpfExtension.vb @@ -0,0 +1,121 @@ +#If _MyType <> "Empty" Then + +Namespace My + ''' + ''' Module used to define the properties that are available in the My Namespace for WPF + ''' + ''' + _ + Module MyWpfExtension + Private s_Computer As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Devices.Computer) + Private s_User As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.ApplicationServices.User) + Private s_Windows As New ThreadSafeObjectProvider(Of MyWindows) + Private s_Log As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Logging.Log) + ''' + ''' Returns the application object for the running application + ''' + _ + Friend ReadOnly Property Application() As Application + Get + Return Global.System.Windows.Application.Current + End Get + End Property + ''' + ''' Returns information about the host computer. + ''' + _ + Friend ReadOnly Property Computer() As Global.Microsoft.VisualBasic.Devices.Computer + Get + Return s_Computer.GetInstance() + End Get + End Property + ''' + ''' Returns information for the current user. If you wish to run the application with the current + ''' Windows user credentials, call My.User.InitializeWithWindowsUser(). + ''' + _ + Friend ReadOnly Property User() As Global.Microsoft.VisualBasic.ApplicationServices.User + Get + Return s_User.GetInstance() + End Get + End Property + ''' + ''' Returns the application log. The listeners can be configured by the application's configuration file. + ''' + _ + Friend ReadOnly Property Log() As Global.Microsoft.VisualBasic.Logging.Log + Get + Return s_Log.GetInstance() + End Get + End Property + + ''' + ''' Returns the collection of Windows defined in the project. + ''' + _ + Friend ReadOnly Property Windows() As MyWindows + _ + Get + Return s_Windows.GetInstance() + End Get + End Property + _ + _ + Friend NotInheritable Class MyWindows + _ + Private Shared Function Create__Instance__(Of T As {New, Global.System.Windows.Window})(ByVal Instance As T) As T + If Instance Is Nothing Then + If s_WindowBeingCreated IsNot Nothing Then + If s_WindowBeingCreated.ContainsKey(GetType(T)) = True Then + Throw New Global.System.InvalidOperationException("The window cannot be accessed via My.Windows from the Window constructor.") + End If + Else + s_WindowBeingCreated = New Global.System.Collections.Hashtable() + End If + s_WindowBeingCreated.Add(GetType(T), Nothing) + Return New T() + s_WindowBeingCreated.Remove(GetType(T)) + Else + Return Instance + End If + End Function + _ + _ + Private Sub Dispose__Instance__(Of T As Global.System.Windows.Window)(ByRef instance As T) + instance = Nothing + End Sub + _ + _ + Public Sub New() + MyBase.New() + End Sub + Private Shared s_WindowBeingCreated As Global.System.Collections.Hashtable + Public Overrides Function Equals(ByVal o As Object) As Boolean + Return MyBase.Equals(o) + End Function + Public Overrides Function GetHashCode() As Integer + Return MyBase.GetHashCode + End Function + _ + _ + Friend Overloads Function [GetType]() As Global.System.Type + Return GetType(MyWindows) + End Function + Public Overrides Function ToString() As String + Return MyBase.ToString + End Function + End Class + End Module +End Namespace +Partial Class Application + Inherits Global.System.Windows.Application + _ + _ + Friend ReadOnly Property Info() As Global.Microsoft.VisualBasic.ApplicationServices.AssemblyInfo + _ + Get + Return New Global.Microsoft.VisualBasic.ApplicationServices.AssemblyInfo(Global.System.Reflection.Assembly.GetExecutingAssembly()) + End Get + End Property +End Class +#End If \ No newline at end of file diff --git a/Code/Chapter 32/StylesAtRuntime/My Project/Resources.Designer.vb b/Code/Chapter 32/StylesAtRuntime/My Project/Resources.Designer.vb new file mode 100644 index 0000000..e4a5560 --- /dev/null +++ b/Code/Chapter 32/StylesAtRuntime/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:$clrversion$ +' +' 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("$safeprojectname$.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/Code/Chapter 32/StylesAtRuntime/My Project/Resources.resx b/Code/Chapter 32/StylesAtRuntime/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 32/StylesAtRuntime/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/Code/Chapter 32/StylesAtRuntime/My Project/Settings.Designer.vb b/Code/Chapter 32/StylesAtRuntime/My Project/Settings.Designer.vb new file mode 100644 index 0000000..9ce5e33 --- /dev/null +++ b/Code/Chapter 32/StylesAtRuntime/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.StylesAtRuntime.My.MySettings + Get + Return Global.StylesAtRuntime.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 32/StylesAtRuntime/My Project/Settings.settings b/Code/Chapter 32/StylesAtRuntime/My Project/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/Code/Chapter 32/StylesAtRuntime/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 32/StylesAtRuntime/StylesAtRuntime.sln b/Code/Chapter 32/StylesAtRuntime/StylesAtRuntime.sln new file mode 100644 index 0000000..ec7c3f3 --- /dev/null +++ b/Code/Chapter 32/StylesAtRuntime/StylesAtRuntime.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "StylesAtRuntime", "StylesAtRuntime.vbproj", "{FA491F65-91D9-4E15-AF25-5B7B7B669243}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FA491F65-91D9-4E15-AF25-5B7B7B669243}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA491F65-91D9-4E15-AF25-5B7B7B669243}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA491F65-91D9-4E15-AF25-5B7B7B669243}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA491F65-91D9-4E15-AF25-5B7B7B669243}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 32/StylesAtRuntime/StylesAtRuntime.suo b/Code/Chapter 32/StylesAtRuntime/StylesAtRuntime.suo new file mode 100644 index 0000000..f73694d Binary files /dev/null and b/Code/Chapter 32/StylesAtRuntime/StylesAtRuntime.suo differ diff --git a/Code/Chapter 32/StylesAtRuntime/StylesAtRuntime.vbproj b/Code/Chapter 32/StylesAtRuntime/StylesAtRuntime.vbproj new file mode 100644 index 0000000..2300422 --- /dev/null +++ b/Code/Chapter 32/StylesAtRuntime/StylesAtRuntime.vbproj @@ -0,0 +1,127 @@ + + + Debug + AnyCPU + {FA491F65-91D9-4E15-AF25-5B7B7B669243} + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + WinExe + StylesAtRuntime + StylesAtRuntime + v3.5 + Custom + On + Binary + Off + On + + + true + full + true + true + true + bin\Debug\ + StylesAtRuntime.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + false + false + true + false + true + bin\Release\ + StylesAtRuntime.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + + 3.5 + + + 3.5 + + + 3.5 + + + 3.0 + + + 3.0 + + + 3.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Application.xaml + Code + + + MainWindow.xaml + Code + + + + + + + + + + + + + + + + + + + + + + + Code + + + Microsoft.VisualBasic.WPF.MyExtension + 1.0.0.0 + + + True + True + Resources.resx + + + True + Settings.settings + True + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + SettingsSingleFileGenerator + Settings.Designer.vb + + + + + \ No newline at end of file diff --git a/Code/Chapter 32/WPFGraphicsOptions/Application.xaml b/Code/Chapter 32/WPFGraphicsOptions/Application.xaml new file mode 100644 index 0000000..ff7991a --- /dev/null +++ b/Code/Chapter 32/WPFGraphicsOptions/Application.xaml @@ -0,0 +1,8 @@ + + + + + diff --git a/Code/Chapter 32/WPFGraphicsOptions/Application.xaml.vb b/Code/Chapter 32/WPFGraphicsOptions/Application.xaml.vb new file mode 100644 index 0000000..084cbe9 --- /dev/null +++ b/Code/Chapter 32/WPFGraphicsOptions/Application.xaml.vb @@ -0,0 +1,6 @@ +Class Application + + ' Application-level events, such as Startup, Exit, and DispatcherUnhandledException + ' can be handled in this file. + +End Class diff --git a/Code/Chapter 32/WPFGraphicsOptions/MainWindow.xaml b/Code/Chapter 32/WPFGraphicsOptions/MainWindow.xaml new file mode 100644 index 0000000..798f88b --- /dev/null +++ b/Code/Chapter 32/WPFGraphicsOptions/MainWindow.xaml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 32/WPFGraphicsOptions/MainWindow.xaml.vb b/Code/Chapter 32/WPFGraphicsOptions/MainWindow.xaml.vb new file mode 100644 index 0000000..36bd30d --- /dev/null +++ b/Code/Chapter 32/WPFGraphicsOptions/MainWindow.xaml.vb @@ -0,0 +1,49 @@ +Class MainWindow +End Class + +#Region "Custom rendering on the Main Window" +'Class MainWindow +' Inherits System.Windows.Window +' ' Our single drawing visual. +' Private rectVisual As New DrawingVisual() +' Private Const NumberOfVisualItems As Integer = 1 + +' Public Sub New() +' InitializeComponent() + +' ' Helper function to create the rectangle. +' CreateRectVisual() +' End Sub + +' Private Sub CreateRectVisual() +' Using drawCtx As DrawingContext = rectVisual.RenderOpen() +' ' The top, left, bottom, and right position of the rectangle. +' Dim rect As New Rect(50, 50, 105, 55) +' drawCtx.DrawRectangle(Brushes.AliceBlue, New Pen(Brushes.Blue, 5), rect) +' End Using + +' ' Register our visual with the object tree, +' ' to ensure it supports routed events, hit testing, etc. +' AddVisualChild(rectVisual) +' AddLogicalChild(rectVisual) +' End Sub + +' ' Necessary overrides. The WPF graphics system +' ' will call these to figure out how many items to +' ' render and what to render. +' Protected Overrides ReadOnly Property VisualChildrenCount() As Integer +' Get +' Return NumberOfVisualItems +' End Get +' End Property + +' Protected Overrides Function GetVisualChild(ByVal index As Integer) As Visual +' ' Collection is zero based, so subtract 1. +' If index <> (NumberOfVisualItems - 1) Then +' Throw New ArgumentOutOfRangeException("index", "Don't have that visual!") +' End If +' Return rectVisual +' End Function +'End Class +#End Region + diff --git a/Code/Chapter 32/WPFGraphicsOptions/My Project/AssemblyInfo.vb b/Code/Chapter 32/WPFGraphicsOptions/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..0d4dad8 --- /dev/null +++ b/Code/Chapter 32/WPFGraphicsOptions/My Project/AssemblyInfo.vb @@ -0,0 +1,59 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices +Imports System.Globalization +Imports System.Resources +Imports System.Windows + +' 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 + + + + + + + + + +'In order to begin building localizable applications, set +'CultureYouAreCodingWith in your .vbproj file +'inside a . For example, if you are using US english +'in your source files, set the to "en-US". Then uncomment the +'NeutralResourceLanguage attribute below. Update the "en-US" in the line +'below to match the UICulture setting in the project file. + +' + + +'The ThemeInfo attribute describes where any theme specific and generic resource dictionaries can be found. +'1st parameter: where theme specific resource dictionaries are located +'(used if a resource is not found in the page, +' or application resource dictionaries) + +'2nd parameter: where the generic resource dictionary is located +'(used if a resource is not found in the page, +'app, and any theme specific resource dictionaries) + + + + +'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/Code/Chapter 32/WPFGraphicsOptions/My Project/MyExtensions/MyWpfExtension.vb b/Code/Chapter 32/WPFGraphicsOptions/My Project/MyExtensions/MyWpfExtension.vb new file mode 100644 index 0000000..739db0e --- /dev/null +++ b/Code/Chapter 32/WPFGraphicsOptions/My Project/MyExtensions/MyWpfExtension.vb @@ -0,0 +1,121 @@ +#If _MyType <> "Empty" Then + +Namespace My + ''' + ''' Module used to define the properties that are available in the My Namespace for WPF + ''' + ''' + _ + Module MyWpfExtension + Private s_Computer As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Devices.Computer) + Private s_User As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.ApplicationServices.User) + Private s_Windows As New ThreadSafeObjectProvider(Of MyWindows) + Private s_Log As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Logging.Log) + ''' + ''' Returns the application object for the running application + ''' + _ + Friend ReadOnly Property Application() As Application + Get + Return Global.System.Windows.Application.Current + End Get + End Property + ''' + ''' Returns information about the host computer. + ''' + _ + Friend ReadOnly Property Computer() As Global.Microsoft.VisualBasic.Devices.Computer + Get + Return s_Computer.GetInstance() + End Get + End Property + ''' + ''' Returns information for the current user. If you wish to run the application with the current + ''' Windows user credentials, call My.User.InitializeWithWindowsUser(). + ''' + _ + Friend ReadOnly Property User() As Global.Microsoft.VisualBasic.ApplicationServices.User + Get + Return s_User.GetInstance() + End Get + End Property + ''' + ''' Returns the application log. The listeners can be configured by the application's configuration file. + ''' + _ + Friend ReadOnly Property Log() As Global.Microsoft.VisualBasic.Logging.Log + Get + Return s_Log.GetInstance() + End Get + End Property + + ''' + ''' Returns the collection of Windows defined in the project. + ''' + _ + Friend ReadOnly Property Windows() As MyWindows + _ + Get + Return s_Windows.GetInstance() + End Get + End Property + _ + _ + Friend NotInheritable Class MyWindows + _ + Private Shared Function Create__Instance__(Of T As {New, Global.System.Windows.Window})(ByVal Instance As T) As T + If Instance Is Nothing Then + If s_WindowBeingCreated IsNot Nothing Then + If s_WindowBeingCreated.ContainsKey(GetType(T)) = True Then + Throw New Global.System.InvalidOperationException("The window cannot be accessed via My.Windows from the Window constructor.") + End If + Else + s_WindowBeingCreated = New Global.System.Collections.Hashtable() + End If + s_WindowBeingCreated.Add(GetType(T), Nothing) + Return New T() + s_WindowBeingCreated.Remove(GetType(T)) + Else + Return Instance + End If + End Function + _ + _ + Private Sub Dispose__Instance__(Of T As Global.System.Windows.Window)(ByRef instance As T) + instance = Nothing + End Sub + _ + _ + Public Sub New() + MyBase.New() + End Sub + Private Shared s_WindowBeingCreated As Global.System.Collections.Hashtable + Public Overrides Function Equals(ByVal o As Object) As Boolean + Return MyBase.Equals(o) + End Function + Public Overrides Function GetHashCode() As Integer + Return MyBase.GetHashCode + End Function + _ + _ + Friend Overloads Function [GetType]() As Global.System.Type + Return GetType(MyWindows) + End Function + Public Overrides Function ToString() As String + Return MyBase.ToString + End Function + End Class + End Module +End Namespace +Partial Class Application + Inherits Global.System.Windows.Application + _ + _ + Friend ReadOnly Property Info() As Global.Microsoft.VisualBasic.ApplicationServices.AssemblyInfo + _ + Get + Return New Global.Microsoft.VisualBasic.ApplicationServices.AssemblyInfo(Global.System.Reflection.Assembly.GetExecutingAssembly()) + End Get + End Property +End Class +#End If \ No newline at end of file diff --git a/Code/Chapter 32/WPFGraphicsOptions/My Project/Resources.Designer.vb b/Code/Chapter 32/WPFGraphicsOptions/My Project/Resources.Designer.vb new file mode 100644 index 0000000..e4a5560 --- /dev/null +++ b/Code/Chapter 32/WPFGraphicsOptions/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:$clrversion$ +' +' 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("$safeprojectname$.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/Code/Chapter 32/WPFGraphicsOptions/My Project/Resources.resx b/Code/Chapter 32/WPFGraphicsOptions/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Code/Chapter 32/WPFGraphicsOptions/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/Code/Chapter 32/WPFGraphicsOptions/My Project/Settings.Designer.vb b/Code/Chapter 32/WPFGraphicsOptions/My Project/Settings.Designer.vb new file mode 100644 index 0000000..42fbc41 --- /dev/null +++ b/Code/Chapter 32/WPFGraphicsOptions/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.WPFGraphicsOptions.My.MySettings + Get + Return Global.WPFGraphicsOptions.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 32/WPFGraphicsOptions/My Project/Settings.settings b/Code/Chapter 32/WPFGraphicsOptions/My Project/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/Code/Chapter 32/WPFGraphicsOptions/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 32/WPFGraphicsOptions/MyCustomRenderer.vb b/Code/Chapter 32/WPFGraphicsOptions/MyCustomRenderer.vb new file mode 100644 index 0000000..f7cc495 --- /dev/null +++ b/Code/Chapter 32/WPFGraphicsOptions/MyCustomRenderer.vb @@ -0,0 +1,34 @@ +Public Class MyCustomRenderer + Inherits FrameworkElement + ' Default size for our rectangle. + Private m_rectWidth As Double = 105, m_rectHeight As Double = 55 + + ' Allow user to override the defaults. + Public Property RectHeight() As Double + Get + Return m_rectHeight + End Get + Set(ByVal value As Double) + m_rectHeight = value + End Set + End Property + Public Property RectWidth() As Double + Get + Return m_rectWidth + End Get + Set(ByVal value As Double) + m_rectWidth = value + End Set + End Property + + Protected Overloads Overrides Sub OnRender(ByVal drawCtx As DrawingContext) + ' Do parent rendering first. + MyBase.OnRender(drawCtx) + + ' Add our custom rendering. + Dim rect As New Rect() + rect.Width = m_rectWidth + rect.Height = m_rectHeight + drawCtx.DrawRectangle(Brushes.LightBlue, New Pen(Brushes.Blue, 5), rect) + End Sub +End Class diff --git a/Code/Chapter 32/WPFGraphicsOptions/WPFGraphicsOptions.sln b/Code/Chapter 32/WPFGraphicsOptions/WPFGraphicsOptions.sln new file mode 100644 index 0000000..e12d4ad --- /dev/null +++ b/Code/Chapter 32/WPFGraphicsOptions/WPFGraphicsOptions.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "WPFGraphicsOptions", "WPFGraphicsOptions.vbproj", "{7F114B61-F488-4F03-A459-3E91D68423D2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7F114B61-F488-4F03-A459-3E91D68423D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7F114B61-F488-4F03-A459-3E91D68423D2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7F114B61-F488-4F03-A459-3E91D68423D2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7F114B61-F488-4F03-A459-3E91D68423D2}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 32/WPFGraphicsOptions/WPFGraphicsOptions.suo b/Code/Chapter 32/WPFGraphicsOptions/WPFGraphicsOptions.suo new file mode 100644 index 0000000..07dff88 Binary files /dev/null and b/Code/Chapter 32/WPFGraphicsOptions/WPFGraphicsOptions.suo differ diff --git a/Code/Chapter 32/WPFGraphicsOptions/WPFGraphicsOptions.vbproj b/Code/Chapter 32/WPFGraphicsOptions/WPFGraphicsOptions.vbproj new file mode 100644 index 0000000..e2ce1f7 --- /dev/null +++ b/Code/Chapter 32/WPFGraphicsOptions/WPFGraphicsOptions.vbproj @@ -0,0 +1,128 @@ + + + Debug + AnyCPU + {7F114B61-F488-4F03-A459-3E91D68423D2} + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + WinExe + WPFGraphicsOptions + WPFGraphicsOptions + v3.5 + Custom + On + Binary + Off + On + + + true + full + true + true + true + bin\Debug\ + WPFGraphicsOptions.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + false + false + true + false + true + bin\Release\ + WPFGraphicsOptions.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + + 3.5 + + + 3.5 + + + 3.5 + + + 3.0 + + + 3.0 + + + 3.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Application.xaml + Code + + + MainWindow.xaml + Code + + + + + + + + + + + + + + + + + + + + + + + Code + + + Microsoft.VisualBasic.WPF.MyExtension + 1.0.0.0 + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + SettingsSingleFileGenerator + Settings.Designer.vb + + + + + \ No newline at end of file diff --git a/Code/Chapter 32/WPFGraphicsOptions/WPFGraphicsOptions.vbproj.user b/Code/Chapter 32/WPFGraphicsOptions/WPFGraphicsOptions.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 32/WPFGraphicsOptions/WPFGraphicsOptions.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 33/CarsWebSite/ClassicAspPage.asp b/Code/Chapter 33/CarsWebSite/ClassicAspPage.asp new file mode 100644 index 0000000..3c95a85 --- /dev/null +++ b/Code/Chapter 33/CarsWebSite/ClassicAspPage.asp @@ -0,0 +1,19 @@ + + +<%@ language="VBScript" %> + + + The Cars Page + + +

Here is what you sent me:

+

+ User Name: + <%= Request.Form("txtUserName") %>
+ Password: + <%= Request.Form("txtPassword") %>
+

+ + + + diff --git a/Code/Chapter 33/CarsWebSite/default.htm b/Code/Chapter 33/CarsWebSite/default.htm new file mode 100644 index 0000000..5cc1bb3 --- /dev/null +++ b/Code/Chapter 33/CarsWebSite/default.htm @@ -0,0 +1,49 @@ + + + + This is the Cars Web Site + + + + + +

The Cars Login Page

+


+ Please enter your user name and password. +

+ +
 

+ User Name: +

+

+ Password: +

+

+ + + +

+
+ + + + + diff --git a/Code/Chapter 33/CodeBehindPageModel/Bin/AutoLotDAL.dll b/Code/Chapter 33/CodeBehindPageModel/Bin/AutoLotDAL.dll new file mode 100644 index 0000000..2b301c5 Binary files /dev/null and b/Code/Chapter 33/CodeBehindPageModel/Bin/AutoLotDAL.dll differ diff --git a/Code/Chapter 33/CodeBehindPageModel/Bin/AutoLotDAL.dll.refresh b/Code/Chapter 33/CodeBehindPageModel/Bin/AutoLotDAL.dll.refresh new file mode 100644 index 0000000..95d7f10 Binary files /dev/null and b/Code/Chapter 33/CodeBehindPageModel/Bin/AutoLotDAL.dll.refresh differ diff --git a/Code/Chapter 33/CodeBehindPageModel/Bin/AutoLotDAL.pdb b/Code/Chapter 33/CodeBehindPageModel/Bin/AutoLotDAL.pdb new file mode 100644 index 0000000..ae0af7f Binary files /dev/null and b/Code/Chapter 33/CodeBehindPageModel/Bin/AutoLotDAL.pdb differ diff --git a/Code/Chapter 33/CodeBehindPageModel/Bin/AutoLotDAL.xml b/Code/Chapter 33/CodeBehindPageModel/Bin/AutoLotDAL.xml new file mode 100644 index 0000000..b8e562a --- /dev/null +++ b/Code/Chapter 33/CodeBehindPageModel/Bin/AutoLotDAL.xml @@ -0,0 +1,24 @@ + + + + +AutoLotDAL + + + + + + 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/Code/Chapter 33/CodeBehindPageModel/Default.aspx b/Code/Chapter 33/CodeBehindPageModel/Default.aspx new file mode 100644 index 0000000..ecae655 --- /dev/null +++ b/Code/Chapter 33/CodeBehindPageModel/Default.aspx @@ -0,0 +1,26 @@ +<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" trace ="true"%> + + + + + + Untitled Page + + +
+
+
+
+ + + + + + + +
+  
+
+ + diff --git a/Code/Chapter 33/CodeBehindPageModel/Default.aspx.vb b/Code/Chapter 33/CodeBehindPageModel/Default.aspx.vb new file mode 100644 index 0000000..567e2a7 --- /dev/null +++ b/Code/Chapter 33/CodeBehindPageModel/Default.aspx.vb @@ -0,0 +1,16 @@ +Imports AutoLotConnectedLayer + +Partial Class _Default + Inherits System.Web.UI.Page + + Protected Sub btnFillGrid_Click(ByVal sender As Object, _ + ByVal e As System.EventArgs) Handles btnFillGrid.Click + Trace.Write("My Category", "Filling the grid!") + Dim dal As New InventoryDAL() + dal.OpenConnection("Data Source=(local)\SQLEXPRESS;" & _ + "Initial Catalog=AutoLot;Integrated Security=True") + carsGridView.DataSource = dal.GetAllInventory() + carsGridView.DataBind() + dal.CloseConnection() + End Sub +End Class diff --git a/Code/Chapter 33/CodeBehindPageModel/web.config b/Code/Chapter 33/CodeBehindPageModel/web.config new file mode 100644 index 0000000..2e184b3 --- /dev/null +++ b/Code/Chapter 33/CodeBehindPageModel/web.config @@ -0,0 +1,115 @@ + + + + + + +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 33/FunWithPageMembers/Default.aspx b/Code/Chapter 33/FunWithPageMembers/Default.aspx new file mode 100644 index 0000000..5c036ac --- /dev/null +++ b/Code/Chapter 33/FunWithPageMembers/Default.aspx @@ -0,0 +1,31 @@ +<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> + + + + + + Untitled Page + + +
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+ + diff --git a/Code/Chapter 33/FunWithPageMembers/Default.aspx.vb b/Code/Chapter 33/FunWithPageMembers/Default.aspx.vb new file mode 100644 index 0000000..27da2df --- /dev/null +++ b/Code/Chapter 33/FunWithPageMembers/Default.aspx.vb @@ -0,0 +1,55 @@ + +Partial Class _Default + Inherits System.Web.UI.Page + + Protected Sub btnSomeTraining_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSomeTraining.Click + Response.Redirect("http://www.IntertechTraining.com") + End Sub + + Protected Sub btnHttpResponse_Click(ByVal sender As Object, _ + ByVal e As System.EventArgs) Handles btnHttpResponse.Click + Response.Write("My name is:
") + Response.Write(Me.ToString()) + Response.Write("

Here was your last request:
") + ' This assumes that you have a file of this name + ' in your virtual directory! + ' Response.WriteFile("MyHTMLPage.htm") + End Sub + + Protected Sub btnGetFormData_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGetFormData.Click + ' Get value for a widget with ID txtFirstName. + Dim firstName As String = Request.Form("txtFirstName") + lblFormData.Text = firstName + End Sub + + Protected Sub btnGetBrowserStats_Click(ByVal sender As Object, _ + ByVal e As System.EventArgs) Handles btnGetBrowserStats.Click + Dim theInfo As String = "" + theInfo &= String.Format("
  • Is the client AOL? {0}
  • ", _ + Request.Browser.AOL) + theInfo &= _ + String.Format("
  • Does the client support ActiveX? {0}
  • ", _ + Request.Browser.ActiveXControls) + theInfo &= String.Format("
  • Is the client a Beta? {0}
  • ", _ + Request.Browser.Beta) + theInfo &= _ + String.Format("
  • Dose the client support Java Applets? {0}
  • ", _ + Request.Browser.JavaApplets) + theInfo &= _ + String.Format("
  • Does the client support Cookies? {0}
  • ", _ + Request.Browser.Cookies) + theInfo &= _ + String.Format("
  • Does the client support VBScript? {0}
  • ", _ + Request.Browser.VBScript) + lblOutput.Text = theInfo + End Sub + + Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load + ' Only fill DataSet the very first time + ' the user comes to this page. + If Not IsPostBack Then + ' Populate DataSet and cache it! + End If + ' Use cached DataSet. + End Sub +End Class diff --git a/Code/Chapter 33/FunWithPageMembers/web.config b/Code/Chapter 33/FunWithPageMembers/web.config new file mode 100644 index 0000000..ff1dfc6 --- /dev/null +++ b/Code/Chapter 33/FunWithPageMembers/web.config @@ -0,0 +1,115 @@ + + + + + + +
    + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 33/PageLifeCycle/Default.aspx b/Code/Chapter 33/PageLifeCycle/Default.aspx new file mode 100644 index 0000000..227176c --- /dev/null +++ b/Code/Chapter 33/PageLifeCycle/Default.aspx @@ -0,0 +1,23 @@ +<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %> + + + + + + Untitled Page + + +
    +
    +
    +
    +
    + +
    +
    +  
    + +
    +
    + + diff --git a/Code/Chapter 33/PageLifeCycle/Default.aspx.vb b/Code/Chapter 33/PageLifeCycle/Default.aspx.vb new file mode 100644 index 0000000..7c24f0a --- /dev/null +++ b/Code/Chapter 33/PageLifeCycle/Default.aspx.vb @@ -0,0 +1,32 @@ +Partial Class _Default + Inherits System.Web.UI.Page + + Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) 'Handles Me.Load + ' Perform load logic here... + Response.Write("Load event fired!") + End Sub + + Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) 'Handles Me.Unload + ' No longer possible to emit data to the HTTP + ' response at this point, so we will write to a local file. + System.IO.File.WriteAllText("C:\MyLog.txt", "Page unloading!") + End Sub + + Protected Sub Page_Error(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Error + Response.Clear() + Response.Write("I am sorry...I can't find a required file.
    ") + Response.Write(String.Format("The error was: {0}", _ + Server.GetLastError().Message)) + Server.ClearError() + End Sub + + Protected Sub btnPostback_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPostback.Click + ' This is just here to allow a postback. + End Sub + + Protected Sub btnTriggerError_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnTriggerError.Click + ' Try to open a nonexistent file on the web server. + ' This will fire the Error event for this page. + System.IO.File.ReadAllText("C:\IDontExist.txt") + End Sub +End Class diff --git a/Code/Chapter 33/PageLifeCycle/web.config b/Code/Chapter 33/PageLifeCycle/web.config new file mode 100644 index 0000000..ff1dfc6 --- /dev/null +++ b/Code/Chapter 33/PageLifeCycle/web.config @@ -0,0 +1,115 @@ + + + + + + +
    + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 33/SinglePageModel/Default.aspx b/Code/Chapter 33/SinglePageModel/Default.aspx new file mode 100644 index 0000000..4dfdbec --- /dev/null +++ b/Code/Chapter 33/SinglePageModel/Default.aspx @@ -0,0 +1,36 @@ +<%@ Page Language="VB" %> +<%@ Import Namespace="AutoLotConnectedLayer" %> +<%@ Assembly Name="AutoLotDAL" %> + + + + + + + + Cars Inventory + + +
    +
    + + +
    +
    + + +
    + +
    +
    + + diff --git a/Code/Chapter 33/SinglePageModel/Web.config b/Code/Chapter 33/SinglePageModel/Web.config new file mode 100644 index 0000000..47a0327 --- /dev/null +++ b/Code/Chapter 33/SinglePageModel/Web.config @@ -0,0 +1,92 @@ + + + + + + +
    + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 33/SinglePageModel/bin/AutoLotDAL.dll b/Code/Chapter 33/SinglePageModel/bin/AutoLotDAL.dll new file mode 100644 index 0000000..2b301c5 Binary files /dev/null and b/Code/Chapter 33/SinglePageModel/bin/AutoLotDAL.dll differ diff --git a/Code/Chapter 34/AspNetCarsSite/Ads.xml b/Code/Chapter 34/AspNetCarsSite/Ads.xml new file mode 100644 index 0000000..81653d5 --- /dev/null +++ b/Code/Chapter 34/AspNetCarsSite/Ads.xml @@ -0,0 +1,14 @@ + + + + SlugBug.jpg + Your new Car? + 80 + + + car.gif + http://www.CarSuperSite.com + Like this Car? + 80 + + diff --git a/Code/Chapter 34/AspNetCarsSite/BuildCar.aspx b/Code/Chapter 34/AspNetCarsSite/BuildCar.aspx new file mode 100644 index 0000000..31976b3 --- /dev/null +++ b/Code/Chapter 34/AspNetCarsSite/BuildCar.aspx @@ -0,0 +1,47 @@ +<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="BuildCar.aspx.vb" Inherits="Default2" title="Untitled Page" %> + +
    +
    + + + + + + + + + + + + + + Purple + Green + Red + Yellow + Pea Soup Green + Black + Lime Green + + + + + + + + + + + + +
    +
    +
    + diff --git a/Code/Chapter 34/AspNetCarsSite/BuildCar.aspx.vb b/Code/Chapter 34/AspNetCarsSite/BuildCar.aspx.vb new file mode 100644 index 0000000..6290eaa --- /dev/null +++ b/Code/Chapter 34/AspNetCarsSite/BuildCar.aspx.vb @@ -0,0 +1,12 @@ + +Partial Class Default2 + Inherits System.Web.UI.Page + + Protected Sub carWizard_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles carWizard.FinishButtonClick + ' Get each value. + Dim order As String = String.Format("{0}, your {1} {2} will arrive on {3}.", _ + txtCarPetName.Text, ListBoxColors.SelectedValue, txtCarModel.Text, carCalendar.SelectedDate.ToShortDateString()) + ' Assign to label + lblOrder.Text = order + End Sub +End Class diff --git a/Code/Chapter 34/AspNetCarsSite/CAR.GIF b/Code/Chapter 34/AspNetCarsSite/CAR.GIF new file mode 100644 index 0000000..b973fdd Binary files /dev/null and b/Code/Chapter 34/AspNetCarsSite/CAR.GIF differ diff --git a/Code/Chapter 34/AspNetCarsSite/Default.aspx b/Code/Chapter 34/AspNetCarsSite/Default.aspx new file mode 100644 index 0000000..7b810ce --- /dev/null +++ b/Code/Chapter 34/AspNetCarsSite/Default.aspx @@ -0,0 +1,11 @@ +<%@ Page Language="VB" +MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" title="Untitled Page" %> + + + + This is the default page of this site.
    + Not too much to do here, so use the menu system
    + to go to more interesting pages!
    +
    + diff --git a/Code/Chapter 34/AspNetCarsSite/Default.aspx.vb b/Code/Chapter 34/AspNetCarsSite/Default.aspx.vb new file mode 100644 index 0000000..75f1603 --- /dev/null +++ b/Code/Chapter 34/AspNetCarsSite/Default.aspx.vb @@ -0,0 +1,5 @@ + +Partial Class _Default + Inherits System.Web.UI.Page + +End Class diff --git a/Code/Chapter 34/AspNetCarsSite/Inventory.aspx b/Code/Chapter 34/AspNetCarsSite/Inventory.aspx new file mode 100644 index 0000000..6b30f5e --- /dev/null +++ b/Code/Chapter 34/AspNetCarsSite/Inventory.aspx @@ -0,0 +1,51 @@ +<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Inventory.aspx.vb" Inherits="Default2" title="Untitled Page" %> + +
    +
    +   + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +  +
    + diff --git a/Code/Chapter 34/AspNetCarsSite/Inventory.aspx.vb b/Code/Chapter 34/AspNetCarsSite/Inventory.aspx.vb new file mode 100644 index 0000000..b078677 --- /dev/null +++ b/Code/Chapter 34/AspNetCarsSite/Inventory.aspx.vb @@ -0,0 +1,5 @@ + +Partial Class Default2 + Inherits System.Web.UI.Page + +End Class diff --git a/Code/Chapter 34/AspNetCarsSite/MasterPage.master b/Code/Chapter 34/AspNetCarsSite/MasterPage.master new file mode 100644 index 0000000..dce503b --- /dev/null +++ b/Code/Chapter 34/AspNetCarsSite/MasterPage.master @@ -0,0 +1,48 @@ +<%@ Master Language="VB" +CodeFile="MasterPage.master.vb" Inherits="MasterPage" %> + + + + + + Untitled Page + + +
    +
    +
    + +
    + +  
    +
    + + + + + + + + + + +   +
    +
    + + +
    + + + + + + +    +
    +
    + + diff --git a/Code/Chapter 34/AspNetCarsSite/MasterPage.master.vb b/Code/Chapter 34/AspNetCarsSite/MasterPage.master.vb new file mode 100644 index 0000000..deccd8e --- /dev/null +++ b/Code/Chapter 34/AspNetCarsSite/MasterPage.master.vb @@ -0,0 +1,5 @@ + +Partial Class MasterPage + Inherits System.Web.UI.MasterPage +End Class + diff --git a/Code/Chapter 34/AspNetCarsSite/SlugBug.jpg b/Code/Chapter 34/AspNetCarsSite/SlugBug.jpg new file mode 100644 index 0000000..c2cccc7 Binary files /dev/null and b/Code/Chapter 34/AspNetCarsSite/SlugBug.jpg differ diff --git a/Code/Chapter 34/AspNetCarsSite/Web.sitemap b/Code/Chapter 34/AspNetCarsSite/Web.sitemap new file mode 100644 index 0000000..cf2cd54 --- /dev/null +++ b/Code/Chapter 34/AspNetCarsSite/Web.sitemap @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/Code/Chapter 34/AspNetCarsSite/web.config b/Code/Chapter 34/AspNetCarsSite/web.config new file mode 100644 index 0000000..24eb4cf --- /dev/null +++ b/Code/Chapter 34/AspNetCarsSite/web.config @@ -0,0 +1,120 @@ + + + + + + +
    + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 34/DynamicCtrls/Default.aspx b/Code/Chapter 34/DynamicCtrls/Default.aspx new file mode 100644 index 0000000..31ce77f --- /dev/null +++ b/Code/Chapter 34/DynamicCtrls/Default.aspx @@ -0,0 +1,33 @@ +<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> + + + + + Untitled Page + + +
    +
    + +
    +
    + +
    +
    + HyperLink + +
    +
    + + +
    +
    +
    +
    +
    +
    +   +
    +
    + + diff --git a/Code/Chapter 34/DynamicCtrls/Default.aspx.vb b/Code/Chapter 34/DynamicCtrls/Default.aspx.vb new file mode 100644 index 0000000..dbc7aa7 --- /dev/null +++ b/Code/Chapter 34/DynamicCtrls/Default.aspx.vb @@ -0,0 +1,56 @@ +Option Explicit On +Option Strict On + +Partial Class _Default + Inherits System.Web.UI.Page + + Private Sub ListControlsInPanel() + Dim theInfo As String + theInfo = String.Format("Has controls? {0}
    ", myPanel.HasControls()) + For Each c As Control In myPanel.Controls + If c.GetType() IsNot GetType(System.Web.UI.LiteralControl) Then + theInfo += "***************************
    " + theInfo += String.Format("Control Name? {0}
    ", c.ToString()) + theInfo += String.Format("ID? {0}
    ", c.ID) + theInfo += String.Format("Control Visible? {0}
    ", c.Visible) + theInfo += String.Format("ViewState? {0}
    ", c.EnableViewState) + End If + Next + lblControlInfo.Text = theInfo + End Sub + + Protected Sub Page_Load(ByVal sender As Object, _ + ByVal e As System.EventArgs) Handles Me.Load + ListControlsInPanel() + End Sub + + Protected Sub btnRemovePanelItems_Click(ByVal sender As Object, _ + ByVal e As System.EventArgs) Handles btnRemovePanelItems.Click + myPanel.Controls.Clear() + ListControlsInPanel() + End Sub + + Protected Sub btnAddWidgets_Click(ByVal sender As Object, _ + ByVal e As System.EventArgs) Handles btnAddWidgets.Click + For i As Integer = 0 To 4 + ' Assign a name so we can get + ' the text value out later + ' using the HttpRequest.QueryString() + ' method. + Dim t As TextBox = New TextBox() + t.ID = String.Format("newTextBox{0}", i) + myPanel.Controls.Add(t) + ListControlsInPanel() + Next + End Sub + + Protected Sub btnGetTextBoxValues_Click(ByVal sender As Object, _ + ByVal e As System.EventArgs) Handles btnGetTextBoxValues.Click + Dim textBoxValues As String = "" + For i As Integer = 0 To Request.Form.Count - 1 + textBoxValues += String.Format("
  • {0}

  • ", Request.Form(i)) + Next + lblTextBoxText.Text = textBoxValues + End Sub +End Class + diff --git a/Code/Chapter 34/DynamicCtrls/web.config b/Code/Chapter 34/DynamicCtrls/web.config new file mode 100644 index 0000000..ff1dfc6 --- /dev/null +++ b/Code/Chapter 34/DynamicCtrls/web.config @@ -0,0 +1,115 @@ + + + + + + +
    + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 34/FunWithThemes/App_Themes/BasicGreen/BasicGreen.skin b/Code/Chapter 34/FunWithThemes/App_Themes/BasicGreen/BasicGreen.skin new file mode 100644 index 0000000..8211e21 --- /dev/null +++ b/Code/Chapter 34/FunWithThemes/App_Themes/BasicGreen/BasicGreen.skin @@ -0,0 +1,21 @@ +<%-- +Default skin template. The following skins are provided as examples only. + +1. Named control skin. The SkinId should be uniquely defined because + duplicate SkinId's per control type are not allowed in the same theme. + + + + + +2. Default skin. The SkinId is not defined. Only one default + control skin per control type is allowed in the same theme. + + +--%> + + + + + + \ No newline at end of file diff --git a/Code/Chapter 34/FunWithThemes/App_Themes/CrazyOrange/CrazyOrange.skin b/Code/Chapter 34/FunWithThemes/App_Themes/CrazyOrange/CrazyOrange.skin new file mode 100644 index 0000000..b6c0ed2 --- /dev/null +++ b/Code/Chapter 34/FunWithThemes/App_Themes/CrazyOrange/CrazyOrange.skin @@ -0,0 +1,40 @@ +<%-- +Default skin template. The following skins are provided as examples only. + +1. Named control skin. The SkinId should be uniquely defined because + duplicate SkinId's per control type are not allowed in the same theme. + + + + + +2. Default skin. The SkinId is not defined. Only one default + control skin per control type is allowed in the same theme. + + +--%> + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 34/FunWithThemes/Default.aspx b/Code/Chapter 34/FunWithThemes/Default.aspx new file mode 100644 index 0000000..687093b --- /dev/null +++ b/Code/Chapter 34/FunWithThemes/Default.aspx @@ -0,0 +1,36 @@ +<%@ Page Language="VB" AutoEventWireup="false" +CodeFile="Default.aspx.vb" +Inherits="_Default" Theme = "CrazyOrange"%> + + + + + + Untitled Page + + +
    +
    +
    +  
    +
    +
    + + +
    +
    +
    +
    + +
    +   +
    + +
    +  
    +
    +
    +
    + + + diff --git a/Code/Chapter 34/FunWithThemes/Default.aspx.vb b/Code/Chapter 34/FunWithThemes/Default.aspx.vb new file mode 100644 index 0000000..bd42855 --- /dev/null +++ b/Code/Chapter 34/FunWithThemes/Default.aspx.vb @@ -0,0 +1,33 @@ +Option Explicit On +Option Strict On + +Partial Class _Default + Inherits System.Web.UI.Page + + Protected Sub btnNoTheme_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNoTheme.Click + ' Empty strings result in no theme being applied. + Session("UserTheme") = "" + ' Trigger the PreInit event again. + Server.Transfer(Request.FilePath) + End Sub + + Protected Sub btnGreenTheme_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGreenTheme.Click + Session("UserTheme") = "BasicGreen" + ' Trigger the PreInit event again. + Server.Transfer(Request.FilePath) + End Sub + + Protected Sub btnOrangeTheme_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnOrangeTheme.Click + Session("UserTheme") = "CrazyOrange" + ' Trigger the PreInit event again. + Server.Transfer(Request.FilePath) + End Sub + + Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit + Try + Theme = Session("UserTheme").ToString() + Catch + Theme = "" + End Try + End Sub +End Class diff --git a/Code/Chapter 34/FunWithThemes/web.config b/Code/Chapter 34/FunWithThemes/web.config new file mode 100644 index 0000000..4fff2ae --- /dev/null +++ b/Code/Chapter 34/FunWithThemes/web.config @@ -0,0 +1,115 @@ + + + + + + +
    + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 34/ValidatorCtrls/Default.aspx b/Code/Chapter 34/ValidatorCtrls/Default.aspx new file mode 100644 index 0000000..61574d9 --- /dev/null +++ b/Code/Chapter 34/ValidatorCtrls/Default.aspx @@ -0,0 +1,54 @@ +<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> + + + + + + Untitled Page + + +
    +
    +
    +
    +
    +
    +
    + Please enter your name +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +  
    + +
    +
    +
    +
    +
    +
    +
    + +
    +
    + + diff --git a/Code/Chapter 34/ValidatorCtrls/Default.aspx.vb b/Code/Chapter 34/ValidatorCtrls/Default.aspx.vb new file mode 100644 index 0000000..dddc719 --- /dev/null +++ b/Code/Chapter 34/ValidatorCtrls/Default.aspx.vb @@ -0,0 +1,8 @@ + +Partial Class _Default + Inherits System.Web.UI.Page + + Protected Sub btnPostback_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPostback.Click + lblValidationComplete.Text = "You passed validation!" + End Sub +End Class diff --git a/Code/Chapter 34/ValidatorCtrls/web.config b/Code/Chapter 34/ValidatorCtrls/web.config new file mode 100644 index 0000000..ff1dfc6 --- /dev/null +++ b/Code/Chapter 34/ValidatorCtrls/web.config @@ -0,0 +1,115 @@ + + + + + + +
    + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 35/AppState/App_Code/CarLotInfo.vb b/Code/Chapter 35/AppState/App_Code/CarLotInfo.vb new file mode 100644 index 0000000..8ab5f12 --- /dev/null +++ b/Code/Chapter 35/AppState/App_Code/CarLotInfo.vb @@ -0,0 +1,19 @@ +Option Explicit On +Option Strict On + +Imports Microsoft.VisualBasic + +Public Class CarLotInfo + Public Sub New(ByVal sPerson As String, _ + ByVal saleCar As String, ByVal popularColor As String) + salesPersonOfTheMonth = sPerson + currentCarOnSale = saleCar + mostPopularColorOnLot = popularColor + End Sub + + ' Public for easy access. + Public salesPersonOfTheMonth As String + Public currentCarOnSale As String + Public mostPopularColorOnLot As String +End Class + diff --git a/Code/Chapter 35/AppState/Default.aspx b/Code/Chapter 35/AppState/Default.aspx new file mode 100644 index 0000000..26a0cc9 --- /dev/null +++ b/Code/Chapter 35/AppState/Default.aspx @@ -0,0 +1,33 @@ +<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> + + + + + + Untitled Page + + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + +
    +
    + +
    + +
    +
    + + diff --git a/Code/Chapter 35/AppState/Default.aspx.vb b/Code/Chapter 35/AppState/Default.aspx.vb new file mode 100644 index 0000000..cf67036 --- /dev/null +++ b/Code/Chapter 35/AppState/Default.aspx.vb @@ -0,0 +1,50 @@ +Option Explicit On +Option Strict On + +Partial Class _Default + Inherits System.Web.UI.Page + + Protected Sub btnShowAppVariables_Click(ByVal sender As Object, _ + ByVal e As System.EventArgs) Handles btnShowAppVariables.Click + ' Get object from application variable. + Dim appVars As CarLotInfo = _ + CType(Application("CarSiteInfo"), CarLotInfo) + + Dim appState As String = _ + String.Format("
  • Car on sale: {0}
  • ", _ + appVars.currentCarOnSale) + + appState &= _ + String.Format("
  • Most popular color: {0}
  • ", _ + appVars.mostPopularColorOnLot) + appState &= _ + String.Format("
  • Big shot SalesPerson: {0}
  • ", _ + appVars.salesPersonOfTheMonth) + lblAppVariables.Text = appState + End Sub + + Protected Sub btnSetNewSP_Click(ByVal sender As Object, _ + ByVal e As System.EventArgs) Handles btnSetNewSP.Click + ' Set the new Salesperson. + CType(Application("CarSiteInfo"), CarLotInfo).salesPersonOfTheMonth _ + = txtNewSP.Text + End Sub + + Protected Sub btnShowCarOnSale_Click(ByVal sender As Object, _ + ByVal e As System.EventArgs) Handles btnShowCarOnSale.Click + 'lblCurrCarOnSale.Text = String.Format("Sale on {0}'s today!", _ + 'CType(Application("CurrentCarOnSale"), String)) + + lblCurrCarOnSale.Text = String.Format("Sale on {0}'s today!", _ + CType(Application("CarSiteInfo"), CarLotInfo).currentCarOnSale) + End Sub + + ' Just as an example... + Private Sub CleanAppData() + ' Remove a single item via string name. + Application.Remove("SomeItemIDontNeed") + + ' Destroy all application data! + Application.RemoveAll() + End Sub +End Class diff --git a/Code/Chapter 35/AppState/Global.asax b/Code/Chapter 35/AppState/Global.asax new file mode 100644 index 0000000..f179e4c --- /dev/null +++ b/Code/Chapter 35/AppState/Global.asax @@ -0,0 +1,35 @@ +<%@ Application Language="VB" %> + + \ No newline at end of file diff --git a/Code/Chapter 35/AppState/web.config b/Code/Chapter 35/AppState/web.config new file mode 100644 index 0000000..ff1dfc6 --- /dev/null +++ b/Code/Chapter 35/AppState/web.config @@ -0,0 +1,115 @@ + + + + + + +
    + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 35/CacheState/Bin/AutoLotDAL.dll b/Code/Chapter 35/CacheState/Bin/AutoLotDAL.dll new file mode 100644 index 0000000..8f15889 Binary files /dev/null and b/Code/Chapter 35/CacheState/Bin/AutoLotDAL.dll differ diff --git a/Code/Chapter 35/CacheState/Bin/AutoLotDAL.dll.refresh b/Code/Chapter 35/CacheState/Bin/AutoLotDAL.dll.refresh new file mode 100644 index 0000000..95d7f10 Binary files /dev/null and b/Code/Chapter 35/CacheState/Bin/AutoLotDAL.dll.refresh differ diff --git a/Code/Chapter 35/CacheState/Bin/AutoLotDAL.pdb b/Code/Chapter 35/CacheState/Bin/AutoLotDAL.pdb new file mode 100644 index 0000000..ab03894 Binary files /dev/null and b/Code/Chapter 35/CacheState/Bin/AutoLotDAL.pdb differ diff --git a/Code/Chapter 35/CacheState/Bin/AutoLotDAL.xml b/Code/Chapter 35/CacheState/Bin/AutoLotDAL.xml new file mode 100644 index 0000000..b8e562a --- /dev/null +++ b/Code/Chapter 35/CacheState/Bin/AutoLotDAL.xml @@ -0,0 +1,24 @@ + + + + +AutoLotDAL + + + + + + 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/Code/Chapter 35/CacheState/Default.aspx b/Code/Chapter 35/CacheState/Default.aspx new file mode 100644 index 0000000..d62223c --- /dev/null +++ b/Code/Chapter 35/CacheState/Default.aspx @@ -0,0 +1,47 @@ +<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> + + + + + + Untitled Page + + +
    +
    +
    +
    +
    +
    +
    + +
    +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    +
    +
    +  
    + + + + + + + +
    + +
    +
    + + diff --git a/Code/Chapter 35/CacheState/Default.aspx.vb b/Code/Chapter 35/CacheState/Default.aspx.vb new file mode 100644 index 0000000..b4b0e11 --- /dev/null +++ b/Code/Chapter 35/CacheState/Default.aspx.vb @@ -0,0 +1,39 @@ +Option Explicit On +Option Strict On + +Imports System.Data +Imports AutoLotConnectedLayer + +Partial Class _Default + Inherits System.Web.UI.Page + Private cnStr As String = "Data Source=(local)\SQLEXPRESS;Initial Catalog=AutoLot;Integrated Security=True" + + Protected Sub btnAddCar_Click(ByVal sender As Object, _ + ByVal e As EventArgs) Handles btnAddCar.Click + ' Update the Inventory table + ' and call RefreshGrid(). + Dim dal As New InventoryDAL() + dal.OpenConnection(cnStr) + + dal.InsertAuto(Integer.Parse(txtCarID.Text), txtCarColor.Text, _ + txtCarMake.Text, txtCarPetName.Text) + dal.CloseConnection() + RefreshGrid() + End Sub + + Private Sub RefreshGrid() + ' Populate grid. + Dim dal As New InventoryDAL() + dal.OpenConnection(cnStr) + Dim theCars As DataTable = dal.GetAllInventory() + carsGridView.DataSource = theCars + carsGridView.DataBind() + dal.CloseConnection() + End Sub + + Protected Sub Page_Load(ByVal sender As Object, _ + ByVal e As System.EventArgs) Handles Me.Load + carsGridView.DataSource = CType(Cache("AppDataTable"), DataTable) + carsGridView.DataBind() + End Sub +End Class diff --git a/Code/Chapter 35/CacheState/Global.asax b/Code/Chapter 35/CacheState/Global.asax new file mode 100644 index 0000000..fd1af05 --- /dev/null +++ b/Code/Chapter 35/CacheState/Global.asax @@ -0,0 +1,72 @@ +<%@ Application Language="VB" %> +<%@ Import Namespace = "System.Data" %> +<%@ Import Namespace="AutoLotConnectedLayer" %> + + \ No newline at end of file diff --git a/Code/Chapter 35/CacheState/web.config b/Code/Chapter 35/CacheState/web.config new file mode 100644 index 0000000..2e184b3 --- /dev/null +++ b/Code/Chapter 35/CacheState/web.config @@ -0,0 +1,115 @@ + + + + + + +
    + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 35/CookieStateApp/Default.aspx b/Code/Chapter 35/CookieStateApp/Default.aspx new file mode 100644 index 0000000..8174358 --- /dev/null +++ b/Code/Chapter 35/CookieStateApp/Default.aspx @@ -0,0 +1,34 @@ +<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> + + + + + + Untitled Page + + +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + + diff --git a/Code/Chapter 35/CookieStateApp/Default.aspx.vb b/Code/Chapter 35/CookieStateApp/Default.aspx.vb new file mode 100644 index 0000000..815a608 --- /dev/null +++ b/Code/Chapter 35/CookieStateApp/Default.aspx.vb @@ -0,0 +1,26 @@ +Option Explicit On +Option Strict On + +Partial Class _Default + Inherits System.Web.UI.Page + + Protected Sub btnNewCookie_Click(ByVal sender As Object, _ + ByVal e As System.EventArgs) Handles btnNewCookie.Click + ' Make a new (persistent) cookie. + Dim theCookie As HttpCookie = _ + New HttpCookie(txtCookieName.Text, _ + txtCookieValue.Text) + theCookie.Expires = DateTime.Parse("03/26/2009") + Response.Cookies.Add(theCookie) + End Sub + + Protected Sub btnShowCookie_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnShowCookie.Click + Dim cookieData As String = "" + For Each s As String In Request.Cookies + cookieData &= String.Format _ + ("
  • Name: {0}, Value: {1}
  • ", _ + s, Request.Cookies(s).Value) + Next + lblCookieData.Text = cookieData + End Sub +End Class diff --git a/Code/Chapter 35/CookieStateApp/web.config b/Code/Chapter 35/CookieStateApp/web.config new file mode 100644 index 0000000..ff1dfc6 --- /dev/null +++ b/Code/Chapter 35/CookieStateApp/web.config @@ -0,0 +1,115 @@ + + + + + + +
    + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 35/FunWithProfiles/App_Code/UserAddress.vb b/Code/Chapter 35/FunWithProfiles/App_Code/UserAddress.vb new file mode 100644 index 0000000..ab9e435 --- /dev/null +++ b/Code/Chapter 35/FunWithProfiles/App_Code/UserAddress.vb @@ -0,0 +1,9 @@ +Imports Microsoft.VisualBasic +Imports System + + _ +Public Class UserAddress + Public street As String + Public city As String + Public state As String +End Class diff --git a/Code/Chapter 35/FunWithProfiles/Default.aspx b/Code/Chapter 35/FunWithProfiles/Default.aspx new file mode 100644 index 0000000..e88252d --- /dev/null +++ b/Code/Chapter 35/FunWithProfiles/Default.aspx @@ -0,0 +1,34 @@ +<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> + + + + + + Untitled Page + + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    + +                 +
    +
    + +               +
    +
    +
    +
    + + + + diff --git a/Code/Chapter 35/FunWithProfiles/Default.aspx.vb b/Code/Chapter 35/FunWithProfiles/Default.aspx.vb new file mode 100644 index 0000000..9051389 --- /dev/null +++ b/Code/Chapter 35/FunWithProfiles/Default.aspx.vb @@ -0,0 +1,27 @@ +Partial Class _Default + Inherits System.Web.UI.Page + + Protected Sub Page_Load(ByVal sender As Object, _ + ByVal e As System.EventArgs) Handles Me.Load + GetUserAddress() + End Sub + + Protected Sub btnSubmit_Click(ByVal sender As Object, _ + ByVal e As System.EventArgs) Handles btnSubmit.Click + ' Database writes happening here! + Profile.AddressInfo.City = txtCity.Text + Profile.AddressInfo.street = txtStreetAddress.Text + Profile.AddressInfo.State = txtState.Text + + ' Get settings from database. + GetUserAddress() + End Sub + + Private Sub GetUserAddress() + ' Database reads happening here! + lblUserData.Text = String.Format("You live here: {0}, {1}, {2}", _ + Profile.AddressInfo.street, Profile.AddressInfo.city, _ + Profile.AddressInfo.state) + End Sub + +End Class diff --git a/Code/Chapter 35/FunWithProfiles/web.config b/Code/Chapter 35/FunWithProfiles/web.config new file mode 100644 index 0000000..83c8043 --- /dev/null +++ b/Code/Chapter 35/FunWithProfiles/web.config @@ -0,0 +1,121 @@ + + + + + + +
    + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 35/SessionState/App_Code/UserShoppingCart.vb b/Code/Chapter 35/SessionState/App_Code/UserShoppingCart.vb new file mode 100644 index 0000000..57006f8 --- /dev/null +++ b/Code/Chapter 35/SessionState/App_Code/UserShoppingCart.vb @@ -0,0 +1,20 @@ +Option Explicit On +Option Strict On + +Imports Microsoft.VisualBasic + +Public Class UserShoppingCart + Public desiredCar As String + Public desiredCarColor As String + Public downPayment As Single + Public isLeasing As Boolean + Public dateOfPickUp As DateTime + + Public Overrides Function ToString() As String + Return String.Format("Car: {0}
    Color: {1}
    " & _ + "$ Down: {2}
    Lease: {3}
    Pick-up Date: {4}", _ + desiredCar, desiredCarColor, downPayment, _ + isLeasing, dateOfPickUp.ToShortDateString()) + End Function +End Class + diff --git a/Code/Chapter 35/SessionState/Default.aspx b/Code/Chapter 35/SessionState/Default.aspx new file mode 100644 index 0000000..137e846 --- /dev/null +++ b/Code/Chapter 35/SessionState/Default.aspx @@ -0,0 +1,52 @@ +<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> + + + + + + Untitled Page + + +
    +
    +
    +
    +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    + +
    +
    + + + + + + + + + + +
    +
    +
    +
    + +
    + +
    +
    + + diff --git a/Code/Chapter 35/SessionState/Default.aspx.vb b/Code/Chapter 35/SessionState/Default.aspx.vb new file mode 100644 index 0000000..c4248ec --- /dev/null +++ b/Code/Chapter 35/SessionState/Default.aspx.vb @@ -0,0 +1,30 @@ +Option Explicit On +Option Strict On + +Partial Class _Default + Inherits System.Web.UI.Page + + Protected Sub btnSubmit_Click(ByVal sender As Object, _ + ByVal e As System.EventArgs) Handles btnSubmit.Click + ' Set current user prefs. + Try + Dim u As UserShoppingCart = CType(Session("UserShoppingCartInfo"), UserShoppingCart) + u.dateOfPickUp = myCalendar.SelectedDate + u.desiredCar = txtCarMake.Text + u.desiredCarColor = txtCarColor.Text + u.downPayment = Single.Parse(txtDownPayment.Text) + u.isLeasing = chkIsLeasing.Checked + lblUserInfo.Text = u.ToString() + Session("UserShoppingCartInfo") = u + Catch ex As Exception + lblUserInfo.Text = ex.Message + End Try + End Sub + + Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load + If Not IsPostBack Then + lblUserID.Text = String.Format("Here is your ID: {0}", _ + Session.SessionID) + End If + End Sub +End Class diff --git a/Code/Chapter 35/SessionState/Global.asax b/Code/Chapter 35/SessionState/Global.asax new file mode 100644 index 0000000..95d0354 --- /dev/null +++ b/Code/Chapter 35/SessionState/Global.asax @@ -0,0 +1,31 @@ +<%@ Application Language="VB" %> + + \ No newline at end of file diff --git a/Code/Chapter 35/SessionState/web.config b/Code/Chapter 35/SessionState/web.config new file mode 100644 index 0000000..ff1dfc6 --- /dev/null +++ b/Code/Chapter 35/SessionState/web.config @@ -0,0 +1,115 @@ + + + + + + +
    + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 35/SimpleStateExample/Default.aspx b/Code/Chapter 35/SimpleStateExample/Default.aspx new file mode 100644 index 0000000..863b0dc --- /dev/null +++ b/Code/Chapter 35/SimpleStateExample/Default.aspx @@ -0,0 +1,25 @@ +<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> + + + + + + Untitled Page + + +
    +
    +
    + +
    +
    + +
    +
    +   + + +
    +
    + + diff --git a/Code/Chapter 35/SimpleStateExample/Default.aspx.vb b/Code/Chapter 35/SimpleStateExample/Default.aspx.vb new file mode 100644 index 0000000..f48445e --- /dev/null +++ b/Code/Chapter 35/SimpleStateExample/Default.aspx.vb @@ -0,0 +1,38 @@ +Option Explicit On +Option Strict On + +' This is the 'stateless' version of the class +' +'Partial Class _Default +' Inherits System.Web.UI.Page +' ' State data? +' Private userFavoriteCar As String + +' Protected Sub btnSetCar_Click(ByVal sender As Object, _ +' ByVal e As System.EventArgs) Handles btnSetCar.Click +' ' Store favorite car in member variable. +' userFavoriteCar = txtFavCar.Text +' End Sub + +' Protected Sub btnGetCar_Click(ByVal sender As Object, _ +' ByVal e As System.EventArgs) Handles btnGetCar.Click +' ' Set label text to value of member variable. +' lblFavCar.Text = userFavoriteCar +' End Sub +'End Class + +' With state! +Partial Class _Default + Inherits System.Web.UI.Page + Protected Sub btnSetCar_Click(ByVal sender As Object, _ + ByVal e As System.EventArgs) Handles btnSetCar.Click + ' Store favorite car in session variable. + Session("UserFavCar") = txtFavCar.Text + End Sub + + Protected Sub btnGetCar_Click(ByVal sender As Object, _ + ByVal e As System.EventArgs) Handles btnGetCar.Click + ' Set label text to value of session variable. + lblFavCar.Text = CType(Session("UserFavCar"), String) + End Sub +End Class diff --git a/Code/Chapter 35/SimpleStateExample/web.config b/Code/Chapter 35/SimpleStateExample/web.config new file mode 100644 index 0000000..ff1dfc6 --- /dev/null +++ b/Code/Chapter 35/SimpleStateExample/web.config @@ -0,0 +1,115 @@ + + + + + + +
    + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 35/ViewStateApp/Default.aspx b/Code/Chapter 35/ViewStateApp/Default.aspx new file mode 100644 index 0000000..c75c592 --- /dev/null +++ b/Code/Chapter 35/ViewStateApp/Default.aspx @@ -0,0 +1,29 @@ +<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" EnableViewState ="false"%> + + + + + + Untitled Page + + +
    +
    +
    +
    +
    +  
    + + +
    +
    +  
    +
    +
    +
    + + +
    +
    + + diff --git a/Code/Chapter 35/ViewStateApp/Default.aspx.vb b/Code/Chapter 35/ViewStateApp/Default.aspx.vb new file mode 100644 index 0000000..dd94c89 --- /dev/null +++ b/Code/Chapter 35/ViewStateApp/Default.aspx.vb @@ -0,0 +1,26 @@ +Option Explicit On +Option Strict On + +' EnableViewState has been set to false in the Page directive! +' Set to true to change the behnvior of this page. + +Partial Class _Default + Inherits System.Web.UI.Page + + Protected Sub btnAddToVS_Click(ByVal sender As Object, _ + ByVal e As System.EventArgs) Handles btnAddToVS.Click + ViewState("CustomViewStateItem") = "Some user data" + lblVSValue.Text = CType(ViewState("CustomViewStateItem"), String) + End Sub + + Protected Sub Page_Load(ByVal sender As Object, _ + ByVal e As System.EventArgs) Handles Me.Load + If Not IsPostBack Then + ' Fill ListBox dynamically! + myListBox.Items.Add("Item One") + myListBox.Items.Add("Item Two") + myListBox.Items.Add("Item Three") + myListBox.Items.Add("Item Four") + End If + End Sub +End Class diff --git a/Code/Chapter 35/ViewStateApp/web.config b/Code/Chapter 35/ViewStateApp/web.config new file mode 100644 index 0000000..ff1dfc6 --- /dev/null +++ b/Code/Chapter 35/ViewStateApp/web.config @@ -0,0 +1,115 @@ + + + + + + +
    + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Chapter 4/FunWithArrays/FunWithArrays.sln b/Code/Chapter 4/FunWithArrays/FunWithArrays.sln new file mode 100644 index 0000000..cbc7128 --- /dev/null +++ b/Code/Chapter 4/FunWithArrays/FunWithArrays.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "FunWithArrays", "FunWithArrays.vbproj", "{50FDA6F4-2E86-4CEE-A8E1-88D6FCFC5C20}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {50FDA6F4-2E86-4CEE-A8E1-88D6FCFC5C20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {50FDA6F4-2E86-4CEE-A8E1-88D6FCFC5C20}.Debug|Any CPU.Build.0 = Debug|Any CPU + {50FDA6F4-2E86-4CEE-A8E1-88D6FCFC5C20}.Release|Any CPU.ActiveCfg = Release|Any CPU + {50FDA6F4-2E86-4CEE-A8E1-88D6FCFC5C20}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 4/FunWithArrays/FunWithArrays.suo b/Code/Chapter 4/FunWithArrays/FunWithArrays.suo new file mode 100644 index 0000000..0573c6c Binary files /dev/null and b/Code/Chapter 4/FunWithArrays/FunWithArrays.suo differ diff --git a/Code/Chapter 4/FunWithArrays/FunWithArrays.vbproj b/Code/Chapter 4/FunWithArrays/FunWithArrays.vbproj new file mode 100644 index 0000000..f72f59b --- /dev/null +++ b/Code/Chapter 4/FunWithArrays/FunWithArrays.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {50FDA6F4-2E86-4CEE-A8E1-88D6FCFC5C20} + Exe + FunWithArrays.Program + FunWithArrays + FunWithArrays + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + FunWithArrays.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + FunWithArrays.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 4/FunWithArrays/FunWithArrays.vbproj.user b/Code/Chapter 4/FunWithArrays/FunWithArrays.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 4/FunWithArrays/FunWithArrays.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 4/FunWithArrays/My Project/Application.Designer.vb b/Code/Chapter 4/FunWithArrays/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 4/FunWithArrays/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 4/FunWithArrays/My Project/Application.myapp b/Code/Chapter 4/FunWithArrays/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 4/FunWithArrays/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 4/FunWithArrays/My Project/AssemblyInfo.vb b/Code/Chapter 4/FunWithArrays/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..6208a08 --- /dev/null +++ b/Code/Chapter 4/FunWithArrays/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/Code/Chapter 4/FunWithArrays/My Project/Resources.Designer.vb b/Code/Chapter 4/FunWithArrays/My Project/Resources.Designer.vb new file mode 100644 index 0000000..80b3487 --- /dev/null +++ b/Code/Chapter 4/FunWithArrays/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("FunWithArrays.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/Code/Chapter 4/FunWithArrays/My Project/Resources.resx b/Code/Chapter 4/FunWithArrays/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 4/FunWithArrays/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/Code/Chapter 4/FunWithArrays/My Project/Settings.Designer.vb b/Code/Chapter 4/FunWithArrays/My Project/Settings.Designer.vb new file mode 100644 index 0000000..1947bfa --- /dev/null +++ b/Code/Chapter 4/FunWithArrays/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.FunWithArrays.My.MySettings + Get + Return Global.FunWithArrays.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 4/FunWithArrays/My Project/Settings.settings b/Code/Chapter 4/FunWithArrays/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 4/FunWithArrays/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 4/FunWithArrays/Program.vb b/Code/Chapter 4/FunWithArrays/Program.vb new file mode 100644 index 0000000..5bdc4ad --- /dev/null +++ b/Code/Chapter 4/FunWithArrays/Program.vb @@ -0,0 +1,165 @@ +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' +'' This program illustrates how to create and manipulate +'' array types. +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' +Module Program + ' Comment / Uncomment method calls within Main() to test. + Sub Main() + Console.WriteLine("***** Fun with Arrays *****") + ' SimpleArrays() + ' ArrayOfObjects() + ' ArrayLowerBounds() + ' RedimPreserve() + ' MultiDimArray() + SystemArrayFunctionality() + End Sub + +End Module + +Module HelperMethods + +#Region "Simple arrays" + Sub SimpleArrays() + Console.WriteLine("=> Simple Array Creation.") + ' Create and fill an array of 3 Integers + Dim myInts() As Integer = {100, 200, 300} + ' Now print each value. + For Each i As Integer In myInts + Console.WriteLine(i) + Next + + ' String array with assigned data. + Dim myStrs(2) As String + myStrs(0) = "Cerebus" + myStrs(1) = "Jaka" + myStrs(2) = "Astoria" + For Each s As String In myStrs + Console.WriteLine(s) + Next + End Sub +#End Region + +#Region "Array of Objects" + Sub ArrayOfObjects() + Console.WriteLine("=> Array of Objects.") + + ' An array of Objects can be anything at all. + Dim myObjects(3) As Object + myObjects(0) = 10 + myObjects(1) = False + myObjects(2) = New DateTime(1969, 3, 24) + myObjects(3) = "Form & Void" + + For Each obj As Object In myObjects + ' Print the type and value for each item in array. + Console.WriteLine("Type: {0}, Value: {1}", obj.GetType(), obj) + Next + Console.WriteLine() + End Sub +#End Region + +#Region "Array w/ lower bounds" + Sub ArrayLowerBounds() + Console.WriteLine("=> Using Array.CreateInstance().") + ' An array representing the length of each dimension + Dim myLengths() As Integer = {3} + ' An array representing the lower bound of each dimension. + Dim myBounds() As Integer = {5} + + ' Call Array.CreateInstance() specifying + ' the type of array, length and bounds. + Dim mySpecialArray As Array = _ + Array.CreateInstance(GetType(Integer), myLengths, myBounds) + Console.WriteLine("Lower Bound: {0}", LBound(mySpecialArray)) + Console.WriteLine("Upper Bound: {0}", UBound(mySpecialArray)) + Console.WriteLine() + End Sub + +#End Region + +#Region "Redim / preserve" + Sub RedimPreserve() + Console.WriteLine("=> Redim / Preserve keywords.") + ' Make an array with 10 slots. + Dim myValues(9) As Integer + For i As Integer = 0 To 9 + myValues(i) = i + Next + For i As Integer = 0 To UBound(myValues) + Console.Write("{0} ", myValues(i)) + Next + + ' ReDim the array with extra slots. + ReDim Preserve myValues(15) + For i As Integer = 9 To UBound(myValues) + myValues(i) = i + Next + For i As Integer = 0 To UBound(myValues) + Console.Write("{0} ", myValues(i)) + Next + Console.WriteLine() + End Sub +#End Region + +#Region "multidim-array" + Sub MultiDimArray() + Console.WriteLine("=> Multidimensional arrays.") + Dim myMatrix(6, 6) As Integer ' makes a 7x7 array + ' Populate array. + Dim k As Integer, j As Integer + For k = 0 To 6 + For j = 0 To 6 + myMatrix(k, j) = k * j + Next j + Next k + ' Show array. + For k = 0 To 6 + For j = 0 To 6 + Console.Write(myMatrix(k, j) & " ") + Next j + Console.WriteLine() + Next k + Console.WriteLine() + End Sub + +#End Region + +#Region "Using System.Array" + Sub SystemArrayFunctionality() + Console.WriteLine("=> Working with System.Array.") + ' Initialize items at startup. + Dim gothicBands() As String = _ + {"Tones on Tail", "Bauhaus", "Sisters of Mercy"} + + ' Print out names in declared order. + Console.WriteLine(" -> Here is the array:") + For i As Integer = 0 To gothicBands.GetUpperBound(0) + ' Print a name + Console.Write(gothicBands(i) & " ") + Next + Console.WriteLine() + Console.WriteLine() + + ' Reverse them... + Array.Reverse(gothicBands) + Console.WriteLine(" -> The reversed array") + ' ... and print them. + For i As Integer = 0 To gothicBands.GetUpperBound(0) + ' Print a name + Console.Write(gothicBands(i) & " ") + Next + Console.WriteLine() + Console.WriteLine() + + ' Clear out all but the final member. + Console.WriteLine(" -> Cleared out all but one...") + Array.Clear(gothicBands, 1, 2) + For i As Integer = 0 To gothicBands.GetUpperBound(0) + ' Print a name + Console.Write(gothicBands(i) & " ") + Next + Console.WriteLine() + End Sub +#End Region + +End Module \ No newline at end of file diff --git a/Code/Chapter 4/FunWithEnums/FunWithEnums.sln b/Code/Chapter 4/FunWithEnums/FunWithEnums.sln new file mode 100644 index 0000000..79a605e --- /dev/null +++ b/Code/Chapter 4/FunWithEnums/FunWithEnums.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "FunWithEnums", "FunWithEnums.vbproj", "{A803D8F3-7941-4E6B-B8F4-4B025371802F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A803D8F3-7941-4E6B-B8F4-4B025371802F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A803D8F3-7941-4E6B-B8F4-4B025371802F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A803D8F3-7941-4E6B-B8F4-4B025371802F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A803D8F3-7941-4E6B-B8F4-4B025371802F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 4/FunWithEnums/FunWithEnums.suo b/Code/Chapter 4/FunWithEnums/FunWithEnums.suo new file mode 100644 index 0000000..d494992 Binary files /dev/null and b/Code/Chapter 4/FunWithEnums/FunWithEnums.suo differ diff --git a/Code/Chapter 4/FunWithEnums/FunWithEnums.vbproj b/Code/Chapter 4/FunWithEnums/FunWithEnums.vbproj new file mode 100644 index 0000000..6fc8b85 --- /dev/null +++ b/Code/Chapter 4/FunWithEnums/FunWithEnums.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {A803D8F3-7941-4E6B-B8F4-4B025371802F} + Exe + FunWithEnums.Program + FunWithEnums + FunWithEnums + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + FunWithEnums.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + FunWithEnums.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 4/FunWithEnums/FunWithEnums.vbproj.user b/Code/Chapter 4/FunWithEnums/FunWithEnums.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 4/FunWithEnums/FunWithEnums.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 4/FunWithEnums/My Project/Application.Designer.vb b/Code/Chapter 4/FunWithEnums/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 4/FunWithEnums/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 4/FunWithEnums/My Project/Application.myapp b/Code/Chapter 4/FunWithEnums/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 4/FunWithEnums/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 4/FunWithEnums/My Project/AssemblyInfo.vb b/Code/Chapter 4/FunWithEnums/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..0e939aa --- /dev/null +++ b/Code/Chapter 4/FunWithEnums/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/Code/Chapter 4/FunWithEnums/My Project/Resources.Designer.vb b/Code/Chapter 4/FunWithEnums/My Project/Resources.Designer.vb new file mode 100644 index 0000000..436f113 --- /dev/null +++ b/Code/Chapter 4/FunWithEnums/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("FunWithEnums.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/Code/Chapter 4/FunWithEnums/My Project/Resources.resx b/Code/Chapter 4/FunWithEnums/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 4/FunWithEnums/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/Code/Chapter 4/FunWithEnums/My Project/Settings.Designer.vb b/Code/Chapter 4/FunWithEnums/My Project/Settings.Designer.vb new file mode 100644 index 0000000..131a4da --- /dev/null +++ b/Code/Chapter 4/FunWithEnums/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.FunWithEnums.My.MySettings + Get + Return Global.FunWithEnums.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 4/FunWithEnums/My Project/Settings.settings b/Code/Chapter 4/FunWithEnums/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 4/FunWithEnums/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 4/FunWithEnums/Program.vb b/Code/Chapter 4/FunWithEnums/Program.vb new file mode 100644 index 0000000..6eb57a7 --- /dev/null +++ b/Code/Chapter 4/FunWithEnums/Program.vb @@ -0,0 +1,73 @@ +Option Strict On +'''''''''''''''''''''''''''''''''''''''''''''''''''' +' This program illustrates how to define and +' manipulate Enum types. +'''''''''''''''''''''''''''''''''''''''''''''''''''' +' Build an alias to System.Enum +Imports DotNetEnum = System.Enum + +#Region "Enum definition" +' A custom enumeration. +' Elements of an enumeration need not be sequential! +' This time, EmpType maps to an underlying Byte. +Enum EmpType As Byte + Manager = 10 + Grunt = 1 + Contractor = 100 + VicePresident = 9 +End Enum +#End Region + +Module Program + Sub Main() + Console.WriteLine("**** Fun with Enums *****") + Dim emp As EmpType + emp = EmpType.Contractor + ' Prints out "Contractor = 100". + Console.WriteLine("{0} = {1}", emp.ToString(), CInt(emp)) + + Dim e2 As EmpType + Dim day As DayOfWeek + Dim cc As ConsoleColor + EvaluateEnum(e2) + EvaluateEnum(day) + EvaluateEnum(cc) + End Sub + +#Region "Evaulate enum" + ' This method will print out the details of any enum. + Sub EvaluateEnum(ByVal e As [Enum]) + Console.WriteLine("=> Information about {0}", e.GetType().Name) + + Console.WriteLine("Underlying storage type: {0}", _ + [Enum].GetUnderlyingType(e.GetType())) + + ' Get all name / value pairs for incoming parameter. + Dim enumData As Array = [Enum].GetValues(e.GetType()) + Console.WriteLine("This enum has {0} members.", enumData.Length) + + ' Now show the string name and associated value. + For i As Integer = 0 To enumData.Length - 1 + Console.WriteLine("Name: {0}, Value: {1}", enumData.GetValue(i).ToString(), CInt(enumData.GetValue(i))) + Next + Console.WriteLine() + End Sub +#End Region + +#Region "Ask for bonus" + ' Enums as parameters. + Sub AskForBonus(ByVal e As EmpType) + Select Case (e) + Case EmpType.Contractor + Console.WriteLine("You already get enough cash...") + Case EmpType.Grunt + Console.WriteLine("You have got to be kidding...") + Case EmpType.Manager + Console.WriteLine("How about stock options instead?") + Case EmpType.VicePresident + Console.WriteLine("VERY GOOD, Sir!") + End Select + End Sub +#End Region + +End Module diff --git a/Code/Chapter 4/FunWithMethods/FunWithMethods.sln b/Code/Chapter 4/FunWithMethods/FunWithMethods.sln new file mode 100644 index 0000000..8873311 --- /dev/null +++ b/Code/Chapter 4/FunWithMethods/FunWithMethods.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "FunWithMethods", "FunWithMethods.vbproj", "{2C64CB54-5135-4BDF-BD95-82FDE8C49E32}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2C64CB54-5135-4BDF-BD95-82FDE8C49E32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2C64CB54-5135-4BDF-BD95-82FDE8C49E32}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2C64CB54-5135-4BDF-BD95-82FDE8C49E32}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2C64CB54-5135-4BDF-BD95-82FDE8C49E32}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 4/FunWithMethods/FunWithMethods.suo b/Code/Chapter 4/FunWithMethods/FunWithMethods.suo new file mode 100644 index 0000000..bca49a8 Binary files /dev/null and b/Code/Chapter 4/FunWithMethods/FunWithMethods.suo differ diff --git a/Code/Chapter 4/FunWithMethods/FunWithMethods.vbproj b/Code/Chapter 4/FunWithMethods/FunWithMethods.vbproj new file mode 100644 index 0000000..bddb219 --- /dev/null +++ b/Code/Chapter 4/FunWithMethods/FunWithMethods.vbproj @@ -0,0 +1,135 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {2C64CB54-5135-4BDF-BD95-82FDE8C49E32} + Exe + FunWithMethods.Program + FunWithMethods + FunWithMethods + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + FunWithMethods.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + FunWithMethods.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 4/FunWithMethods/FunWithMethods.vbproj.user b/Code/Chapter 4/FunWithMethods/FunWithMethods.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 4/FunWithMethods/FunWithMethods.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 4/FunWithMethods/HelperFunctions.vb b/Code/Chapter 4/FunWithMethods/HelperFunctions.vb new file mode 100644 index 0000000..5581dbc --- /dev/null +++ b/Code/Chapter 4/FunWithMethods/HelperFunctions.vb @@ -0,0 +1,63 @@ +Module HelperFunctions + +#Region "ByRef / ByVal" + ' Subroutines have no return value. + Sub PrintMessage(ByRef msg As String) + Console.WriteLine("Your message is: {0}", msg) + ' Caller will see this change! + msg = "Thank you for calling this method" + End Sub + + ' Functions have a return value. + Function Add(ByVal x As Integer, ByVal y As Integer) As Integer + Dim answer As Integer = x + y + ' Try to set the params to a new value. + x = 22 : y = 30 + Return answer + End Function + + ' This will not compile if Option Strict is on! + Function Test() ' As Object assumed. + Return 5 + End Function +#End Region + +#Region "Optional args" + Sub PrintFormattedMessage(ByVal msg As String, _ + Optional ByVal upperCase As Boolean = False, _ + Optional ByVal timesToRepeat As Integer = 0, _ + Optional ByVal textColor As ConsoleColor = ConsoleColor.Green) + ' Store current console foreground color. + Dim fGroundColor As ConsoleColor = Console.ForegroundColor + ' Set Console foreground color. + Console.ForegroundColor = textColor + ' Print mesage in correct case x number of times. + For i As Integer = 0 To timesToRepeat + Console.WriteLine(msg) + Next + ' Reset current console forground color. + Console.ForegroundColor = fGroundColor + End Sub +#End Region + +#Region "Param array" + Function CalculateAverage(ByVal ParamArray itemsToAvg() As Integer) As Double + Dim itemCount As Integer = UBound(itemsToAvg) + Dim result As Integer + For i As Integer = 0 To itemCount + result += itemsToAvg(i) + Next + Return result / itemCount + End Function +#End Region + +#Region "Static data in method" + Sub PrintLocalCounter() + ' Note the Static keyword. + Static Dim localCounter As Integer + localCounter += 1 + Console.Write("{0} ", localCounter) + End Sub +#End Region + +End Module diff --git a/Code/Chapter 4/FunWithMethods/My Project/Application.Designer.vb b/Code/Chapter 4/FunWithMethods/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 4/FunWithMethods/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 4/FunWithMethods/My Project/Application.myapp b/Code/Chapter 4/FunWithMethods/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 4/FunWithMethods/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 4/FunWithMethods/My Project/AssemblyInfo.vb b/Code/Chapter 4/FunWithMethods/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..9dc0210 --- /dev/null +++ b/Code/Chapter 4/FunWithMethods/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/Code/Chapter 4/FunWithMethods/My Project/Resources.Designer.vb b/Code/Chapter 4/FunWithMethods/My Project/Resources.Designer.vb new file mode 100644 index 0000000..58fca3f --- /dev/null +++ b/Code/Chapter 4/FunWithMethods/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("FunWithMethods.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/Code/Chapter 4/FunWithMethods/My Project/Resources.resx b/Code/Chapter 4/FunWithMethods/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 4/FunWithMethods/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/Code/Chapter 4/FunWithMethods/My Project/Settings.Designer.vb b/Code/Chapter 4/FunWithMethods/My Project/Settings.Designer.vb new file mode 100644 index 0000000..495b894 --- /dev/null +++ b/Code/Chapter 4/FunWithMethods/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.FunWithMethods.My.MySettings + Get + Return Global.FunWithMethods.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 4/FunWithMethods/My Project/Settings.settings b/Code/Chapter 4/FunWithMethods/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 4/FunWithMethods/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 4/FunWithMethods/Program.vb b/Code/Chapter 4/FunWithMethods/Program.vb new file mode 100644 index 0000000..e52d6c8 --- /dev/null +++ b/Code/Chapter 4/FunWithMethods/Program.vb @@ -0,0 +1,54 @@ +''''''''''''''''''''''''''''''''''''''''''''''' +' This program illustrates the construction of +' methods and the ByVal, ByRef, ParamArray and +' Optional keywords as well as static local +' data. +''''''''''''''''''''''''''''''''''''''''''''''' +Module Program + + Sub Main() + Console.WriteLine("***** Fun with Methods *****") + ' Pass two Integers by value. + Dim x, y As Integer + x = 10 : y = 20 + Console.WriteLine("{0} + {1} = {2}", x, y, Add(x, y)) + + ' X is still 10 and y is still 20. + Console.WriteLine("After call x = {0} and y = {1}", x, y) + Console.WriteLine() + + ' Pass a string by value, via (). + Dim msg As String = "Hello from Main!" + PrintMessage(msg) + Console.WriteLine("After call msg = {0}", msg) + Console.WriteLine() + + ' Call PrintFormattedMessage() using various optional args. + ' Accept all defaults for the optional args. + PrintFormattedMessage("Call One") + + ' Provide each optional argument. + PrintFormattedMessage("Call Two", True, 5, ConsoleColor.Yellow) + + ' Print this message in current case, one time, in gray. + PrintFormattedMessage("Call Three", , , ConsoleColor.Gray) + + ' Same as previously shown, but cleaner! + PrintFormattedMessage("Call Four", textColor:=ConsoleColor.Gray) + + ' ParamArray data can be sent as a caller supplied array + ' or a comma-delimited list of arguments. + Console.WriteLine(CalculateAverage(10, 11, 12, 44)) + Dim data() As Integer = {22, 33, 44, 55} + Console.WriteLine(CalculateAverage(data)) + Console.WriteLine() + + ' Call method with static local data. + For i As Integer = 0 To 10 + PrintLocalCounter() + Next + Console.WriteLine() + Console.ReadLine() + End Sub + +End Module diff --git a/Code/Chapter 4/FunWithStructures/FunWithStructures.sln b/Code/Chapter 4/FunWithStructures/FunWithStructures.sln new file mode 100644 index 0000000..42dacab --- /dev/null +++ b/Code/Chapter 4/FunWithStructures/FunWithStructures.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "FunWithStructures", "FunWithStructures.vbproj", "{E755D0A0-9707-4590-905B-87309BB2F987}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E755D0A0-9707-4590-905B-87309BB2F987}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E755D0A0-9707-4590-905B-87309BB2F987}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E755D0A0-9707-4590-905B-87309BB2F987}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E755D0A0-9707-4590-905B-87309BB2F987}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 4/FunWithStructures/FunWithStructures.suo b/Code/Chapter 4/FunWithStructures/FunWithStructures.suo new file mode 100644 index 0000000..04ccf68 Binary files /dev/null and b/Code/Chapter 4/FunWithStructures/FunWithStructures.suo differ diff --git a/Code/Chapter 4/FunWithStructures/FunWithStructures.vbproj b/Code/Chapter 4/FunWithStructures/FunWithStructures.vbproj new file mode 100644 index 0000000..7f353ec --- /dev/null +++ b/Code/Chapter 4/FunWithStructures/FunWithStructures.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {E755D0A0-9707-4590-905B-87309BB2F987} + Exe + FunWithStructures.Program + FunWithStructures + FunWithStructures + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + FunWithStructures.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + FunWithStructures.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 4/FunWithStructures/FunWithStructures.vbproj.user b/Code/Chapter 4/FunWithStructures/FunWithStructures.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 4/FunWithStructures/FunWithStructures.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 4/FunWithStructures/My Project/Application.Designer.vb b/Code/Chapter 4/FunWithStructures/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 4/FunWithStructures/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 4/FunWithStructures/My Project/Application.myapp b/Code/Chapter 4/FunWithStructures/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 4/FunWithStructures/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 4/FunWithStructures/My Project/AssemblyInfo.vb b/Code/Chapter 4/FunWithStructures/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..86a8f0c --- /dev/null +++ b/Code/Chapter 4/FunWithStructures/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/Code/Chapter 4/FunWithStructures/My Project/Resources.Designer.vb b/Code/Chapter 4/FunWithStructures/My Project/Resources.Designer.vb new file mode 100644 index 0000000..127380b --- /dev/null +++ b/Code/Chapter 4/FunWithStructures/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("FunWithStructures.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/Code/Chapter 4/FunWithStructures/My Project/Resources.resx b/Code/Chapter 4/FunWithStructures/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 4/FunWithStructures/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/Code/Chapter 4/FunWithStructures/My Project/Settings.Designer.vb b/Code/Chapter 4/FunWithStructures/My Project/Settings.Designer.vb new file mode 100644 index 0000000..70346eb --- /dev/null +++ b/Code/Chapter 4/FunWithStructures/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.FunWithStructures.My.MySettings + Get + Return Global.FunWithStructures.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 4/FunWithStructures/My Project/Settings.settings b/Code/Chapter 4/FunWithStructures/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 4/FunWithStructures/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 4/FunWithStructures/Program.vb b/Code/Chapter 4/FunWithStructures/Program.vb new file mode 100644 index 0000000..31ef4e5 --- /dev/null +++ b/Code/Chapter 4/FunWithStructures/Program.vb @@ -0,0 +1,43 @@ +''''''''''''''''''''''''''''''''''''''''''' +' This example illustrates the basics +' of working with Structure types. +' Later chapters in the text will dive +' into further details. +''''''''''''''''''''''''''''''''''''''''''' +#Region "A simple structure type" +Structure Point + Public X, Y As Integer + Sub Display() + Console.WriteLine("X = {0}, Y = {1}", X, Y) + End Sub + Sub Increment() + X += 1 : Y += 1 + End Sub + Sub Decrement() + X -= 1 : Y -= 1 + End Sub + ' Recall that the ‘x’ format flag displays the + ' data in hex format. + Function PointAsHexString() As String + Return String.Format("X = {0:x}, Y = {1:x}", X, Y) + End Function +End Structure +#End Region + +Module Program + + Sub Main() + Console.WriteLine("***** A First Look at Structures *****") + ' Create an initial Point. + Dim myPoint As Point + myPoint.X = 349 + myPoint.Y = 76 + myPoint.Display() + + ' Adjust the X and Y values. + myPoint.Increment() + myPoint.Display() + Console.WriteLine("Point in hex: {0}", myPoint.PointAsHexString()) + End Sub + +End Module diff --git a/Code/Chapter 4/MethodOverloading/MethodOverloading.sln b/Code/Chapter 4/MethodOverloading/MethodOverloading.sln new file mode 100644 index 0000000..a41a5e8 --- /dev/null +++ b/Code/Chapter 4/MethodOverloading/MethodOverloading.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MethodOverloading", "MethodOverloading.vbproj", "{A5BA8AA5-AE89-446F-A061-D6BFC3F1F14E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A5BA8AA5-AE89-446F-A061-D6BFC3F1F14E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A5BA8AA5-AE89-446F-A061-D6BFC3F1F14E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A5BA8AA5-AE89-446F-A061-D6BFC3F1F14E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A5BA8AA5-AE89-446F-A061-D6BFC3F1F14E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 4/MethodOverloading/MethodOverloading.suo b/Code/Chapter 4/MethodOverloading/MethodOverloading.suo new file mode 100644 index 0000000..952b77a Binary files /dev/null and b/Code/Chapter 4/MethodOverloading/MethodOverloading.suo differ diff --git a/Code/Chapter 4/MethodOverloading/MethodOverloading.vbproj b/Code/Chapter 4/MethodOverloading/MethodOverloading.vbproj new file mode 100644 index 0000000..0b7ae1c --- /dev/null +++ b/Code/Chapter 4/MethodOverloading/MethodOverloading.vbproj @@ -0,0 +1,139 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {A5BA8AA5-AE89-446F-A061-D6BFC3F1F14E} + Exe + MethodOverloading.Program + MethodOverloading + MethodOverloading + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + On + + + true + full + true + true + bin\Debug\ + MethodOverloading.xml + + + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + + + pdbonly + false + true + true + bin\Release\ + MethodOverloading.xml + + + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 4/MethodOverloading/MethodOverloading.vbproj.user b/Code/Chapter 4/MethodOverloading/MethodOverloading.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 4/MethodOverloading/MethodOverloading.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 4/MethodOverloading/My Project/Application.Designer.vb b/Code/Chapter 4/MethodOverloading/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 4/MethodOverloading/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 4/MethodOverloading/My Project/Application.myapp b/Code/Chapter 4/MethodOverloading/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 4/MethodOverloading/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 4/MethodOverloading/My Project/AssemblyInfo.vb b/Code/Chapter 4/MethodOverloading/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..31fb571 --- /dev/null +++ b/Code/Chapter 4/MethodOverloading/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/Code/Chapter 4/MethodOverloading/My Project/Resources.Designer.vb b/Code/Chapter 4/MethodOverloading/My Project/Resources.Designer.vb new file mode 100644 index 0000000..46857c9 --- /dev/null +++ b/Code/Chapter 4/MethodOverloading/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("MethodOverloading.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/Code/Chapter 4/MethodOverloading/My Project/Resources.resx b/Code/Chapter 4/MethodOverloading/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 4/MethodOverloading/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/Code/Chapter 4/MethodOverloading/My Project/Settings.Designer.vb b/Code/Chapter 4/MethodOverloading/My Project/Settings.Designer.vb new file mode 100644 index 0000000..a92fa5d --- /dev/null +++ b/Code/Chapter 4/MethodOverloading/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.MethodOverloading.My.MySettings + Get + Return Global.MethodOverloading.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 4/MethodOverloading/My Project/Settings.settings b/Code/Chapter 4/MethodOverloading/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 4/MethodOverloading/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 4/MethodOverloading/Program.vb b/Code/Chapter 4/MethodOverloading/Program.vb new file mode 100644 index 0000000..3c419b0 --- /dev/null +++ b/Code/Chapter 4/MethodOverloading/Program.vb @@ -0,0 +1,58 @@ +''''''''''''''''''''''''''''''''''''''''''''''' +' This program illustrates the use of +' method overloading. +''''''''''''''''''''''''''''''''''''''''''''''' +Module Program + + Sub Main() + Console.WriteLine("***** Fun with Method Overloading *****") + ' Calls Integer version of Add() + Console.WriteLine(Add(10, 10)) + ' Calls Long verson of Add() + Console.WriteLine(Add(900000000000, 900000000000)) + ' Calls Double version of Add() + Console.WriteLine(Add(4.3, 4.4)) + End Sub + +End Module + +#Region "Add() overloads" +Module MathUtils + Function Add(ByVal x As Integer, ByVal y As Integer) As Integer + Return x + y + End Function + Function Add(ByVal x As Double, ByVal y As Double) As Double + Return x + y + End Function + Function Add(ByVal x As Long, ByVal y As Long) As Long + Return x + y + End Function +End Module +#End Region + +#Region "Just for an example..." +Class MathUtilsClass + Overloads Function Add(ByVal x As Integer, ByVal y As Integer) As Integer + Return x + y + End Function + Overloads Function Add(ByVal x As Double, ByVal y As Double) As Double + Return x + y + End Function + Overloads Function Add(ByVal x As Long, ByVal y As Long) As Long + Return x + y + End Function +End Class +#End Region + +#Region "Uncomment to generate errors..." +'Module LotsOfErrors +' ' Compiler error! Methods can't differ only by +' ' ByRef/ByVal +' Sub TestSub(ByVal a As Integer) +' End Sub +' Sub TestSub(ByRef a As Integer) +' End Sub +' Sub TestSub(ByVal a As Integer, Optional ByVal b As Integer = 0) +' End Sub +'End Module +#End Region \ No newline at end of file diff --git a/Code/Chapter 5/ConstData/ConstData.sln b/Code/Chapter 5/ConstData/ConstData.sln new file mode 100644 index 0000000..be7d6b0 --- /dev/null +++ b/Code/Chapter 5/ConstData/ConstData.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ConstData", "ConstData.vbproj", "{F55D6BAD-CAD2-4C91-9A93-420F5F678788}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F55D6BAD-CAD2-4C91-9A93-420F5F678788}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F55D6BAD-CAD2-4C91-9A93-420F5F678788}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F55D6BAD-CAD2-4C91-9A93-420F5F678788}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F55D6BAD-CAD2-4C91-9A93-420F5F678788}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 5/ConstData/ConstData.suo b/Code/Chapter 5/ConstData/ConstData.suo new file mode 100644 index 0000000..0a258a1 Binary files /dev/null and b/Code/Chapter 5/ConstData/ConstData.suo differ diff --git a/Code/Chapter 5/ConstData/ConstData.vbproj b/Code/Chapter 5/ConstData/ConstData.vbproj new file mode 100644 index 0000000..0424788 --- /dev/null +++ b/Code/Chapter 5/ConstData/ConstData.vbproj @@ -0,0 +1,134 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {F55D6BAD-CAD2-4C91-9A93-420F5F678788} + Exe + ConstData.Program + ConstData + ConstData + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + ConstData.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + ConstData.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 5/ConstData/ConstData.vbproj.user b/Code/Chapter 5/ConstData/ConstData.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 5/ConstData/ConstData.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 5/ConstData/My Project/Application.Designer.vb b/Code/Chapter 5/ConstData/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 5/ConstData/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 5/ConstData/My Project/Application.myapp b/Code/Chapter 5/ConstData/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 5/ConstData/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 5/ConstData/My Project/AssemblyInfo.vb b/Code/Chapter 5/ConstData/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..861d53c --- /dev/null +++ b/Code/Chapter 5/ConstData/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/Code/Chapter 5/ConstData/My Project/Resources.Designer.vb b/Code/Chapter 5/ConstData/My Project/Resources.Designer.vb new file mode 100644 index 0000000..167ea28 --- /dev/null +++ b/Code/Chapter 5/ConstData/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("ConstData.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/Code/Chapter 5/ConstData/My Project/Resources.resx b/Code/Chapter 5/ConstData/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 5/ConstData/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/Code/Chapter 5/ConstData/My Project/Settings.Designer.vb b/Code/Chapter 5/ConstData/My Project/Settings.Designer.vb new file mode 100644 index 0000000..8c86c89 --- /dev/null +++ b/Code/Chapter 5/ConstData/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.ConstData.My.MySettings + Get + Return Global.ConstData.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 5/ConstData/My Project/Settings.settings b/Code/Chapter 5/ConstData/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 5/ConstData/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 5/ConstData/Program.vb b/Code/Chapter 5/ConstData/Program.vb new file mode 100644 index 0000000..812f9e7 --- /dev/null +++ b/Code/Chapter 5/ConstData/Program.vb @@ -0,0 +1,33 @@ +' This program illustrates constant data and read only fields. + +#Region "MyMathClass" +Public Class MyMathClass + Public Shared ReadOnly PI As Double + Shared Sub New() + PI = 3.14 + End Sub +End Class +#End Region + +Module Program + Sub Main() + Console.WriteLine("***** Fun with Const *****") + Console.WriteLine("The value of PI is: {0}", MyMathClass.PI) + + ' Error! Can't change a constant! + ' MyMathClass.PI = 3.1444 + + Console.ReadLine() + End Sub + + Sub LocalConstStringVariable() + ' A local constant data point. + Const fixedStr As String = "Fixed String Data" + Console.WriteLine(fixedStr) + + ' Error! + ' fixedStr = "This will not work!" + End Sub + +End Module + diff --git a/Code/Chapter 5/EmployeeApp Documentation/Documentation.chm b/Code/Chapter 5/EmployeeApp Documentation/Documentation.chm new file mode 100644 index 0000000..8b02708 Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/Documentation.chm differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_build.log b/Code/Chapter 5/EmployeeApp Documentation/ndoc_build.log new file mode 100644 index 0000000..6eb81bc --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_build.log @@ -0,0 +1,100 @@ +Memory before build: 980480 +Initializing Workspace +Creating Help Project Resources +Analyzing Assemblies & Merging XML Documentation +Memory making xml: 1929564 +AssemblyLoader: Loading "C:\Users\Andrew Troelsen\My Books\VB 3rd Edition\Code\Chapter 5\EmployeeApp\bin\Debug\EmployeeApp.exe". +XmlDocCommentLoader: Loaded 'C:\Users\Andrew Troelsen\My Books\VB 3rd Edition\Code\Chapter 5\EmployeeApp\bin\Debug\EmployeeApp.xml' (0.128 sec.) +XmlDocCommentLoader: Cache 12 +Docs found : C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.xml +XmlDocCommentLoader: Loaded 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.xml' (1.626 sec.) +XmlDocCommentLoader: Cache 14000 +XmlDocCommentLoader: Loaded 'C:\Users\Andrew Troelsen\Desktop\NDoc2-Alpha3u\Configuration\Supplemental Docs\en\mscorlib.xml' (0.044 sec.) +XmlDocCommentLoader: Cache 15022 +AssemblyLoader: Attempting to resolve "Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". +AssemblyLoader: Loaded "C:/Windows/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll" +AssemblyLoader: Attempting to resolve "System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089". +AssemblyLoader: Loaded "C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll" +Writing namespace EmployeeApp... + Wrote 1 classes. +Completed EmployeeApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null +0.203 sec. +MakeXML : 2.235 sec. +Determining Document Structure +Load Docs for Structure Production: 0.929 msec. +Building File Map: 4.820 msec. +Structure Production: 193.860 msec. +Initializing Documenter +xslt-preprocess.xslt +retrieved xslt-preprocess.xslt from Style2005 + topics_main.xslt + retrieved topics_main.xslt from common + retrieved common.xslt from common + retrieved tags.xslt from Style2005 + retrieved blank.xslt from common + retrieved indices.xslt from common + retrieved XLinks.xslt from common + retrieved style-common.xslt from Style2005 + retrieved see-also.xslt from common + retrieved syntax.xslt from Style2005 + retrieved syntax-common.xslt from common + retrieved syntax-map.xslt from common + retrieved memberscommon.xslt from Style2005 + retrieved allmembers.xslt from Style2005 + retrieved event.xslt from common + retrieved field.xslt from common + retrieved individualmembers.xslt from Style2005 + retrieved member.xslt from common + retrieved memberoverload.xslt from Style2005 + retrieved namespace.xslt from Style2005 + retrieved namespacehierarchy.xslt from common + retrieved property.xslt from common + retrieved type.xslt from Style2005 + retrieved typehierarchy.xslt from Style2005 + 0.444 + toc_htmlhelp1.xslt + retrieved toc_htmlhelp1.xslt from common + 0.002 + toc_htmlhelp2.xslt + retrieved toc_htmlhelp2.xslt from common + 0.001 + toc_web.xslt + retrieved toc_web.xslt from common + 0.002 +Building stylesheets 0.486 +Building Table-of-Contents +Building Topic Pages +284.530 namespace N_EmployeeApp.html +105.709 namespacehierarchy Hier_N_EmployeeApp.html +374.286 type T_EmployeeApp_Employee.html +278.273 allmembers T_EmployeeApp_Employee_Members.html +22.759 individualmembers T_EmployeeApp_Employee_Properties.html +2.813 individualmembers T_EmployeeApp_Employee_Methods.html +100.720 memberoverload T_EmployeeApp_Employee_Constructor.html +85.949 member C_EmployeeApp_Employee_ctor_.html +37.972 member C_EmployeeApp_Employee_ctor_c97a4a35.html +131.866 property P_EmployeeApp_Employee_Age.html +20.746 property P_EmployeeApp_Employee_Company.html +1.516 property P_EmployeeApp_Employee_ID.html +1.673 property P_EmployeeApp_Employee_Name.html +14.812 property P_EmployeeApp_Employee_Pay.html +13.540 property P_EmployeeApp_Employee_SocialSecurityNumber.html +27.502 member M_EmployeeApp_Employee_DisplayStats.html +26.339 member M_EmployeeApp_Employee_GiveBonus.html +It took 2 seconds to make the html +Completing Help Project Resources +Compiling HTML Help file... +Microsoft HTML Help Compiler 4.74.8702 +Compiling c:\Users\Andrew Troelsen\My Books\VB 3rd Edition\Code\Chapter 5\EmployeeApp Documentation\ndoc_msdn_temp\Documentation.chm +Compile time: 0 minutes, 1 second +21 Topics +100 Local links +0 Internet links +15 Graphics +Created c:\Users\Andrew Troelsen\My Books\VB 3rd Edition\Code\Chapter 5\EmployeeApp Documentation\ndoc_msdn_temp\Documentation.chm, 44,810 bytes +Compression decreased file by 188,809 bytes. + +Html Help compile complete +Writing documentation to output path +Build Completed. +The build took a total of 7 seconds diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/CFW.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/CFW.gif new file mode 100644 index 0000000..cbcabf1 Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/CFW.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/C_EmployeeApp_Employee_ctor_.html b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/C_EmployeeApp_Employee_ctor_.html new file mode 100644 index 0000000..646982f --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/C_EmployeeApp_Employee_ctor_.html @@ -0,0 +1,135 @@ + + + + Employee Constructor () + + + + + + + + + + + + + + + + +
    +
    +
    +

    The default constructor.

    +
    + Namespace: + EmployeeApp +
    + Assembly: EmployeeApp (in EmployeeApp.exe) +

    Syntax

    Visual Basic (Declaration)
    Public Sub New()
    C#
    public Employee()
    C++
    public:
     Employee() sealed 
    J#
    public Employee()
    JScript
    public function Employee()

    See Also

    + +
    + + \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/C_EmployeeApp_Employee_ctor_c97a4a35.html b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/C_EmployeeApp_Employee_ctor_c97a4a35.html new file mode 100644 index 0000000..4bce93a --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/C_EmployeeApp_Employee_ctor_c97a4a35.html @@ -0,0 +1,137 @@ + + + + Employee Constructor (String, Int32, Int32, Single, String) + + + + + + + + + + + + + + + + +
    +
    +
    +

    A custom constrctor to set the state of an employee.

    +
    + Namespace: + EmployeeApp +
    + Assembly: EmployeeApp (in EmployeeApp.exe) +

    Syntax

    Visual Basic (Declaration)
    Public Sub New( _ 
       ByVal name As String,  _ 
       ByVal age As Integer,  _ 
       ByVal id As Integer,  _ 
       ByVal pay As Single,  _ 
       ByVal ssn As String _ 
    )
    C#
    public Employee(
       string name,
       int age,
       int id,
       float pay,
       string ssn
    )
    C++
    public:
     Employee(
       String name,
       int age,
       int id,
       float pay,
       String ssn
    ) sealed 
    J#
    public Employee(
       string name,
       int age,
       int id,
       float pay,
       string ssn
    )
    JScript
    public function Employee(
       name : String,
       age : int,
       id : int,
       pay : float,
       ssn : String
    )

    + Parameters +

    name
    age
    id
    pay
    ssn

    See Also

    + +
    + + \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/Caution.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/Caution.gif new file mode 100644 index 0000000..4d585bb Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/Caution.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/Documentation.hhc b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/Documentation.hhc new file mode 100644 index 0000000..3fb5926 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/Documentation.hhc @@ -0,0 +1 @@ +
    \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/Documentation.hhk b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/Documentation.hhk new file mode 100644 index 0000000..fc02d78 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/Documentation.hhk @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/Documentation.hhp b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/Documentation.hhp new file mode 100644 index 0000000..3fa6111 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/Documentation.hhp @@ -0,0 +1,40 @@ +[FILES] +sdkLinkmanager.html +N_EmployeeApp.html +Hier_N_EmployeeApp.html +T_EmployeeApp_Employee.html +T_EmployeeApp_Employee_Members.html +T_EmployeeApp_Employee_Constructor.html +C_EmployeeApp_Employee_ctor_.html +C_EmployeeApp_Employee_ctor_c97a4a35.html +T_EmployeeApp_Employee_Properties.html +P_EmployeeApp_Employee_Age.html +P_EmployeeApp_Employee_Company.html +P_EmployeeApp_Employee_ID.html +P_EmployeeApp_Employee_Name.html +P_EmployeeApp_Employee_Pay.html +P_EmployeeApp_Employee_SocialSecurityNumber.html +T_EmployeeApp_Employee_Methods.html +M_EmployeeApp_Employee_DisplayStats.html +M_EmployeeApp_Employee_GiveBonus.html +tooltip.htc + +[OPTIONS] +Title=Documentation +Auto Index=Yes +Binary TOC=Yes +Compatibility=1.1 or later +Compiled file=Documentation.chm +Default Window=MsdnHelp +Default topic=N_EmployeeApp.html +Display compile progress=No +Error log file=Documentation.log +Full-text search=Yes +Index file=Documentation.hhk +Language=0x409 English (United States) +Contents file=Documentation.hhc + +[WINDOWS] +MsdnHelp="Documentation Help","Documentation.hhc","Documentation.hhk","N_EmployeeApp.html","N_EmployeeApp.html",,,,,0x62520,220,0x387e,[86,51,872,558],,,,,,,0 + +[INFOTYPES] diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/Documentation.log b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/Documentation.log new file mode 100644 index 0000000..3853e91 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/Documentation.log @@ -0,0 +1,14 @@ +Microsoft HTML Help Compiler 4.74.8702 + +Compiling c:\Users\Andrew Troelsen\My Books\VB 3rd Edition\Code\Chapter 5\EmployeeApp Documentation\ndoc_msdn_temp\Documentation.chm + + +Compile time: 0 minutes, 1 second +21 Topics +100 Local links +0 Internet links +15 Graphics + + +Created c:\Users\Andrew Troelsen\My Books\VB 3rd Edition\Code\Chapter 5\EmployeeApp Documentation\ndoc_msdn_temp\Documentation.chm, 44,810 bytes +Compression decreased file by 188,809 bytes. diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/Help1NamespaceMap.xml b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/Help1NamespaceMap.xml new file mode 100644 index 0000000..2025751 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/Help1NamespaceMap.xml @@ -0,0 +1,269 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/Help1NamespaceMap.xsd b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/Help1NamespaceMap.xsd new file mode 100644 index 0000000..b27ce39 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/Help1NamespaceMap.xsd @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/Hier_N_EmployeeApp.html b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/Hier_N_EmployeeApp.html new file mode 100644 index 0000000..f3494f7 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/Hier_N_EmployeeApp.html @@ -0,0 +1,86 @@ + + + + EmployeeApp Hierarchy + + + + + + + + + + + + + + + + +
    +
    +
    + +

    + + See Also +

    + +
    + +
    + + \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/M_EmployeeApp_Employee_DisplayStats.html b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/M_EmployeeApp_Employee_DisplayStats.html new file mode 100644 index 0000000..075a7dd --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/M_EmployeeApp_Employee_DisplayStats.html @@ -0,0 +1,138 @@ + + + + DisplayStats Method + + + + + + + + + + + + + + + + +
    +
    +
    +

    This method displays the state of the object.

    +
    + Namespace: + EmployeeApp +
    + Assembly: EmployeeApp (in EmployeeApp.exe) +

    Syntax

    Visual Basic (Declaration)
    Public Sub DisplayStats()
    C#
    public void DisplayStats()
    C++
    public:
     void DisplayStats() sealed 
    J#
    public void DisplayStats()
    JScript
    public  + function DisplayStats()

    See Also

    + + + +
    + + \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/M_EmployeeApp_Employee_GiveBonus.html b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/M_EmployeeApp_Employee_GiveBonus.html new file mode 100644 index 0000000..0f7ad8f --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/M_EmployeeApp_Employee_GiveBonus.html @@ -0,0 +1,140 @@ + + + + GiveBonus Method + + + + + + + + + + + + + + + + +
    +
    +
    +

    This method gives a pay increase to the employee.

    +
    + Namespace: + EmployeeApp +
    + Assembly: EmployeeApp (in EmployeeApp.exe) +

    Syntax

    Visual Basic (Declaration)
    Public Sub GiveBonus( _ 
       ByVal amount As Single _ 
    )
    C#
    public void GiveBonus(
       float amount
    )
    C++
    public:
     void GiveBonus(
       float amount
    ) sealed 
    J#
    public void GiveBonus(
       float amount
    )
    JScript
    public  + function GiveBonus(
       amount : float
    )

    + Parameters +

    amount

    See Also

    + + + +
    + + \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/N_EmployeeApp.html b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/N_EmployeeApp.html new file mode 100644 index 0000000..26113e6 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/N_EmployeeApp.html @@ -0,0 +1,100 @@ + + + + EmployeeApp + + + + + + + + + + + + + + + + +
    +
    +
    +

    + + Classes +

    +
    + + + + + + + + + + + + + + +
     ClassDescription
    + Public class + + Employee + This class represents an employee.
    +
    +
    + + +
    + + \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/P_EmployeeApp_Employee_Age.html b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/P_EmployeeApp_Employee_Age.html new file mode 100644 index 0000000..f1052e3 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/P_EmployeeApp_Employee_Age.html @@ -0,0 +1,137 @@ + + + + Age Property + + + + + + + + + + + + + + + + +
    +
    +
    +

    Gets or sets the age of the employee.

    +
    + Namespace: + EmployeeApp +
    + Assembly: EmployeeApp (in EmployeeApp.exe) +

    Syntax

    Visual Basic (Declaration)
    Public Property Age As Integer
    C#
    public int Age { get; set; }
    C++
    public property int Age sealed  {
        int get();
        void set(int value);
    }
    J#
    /** property */
    public int get_Age();

    /** property */
    public void set_Age(int value);
    JScript
    public function get Age() : int

    public function set Age(value : int);

    See Also

    + + + +
    + + \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/P_EmployeeApp_Employee_Company.html b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/P_EmployeeApp_Employee_Company.html new file mode 100644 index 0000000..c3fa8e6 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/P_EmployeeApp_Employee_Company.html @@ -0,0 +1,137 @@ + + + + Company Property + + + + + + + + + + + + + + + + +
    +
    +
    +

    Set the company name of the employees.

    +
    + Namespace: + EmployeeApp +
    + Assembly: EmployeeApp (in EmployeeApp.exe) +

    Syntax

    Visual Basic (Declaration)
    Public Shared Property Company As String
    C#
    public static string Company { get; set; }
    C++
    public static property string Company {
        String get();
        void set(String value);
    }
    J#
    /** property */
    public string get_Company();

    /** property */
    public void set_Company(string value);
    JScript
    public function get Company() : String

    public function set Company(value : String);

    See Also

    + + + +
    + + \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/P_EmployeeApp_Employee_ID.html b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/P_EmployeeApp_Employee_ID.html new file mode 100644 index 0000000..befaf4d --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/P_EmployeeApp_Employee_ID.html @@ -0,0 +1,137 @@ + + + + ID Property + + + + + + + + + + + + + + + + +
    +
    +
    +

    Gets or sets the ID of the employee.

    +
    + Namespace: + EmployeeApp +
    + Assembly: EmployeeApp (in EmployeeApp.exe) +

    Syntax

    Visual Basic (Declaration)
    Public Property ID As Integer
    C#
    public int ID { get; set; }
    C++
    public property int ID sealed  {
        int get();
        void set(int value);
    }
    J#
    /** property */
    public int get_ID();

    /** property */
    public void set_ID(int value);
    JScript
    public function get ID() : int

    public function set ID(value : int);

    See Also

    + + + +
    + + \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/P_EmployeeApp_Employee_Name.html b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/P_EmployeeApp_Employee_Name.html new file mode 100644 index 0000000..6e99140 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/P_EmployeeApp_Employee_Name.html @@ -0,0 +1,137 @@ + + + + Name Property + + + + + + + + + + + + + + + + +
    +
    +
    +

    Gets or sets the name of the employee.

    +
    + Namespace: + EmployeeApp +
    + Assembly: EmployeeApp (in EmployeeApp.exe) +

    Syntax

    Visual Basic (Declaration)
    Public Property Name As String
    C#
    public string Name { get; set; }
    C++
    public property string Name sealed  {
        String get();
        void set(String value);
    }
    J#
    /** property */
    public string get_Name();

    /** property */
    public void set_Name(string value);
    JScript
    public function get Name() : String

    public function set Name(value : String);

    See Also

    + + + +
    + + \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/P_EmployeeApp_Employee_Pay.html b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/P_EmployeeApp_Employee_Pay.html new file mode 100644 index 0000000..40ab053 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/P_EmployeeApp_Employee_Pay.html @@ -0,0 +1,137 @@ + + + + Pay Property + + + + + + + + + + + + + + + + +
    +
    +
    +

    Gets or sets the current pay of the employee.

    +
    + Namespace: + EmployeeApp +
    + Assembly: EmployeeApp (in EmployeeApp.exe) +

    Syntax

    Visual Basic (Declaration)
    Public Property Pay As Single
    C#
    public float Pay { get; set; }
    C++
    public property float Pay sealed  {
        float get();
        void set(float value);
    }
    J#
    /** property */
    public float get_Pay();

    /** property */
    public void set_Pay(float value);
    JScript
    public function get Pay() : float

    public function set Pay(value : float);

    See Also

    + + + +
    + + \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/P_EmployeeApp_Employee_SocialSecurityNumber.html b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/P_EmployeeApp_Employee_SocialSecurityNumber.html new file mode 100644 index 0000000..29004d9 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/P_EmployeeApp_Employee_SocialSecurityNumber.html @@ -0,0 +1,137 @@ + + + + SocialSecurityNumber Property + + + + + + + + + + + + + + + + +
    +
    +
    +

    Read only access to SSN. Set this value with a constructor argument.

    +
    + Namespace: + EmployeeApp +
    + Assembly: EmployeeApp (in EmployeeApp.exe) +

    Syntax

    Visual Basic (Declaration)
    Public ReadOnly Property SocialSecurityNumber As String
    C#
    public string SocialSecurityNumber { get; }
    C++
    public property string SocialSecurityNumber sealed  {
        String get();
    }
    J#
    /** property */
    public string get_SocialSecurityNumber();
    JScript
    public function get SocialSecurityNumber() : String

    See Also

    + + + +
    + + \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/T_EmployeeApp_Employee.html b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/T_EmployeeApp_Employee.html new file mode 100644 index 0000000..1c09570 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/T_EmployeeApp_Employee.html @@ -0,0 +1,137 @@ + + + + Employee Class + + + + + + + + + + + + + + + + +
    +
    +
    +

    This class represents an employee.

    +
    + Namespace: + EmployeeApp +
    + Assembly: EmployeeApp (in EmployeeApp.exe) +

    Syntax

    Visual Basic (Declaration)
    Public Class Employee
    C#
    public class Employee
    C++
    ref class Employee
    J#
    public class Employee
    JScript
    public class Employee

    Inheritance Hierarchy

    System.Object
       EmployeeApp.Employee

    Thread Safety

    Public static (Shared in Visual Basic)staticShared members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

    See Also

    + + +
    + + \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/T_EmployeeApp_Employee_Constructor.html b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/T_EmployeeApp_Employee_Constructor.html new file mode 100644 index 0000000..c1b4be6 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/T_EmployeeApp_Employee_Constructor.html @@ -0,0 +1,125 @@ + + + + Employee Constructor + + + + + + + + + + + + + + + + +
    +
    +
    +
    +

    Initializes a new instance of the Employee class.

    +

    + + Overload List +

    +
    + + + + + + + + + + + + + + + + + + + +
      + Name + + Description +
    + Public method + + Employee + The default constructor.
    + Public method + + Employee (String, Int32, Int32, Single, String) + A custom constrctor to set the state of an employee.
    +
    +

    + + See Also +

    + +
    + + + + +
    + + \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/T_EmployeeApp_Employee_Members.html b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/T_EmployeeApp_Employee_Members.html new file mode 100644 index 0000000..394ad6b --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/T_EmployeeApp_Employee_Members.html @@ -0,0 +1,347 @@ + + + + Employee Members + + + + + + + + + + + + + + + + +
    +
    +
    +

    This class represents an employee.

    +
    +

    The following tables list the members exposed by Employee.

    +

    + + Public Constructors +

    +
    + + + + + + + + + + + + + + +
     NameDescription
    + Static + Public method + + Employee + Overloaded. Initializes a new instance of the Employee class.
    + Top +
    +

    + + Public Properties +

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
     NameDescription
    + Public property + + Age + Gets or sets the age of the employee.
    + Public property + Static + + Company + Set the company name of the employees.
    + Public property + + ID + Gets or sets the ID of the employee.
    + Public property + + Name + Gets or sets the name of the employee.
    + Public property + + Pay + Gets or sets the current pay of the employee.
    + Public property + + SocialSecurityNumber + Read only access to SSN. Set this value with a constructor argument.
    + Top +
    +

    + + Public Methods +

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
     NameDescription
    + Public method + + DisplayStats + This method displays the state of the object.
    + Public method + EqualsDetermines whether the specified Object is equal to the current Object. (inherited from Object)
    + Public method + GetHashCodeServes as a hash function for a particular type. (inherited from Object)
    + Public method + GetTypeGets the Type of the current instance. (inherited from Object)
    + Public method + + GiveBonus + This method gives a pay increase to the employee.
    + Public method + ToStringReturns a String that represents the current Object. (inherited from Object)
    + Top +
    +

    + + Protected Methods +

    +
    + + + + + + + + + + + + + + + + + + + +
     NameDescription
    + Family method + FinalizeAllows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (inherited from Object)
    + Family method + MemberwiseCloneCreates a shallow copy of the current Object. (inherited from Object)
    + Top +
    +

    + + Explicit Interface Implementations +

    +
    + + + + + + + + + + + + + + +
     NameDescription
    + Static + Private method + + Employee + Overloaded. Initializes a new instance of the Employee class.
    + Top +
    +

    + + See Also +

    + +
    + + + + +
    + + \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/T_EmployeeApp_Employee_Methods.html b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/T_EmployeeApp_Employee_Methods.html new file mode 100644 index 0000000..29ff8ab --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/T_EmployeeApp_Employee_Methods.html @@ -0,0 +1,213 @@ + + + + Methods + + + + + + + + + + + + + + + + +
    +
    +
    +

    + + Public Methods +

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
     NameDescription
    + Public method + + DisplayStats + This method displays the state of the object.
    + Public method + EqualsDetermines whether the specified Object is equal to the current Object. (inherited from Object)
    + Public method + GetHashCodeServes as a hash function for a particular type. (inherited from Object)
    + Public method + GetTypeGets the Type of the current instance. (inherited from Object)
    + Public method + + GiveBonus + This method gives a pay increase to the employee.
    + Public method + ToStringReturns a String that represents the current Object. (inherited from Object)
    + Top +
    +

    + + Protected Methods +

    +
    + + + + + + + + + + + + + + + + + + + +
     NameDescription
    + Family method + FinalizeAllows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (inherited from Object)
    + Family method + MemberwiseCloneCreates a shallow copy of the current Object. (inherited from Object)
    + Top +
    +

    + + See Also +

    + +
    + + +
    + + \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/T_EmployeeApp_Employee_Properties.html b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/T_EmployeeApp_Employee_Properties.html new file mode 100644 index 0000000..813d6c8 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/T_EmployeeApp_Employee_Properties.html @@ -0,0 +1,191 @@ + + + + Properties + + + + + + + + + + + + + + + + +
    +
    +
    +

    + + Public Properties +

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
     NameDescription
    + Public property + + Age + Gets or sets the age of the employee.
    + Public property + Static + + Company + Set the company name of the employees.
    + Public property + + ID + Gets or sets the ID of the employee.
    + Public property + + Name + Gets or sets the name of the employee.
    + Public property + + Pay + Gets or sets the current pay of the employee.
    + Public property + + SocialSecurityNumber + Read only access to SSN. Set this value with a constructor argument.
    + Top +
    +

    + + See Also +

    + +
    + + +
    + + \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/box.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/box.gif new file mode 100644 index 0000000..c022894 Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/box.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/collall.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/collall.gif new file mode 100644 index 0000000..66a6f11 Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/collall.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/collapse.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/collapse.gif new file mode 100644 index 0000000..45f018a Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/collapse.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/collapse_all.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/collapse_all.gif new file mode 100644 index 0000000..45f018a Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/collapse_all.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/copycode.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/copycode.gif new file mode 100644 index 0000000..1678162 Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/copycode.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/copycodeHighlight.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/copycodeHighlight.gif new file mode 100644 index 0000000..be87230 Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/copycodeHighlight.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/drpdown.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/drpdown.gif new file mode 100644 index 0000000..9d3bbb6 Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/drpdown.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/drpdown_orange.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/drpdown_orange.gif new file mode 100644 index 0000000..cf50c20 Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/drpdown_orange.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/drpdown_orange_up.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/drpdown_orange_up.gif new file mode 100644 index 0000000..a173df1 Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/drpdown_orange_up.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/drpup.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/drpup.gif new file mode 100644 index 0000000..de77198 Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/drpup.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/exp.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/exp.gif new file mode 100644 index 0000000..123fda9 Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/exp.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/expall.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/expall.gif new file mode 100644 index 0000000..1a91b12 Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/expall.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/expand_all.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/expand_all.gif new file mode 100644 index 0000000..123fda9 Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/expand_all.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/footer.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/footer.gif new file mode 100644 index 0000000..7d0c287 Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/footer.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/greencheck.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/greencheck.gif new file mode 100644 index 0000000..4ba1751 Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/greencheck.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/greychck.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/greychck.gif new file mode 100644 index 0000000..adb8fa1 Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/greychck.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intclass.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intclass.gif new file mode 100644 index 0000000..4d79eaf Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intclass.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intdelegate.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intdelegate.gif new file mode 100644 index 0000000..55188de Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intdelegate.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intenumeration.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intenumeration.gif new file mode 100644 index 0000000..a405bd6 Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intenumeration.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intevent.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intevent.gif new file mode 100644 index 0000000..7c6e80f Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intevent.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intfield.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intfield.gif new file mode 100644 index 0000000..e6b4d1c Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intfield.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intinterface.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intinterface.gif new file mode 100644 index 0000000..8c6a750 Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intinterface.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intmethod.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intmethod.gif new file mode 100644 index 0000000..d490b6e Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intmethod.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intproperty.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intproperty.gif new file mode 100644 index 0000000..6da0911 Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intproperty.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intstructure.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intstructure.gif new file mode 100644 index 0000000..a36eb0b Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/intstructure.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/ndoc.css b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/ndoc.css new file mode 100644 index 0000000..6e120c3 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/ndoc.css @@ -0,0 +1,572 @@ +.userDataStyle +{ + behavior: url(#default#userData); +} + +@media all +{ + tool\:tip{behavior: url(tooltip.htc)} +} + +body +{ + background: #FFFFFF; + color: #000000; + font-family: Verdana; + font-size: medium; + font-style: normal; + font-weight: normal; + margin: 0px; + width: 100%; +} + +a +{ + color: #0000FF; +} + +a:visited +{ + color: #0000FF; +} + +a:hover +{ + color: #3366FF; +} + +div#mainSection +{ + font-size: 70%; + width: 100%; +} + +div#mainBody +{ + font-size: 90%; + margin-left: 15px; + margin-top: 10px; + padding-bottom: 20px; +} +div#mainBody p, div#mainBody ol, div#mainBody ul, div#mainBody dl +{ + padding-right: 5; +} + +div#header +{ + background-color: #D4DFFF; + padding: 0px; + width: 100%; +} + +div#header table +{ + border-bottom: solid 1px #C8CDDE; + width: 100%; +} + +span#runningHeaderText +{ + color: #003399; + font-size: 90%; + padding-left: 13px; +} + + +span#nsrTitle +{ + color: #003399; + font-size: 120%; + font-weight: bold; + padding-left: 13px; +} + +div#header table td +{ + color: #0000FF; + font-size: 70%; + margin-top: 0px; + margin-bottom: 0px; + padding-right: 20px; +} + +div#header table tr#headerTableRow3 td +{ + padding-bottom: 2px; + padding-top: 5px; + padding-left: 15px; +} + +div#header table#bottomTable +{ + border-top: solid 1px #FFFFFF; + text-align: left; + padding-left: 15px; +} + +div#footer +{ + font-size: 90%; + margin: 0px; + padding: 2px; + width: 100%; +} + +hr#footerHR +{ + border-bottom: solid 1px #EEEEFF; + border-top: solid 1px #C8CDDE; + height: 3px; + color: #D4DFFF; +} +/* +div.saveHistory +{ + behavior:url(#default#saveHistory); +} +*/ +div.section +{ + padding-top: 2px; + padding-bottom: 2px; + padding-left: 16px; + padding-right: 15px; + width: 100%; +} + +.heading +{ + font-weight: bold; + margin-top: 18px; + margin-bottom: 8px; +} + +h1.heading +{ + color: #003399; + font-size: 130%; +} + +.subHeading +{ + font-weight: bold; + margin-bottom: 4px; +} + +h3.subHeading +{ + color: #000000; + font-size: 120%; + font-weight: normal; +} + +h4.subHeading +{ + color: #000000; + font-size: 100%; +} + +img.toggle +{ + border: none; + margin-right: 5px; +} + +img.copyCodeImage +{ + border: none; + margin: 1px; + margin-right: 3px; +} + +img.downloadCodeImage +{ + border: none; + margin-right: 3px; +} + +img.viewCodeImage +{ + border: none; + margin-right: 3px; +} + +img.note +{ + border: none; + margin-right: 3px; +} + +img#languageFilterImage +{ + border: none; + margin-left: 10px; + vertical-align: middle; +} + +img#membersOptionsFilterImage +{ + border: none; + margin-left: 10px; + vertical-align: middle; +} + +img#toggleAllImage +{ + margin-left: 4px; + vertical-align: middle; +} + +div#mainSection table +{ + border: none; + font-size: 100%; + width: 100%; + margin-top: 5px; + margin-bottom: 5px; +} + +div#mainSection table tr +{ + vertical-align: top; +} + +div#mainSection table th +{ + background-color: #EFEFF7; + border-bottom: solid 1px #C8CDDE; + color: #000066; + padding-left: 5px; + padding-right: 5px; + text-align: left; +} + +div#mainSection table td +{ + background-color: #F7F7FF; + border-bottom: solid 1px #D5D5D3; + /*border-left: solid 1px #D5D5D3;*/ + padding-left: 5px; + padding-right: 5px; + margin: 1px; +} + +div#mainSection table td.imageCell +{ + white-space: nowrap; + /*width: 1%;*/ +} + +div#mainSection table td.nameCell +{ + white-space: nowrap; +} + +div.code table +{ + border: none; + font-size: 95%; + margin-bottom: 5px; + margin-top:-.4em; + width: 100%; +} + +div.code table th +{ + background: #EFEFF7; + border-bottom: solid 1px #C8CDDE; + color: #000066; + font-weight: bold; + padding-left: 5px; + padding-right: 5px; +} + +div.code table td +{ + background: #F7F7FF; + border-top: solid 1px #FFFFFF; + padding-left: 5px; + padding-right: 5px; + padding-top: 5px; + padding-bottom: 15px; +} + +div.code table td.syntax +{ + font-family: Monospace, Courier New, Courier; + font-size: 105%; + color: #000066; + white-space: nowrap; +} + +div.code table td.message +{ +} + +div.alert table +{ + border: none; + font-size: 100%; + width: 100%; +} + +div.alert table th +{ + background: #EFEFF7; + border-bottom-width: 0px; + color: #000066; + padding-left: 5px; + padding-right: 5px; +} + +div.alert table td +{ + background: #F7F7FF; + border-top: solid 1px #FFFFFF; + padding-left: 5px; + padding-right: 5px; +} + +span.copyCode +{ + color: #0000ff; + font-size: 90%; + font-weight: normal; + cursor: hand; + float: right; + display: inline; + text-align: right; +} + +.downloadCode +{ + color: #0000ff; + font-size: 90%; + font-weight: normal; + cursor: hand; +} + +.viewCode +{ + color: #0000ff; + font-size: 90%; + font-weight: normal; + cursor: hand; +} + +code +{ + font-family: Monospace, Courier New, Courier; + font-size: 105%; + color: #000066; +} + +dl +{ + margin-top: 0px; + padding-left: 1px; +} + +dt +{ + font-style: italic; +} + +dd +{ + margin-bottom: 0px; + margin-left: 0px; +} + +ul +{ + margin-top:0px; + margin-bottom:0px; + margin-left: 17px; + list-style-type: disc; +} + +ul ul +{ + margin-bottom: 4px; + margin-left: 17px; + margin-top: 3px; + list-style-type: disc; +} + +ol +{ + margin-top:0px; + margin-bottom:0px; + margin-left: 28px; + list-style-type: decimal; +} + +ol ol +{ + margin-bottom: 4px; + margin-left: 24px; + margin-top: 3px; + list-style-type: lower-alpha; +} + +li +{ + margin-top:-2px; + margin-bottom: 3px; +} + +p +{ + margin-top: 10px; + margin-bottom: 5px; +} + +.tip +{ + color: #0000FF; + font-style: italic; + cursor: hand; + text-decoration: underline; +} + +.languageFilter +{ + color: #0000FF; + cursor: hand; + text-decoration: underline; + padding-bottom: 4px; +} + +.math +{ + font-family: Times New Roman; + font-size: 125%; +} + +.sourceCodeList +{ + font-family: Verdana; + font-size: 90%; +} + +pre.viewCode +{ + width: 100%; + overflow: auto; +} + +MSHelp\:link +{ + text-decoration: underline; + color: #0000ff; + hoverColor: #3366ff; + filterString: ; +} + + +/*----------------------------------------------*/ +/* +.attribute a:link +{ + color: #000088; + text-decoration: none; +} +.attribute a:visited +{ + color: #000088; + text-decoration: none; +} +.attribute a:hover +{ + color: #3366ff; +} + +.attribute MSHelp\:link + { + text-decoration: underline; + color: #0000ff; + hoverColor: #3366ff; + filterString: ; + } +*/ +.missing +{ + color: Red; + font-weight: bold; +} +div.hier +{ + margin-top: 0.5em; + margin-right: 0.0em; + margin-bottom: 0.5em; + margin-left: 1.0em; +} +div#mainSection table.hier +{ + border: none; + font-size: 100%; + padding: 0px; + margin: 0px; + border-collapse: collapse; + width: auto; +} +div#mainSection table.hier tr +{ + padding: 0px; + margin: 0px; +} +div#mainSection table.hier td +{ + border: none; + vertical-align: top; + padding: 0px; + margin: 50px; + background-color: transparent; +} + +div.code table td span.attribute +{ + padding: 0px; + margin: 0px; +} + +p.inheritDoc +{ + padding: 2px; + margin: 0px; + background-color: #FFFFE0; + border-top: solid 1px #E0E0C0; +} +p.inheritSource +{ + padding: 0px 2px; + margin: 0px; + font-size: 85%; + background-color: #F0F0D0; + color: #606050; +} +span.autoText +{ + padding: 2px; + margin: 0px; + background-color: #E0FFE0; + color: #206020; +} + +p.missing +{ + padding: 2px; + margin: 0px; + font-size: 85%; + background-color: #FFE0E0; + color: #800000; + font-weight: bold; +} + +.topicstatus /* Topic Status Boilerplate class */ + { + display: block; + color: red; + } diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/ndoc.js b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/ndoc.js new file mode 100644 index 0000000..6554af2 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/ndoc.js @@ -0,0 +1,1458 @@ +window.onload=LoadPage; +window.onunload=Window_Unload; +window.onresize=ResizeWindow; +window.onbeforeprint = set_to_print; +window.onafterprint = reset_form; + +var vbDeclaration; +var vbUsage; +var csLang; +var cLang; +var jsharpLang; +var jsLang; + +var scrollPos = 0; + +var inheritedMembers; +var protectedMembers; +var assemblyMembers; +var privateMembers; +var netcfMembersOnly; + +var sdkNamespace="ms-help://MS.NETDEVFX.v20.en"; + +/* +********** +********** Begin +********** +*/ + +function LoadPage() +{ + if(IsEvilUrl()) + { + ReloadEvilUrlAsGoodUrl(); + return; // in just a moment, page will reload. + } + + SeeAlsoLinkVisibility() + ExampleLinkVisibility() + + // show correct language + LoadLanguages(); + LoadMembersOptions(); + + Set_up_checkboxes(); + + DisplayLanguages(); + + if(inheritedMembers=="off") + DisplayInheritedMembers(); + if(protectedMembers=="off") + DisplayProtectedMembers(); + if(assemblyMembers=="off") + DisplayAssemblyMembers(); + if(privateMembers=="off") + DisplayPrivateMembers(); + if(netcfMembersOnly=="on") + DisplayNETCFMembers(); + + ChangeMembersOptionsFilterLabel(); + + LoadSections(); + + LoadNamespace(); + + ResizeWindow(); + + // vs70.js did this to allow up/down arrow scrolling, I think + try { mainSection.setActive(); } catch(e) { } + + // make body visible, now that we're ready to render + document.body.style.display = ""; + + //set the scroll position + try{mainSection.scrollTop = scrollPos;} + catch(e){} +} + +function Window_Unload() +{ + if (IsGoodUrl()) + { + SaveLanguages(); + SaveMembersOptions(); + SaveSections(); + } +} + +function ResizeWindow() +{ + if (document.body.clientWidth==0) return; + var header = document.all.item("header"); + var mainSection = document.all.item("mainSection"); + if (mainSection == null) return; + + + document.body.scroll = "no" + mainSection.style.overflow= "auto"; + header.style.width= document.body.offsetWidth - 2; + //mainSection.style.paddingRight = "20px"; // Width issue code + mainSection.style.width= document.body.offsetWidth - 4; + mainSection.style.top=0; + if (document.body.offsetHeight > header.offsetHeight + 4) + mainSection.style.height= document.body.offsetHeight - (header.offsetHeight + 4); + else + mainSection.style.height=0; + + try + { + mainSection.setActive(); + } + catch(e) + { + } +} + +function Load(key) +{ + userDataCache.load("docSettings"); + var value = userDataCache.getAttribute(key); + return value; + return null; +} + +function Save(key, value) +{ + userDataCache.setAttribute(key, value); + userDataCache.save("docSettings"); +} + +function RemoveAttribute(key) +{ + userDataCache.removeAttribute(key); + userDataCache.save("docSettings"); +} + +function set_to_print() +{ + //breaks out of divs to print + var i; + + if (window.text)document.all.text.style.height = "auto"; + + for (i=0; i < document.all.length; i++) + { + if (document.all[i].tagName == "body") + { + document.all[i].scroll = "yes"; + } + if (document.all[i].id == "header") + { + document.all[i].style.margin = "0px 0px 0px 0px"; + document.all[i].style.width = "100%"; + } + if (document.all[i].id == "mainSection") + { + document.all[i].style.overflow = "visible"; + document.all[i].style.top = "5px"; + document.all[i].style.width = "100%"; + document.all[i].style.padding = "0px 10px 0px 30px"; + } + } +} + +function reset_form() +{ + //returns to the div nonscrolling region after print + document.location.reload(); +} + +function IsEvilUrl() +{ + var url = "" + document.location + "."; + var r = url.indexOf("mk:@MSITStore") != -1; + return r; +} + +function IsGoodUrl() +{ + return !IsEvilUrl(); +} + +function ReloadEvilUrlAsGoodUrl() +{ + var url = "" + document.location + "."; + var i = url.indexOf("mk:@MSITStore"); + if(i != -1) + { + url = "ms-its:" + url.substring(14, url.length - 1); + document.location.replace(url); + } +} + +function SeeAlsoLinkVisibility() +{ + var seeAlsoSection; + + seeAlsoSection = document.getElementById("seeAlsoSection"); + if(seeAlsoSection == null) + { + document.getElementById("seeAlsoSectionLink").style.display = "none"; + } +} +function ExampleLinkVisibility() +{ + var exampleSection; + + exampleSection = document.getElementById("codeExampleSection"); + if(exampleSection == null) + { + document.getElementById("exampleSectionLink").style.display = "none"; + } +} + +function Set_up_checkboxes() +{ + var checkbox; + + checkbox = document.getElementById("vbDeclarationCheckbox"); + if(checkbox != null) + { + if(vbDeclaration == "on") + checkbox.checked = true; + else + checkbox.checked = false; + } + + checkbox = document.getElementById("vbUsageCheckbox"); + if(checkbox != null) + { + if(vbUsage == "on") + checkbox.checked = true; + else + checkbox.checked = false; + } + + checkbox = document.getElementById("csCheckbox"); + if(checkbox != null) + { + if(csLang == "on") + checkbox.checked = true; + else + checkbox.checked = false; + } + + checkbox = document.getElementById("cCheckbox"); + if(checkbox != null) + { + if(cLang == "on") + checkbox.checked = true; + else + checkbox.checked = false; + } + + checkbox = document.getElementById("jsharpCheckbox"); + if(checkbox != null) + { + if(jsharpLang == "on") + checkbox.checked = true; + else + checkbox.checked = false; + } + + checkbox = document.getElementById("jsCheckbox"); + if(checkbox != null) + { + if(jsLang == "on") + checkbox.checked = true; + else + checkbox.checked = false; + } + + checkbox = document.getElementById("inheritedCheckbox"); + if(checkbox != null) + { + if(inheritedMembers == "on") + checkbox.checked = true; + else + checkbox.checked = false; + } + + checkbox = document.getElementById("protectedCheckbox"); + if(checkbox != null) + { + if(protectedMembers == "on") + checkbox.checked = true; + else + checkbox.checked = false; + } + + checkbox = document.getElementById("assemblyCheckbox"); + if(checkbox != null) + { + if(assemblyMembers == "on") + checkbox.checked = true; + else + checkbox.checked = false; + } + + checkbox = document.getElementById("privateCheckbox"); + if(checkbox != null) + { + if(privateMembers == "on") + checkbox.checked = true; + else + checkbox.checked = false; + } + + checkbox = document.getElementById("netcfCheckbox"); + if(checkbox != null) + { + if(netcfMembersOnly == "on") + checkbox.checked = true; + else + checkbox.checked = false; + } +} + +/* +********** +********** End +********** +*/ +var sdkLinkType="sdklink://"; +function LoadNamespace() +{ + var ns = Load("sdkNamespace"); + if (ns!=null) + { + if(sdkNamespace!=ns) sdkNamespace=ns; + } + + var iMembers = document.getElementsByTagName("a"); + for(var i = 0; i < iMembers.length; ++i) + { + var strHref = iMembers[i].href; + if(strHref.substr(0, sdkLinkType.length)==sdkLinkType) + { + var newHref = sdkNamespace + "/" + strHref.substr(sdkLinkType.length); + iMembers[i].href=newHref; + } + } +} + +/* +********** +********** Begin Language Filtering +********** +*/ + +function SetLanguage(key) +{ + var i = 0; + if(vbDeclaration == "on") + i++; + if(vbUsage == "on") + i++; + if(csLang == "on") + i++; + if(cLang == "on") + i++; + if(jsharpLang == "on") + i++; + if(jsLang == "on") + i++; + + if(key.id == "vbDeclarationCheckbox") + { + if(vbDeclaration == "on") + { + if(i == 1) + { + key.checked = true; + return; + } + + vbDeclaration = "off"; + } + else + vbDeclaration = "on"; + } + if(key.id == "vbUsageCheckbox") + { + if(vbUsage == "on") + { + if(i == 1) + { + key.checked = true; + return; + } + + vbUsage = "off"; + } + else + vbUsage = "on"; + } + + if(key.id == "csCheckbox") + { + if(csLang == "on") + { + if(i == 1) + { + key.checked = true; + return; + } + + csLang = "off"; + } + else + csLang = "on"; + } + if(key.id == "cCheckbox") + { + if(cLang == "on") + { + if(i == 1) + { + key.checked = true; + return; + } + + cLang = "off"; + } + else + cLang = "on"; + } + if(key.id == "jsharpCheckbox") + { + if(jsharpLang == "on") + { + if(i == 1) + { + key.checked = true; + return; + } + + jsharpLang = "off"; + } + else + jsharpLang = "on"; + } + if(key.id == "jsCheckbox") + { + if(jsLang == "on") + { + if(i == 1) + { + key.checked = true; + return; + } + + jsLang = "off"; + } + else + jsLang = "on"; + } + + DisplayLanguages(); +} + +function DisplayLanguages() +{ + var spanElements = document.getElementsByTagName("span"); + + var x = 0; + if(vbDeclaration == "on") + x++; + if(vbUsage == "on") + x++; + if(csLang == "on") + x++; + if(cLang == "on") + x++; + if(jsharpLang == "on") + x++; + if(jsLang == "on") + x++; + + var i; + for(i = 0; i < spanElements.length; ++i) + { + if(spanElements[i].codeLanguage != null) + { + if(spanElements[i].codeLanguage == "VisualBasic") + { + if(vbDeclaration == "on" || vbUsage == "on") + spanElements[i].style.display = ""; + else + spanElements[i].style.display = "none"; + } + if(spanElements[i].codeLanguage == "VisualBasicDeclaration") + { + if(vbDeclaration == "on") + spanElements[i].style.display = ""; + else + spanElements[i].style.display = "none"; + } + + if(spanElements[i].codeLanguage == "VisualBasicUsage") + { + if(vbUsage == "on") + spanElements[i].style.display = ""; + else + spanElements[i].style.display = "none"; + } + + if(spanElements[i].codeLanguage == "CSharp") + { + if(csLang == "on") + spanElements[i].style.display = ""; + else + spanElements[i].style.display = "none"; + } + + if(spanElements[i].codeLanguage == "ManagedCPlusPlus") + { + if(cLang == "on") + spanElements[i].style.display = ""; + else + spanElements[i].style.display = "none"; + } + if(spanElements[i].codeLanguage == "JSharp") + { + if(jsharpLang == "on") + spanElements[i].style.display = ""; + else + spanElements[i].style.display = "none"; + } + if(spanElements[i].codeLanguage == "JScript") + { + if(jsLang == "on") + spanElements[i].style.display = ""; + else + spanElements[i].style.display = "none"; + } + + if(spanElements[i].codeLanguage == "NotVisualBasicUsage") + { + if((x == 1) && (vbUsage == "on")) + { + spanElements[i].style.display = "none"; + } + else + { + spanElements[i].style.display = ""; + } + } + if(spanElements[i].codeLanguage == "OnlyVisualBasic") + { + if(((vbDeclaration == "on")||(vbUsage == "on")) && (csLang != "on")) + { + spanElements[i].style.display = ""; + } + else + { + spanElements[i].style.display = "none"; + } + } + if(spanElements[i].codeLanguage == "AnyButVisualBasic") + { + if((vbDeclaration != "on") && (vbUsage != "on") && (csLang == "on")) + { + spanElements[i].style.display = ""; + } + else + { + spanElements[i].style.display = "none"; + } + } + if(spanElements[i].codeLanguage == "VisualBasicAndAnother") + { + if(((vbDeclaration == "on") || (vbUsage == "on")) && (csLang == "on")) + { + spanElements[i].style.display = ""; + } + else + { + spanElements[i].style.display = "none"; + } + } + } + } + ChangeLanguageFilterLabel(); +} + +function ChangeLanguageFilterLabel() +{ + var i = 0; + if(vbDeclaration == "on") + i++; + if(vbUsage == "on") + i++; + if(csLang == "on") + i++; + if(cLang == "on") + i++; + if(jsharpLang == "on") + i++; + if(jsLang == "on") + i++; + + var labelElement; + + labelElement = document.getElementById("showAllLabel"); + + if(labelElement == null) + return; + + labelElement.style.display = "none"; + + labelElement = document.getElementById("multipleLabel"); + labelElement.style.display = "none"; + + labelElement = document.getElementById("vbLabel"); + labelElement.style.display = "none"; + + labelElement = document.getElementById("csLabel"); + labelElement.style.display = "none"; + + labelElement = document.getElementById("cLabel"); + labelElement.style.display = "none"; + + labelElement = document.getElementById("jsharpLabel"); + labelElement.style.display = "none"; + + labelElement = document.getElementById("jsLabel"); + labelElement.style.display = "none"; + + if(i == 6) + { + labelElement = document.getElementById("showAllLabel"); + labelElement.style.display = "inline"; + } + else if ((i > 1) && (i < 6)) + { + if((i == 2) && ((vbDeclaration == "on") && (vbUsage == "on"))) + { + labelElement = document.getElementById("vbLabel"); + labelElement.style.display = "inline"; + } + else + { + labelElement = document.getElementById("multipleLabel"); + labelElement.style.display = "inline"; + } + } + else if (i == 1) + { + if(vbDeclaration == "on" || vbUsage == "on") + { + labelElement = document.getElementById("vbLabel"); + labelElement.style.display = "inline"; + } + if(csLang == "on") + { + labelElement = document.getElementById("csLabel"); + labelElement.style.display = "inline"; + } + if(cLang == "on") + { + labelElement = document.getElementById("cLabel"); + labelElement.style.display = "inline"; + } + if(jsharpLang == "on") + { + labelElement = document.getElementById("jsharpLabel"); + labelElement.style.display = "inline"; + } + if(jsLang == "on") + { + labelElement = document.getElementById("jsLabel"); + labelElement.style.display = "inline"; + } + } +} + +function LoadLanguages() +{ + var value; + value = Load("vbDeclaration"); + if(value == null) + vbDeclaration = "on"; + else + vbDeclaration = value; + + value = Load("vbUsage"); + if(value == null) + vbUsage = "on"; + else + vbUsage = value; + + value = Load("csLang"); + if(value == null) + csLang = "on"; + else + csLang = value; + + value = Load("cLang"); + if(value == null) + cLang = "on"; + else + cLang = value; + + value = Load("jsharpLang"); + if(value == null) + jsharpLang = "on"; + else + jsharpLang = value; + + value = Load("jsLang"); + if(value == null) + jsLang = "on"; + else + jsLang = value; + +} + +function SaveLanguages() +{ + Save("vbDeclaration", vbDeclaration); + Save("vbUsage", vbUsage); + Save("csLang", csLang); + Save("cLang", cLang); + Save("jsharpLang", jsharpLang); + Save("jsLang", jsLang); +} + +/* +********** +********** End Language Filtering +********** +*/ + + +/* +********** +********** Begin Members Options Filtering +********** +*/ + +function SetMembersOptions(key) +{ + if(key.id == "inheritedCheckbox") + { + if(key.checked == true) + inheritedMembers = "on"; + else + inheritedMembers = "off"; + + DisplayInheritedMembers(); + } + if(key.id == "protectedCheckbox") + { + if(key.checked == true) + protectedMembers = "on"; + else + protectedMembers = "off"; + + DisplayProtectedMembers(); + } + if(key.id == "assemblyCheckbox") + { + if(key.checked == true) + assemblyMembers = "on"; + else + assemblyMembers = "off"; + + DisplayAssemblyMembers(); + } + if(key.id == "privateCheckbox") + { + if(key.checked == true) + privateMembers = "on"; + else + privateMembers = "off"; + + DisplayPrivateMembers(); + } + if(key.id == "netcfCheckbox") + { + if(key.checked == true) + netcfMembersOnly = "on"; + else + netcfMembersOnly = "off"; + + DisplayNETCFMembers(); + } + + ChangeMembersOptionsFilterLabel(); +} + +function DisplayInheritedMembers() +{ + var iMembers = document.getElementsByTagName("tr"); + var i; + + if(inheritedMembers == "off") + { + for(i = 0; i < iMembers.length; ++i) + { + if(iMembers[i].name == "inheritedMember") + iMembers[i].style.display = "none"; + } + } + else + { + for(i = 0; i < iMembers.length; ++i) + { + if(iMembers[i].name == "inheritedMember") + { + if(netcfMembersOnly == "on") + { + if(iMembers[i].notSupportedOn == "netcf") + { + iMembers[i].style.display = "none"; + } + else + { + iMembers[i].style.display = ""; + } + } + else + iMembers[i].style.display = ""; + } + } + } +} + +function DisplayProtectedMembers() +{ + var imgElements = document.getElementsByName("toggleSwitch"); + var i; + + if(protectedMembers == "off") + { + for(i = 0; i < imgElements.length; ++i) + { + if(imgElements[i].id.indexOf("Family",0) >= 0) + { + if(imgElements[i].id.indexOf("Assembly", 0) >= 0) + { + if(assemblyMembers == "off") + { + if(ItemCollapsed(imgElements[i].id) == false) + { + ExpandCollapse(imgElements[i]); + } + } + } + else + { + if(ItemCollapsed(imgElements[i].id) == false) + { + ExpandCollapse(imgElements[i]); + } + } + } + } + } + else + { + for(i = 0; i < imgElements.length; ++i) + { + if(imgElements[i].id.indexOf("Family",0) >= 0) + { + if(ItemCollapsed(imgElements[i].id) == true) + { + ExpandCollapse(imgElements[i]); + } + } + } + } + +} + +function DisplayAssemblyMembers() +{ + var imgElements = document.getElementsByName("toggleSwitch"); + var i; + + if(assemblyMembers == "off") + { + for(i = 0; i < imgElements.length; ++i) + { + if(imgElements[i].id.indexOf("Assembly", 0) >= 0) + { + if(imgElements[i].id.indexOf("Family", 0) >= 0) + { + if(protectedMembers == "off") + { + if(ItemCollapsed(imgElements[i].id) == false) + { + ExpandCollapse(imgElements[i]); + } + } + } + else + { + if(ItemCollapsed(imgElements[i].id) == false) + { + ExpandCollapse(imgElements[i]); + } + } + } + } + } + else + { + for(i = 0; i < imgElements.length; ++i) + { + if(imgElements[i].id.indexOf("Assembly", 0) >= 0) + { + if(ItemCollapsed(imgElements[i].id) == true) + { + ExpandCollapse(imgElements[i]); + } + } + } + } + +} + +function DisplayPrivateMembers() +{ + var imgElements = document.getElementsByName("toggleSwitch"); + var i; + + if(privateMembers == "off") + { + for(i = 0; i < imgElements.length; ++i) + { + if(imgElements[i].id.indexOf("Private", 0) == 0) + { + if(ItemCollapsed(imgElements[i].id) == false) + { + ExpandCollapse(imgElements[i]); + } + } + } + } + else + { + for(i = 0; i < imgElements.length; ++i) + { + if(imgElements[i].id.indexOf("Private", 0) == 0) + { + if(ItemCollapsed(imgElements[i].id) == true) + { + ExpandCollapse(imgElements[i]); + } + } + } + } + +} + +function DisplayNETCFMembers() +{ + var netcfMembers = document.getElementsByTagName("tr"); + var i; + + if(netcfMembersOnly == "off") + { + for(i = 0; i < netcfMembers.length; ++i) + { + if(netcfMembers[i].notSupportedOn == "netcf") + { + netcfMembers[i].style.display = ""; + } + } + DisplayInheritedMembers(); + } + else + { + for(i = 0; i < netcfMembers.length; ++i) + { + if(netcfMembers[i].notSupportedOn == "netcf") + { + netcfMembers[i].style.display = "none"; + } + } + } +} + +function ChangeMembersOptionsFilterLabel() +{ + + var filtered = false; + + if((inheritedMembers=="off") || (protectedMembers=="off") || (assemblyMembers=="off") || (privateMembers=="off") || (netcfMembersOnly=="on")) + filtered = true; + + var labelElement; + + labelElement = document.getElementById("showAllMembersLabel"); + + if(labelElement == null) + return; + + labelElement.style.display = "none"; + + labelElement = document.getElementById("filteredMembersLabel"); + labelElement.style.display = "none"; + + if(filtered) + { + labelElement = document.getElementById("filteredMembersLabel"); + labelElement.style.display = "inline"; + } + else + { + labelElement = document.getElementById("showAllMembersLabel"); + labelElement.style.display = "inline"; + } +} + +function LoadMembersOptions() +{ + var value; + value = Load("inheritedMembers"); + if(value == null) + inheritedMembers = "on"; + else + inheritedMembers = value; + + value = Load("protectedMembers"); + if(value == null) + protectedMembers = "on"; + else + protectedMembers = value; + + value = Load("assemblyMembers"); + if(value == null) + assemblyMembers = "on"; + else + assemblyMembers = value; + + value = Load("privateMembers"); + if(value == null) + privateMembers = "on"; + else + privateMembers = value; + + value = Load("netcfMembersOnly"); + if(value == null) + netcfMembersOnly = "off"; + else + netcfMembersOnly = value; +} + +function SaveMembersOptions() +{ + Save("inheritedMembers", inheritedMembers); + Save("protectedMembers", protectedMembers); + Save("assemblyMembers", assemblyMembers); + Save("privateMembers", privateMembers); + Save("netcfMembersOnly", netcfMembersOnly); +} + +/* +********** +********** End Members Options Filtering +********** +*/ + + +/* +********** +********** Begin Expand/Collapse +********** +*/ + +var collapsedItems = new Array(); + +function ExpandCollapse(imageItem) +{ + if(ItemCollapsed(imageItem.id) == true) + { + imageItem.src = collapseImage.src; + ExpandSection(imageItem); + RemoveCollapsedItem(imageItem.id); + + if(imageItem.id.indexOf("Family", 0) == 0) + { + protectedMembers = "on"; + Set_up_checkboxes(); + ChangeMembersOptionsFilterLabel(); + } + } + else + { + imageItem.src = expandImage.src; + CollapseSection(imageItem); + AddCollapsedItem(imageItem.id); + } + + SetCollapseAll(); +} + +function ExpandCollapseAll(imageItem) +{ + var imgElements = document.getElementsByName("toggleSwitch"); + var i; + + if(ItemCollapsed(imageItem.id) == true) + { + imageItem.src = collapseAllImage.src; + RemoveCollapsedItem(imageItem.id); + for(i = 0; i < imgElements.length; ++i) + { + imgElements[i].src = collapseImage.src; + ExpandSection(imgElements[i]); + RemoveCollapsedItem(imgElements[i].id); + + if(imgElements[i].id.indexOf("Family", 0) == 0) + protectedMembers = "on"; + if(imgElements[i].id.indexOf("Assembly", 0) == 0) + assemblyMembers = "on"; + if(imgElements[i].id.indexOf("Private", 0) == 0) + privateMembers = "on"; + } + SetToggleAllLabel(false); + } + else + { + imageItem.src = expandAllImage.src; + AddCollapsedItem(imageItem.id); + for(i = 0; i < imgElements.length; ++i) + { + imgElements[i].src = expandImage.src; + CollapseSection(imgElements[i]); + AddCollapsedItem(imgElements[i].id); + } + SetToggleAllLabel(true); + } +} + +function ExpandCollapse_CheckKey(imageItem) +{ + if(window.event.keyCode == 13) + ExpandCollapse(imageItem); +} + +function ExpandCollapseAll_CheckKey(imageItem) +{ + if(window.event.keyCode == 13) + ExpandCollapseAll(imageItem); +} + +function ExpandSection(imageItem) +{ + imageItem.parentElement.parentElement.nextSibling.style.display = ""; +} + +function CollapseSection(imageItem) +{ + imageItem.parentElement.parentElement.nextSibling.style.display = "none"; +} + +function SetCollapseAll() +{ + var imageElement = document.getElementById("toggleAllImage"); + + if(imageElement == null) + return; + + var imgElements = document.getElementsByName("toggleSwitch"); + var allCollapsed = true; + var i; + + for(i = 0; i < imgElements.length; ++i) + { + allCollapsed = allCollapsed && ItemCollapsed(imgElements[i].id) + } + + if(allCollapsed) + { + imageElement.src = expandAllImage.src; + AddCollapsedItem(imageElement.id); + } + else + { + imageElement.src = collapseAllImage.src; + RemoveCollapsedItem(imageElement.id); + } + + SetToggleAllLabel(allCollapsed); +} + +function SetToggleAllLabel(allCollapsed) +{ + var labelElement; + labelElement = document.getElementById("collapseAllLabel"); + + if(labelElement == null) + return; + + labelElement.style.display = "none"; + + labelElement = document.getElementById("expandAllLabel"); + labelElement.style.display = "none"; + + if(allCollapsed) + { + labelElement = document.getElementById("expandAllLabel"); + labelElement.style.display = "inline"; + } + else + { + labelElement = document.getElementById("collapseAllLabel"); + labelElement.style.display = "inline"; + } +} + +function ItemCollapsed(imageId) +{ + var i; + + for(i = 0; i < collapsedItems.length; ++i) + { + if(imageId == collapsedItems[i]) + return true; + } + + return false; +} + +function AddCollapsedItem(imageId) +{ + if(ItemCollapsed(imageId) == false) + collapsedItems[collapsedItems.length] = imageId; +} + +function RemoveCollapsedItem(imageId) +{ + var i; + + for(i = 0; i < collapsedItems.length; ++i) + { + if(imageId == collapsedItems[i]) + collapsedItems.splice(i, 1); + } +} + +function SaveSections() +{ + var i; + var x = 0; + + CleanUserDataStore(); + + for(i = 0; i < collapsedItems.length; ++i) + { + if(ShouldSave(collapsedItems[i]) == true) + { + Save("imageValue" + x, collapsedItems[i]); + x++; + } + } +} + +function LoadSections() +{ + var i = 0; + var imageId = Load("imageValue" + i); + + while(imageId != null) + { + var imageItem = document.getElementById(imageId); + + if(imageItem != null) + { + if(imageItem.id.indexOf("Family", 0) == 0) + { + if(protectedMembers == "on") + { + ExpandCollapse(imageItem); + } + } + else if(imageItem.id.indexOf("Assembly", 0) == 0) + { + if(assemblyMembers == "on") + { + ExpandCollapse(imageItem); + } + } + else if(imageItem.id.indexOf("Private", 0) == 0) + { + if(privateMembers == "on") + { + ExpandCollapse(imageItem); + } + } + else + ExpandCollapse(imageItem); + } + else + { + AddCollapsedItem(imageId); + } + + i++; + imageId = Load("imageValue" + i); + } + + SetCollapseAll(); +} + +function CleanUserDataStore() +{ + var i = 0; + var imageId = Load("imageValue" + i); + + while(imageId != null) + { + RemoveAttribute("imageValue" + i); + i++; + imageId = Load("imageValue" + i); + } +} + +function ShouldSave(imageId) +{ + var toggleName; + + if(imageId == "toggleAllImage") + return false; + + toggleName = "procedureToggle"; + if(imageId.indexOf(toggleName, 0) == 0) + return false; + + toggleName = "sectionToggle"; + if(imageId.indexOf(toggleName, 0) == 0) + return false; + + return true; +} + +function OpenSection(imageItem) +{ + if(ItemCollapsed(imageItem.id) == true) + ExpandCollapse(imageItem); +} + +/* +********** +********** End Expand/Collapse +********** +*/ + + + +/* +********** +********** Begin Copy Code +********** +*/ + +function CopyCode(key) +{ + var trElements = document.getElementsByTagName("tr"); + var i; + for(i = 0; i < trElements.length; ++i) + { + if(key.parentElement.parentElement.parentElement == trElements[i].parentElement) + { + window.clipboardData.setData("Text", trElements[i].innerText); + } + } +} + +function ChangeCopyCodeIcon(key) +{ + var i; + var imageElements = document.getElementsByName("ccImage") + for(i=0; i + + SDK Link Manager + + + + + + + +
    +
    +
    +

    +

    SDK Link Namespace

    + + + + +
    +
    + + + diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/security.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/security.gif new file mode 100644 index 0000000..48661ce Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/security.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/static.gif b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/static.gif new file mode 100644 index 0000000..14f9a7a Binary files /dev/null and b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/static.gif differ diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/tooltip.htc b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/tooltip.htc new file mode 100644 index 0000000..5d8fe0f --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_msdn_temp/tooltip.htc @@ -0,0 +1,765 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp Documentation/ndoc_qa.log b/Code/Chapter 5/EmployeeApp Documentation/ndoc_qa.log new file mode 100644 index 0000000..b024076 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp Documentation/ndoc_qa.log @@ -0,0 +1,30 @@ +information QA1004: blank or 'noise' tag ignored for member: "P:EmployeeApp.Employee.Name" +information QA1004: blank or 'noise' tag ignored for member: "P:EmployeeApp.Employee.Name" +information QA1004: blank or 'noise' tag ignored for member: "P:EmployeeApp.Employee.Name" +information QA1004: blank or 'noise' tag ignored for member: "P:EmployeeApp.Employee.ID" +information QA1004: blank or 'noise' tag ignored for member: "P:EmployeeApp.Employee.ID" +information QA1004: blank or 'noise' tag ignored for member: "P:EmployeeApp.Employee.ID" +information QA1004: blank or 'noise' tag ignored for member: "P:EmployeeApp.Employee.Pay" +information QA1004: blank or 'noise' tag ignored for member: "P:EmployeeApp.Employee.Pay" +information QA1004: blank or 'noise' tag ignored for member: "P:EmployeeApp.Employee.Pay" +information QA1004: blank or 'noise' tag ignored for member: "P:EmployeeApp.Employee.Age" +information QA1004: blank or 'noise' tag ignored for member: "P:EmployeeApp.Employee.Age" +information QA1004: blank or 'noise' tag ignored for member: "P:EmployeeApp.Employee.Age" +information QA1004: blank or 'noise' tag ignored for member: "P:EmployeeApp.Employee.SocialSecurityNumber" +information QA1004: blank or 'noise' tag ignored for member: "P:EmployeeApp.Employee.SocialSecurityNumber" +information QA1004: blank or 'noise' tag ignored for member: "P:EmployeeApp.Employee.SocialSecurityNumber" +information QA1004: blank or 'noise' tag ignored for member: "P:EmployeeApp.Employee.Company" +information QA1004: blank or 'noise' tag ignored for member: "P:EmployeeApp.Employee.Company" +information QA1004: blank or 'noise' tag ignored for member: "P:EmployeeApp.Employee.Company" +information QA1004: blank or 'noise' tag ignored for member: "M:EmployeeApp.Employee.#ctor" +information QA1004: blank or 'noise' tag ignored for member: "M:EmployeeApp.Employee.#ctor(System.String,System.Int32,System.Int32,System.Single,System.String)" +information QA1004: blank or 'noise' tag ignored for member: "M:EmployeeApp.Employee.#ctor(System.String,System.Int32,System.Int32,System.Single,System.String)" +information QA1004: blank or 'noise' tag ignored for member: "M:EmployeeApp.Employee.#ctor(System.String,System.Int32,System.Int32,System.Single,System.String)" +information QA1004: blank or 'noise' tag ignored for member: "M:EmployeeApp.Employee.#ctor(System.String,System.Int32,System.Int32,System.Single,System.String)" +information QA1004: blank or 'noise' tag ignored for member: "M:EmployeeApp.Employee.#ctor(System.String,System.Int32,System.Int32,System.Single,System.String)" +information QA1004: blank or 'noise' tag ignored for member: "M:EmployeeApp.Employee.#ctor(System.String,System.Int32,System.Int32,System.Single,System.String)" +information QA1004: blank or 'noise' tag ignored for member: "M:EmployeeApp.Employee.#cctor" +information QA1004: blank or 'noise' tag ignored for member: "M:EmployeeApp.Employee.GiveBonus(System.Single)" +information QA1004: blank or 'noise' tag ignored for member: "M:EmployeeApp.Employee.GiveBonus(System.Single)" +information QA1004: blank or 'noise' tag ignored for member: "M:EmployeeApp.Employee.DisplayStats" +information QA1004: blank or 'noise' tag ignored for member: "T:EmployeeApp.Employee" diff --git a/Code/Chapter 5/EmployeeApp/Employee.Internal.vb b/Code/Chapter 5/EmployeeApp/Employee.Internal.vb new file mode 100644 index 0000000..a1a4c72 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp/Employee.Internal.vb @@ -0,0 +1,157 @@ +Public Class Employee + +#Region "Private Fields" + ' Field data. + Private empName As String + Private empID As Integer + Private currPay As Single + Private empAge As Integer + Private empSSN As String + Private Shared companyName As String +#End Region + +#Region "Properties" + ''' + ''' Gets or sets the name of the employee. + ''' + ''' + ''' + ''' + Public Property Name() As String + Get + Return empName + End Get + Set(ByVal value As String) + empName = value + End Set + End Property + + ''' + ''' Gets or sets the ID of the employee. + ''' + ''' + ''' + ''' + Public Property ID() As Integer + Get + Return empID + End Get + Set(ByVal value As Integer) + empID = value + End Set + End Property + + ''' + ''' Gets or sets the current pay of the employee. + ''' + ''' + ''' + ''' + Public Property Pay() As Single + Get + Return currPay + End Get + Set(ByVal value As Single) + currPay = value + End Set + End Property + + ''' + ''' Gets or sets the age of the employee. + ''' + ''' + ''' + ''' + Public Property Age() As Integer + Get + Return empAge + End Get + Set(ByVal value As Integer) + empAge = value + End Set + End Property + ''' + ''' Read only access to SSN. + ''' Set this value with a constructor argument. + ''' + ''' + ''' + ''' + Public ReadOnly Property SocialSecurityNumber() As String + Get + Return empSSN + End Get + End Property + + ''' + ''' Set the company name of the employees. + ''' + ''' + ''' + ''' + Public Shared Property Company() As String + Get + Return companyName + End Get + Set(ByVal value As String) + companyName = value + End Set + End Property +#End Region + +#Region "Constructors" + ''' + ''' The default constructor. + ''' + ''' + Public Sub New() + End Sub + ''' + ''' A custom constrctor to set the state of an employee. + ''' + ''' + ''' + ''' + ''' + ''' + ''' + Public Sub New(ByVal name As String, ByVal age As Integer, _ + ByVal id As Integer, ByVal pay As Single, _ + ByVal ssn As String) + empName = name + empAge = age + empID = id + empSSN = ssn + currPay = pay + End Sub + ''' + ''' This shared constructor sets the shared companyName + ''' field. + ''' + ''' + Shared Sub New() + companyName = "Intertech Training" + End Sub +#End Region + +#Region "Getter / Setter for empName field" + '' Accessor (get method) + 'Public Function GetName() As String + ' Return empName + 'End Function + + '' Mutator (set method) + 'Public Sub SetName(ByVal name As String) + ' ' Remove any illegal characters (!,@,#,$,%), + ' ' check maximum length or case before making assignment. + ' empName = name + 'End Sub + 'Public Function get_SocialSecurityNumber() As String + ' Return empSSN + 'End Function + 'Public Sub set_SocialSecurityNumber(ByVal val As String) + ' empSSN = val + 'End Sub +#End Region + +End Class diff --git a/Code/Chapter 5/EmployeeApp/Employee.vb b/Code/Chapter 5/EmployeeApp/Employee.vb new file mode 100644 index 0000000..157dbe2 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp/Employee.vb @@ -0,0 +1,31 @@ +''' +''' This is the Employee class +''' +''' +Partial Public Class Employee + +#Region "Members" + ''' + ''' This method gives a pay increase to the + ''' employee. + ''' + ''' + ''' + Public Sub GiveBonus(ByVal amount As Single) + currPay += amount + End Sub + + ''' + ''' This method displays the state of the object. + ''' + ''' + Public Sub DisplayStats() + Console.WriteLine("Name: {0}", empName) + Console.WriteLine("Age: {0}", empAge) + Console.WriteLine("SSN: {0}", empSSN) + Console.WriteLine("ID: {0}", empID) + Console.WriteLine("Pay: {0}", currPay) + End Sub +#End Region + +End Class diff --git a/Code/Chapter 5/EmployeeApp/EmployeeApp.cd b/Code/Chapter 5/EmployeeApp/EmployeeApp.cd new file mode 100644 index 0000000..732b5ac --- /dev/null +++ b/Code/Chapter 5/EmployeeApp/EmployeeApp.cd @@ -0,0 +1,11 @@ + + + + + + + Employee.Internal.vb + AAAAAAAAAAgAggAAAEAIAAQQEAAAAACEAAAABQAAAUA= + + + \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp/EmployeeApp.sln b/Code/Chapter 5/EmployeeApp/EmployeeApp.sln new file mode 100644 index 0000000..b8045d8 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp/EmployeeApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EmployeeApp", "EmployeeApp.vbproj", "{83ECB051-6E12-454C-A344-C8F64EB5C3C9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {83ECB051-6E12-454C-A344-C8F64EB5C3C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {83ECB051-6E12-454C-A344-C8F64EB5C3C9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {83ECB051-6E12-454C-A344-C8F64EB5C3C9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {83ECB051-6E12-454C-A344-C8F64EB5C3C9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 5/EmployeeApp/EmployeeApp.suo b/Code/Chapter 5/EmployeeApp/EmployeeApp.suo new file mode 100644 index 0000000..5efd694 Binary files /dev/null and b/Code/Chapter 5/EmployeeApp/EmployeeApp.suo differ diff --git a/Code/Chapter 5/EmployeeApp/EmployeeApp.vbproj b/Code/Chapter 5/EmployeeApp/EmployeeApp.vbproj new file mode 100644 index 0000000..691f466 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp/EmployeeApp.vbproj @@ -0,0 +1,137 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {83ECB051-6E12-454C-A344-C8F64EB5C3C9} + Exe + EmployeeApp.Program + EmployeeApp + EmployeeApp + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + EmployeeApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + EmployeeApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp/EmployeeApp.vbproj.user b/Code/Chapter 5/EmployeeApp/EmployeeApp.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp/EmployeeApp.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 5/EmployeeApp/My Project/Application.Designer.vb b/Code/Chapter 5/EmployeeApp/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 5/EmployeeApp/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 5/EmployeeApp/My Project/Application.myapp b/Code/Chapter 5/EmployeeApp/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 5/EmployeeApp/My Project/AssemblyInfo.vb b/Code/Chapter 5/EmployeeApp/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..809f624 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp/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/Code/Chapter 5/EmployeeApp/My Project/Resources.Designer.vb b/Code/Chapter 5/EmployeeApp/My Project/Resources.Designer.vb new file mode 100644 index 0000000..0387836 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("EmployeeApp.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/Code/Chapter 5/EmployeeApp/My Project/Resources.resx b/Code/Chapter 5/EmployeeApp/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp/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/Code/Chapter 5/EmployeeApp/My Project/Settings.Designer.vb b/Code/Chapter 5/EmployeeApp/My Project/Settings.Designer.vb new file mode 100644 index 0000000..6883ba3 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.EmployeeApp.My.MySettings + Get + Return Global.EmployeeApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 5/EmployeeApp/My Project/Settings.settings b/Code/Chapter 5/EmployeeApp/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 5/EmployeeApp/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 5/EmployeeApp/Program.vb b/Code/Chapter 5/EmployeeApp/Program.vb new file mode 100644 index 0000000..9d030d2 --- /dev/null +++ b/Code/Chapter 5/EmployeeApp/Program.vb @@ -0,0 +1,16 @@ +' This project illustrates the use of encapsulation +' services (the first pillar of OOP). +Module Program + + Sub Main() + Console.WriteLine("***** Fun with Encapsulation *****") + Console.WriteLine("These folks work at {0}", Employee.Company) + + Dim emp As New Employee("Marvin", 24, 456, 30000, "111-11-1111") + emp.GiveBonus(1000) + emp.DisplayStats() + + Console.ReadLine() + End Sub + +End Module diff --git a/Code/Chapter 5/SharedData/My Project/Application.Designer.vb b/Code/Chapter 5/SharedData/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 5/SharedData/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 5/SharedData/My Project/Application.myapp b/Code/Chapter 5/SharedData/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 5/SharedData/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 5/SharedData/My Project/AssemblyInfo.vb b/Code/Chapter 5/SharedData/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..a71deec --- /dev/null +++ b/Code/Chapter 5/SharedData/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/Code/Chapter 5/SharedData/My Project/Resources.Designer.vb b/Code/Chapter 5/SharedData/My Project/Resources.Designer.vb new file mode 100644 index 0000000..a2bcb88 --- /dev/null +++ b/Code/Chapter 5/SharedData/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("SharedData.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/Code/Chapter 5/SharedData/My Project/Resources.resx b/Code/Chapter 5/SharedData/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 5/SharedData/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/Code/Chapter 5/SharedData/My Project/Settings.Designer.vb b/Code/Chapter 5/SharedData/My Project/Settings.Designer.vb new file mode 100644 index 0000000..4c6411d --- /dev/null +++ b/Code/Chapter 5/SharedData/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SharedData.My.MySettings + Get + Return Global.SharedData.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 5/SharedData/My Project/Settings.settings b/Code/Chapter 5/SharedData/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 5/SharedData/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 5/SharedData/Program.vb b/Code/Chapter 5/SharedData/Program.vb new file mode 100644 index 0000000..2c646e6 --- /dev/null +++ b/Code/Chapter 5/SharedData/Program.vb @@ -0,0 +1,18 @@ +' This project illustrates the use of shared data and +' shared constructors. + +Module Program + Sub Main() + Console.WriteLine("***** Fun with Shared Data *****") + SavingsAccount.SetInterestRate(0.09) + Dim s1 As New SavingsAccount(50) + Dim s2 As New SavingsAccount(100) + + ' All three lines print out "Interest Rate is: 0.09" + Console.WriteLine("Interest Rate is: {0}", s1.GetInterestRateObj()) + Console.WriteLine("Interest Rate is: {0}", s2.GetInterestRateObj()) + Console.WriteLine("Interest Rate is: {0}", SavingsAccount.GetInterestRate()) + Console.ReadLine() + End Sub + +End Module diff --git a/Code/Chapter 5/SharedData/SavingsAccount.vb b/Code/Chapter 5/SharedData/SavingsAccount.vb new file mode 100644 index 0000000..214ec43 --- /dev/null +++ b/Code/Chapter 5/SharedData/SavingsAccount.vb @@ -0,0 +1,31 @@ +Public Class SavingsAccount + Public currBalance As Double + Public Shared currInterestRate As Double = 0.04 + + ' Instance constructor. + Public Sub New(ByVal balance As Double) + currBalance = balance + End Sub + + ' A shared constructor. + Shared Sub New() + Console.WriteLine("In Shared ctor!") + currInterestRate = 0.04 + End Sub + + ' Shared members to get/set interest rate. + Public Shared Sub SetInterestRate(ByVal newRate As Double) + currInterestRate = newRate + End Sub + Public Shared Function GetInterestRate() As Double + Return currInterestRate + End Function + + ' Instance members to get/set interest rate. + Public Sub SetInterestRateObj(ByVal newRate As Double) + currInterestRate = newRate + End Sub + Public Function GetInterestRateObj() As Double + Return currInterestRate + End Function +End Class diff --git a/Code/Chapter 5/SharedData/SharedData.sln b/Code/Chapter 5/SharedData/SharedData.sln new file mode 100644 index 0000000..847b38f --- /dev/null +++ b/Code/Chapter 5/SharedData/SharedData.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SharedData", "SharedData.vbproj", "{5FE1541F-1EE3-4592-8B5E-183148480E14}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5FE1541F-1EE3-4592-8B5E-183148480E14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5FE1541F-1EE3-4592-8B5E-183148480E14}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5FE1541F-1EE3-4592-8B5E-183148480E14}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5FE1541F-1EE3-4592-8B5E-183148480E14}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 5/SharedData/SharedData.suo b/Code/Chapter 5/SharedData/SharedData.suo new file mode 100644 index 0000000..9102704 Binary files /dev/null and b/Code/Chapter 5/SharedData/SharedData.suo differ diff --git a/Code/Chapter 5/SharedData/SharedData.vbproj b/Code/Chapter 5/SharedData/SharedData.vbproj new file mode 100644 index 0000000..9656c39 --- /dev/null +++ b/Code/Chapter 5/SharedData/SharedData.vbproj @@ -0,0 +1,135 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {5FE1541F-1EE3-4592-8B5E-183148480E14} + Exe + SharedData.Program + SharedData + SharedData + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + SharedData.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SharedData.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 5/SharedData/SharedData.vbproj.user b/Code/Chapter 5/SharedData/SharedData.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 5/SharedData/SharedData.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 5/SharedMethods/My Project/Application.Designer.vb b/Code/Chapter 5/SharedMethods/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 5/SharedMethods/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 5/SharedMethods/My Project/Application.myapp b/Code/Chapter 5/SharedMethods/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 5/SharedMethods/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 5/SharedMethods/My Project/AssemblyInfo.vb b/Code/Chapter 5/SharedMethods/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..3676154 --- /dev/null +++ b/Code/Chapter 5/SharedMethods/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/Code/Chapter 5/SharedMethods/My Project/Resources.Designer.vb b/Code/Chapter 5/SharedMethods/My Project/Resources.Designer.vb new file mode 100644 index 0000000..b4123ff --- /dev/null +++ b/Code/Chapter 5/SharedMethods/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("SharedMethods.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/Code/Chapter 5/SharedMethods/My Project/Resources.resx b/Code/Chapter 5/SharedMethods/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 5/SharedMethods/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/Code/Chapter 5/SharedMethods/My Project/Settings.Designer.vb b/Code/Chapter 5/SharedMethods/My Project/Settings.Designer.vb new file mode 100644 index 0000000..cb31b4f --- /dev/null +++ b/Code/Chapter 5/SharedMethods/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SharedMethods.My.MySettings + Get + Return Global.SharedMethods.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 5/SharedMethods/My Project/Settings.settings b/Code/Chapter 5/SharedMethods/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 5/SharedMethods/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 5/SharedMethods/Program.vb b/Code/Chapter 5/SharedMethods/Program.vb new file mode 100644 index 0000000..9bb647e --- /dev/null +++ b/Code/Chapter 5/SharedMethods/Program.vb @@ -0,0 +1,23 @@ +' This project illustrates the use of the Shared keyword. +Module Program + + Sub Main() + Console.WriteLine("***** Fun with Shared Methods *****") + For i As Integer = 0 To 5 + Console.WriteLine(Teenager.Complain()) + Next + + Console.WriteLine() + + ' VB-ism! This will be a compiler error + ' by setting the Instance variable accesses + ' shared member condition to "Error" using the My Project window. + Dim bob As New Teenager() + For i As Integer = 0 To 5 + Console.WriteLine(bob.Complain()) + Next + + Console.ReadLine() + End Sub + +End Module diff --git a/Code/Chapter 5/SharedMethods/SharedMethods.sln b/Code/Chapter 5/SharedMethods/SharedMethods.sln new file mode 100644 index 0000000..cd7863c --- /dev/null +++ b/Code/Chapter 5/SharedMethods/SharedMethods.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SharedMethods", "SharedMethods.vbproj", "{43D94E69-0782-4E02-8A61-BB38297CA103}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {43D94E69-0782-4E02-8A61-BB38297CA103}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {43D94E69-0782-4E02-8A61-BB38297CA103}.Debug|Any CPU.Build.0 = Debug|Any CPU + {43D94E69-0782-4E02-8A61-BB38297CA103}.Release|Any CPU.ActiveCfg = Release|Any CPU + {43D94E69-0782-4E02-8A61-BB38297CA103}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 5/SharedMethods/SharedMethods.suo b/Code/Chapter 5/SharedMethods/SharedMethods.suo new file mode 100644 index 0000000..13fe3bf Binary files /dev/null and b/Code/Chapter 5/SharedMethods/SharedMethods.suo differ diff --git a/Code/Chapter 5/SharedMethods/SharedMethods.vbproj b/Code/Chapter 5/SharedMethods/SharedMethods.vbproj new file mode 100644 index 0000000..3aa6ad3 --- /dev/null +++ b/Code/Chapter 5/SharedMethods/SharedMethods.vbproj @@ -0,0 +1,139 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {43D94E69-0782-4E02-8A61-BB38297CA103} + Exe + SharedMethods.Program + SharedMethods + SharedMethods + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + SharedMethods.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + + + + + pdbonly + false + true + true + bin\Release\ + SharedMethods.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 + + + + + + + 3.5 + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 5/SharedMethods/SharedMethods.vbproj.user b/Code/Chapter 5/SharedMethods/SharedMethods.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 5/SharedMethods/SharedMethods.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 5/SharedMethods/Teenager.vb b/Code/Chapter 5/SharedMethods/Teenager.vb new file mode 100644 index 0000000..02a64ee --- /dev/null +++ b/Code/Chapter 5/SharedMethods/Teenager.vb @@ -0,0 +1,14 @@ +Public Class Teenager + Public Shared r As Random = New Random() + + Public Shared Function GetRandomNumber(ByVal upperLimit As Short) As Integer + Return r.Next(upperLimit) + End Function + + Public Shared Function Complain() As String + Dim messages As String() = _ + {"Do I have to?", "He started it!", "I'm too tired...", _ + "I hate school!", "You are sooooooo wrong!"} + Return messages(GetRandomNumber(5)) + End Function +End Class diff --git a/Code/Chapter 5/SimpleClassExample/Car.vb b/Code/Chapter 5/SimpleClassExample/Car.vb new file mode 100644 index 0000000..85b94df --- /dev/null +++ b/Code/Chapter 5/SimpleClassExample/Car.vb @@ -0,0 +1,34 @@ +Public Class Car + ' The 'state' of the Car. + Public petName As String + Public currSpeed As Integer + +#Region "Constructors" + ' A custom default constructor. + Public Sub New() + petName = "Chuck" + currSpeed = 10 + End Sub + + ' Here, currSpeed will receive the + ' default value of an Integer (zero). + Public Sub New(ByVal pn As String) + petName = pn + End Sub + + ' Let caller set the full 'state' of the Car. + Public Sub New(ByVal pn As String, ByVal cs As Integer) + petName = pn + currSpeed = cs + End Sub +#End Region + + ' The functionality of the Car. + Public Sub PrintState() + Console.WriteLine("{0} is going {1} MPH.", _ + petName, currSpeed) + End Sub + Public Sub SpeedUp(ByVal delta As Integer) + currSpeed += delta + End Sub +End Class diff --git a/Code/Chapter 5/SimpleClassExample/Motorcycle.vb b/Code/Chapter 5/SimpleClassExample/Motorcycle.vb new file mode 100644 index 0000000..90e72f8 --- /dev/null +++ b/Code/Chapter 5/SimpleClassExample/Motorcycle.vb @@ -0,0 +1,45 @@ +Public Class Motorcycle + Public driverIntensity As Integer + Public driverName As String + + Public Sub SetDriverName(ByVal name As String) + ' These two line are functionally identical. + driverName = name + Me.driverName = name + End Sub + + Public Sub PopAWheely() + For i As Integer = 0 To driverIntensity + Console.WriteLine("Yeeeeeee Haaaaaeewww!") + Next + End Sub + +#Region "Constructors" + Public Sub New() + Console.WriteLine("In default c-tor") + End Sub + + Public Sub New(ByVal intensity As Integer) + Me.New(intensity, "") + Console.WriteLine("In c-tor taking an Integer") + End Sub + + Public Sub New(ByVal name As String) + Me.New(5, name) + Console.WriteLine("In c-tor taking a String") + End Sub + + Public Sub New(ByVal intensity As Integer, ByVal name As String) + Console.WriteLine("In master c-tor") + If intensity > 10 Then + intensity = 10 + End If + driverIntensity = intensity + driverName = name + End Sub +#End Region + +End Class + + + diff --git a/Code/Chapter 5/SimpleClassExample/My Project/Application.Designer.vb b/Code/Chapter 5/SimpleClassExample/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 5/SimpleClassExample/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 5/SimpleClassExample/My Project/Application.myapp b/Code/Chapter 5/SimpleClassExample/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 5/SimpleClassExample/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 5/SimpleClassExample/My Project/AssemblyInfo.vb b/Code/Chapter 5/SimpleClassExample/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..1f9eece --- /dev/null +++ b/Code/Chapter 5/SimpleClassExample/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/Code/Chapter 5/SimpleClassExample/My Project/Resources.Designer.vb b/Code/Chapter 5/SimpleClassExample/My Project/Resources.Designer.vb new file mode 100644 index 0000000..17242ff --- /dev/null +++ b/Code/Chapter 5/SimpleClassExample/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("SimpleClassExample.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/Code/Chapter 5/SimpleClassExample/My Project/Resources.resx b/Code/Chapter 5/SimpleClassExample/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 5/SimpleClassExample/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/Code/Chapter 5/SimpleClassExample/My Project/Settings.Designer.vb b/Code/Chapter 5/SimpleClassExample/My Project/Settings.Designer.vb new file mode 100644 index 0000000..bd3e36d --- /dev/null +++ b/Code/Chapter 5/SimpleClassExample/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SimpleClassExample.My.MySettings + Get + Return Global.SimpleClassExample.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 5/SimpleClassExample/My Project/Settings.settings b/Code/Chapter 5/SimpleClassExample/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 5/SimpleClassExample/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 5/SimpleClassExample/Program.vb b/Code/Chapter 5/SimpleClassExample/Program.vb new file mode 100644 index 0000000..ce74ee3 --- /dev/null +++ b/Code/Chapter 5/SimpleClassExample/Program.vb @@ -0,0 +1,41 @@ +' This project examines the basics of class design and usage +' (Constructors, the New keyword and the Me keyword). + +Module Program + Sub Main() + Console.WriteLine("***** Fun with Class Types *****") + + ' Allocate and configure a Car object. + Dim myCar As New Car() + myCar.petName = "Henry" + myCar.currSpeed = 10 + + ' Speed up the car a few times and print out the + ' new state. + For i As Integer = 0 To 10 + myCar.SpeedUp(5) + myCar.PrintState() + Next + Console.WriteLine() + + ' Make a Car called Chuck going 10 MPH. + Dim chuck As New Car() + chuck.PrintState() + + ' Make a Car called Mary going 0 MPH. + Dim mary As New Car("Mary") + mary.PrintState() + + ' Make a Car called Daisy going 75 MPH. + Dim daisy As New Car("Daisy", 75) + daisy.PrintState() + Console.WriteLine() + + ' Make a Motorcycle. + Dim c As New Motorcycle(5) + c.SetDriverName("Tiny") + c.PopAWheely() + Console.WriteLine("Rider name is {0}", c.driverName) + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 5/SimpleClassExample/SimpleClassExample.sln b/Code/Chapter 5/SimpleClassExample/SimpleClassExample.sln new file mode 100644 index 0000000..8787ac8 --- /dev/null +++ b/Code/Chapter 5/SimpleClassExample/SimpleClassExample.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SimpleClassExample", "SimpleClassExample.vbproj", "{DE1149B7-6FE7-4A5B-9975-7164F086A603}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DE1149B7-6FE7-4A5B-9975-7164F086A603}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DE1149B7-6FE7-4A5B-9975-7164F086A603}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DE1149B7-6FE7-4A5B-9975-7164F086A603}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DE1149B7-6FE7-4A5B-9975-7164F086A603}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 5/SimpleClassExample/SimpleClassExample.suo b/Code/Chapter 5/SimpleClassExample/SimpleClassExample.suo new file mode 100644 index 0000000..efcc4bd Binary files /dev/null and b/Code/Chapter 5/SimpleClassExample/SimpleClassExample.suo differ diff --git a/Code/Chapter 5/SimpleClassExample/SimpleClassExample.vbproj b/Code/Chapter 5/SimpleClassExample/SimpleClassExample.vbproj new file mode 100644 index 0000000..c57a991 --- /dev/null +++ b/Code/Chapter 5/SimpleClassExample/SimpleClassExample.vbproj @@ -0,0 +1,136 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {DE1149B7-6FE7-4A5B-9975-7164F086A603} + Exe + SimpleClassExample.Program + SimpleClassExample + SimpleClassExample + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + SimpleClassExample.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SimpleClassExample.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 5/SimpleClassExample/SimpleClassExample.vbproj.user b/Code/Chapter 5/SimpleClassExample/SimpleClassExample.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 5/SimpleClassExample/SimpleClassExample.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 6/BasicInheritance/BasicInheritance.sln b/Code/Chapter 6/BasicInheritance/BasicInheritance.sln new file mode 100644 index 0000000..a0e6e2b --- /dev/null +++ b/Code/Chapter 6/BasicInheritance/BasicInheritance.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "BasicInheritance", "BasicInheritance.vbproj", "{52A63402-20EF-4EDA-B60C-F4B910E9616E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {52A63402-20EF-4EDA-B60C-F4B910E9616E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {52A63402-20EF-4EDA-B60C-F4B910E9616E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {52A63402-20EF-4EDA-B60C-F4B910E9616E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {52A63402-20EF-4EDA-B60C-F4B910E9616E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 6/BasicInheritance/BasicInheritance.suo b/Code/Chapter 6/BasicInheritance/BasicInheritance.suo new file mode 100644 index 0000000..4fc6890 Binary files /dev/null and b/Code/Chapter 6/BasicInheritance/BasicInheritance.suo differ diff --git a/Code/Chapter 6/BasicInheritance/BasicInheritance.vbproj b/Code/Chapter 6/BasicInheritance/BasicInheritance.vbproj new file mode 100644 index 0000000..fd28c4d --- /dev/null +++ b/Code/Chapter 6/BasicInheritance/BasicInheritance.vbproj @@ -0,0 +1,137 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {52A63402-20EF-4EDA-B60C-F4B910E9616E} + Exe + BasicInheritance.Program + BasicInheritance + BasicInheritance + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + BasicInheritance.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + BasicInheritance.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 6/BasicInheritance/BasicInheritance.vbproj.user b/Code/Chapter 6/BasicInheritance/BasicInheritance.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 6/BasicInheritance/BasicInheritance.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 6/BasicInheritance/Car.vb b/Code/Chapter 6/BasicInheritance/Car.vb new file mode 100644 index 0000000..1bb7635 --- /dev/null +++ b/Code/Chapter 6/BasicInheritance/Car.vb @@ -0,0 +1,24 @@ +' A simple Car class. +Public Class Car + Public ReadOnly MaxSpeed As Integer + Private currSpeed As Integer + + Public Sub New(ByVal max As Integer) + MaxSpeed = max + End Sub + Public Sub New() + MaxSpeed = 55 + End Sub + + Public Property Speed() As Integer + Get + Return currSpeed + End Get + Set(ByVal value As Integer) + currSpeed = value + If currSpeed > MaxSpeed Then + currSpeed = MaxSpeed + End If + End Set + End Property +End Class diff --git a/Code/Chapter 6/BasicInheritance/Cars.cd b/Code/Chapter 6/BasicInheritance/Cars.cd new file mode 100644 index 0000000..b48b91d --- /dev/null +++ b/Code/Chapter 6/BasicInheritance/Cars.cd @@ -0,0 +1,25 @@ + + + + + + + Car.vb + AAACAAAAAAAAAAAAAAAEAAABAAAAAAAAAAAAAAAAAAA= + + + + + + MiniVan.vb + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + + + + + + Program.vb + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAA= + + + \ No newline at end of file diff --git a/Code/Chapter 6/BasicInheritance/MiniVan.vb b/Code/Chapter 6/BasicInheritance/MiniVan.vb new file mode 100644 index 0000000..355b90f --- /dev/null +++ b/Code/Chapter 6/BasicInheritance/MiniVan.vb @@ -0,0 +1,12 @@ +' This class cannot be extended! +Public NotInheritable Class MiniVan + Inherits Car + ' Here, we can now define members which are unique to + ' the MiniVan type. +End Class + +' Error! Cannot extend +' a class marked NotInheritable! +'Public Class BetterMiniVan +' Inherits MiniVan +'End Class diff --git a/Code/Chapter 6/BasicInheritance/My Project/Application.Designer.vb b/Code/Chapter 6/BasicInheritance/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 6/BasicInheritance/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 6/BasicInheritance/My Project/Application.myapp b/Code/Chapter 6/BasicInheritance/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 6/BasicInheritance/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 6/BasicInheritance/My Project/AssemblyInfo.vb b/Code/Chapter 6/BasicInheritance/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..dd35d39 --- /dev/null +++ b/Code/Chapter 6/BasicInheritance/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/Code/Chapter 6/BasicInheritance/My Project/Resources.Designer.vb b/Code/Chapter 6/BasicInheritance/My Project/Resources.Designer.vb new file mode 100644 index 0000000..16e4a33 --- /dev/null +++ b/Code/Chapter 6/BasicInheritance/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("BasicInheritance.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/Code/Chapter 6/BasicInheritance/My Project/Resources.resx b/Code/Chapter 6/BasicInheritance/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 6/BasicInheritance/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/Code/Chapter 6/BasicInheritance/My Project/Settings.Designer.vb b/Code/Chapter 6/BasicInheritance/My Project/Settings.Designer.vb new file mode 100644 index 0000000..4d9d003 --- /dev/null +++ b/Code/Chapter 6/BasicInheritance/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.BasicInheritance.My.MySettings + Get + Return Global.BasicInheritance.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 6/BasicInheritance/My Project/Settings.settings b/Code/Chapter 6/BasicInheritance/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 6/BasicInheritance/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 6/BasicInheritance/Program.vb b/Code/Chapter 6/BasicInheritance/Program.vb new file mode 100644 index 0000000..10de09a --- /dev/null +++ b/Code/Chapter 6/BasicInheritance/Program.vb @@ -0,0 +1,24 @@ +' The project illustrates the use of classical inheritance. + +Module Program + + Sub Main() + Console.WriteLine("***** Basic Inheritance *****") + ' Make a Car type. + Dim myCar As New Car(80) + myCar.Speed = 50 + Console.WriteLine("My car is going {0} MPH", _ + myCar.Speed) + + ' Now make a MiniVan + Dim myVan As New MiniVan() + myVan.Speed = 10 + Console.WriteLine("My van is going {0} MPH", _ + myVan.Speed) + + ' Error! Cannot access private data of the parent from an object! + ' myVan.currSpeed = 10 + Console.ReadLine() + End Sub + +End Module \ No newline at end of file diff --git a/Code/Chapter 6/Employees/Employee.Internal.vb b/Code/Chapter 6/Employees/Employee.Internal.vb new file mode 100644 index 0000000..5d805c5 --- /dev/null +++ b/Code/Chapter 6/Employees/Employee.Internal.vb @@ -0,0 +1,154 @@ +Public Class Employee + ' Field data. + Private empName As String + Private empID As Integer + Private currPay As Single + Private empAge As Integer + Private empSSN As String + Private Shared companyName As String + +#Region "Properties" + ''' + ''' Gets or sets the name of the employee. + ''' + ''' + ''' + ''' + Public Property Name() As String + Get + Return empName + End Get + Set(ByVal value As String) + empName = value + End Set + End Property + + ''' + ''' Gets or sets the ID of the employee. + ''' + ''' + ''' + ''' + Public Property ID() As Integer + Get + Return empID + End Get + Set(ByVal value As Integer) + empID = value + End Set + End Property + + ''' + ''' Gets or sets the current pay of the employee. + ''' + ''' + ''' + ''' + Public Property Pay() As Single + Get + Return currPay + End Get + Set(ByVal value As Single) + currPay = value + End Set + End Property + + ''' + ''' Gets or sets the age of the employee. + ''' + ''' + ''' + ''' + Public Property Age() As Integer + Get + Return empAge + End Get + Set(ByVal value As Integer) + empAge = value + End Set + End Property + ''' + ''' Read only access to SSN. + ''' Set this value with a constructor argument. + ''' + ''' + ''' + ''' + Public ReadOnly Property SocialSecurityNumber() As String + Get + Return empSSN + End Get + End Property + + ''' + ''' Set the company name of the employees. + ''' + ''' + ''' + ''' + Public Shared Property Company() As String + Get + Return companyName + End Get + Set(ByVal value As String) + companyName = value + End Set + End Property +#End Region + +#Region "Constructors" + ''' + ''' The default constructor. + ''' + ''' + Sub New() + End Sub + ''' + ''' A custom constrctor to set the state of an employee. + ''' + ''' + ''' + ''' + ''' + ''' + ''' + Sub New(ByVal name As String, ByVal age As Integer, _ + ByVal id As Integer, ByVal pay As Single, _ + ByVal ssn As String) + empName = name + empAge = age + empID = id + empSSN = ssn + currPay = pay + End Sub + ''' + ''' This shared constructor sets the shared companyName + ''' field. + ''' + ''' + Shared Sub New() + companyName = "Intertech Training" + End Sub +#End Region + +#Region "Getter / Setter for empName field" + '' Accessor (get method) + 'Public Function GetName() As String + ' Return empName + 'End Function + + '' Mutator (set method) + 'Public Sub SetName(ByVal name As String) + ' ' Remove any illegal characters (!,@,#,$,%), + ' ' check maximum length or case before making assignment. + ' empName = name + 'End Sub + 'Public Function get_SocialSecurityNumber() As String + ' Return empSSN + 'End Function + 'Public Sub set_SocialSecurityNumber(ByVal val As String) + ' empSSN = val + 'End Sub +#End Region + +End Class diff --git a/Code/Chapter 6/Employees/Employee.vb b/Code/Chapter 6/Employees/Employee.vb new file mode 100644 index 0000000..424e676 --- /dev/null +++ b/Code/Chapter 6/Employees/Employee.vb @@ -0,0 +1,64 @@ +''' +''' This class represents an employee. +''' +''' +Partial Public MustInherit Class Employee + +#Region "Functionality for the benefits package" + Public Class BenefitPackage + Public Enum BenefitPackageLevel + Standard + Gold + Platinum + End Enum + ' Assume we have other members that represent + ' 401K plans, dental/health benefits, and so on. + Public Function ComputePayDeduction() As Double + Return 125.0 + End Function + End Class + + ' Contain a BenefitPackage object. + Protected empBenefits As New BenefitPackage() + + ' Expose certain benefit behaviors of object. + Public Function GetBenefitCost() As Double + Return empBenefits.ComputePayDeduction() + End Function + ' Expose object through a custom property. + Public Property Benefits() As BenefitPackage + Get + Return empBenefits + End Get + Set(ByVal value As BenefitPackage) + empBenefits = value + End Set + End Property +#End Region + +#Region "Members" + ''' + ''' This method gives a pay increase to the + ''' employee. + ''' + ''' + ''' + Public Overridable Sub GiveBonus(ByVal amount As Single) + currPay += amount + End Sub + + + ''' + ''' This method displays the state of the object. + ''' + ''' + Public Overridable Sub DisplayStats() + Console.WriteLine("Name: {0}", empName) + Console.WriteLine("Age: {0}", empAge) + Console.WriteLine("SSN: {0}", empSSN) + Console.WriteLine("ID: {0}", empID) + Console.WriteLine("Pay: {0}", currPay) + End Sub +#End Region + +End Class diff --git a/Code/Chapter 6/Employees/Employees.cd b/Code/Chapter 6/Employees/Employees.cd new file mode 100644 index 0000000..071b9b7 --- /dev/null +++ b/Code/Chapter 6/Employees/Employees.cd @@ -0,0 +1,55 @@ + + + + + + + Employee.Internal.vb + AAAAAAAAIAgAggAAAEAIAEQQEAAAAACEAAAAhQAAAUA= + + + + + + + + + + + Employee.vb + + + + + + + + Employee.vb + + + + + + + + + + Manager.vb + AAAABAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAQA= + + + + + + SalesPerson.vb + AAAAAAAAAAAAAAAAAAAAAAAAEAAAgCAAAAAAAAAAAQA= + + + + + + PTSalesPerson.vb + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + + + \ No newline at end of file diff --git a/Code/Chapter 6/Employees/Employees.sln b/Code/Chapter 6/Employees/Employees.sln new file mode 100644 index 0000000..c132be9 --- /dev/null +++ b/Code/Chapter 6/Employees/Employees.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Employees", "Employees.vbproj", "{29C6E0DA-EAF7-47C1-A4F3-C4EA84CD77B1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {29C6E0DA-EAF7-47C1-A4F3-C4EA84CD77B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {29C6E0DA-EAF7-47C1-A4F3-C4EA84CD77B1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {29C6E0DA-EAF7-47C1-A4F3-C4EA84CD77B1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {29C6E0DA-EAF7-47C1-A4F3-C4EA84CD77B1}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 6/Employees/Employees.suo b/Code/Chapter 6/Employees/Employees.suo new file mode 100644 index 0000000..6a76b97 Binary files /dev/null and b/Code/Chapter 6/Employees/Employees.suo differ diff --git a/Code/Chapter 6/Employees/Employees.vbproj b/Code/Chapter 6/Employees/Employees.vbproj new file mode 100644 index 0000000..3d3b4c8 --- /dev/null +++ b/Code/Chapter 6/Employees/Employees.vbproj @@ -0,0 +1,140 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {29C6E0DA-EAF7-47C1-A4F3-C4EA84CD77B1} + Exe + Employees.Program + Employees + Employees + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + Employees.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + Employees.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 6/Employees/Employees.vbproj.user b/Code/Chapter 6/Employees/Employees.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 6/Employees/Employees.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 6/Employees/Manager.vb b/Code/Chapter 6/Employees/Manager.vb new file mode 100644 index 0000000..d442a94 --- /dev/null +++ b/Code/Chapter 6/Employees/Manager.vb @@ -0,0 +1,40 @@ +' Managers need to know their number of stock options. +Public Class Manager + Inherits Employee + Private numberOfOptions As Integer + Public Property StockOptions() As Integer + Get + Return numberOfOptions + End Get + Set(ByVal value As Integer) + numberOfOptions = value + End Set + End Property + +#Region "Constructors" + Public Sub New() + End Sub + ' This time, use the VB 2005 "MyBase" keyword to call a custom + ' constructor on the base class. + Public Sub New(ByVal fullName As String, ByVal empAge As Integer, _ + ByVal empID As Integer, ByVal currPay As Single, _ + ByVal ssn As String, ByVal numbOfOpts As Integer) + ' Pass these arguments to the parent's constructor. + MyBase.New(fullName, empAge, empID, currPay, ssn) + + ' This belongs with us! + numberOfOptions = numbOfOpts + End Sub +#End Region + + Public Overrides Sub GiveBonus(ByVal amount As Single) + MyBase.GiveBonus(amount) + Dim r As New Random() + numberOfOptions += r.Next(500) + End Sub + + Public Overrides Sub DisplayStats() + MyBase.DisplayStats() + Console.WriteLine("Number of Stock Options: {0}", numberOfOptions) + End Sub +End Class diff --git a/Code/Chapter 6/Employees/My Project/Application.Designer.vb b/Code/Chapter 6/Employees/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 6/Employees/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 6/Employees/My Project/Application.myapp b/Code/Chapter 6/Employees/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 6/Employees/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 6/Employees/My Project/AssemblyInfo.vb b/Code/Chapter 6/Employees/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..d4a6e40 --- /dev/null +++ b/Code/Chapter 6/Employees/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/Code/Chapter 6/Employees/My Project/Resources.Designer.vb b/Code/Chapter 6/Employees/My Project/Resources.Designer.vb new file mode 100644 index 0000000..49641fe --- /dev/null +++ b/Code/Chapter 6/Employees/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("Employees.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/Code/Chapter 6/Employees/My Project/Resources.resx b/Code/Chapter 6/Employees/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 6/Employees/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/Code/Chapter 6/Employees/My Project/Settings.Designer.vb b/Code/Chapter 6/Employees/My Project/Settings.Designer.vb new file mode 100644 index 0000000..4623dd6 --- /dev/null +++ b/Code/Chapter 6/Employees/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.Employees.My.MySettings + Get + Return Global.Employees.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 6/Employees/My Project/Settings.settings b/Code/Chapter 6/Employees/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 6/Employees/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 6/Employees/PTSalesPerson.vb b/Code/Chapter 6/Employees/PTSalesPerson.vb new file mode 100644 index 0000000..d7556bc --- /dev/null +++ b/Code/Chapter 6/Employees/PTSalesPerson.vb @@ -0,0 +1,11 @@ +Public NotInheritable Class PTSalesPerson + Inherits SalesPerson + + Public Sub New(ByVal fullName As String, ByVal empAge As Integer, _ + ByVal empID As Integer, ByVal currPay As Single, _ + ByVal ssn As String, ByVal numbOfSales As Integer) + ' Pass these arguments to the parent's constructor. + MyBase.New(fullName, empAge, empID, currPay, ssn, numbOfSales) + End Sub + ' Assume other members here... +End Class diff --git a/Code/Chapter 6/Employees/Program.vb b/Code/Chapter 6/Employees/Program.vb new file mode 100644 index 0000000..746d3fb --- /dev/null +++ b/Code/Chapter 6/Employees/Program.vb @@ -0,0 +1,68 @@ +' This example illustrates the details of building +' class heirarchies. + +' We are enabling this option to ensure that we must +' explicitly cast +Option Strict On + +Module Program + Sub Main() + Console.WriteLine("***** The Employee Class Hierarchy *****") + Console.WriteLine() + ' A better bonus system! + Dim chucky As New Manager("Chucky", 50, 92, 100000, "333-23-2322", 9000) + chucky.GiveBonus(300) + chucky.DisplayStats() + Console.WriteLine() + + Dim fran As New SalesPerson("Fran", 43, 93, 3000, "932-32-3232", 31) + fran.GiveBonus(200) + fran.DisplayStats() + Console.WriteLine() + + ' This method fires the staff ;-) + FunWithCasting() + Console.ReadLine() + End Sub + +#Region "Helper methods" + Sub FunWithCasting() + ' A Manager "is-a" System.Object. + Dim frank As Object = _ + New Manager("Frank Zappa", 9, 3000, 40000, "111-11-1111", 5) + + ' A Manager "is-a" Employee too. + Dim moonUnit As Employee = New Manager("MoonUnit Zappa", 2, 3001, _ + 20000, "101-11-1321", 1) + + ' A PTSalesPerson "is-a" SalesPerson. + Dim jill As SalesPerson = New PTSalesPerson("Jill", 834, 3002, _ + 100000, "111-12-1119", 90) + + ' Streamline the staff. + FireThisPerson(moonUnit) ' "moonUnit" was declared as an Employee. + FireThisPerson(jill) ' "jill" was declared as a SalesPerson. + + ' OK even with Option Strict enabled. + FireThisPerson(CType(frank, Manager)) + End Sub + + Public Sub FireThisPerson(ByVal emp As Employee) + If TypeOf emp Is SalesPerson Then + Console.WriteLine("Lost a sales person named {0}", emp.Name) + Console.WriteLine("{0} made {1} sale(s)...", emp.Name, _ + CType(emp, SalesPerson).SalesNumber) + Console.WriteLine() + End If + If TypeOf emp Is Manager Then + Console.WriteLine("Lost a suit named {0}", emp.Name) + Console.WriteLine("{0} had {1} stock options...", emp.Name, _ + CType(emp, Manager).StockOptions) + Console.WriteLine() + End If + End Sub +#End Region + +End Module + + diff --git a/Code/Chapter 6/Employees/SalesPerson.vb b/Code/Chapter 6/Employees/SalesPerson.vb new file mode 100644 index 0000000..5d0c55c --- /dev/null +++ b/Code/Chapter 6/Employees/SalesPerson.vb @@ -0,0 +1,52 @@ +' Salespeople need to know their number of sales. +Public Class SalesPerson + Inherits Employee + Private numberOfSales As Integer + Public Property SalesNumber() As Integer + Get + Return numberOfSales + End Get + Set(ByVal value As Integer) + numberOfSales = value + End Set + End Property + +#Region "Constructors" + Public Sub New() + End Sub + + ' As a general rule, all subclasses should explicitly call an appropriate + ' base class constructor. + Public Sub New(ByVal fullName As String, ByVal empAge As Integer, _ + ByVal empID As Integer, ByVal currPay As Single, _ + ByVal ssn As String, ByVal numbOfSales As Integer) + ' Pass these arguments to the parent's constructor. + MyBase.New(fullName, empAge, empID, currPay, ssn) + + ' This belongs with us! + numberOfSales = numbOfSales + End Sub +#End Region + + ' A salesperson's bonus is influenced by the number of sales. + Public NotOverridable Overrides Sub GiveBonus(ByVal amount As Single) + Dim salesBonus As Integer = 0 + If numberOfSales >= 0 AndAlso numberOfSales <= 100 Then + salesBonus = 10 + Else + If numberOfSales >= 101 AndAlso numberOfSales <= 200 Then + salesBonus = 15 + Else + salesBonus = 20 + End If + End If + MyBase.GiveBonus(amount * salesBonus) + End Sub + + Public Overrides Sub DisplayStats() + MyBase.DisplayStats() + Console.WriteLine("Number of Sales: {0}", numberOfSales) + End Sub + +End Class + diff --git a/Code/Chapter 6/ObjectOverrides/My Project/Application.Designer.vb b/Code/Chapter 6/ObjectOverrides/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 6/ObjectOverrides/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 6/ObjectOverrides/My Project/Application.myapp b/Code/Chapter 6/ObjectOverrides/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 6/ObjectOverrides/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 6/ObjectOverrides/My Project/AssemblyInfo.vb b/Code/Chapter 6/ObjectOverrides/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..736a8a0 --- /dev/null +++ b/Code/Chapter 6/ObjectOverrides/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/Code/Chapter 6/ObjectOverrides/My Project/Resources.Designer.vb b/Code/Chapter 6/ObjectOverrides/My Project/Resources.Designer.vb new file mode 100644 index 0000000..422465b --- /dev/null +++ b/Code/Chapter 6/ObjectOverrides/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("ObjectOverrides.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/Code/Chapter 6/ObjectOverrides/My Project/Resources.resx b/Code/Chapter 6/ObjectOverrides/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 6/ObjectOverrides/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/Code/Chapter 6/ObjectOverrides/My Project/Settings.Designer.vb b/Code/Chapter 6/ObjectOverrides/My Project/Settings.Designer.vb new file mode 100644 index 0000000..c88d9a0 --- /dev/null +++ b/Code/Chapter 6/ObjectOverrides/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.ObjectOverrides.My.MySettings + Get + Return Global.ObjectOverrides.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 6/ObjectOverrides/My Project/Settings.settings b/Code/Chapter 6/ObjectOverrides/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 6/ObjectOverrides/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 6/ObjectOverrides/ObjectOverrides.sln b/Code/Chapter 6/ObjectOverrides/ObjectOverrides.sln new file mode 100644 index 0000000..828325f --- /dev/null +++ b/Code/Chapter 6/ObjectOverrides/ObjectOverrides.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ObjectOverrides", "ObjectOverrides.vbproj", "{4A50CBA9-B214-4B8B-8B19-478E83DABC7D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4A50CBA9-B214-4B8B-8B19-478E83DABC7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4A50CBA9-B214-4B8B-8B19-478E83DABC7D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4A50CBA9-B214-4B8B-8B19-478E83DABC7D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4A50CBA9-B214-4B8B-8B19-478E83DABC7D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 6/ObjectOverrides/ObjectOverrides.suo b/Code/Chapter 6/ObjectOverrides/ObjectOverrides.suo new file mode 100644 index 0000000..b2d852a Binary files /dev/null and b/Code/Chapter 6/ObjectOverrides/ObjectOverrides.suo differ diff --git a/Code/Chapter 6/ObjectOverrides/ObjectOverrides.vbproj b/Code/Chapter 6/ObjectOverrides/ObjectOverrides.vbproj new file mode 100644 index 0000000..0d3e740 --- /dev/null +++ b/Code/Chapter 6/ObjectOverrides/ObjectOverrides.vbproj @@ -0,0 +1,135 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {4A50CBA9-B214-4B8B-8B19-478E83DABC7D} + Exe + ObjectOverrides.Program + ObjectOverrides + ObjectOverrides + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + ObjectOverrides.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + ObjectOverrides.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 6/ObjectOverrides/ObjectOverrides.vbproj.user b/Code/Chapter 6/ObjectOverrides/ObjectOverrides.vbproj.user new file mode 100644 index 0000000..26d4d5b --- /dev/null +++ b/Code/Chapter 6/ObjectOverrides/ObjectOverrides.vbproj.user @@ -0,0 +1,17 @@ + + + + + + + + + + + + + en-US + false + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 6/ObjectOverrides/Person.vb b/Code/Chapter 6/ObjectOverrides/Person.vb new file mode 100644 index 0000000..312f99e --- /dev/null +++ b/Code/Chapter 6/ObjectOverrides/Person.vb @@ -0,0 +1,53 @@ +' Remember! Person extends Object. +Class Person + Public Sub New(ByVal firstName As String, ByVal lastName As String, _ + ByVal age As Byte) + fName = firstName + lName = lastName + personAge = age + End Sub + Sub New() + End Sub + + ' Public only for simplicity. Properties and Private data + ' would obviously be perferred. + Public fName As String + Public lName As String + Public personAge As Byte + +#Region "System.Object overrides" + Public Overrides Function ToString() As String + Dim myState As String + myState = String.Format("[First Name: {0}; Last Name: {1}; Age: {2}]", _ + fName, lName, personAge) + Return myState + End Function + + 'Public Overrides Function Equals(ByVal obj As Object) As Boolean + ' If TypeOf obj Is Person AndAlso obj IsNot Nothing Then + ' Dim temp As Person = CType(obj, Person) + ' If temp.fName = Me.fName AndAlso _ + ' temp.lName = Me.fName AndAlso _ + ' temp.personAge = Me.personAge Then + ' Return True + ' Else + ' Return False + ' End If + ' Return False + ' End If + 'End Function + + Public Overrides Function Equals(ByVal obj As Object) As Boolean + ' No need to cast 'obj' to a Person anymore, + ' as everyting has a ToString() method. + Return obj.ToString = Me.ToString() + End Function + + ' Return a hash code based on the person's ToString() value. + Public Overrides Function GetHashCode() As Integer + Return Me.ToString().GetHashCode() + End Function + +#End Region + +End Class diff --git a/Code/Chapter 6/ObjectOverrides/Program.vb b/Code/Chapter 6/ObjectOverrides/Program.vb new file mode 100644 index 0000000..d7f7a45 --- /dev/null +++ b/Code/Chapter 6/ObjectOverrides/Program.vb @@ -0,0 +1,49 @@ +' The example illustrates the role of +' the top-most parent class in .NET, +' System.Object + +Module Program + Sub Main() + Console.WriteLine("***** Fun with System.Object *****") + Console.WriteLine() + + ' NOTE: We want these to be identical to test + ' the Equals() and GetHashCode() methods. + Dim p1 As New Person("Homer", "Simpson", 50) + Dim p2 As New Person("Homer", "Simpson", 50) + + ' Get stringified version of objects. + Console.WriteLine("p1.ToString() = {0}", p1.ToString()) + Console.WriteLine("p2.ToString() = {0}", p2.ToString()) + + ' Test Overridden Equals() + Console.WriteLine("p1 = p2?: {0}", p1.Equals(p2)) + + ' Test hash codes. + Console.WriteLine("Same hash codes?: {0}", _ + p1.GetHashCode() = p2.GetHashCode()) + Console.WriteLine() + + ' Change age of p2 and test again. + p2.personAge = 45 + Console.WriteLine("p1.ToString() = {0}", p1.ToString()) + Console.WriteLine("p2.ToString() = {0}", p2.ToString()) + Console.WriteLine("p1 = p2?: {0}", p1.Equals(p2)) + Console.WriteLine("Same hash codes?: {0}", _ + p1.GetHashCode() = p2.GetHashCode()) + + Console.WriteLine() + SharedMembersOfObject() + Console.ReadLine() + End Sub + + Sub SharedMembersOfObject() + ' Shared members of System.Object. + Dim p3 As New Person("Sally", "Jones", 4) + Dim p4 As New Person("Sally", "Jones", 4) + Console.WriteLine("P3 and P4 have same state: {0}", Object.Equals(p3, p4)) + Console.WriteLine("P3 and P4 are pointing to same object: {0}", _ + Object.ReferenceEquals(p3, p4)) + End Sub +End Module + diff --git a/Code/Chapter 6/Shapes/My Project/Application.Designer.vb b/Code/Chapter 6/Shapes/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 6/Shapes/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 6/Shapes/My Project/Application.myapp b/Code/Chapter 6/Shapes/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 6/Shapes/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 6/Shapes/My Project/AssemblyInfo.vb b/Code/Chapter 6/Shapes/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..63daae2 --- /dev/null +++ b/Code/Chapter 6/Shapes/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/Code/Chapter 6/Shapes/My Project/Resources.Designer.vb b/Code/Chapter 6/Shapes/My Project/Resources.Designer.vb new file mode 100644 index 0000000..d27017f --- /dev/null +++ b/Code/Chapter 6/Shapes/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("Shapes.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/Code/Chapter 6/Shapes/My Project/Resources.resx b/Code/Chapter 6/Shapes/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 6/Shapes/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/Code/Chapter 6/Shapes/My Project/Settings.Designer.vb b/Code/Chapter 6/Shapes/My Project/Settings.Designer.vb new file mode 100644 index 0000000..48c24eb --- /dev/null +++ b/Code/Chapter 6/Shapes/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.Shapes.My.MySettings + Get + Return Global.Shapes.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 6/Shapes/My Project/Settings.settings b/Code/Chapter 6/Shapes/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 6/Shapes/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 6/Shapes/MyShapes.vb b/Code/Chapter 6/Shapes/MyShapes.vb new file mode 100644 index 0000000..a355677 --- /dev/null +++ b/Code/Chapter 6/Shapes/MyShapes.vb @@ -0,0 +1,41 @@ +' If we did not implement the MustOverride Draw() method, Circle would also be +' considered abstract, and would have to be marked MustInherit! +Public Class Circle + Inherits Shape + Public Sub New() + End Sub + Public Sub New(ByVal name As String) + MyBase.New(name) + End Sub + Public Overrides Sub Draw() + Console.WriteLine("Drawing {0} the Circle", shapeName) + End Sub +End Class + + +' Hexagon DOES override Draw(). +Public Class Hexagon + Inherits Shape + Public Sub New() + End Sub + Public Sub New(ByVal name As String) + MyBase.New(name) + End Sub + Public Overrides Sub Draw() + Console.WriteLine("Drawing {0} the Hexagon", shapeName) + End Sub +End Class + +' This class extends Circle and hides the inherited Draw() method. +Public Class ThreeDCircle + Inherits Circle + + ' Hide the shapeName field above me. + Protected Shadows shapeName As String + + ' Hide any Draw() implementation above me. + Public Shadows Sub Draw() + Console.WriteLine("Drawing a 3D Circle") + End Sub +End Class + diff --git a/Code/Chapter 6/Shapes/Program.vb b/Code/Chapter 6/Shapes/Program.vb new file mode 100644 index 0000000..2f4adb3 --- /dev/null +++ b/Code/Chapter 6/Shapes/Program.vb @@ -0,0 +1,26 @@ +' This example illustrates how to construct a polymorphic interface +' in a class heirarchy. + +Module Program + Sub Main() + Console.WriteLine("***** Fun with Polymorphism *****") + Console.WriteLine() + + ' Make an array of Shape compatible objects. + Dim myShapes() As Shape = {New Hexagon(), New Circle(), _ + New Hexagon("Mick"), New Circle("Beth"), _ + New Hexagon("Linda")} + + ' Loop over each items and interact with the + ' polymorphic interface. + For Each s As Shape In myShapes + s.Draw() + Next + + ' Fun with shadowing. + Dim o As ThreeDCircle = New ThreeDCircle() + o.Draw() + CType(o, Circle).Draw() + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 6/Shapes/Shape.vb b/Code/Chapter 6/Shapes/Shape.vb new file mode 100644 index 0000000..bfa12ae --- /dev/null +++ b/Code/Chapter 6/Shapes/Shape.vb @@ -0,0 +1,22 @@ +' The abstract base class of the hierarchy. +Public MustInherit Class Shape + Protected shapeName As String + + Public Sub New() + shapeName = "NoName" + End Sub + Public Sub New(ByVal s As String) + shapeName = s + End Sub + + Public MustOverride Sub Draw() + + Public Property PetName() As String + Get + Return shapeName + End Get + Set(ByVal value As String) + shapeName = value + End Set + End Property +End Class diff --git a/Code/Chapter 6/Shapes/Shapes.cd b/Code/Chapter 6/Shapes/Shapes.cd new file mode 100644 index 0000000..1e6152c --- /dev/null +++ b/Code/Chapter 6/Shapes/Shapes.cd @@ -0,0 +1,32 @@ + + + + + + AAAAIAAAAAAAAgAAAAAAAAAAAAABAAAAAAAAAAAAAAA= + Shape.vb + + + + + + AAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + MyShapes.vb + + + + + + AAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + MyShapes.vb + + + + + + AAAAAAAAAAAAAgAAAAAAAAAAAAABAAAAAAAAAAAAAAA= + MyShapes.vb + + + + \ No newline at end of file diff --git a/Code/Chapter 6/Shapes/Shapes.sln b/Code/Chapter 6/Shapes/Shapes.sln new file mode 100644 index 0000000..8bbafcf --- /dev/null +++ b/Code/Chapter 6/Shapes/Shapes.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Shapes", "Shapes.vbproj", "{BF51C036-2394-4E4C-BA60-2439A87FE6A1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BF51C036-2394-4E4C-BA60-2439A87FE6A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BF51C036-2394-4E4C-BA60-2439A87FE6A1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BF51C036-2394-4E4C-BA60-2439A87FE6A1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BF51C036-2394-4E4C-BA60-2439A87FE6A1}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 6/Shapes/Shapes.suo b/Code/Chapter 6/Shapes/Shapes.suo new file mode 100644 index 0000000..61864c2 Binary files /dev/null and b/Code/Chapter 6/Shapes/Shapes.suo differ diff --git a/Code/Chapter 6/Shapes/Shapes.vbproj b/Code/Chapter 6/Shapes/Shapes.vbproj new file mode 100644 index 0000000..0089107 --- /dev/null +++ b/Code/Chapter 6/Shapes/Shapes.vbproj @@ -0,0 +1,137 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {BF51C036-2394-4E4C-BA60-2439A87FE6A1} + Exe + Shapes.Program + Shapes + Shapes + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + Shapes.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + Shapes.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 6/Shapes/Shapes.vbproj.user b/Code/Chapter 6/Shapes/Shapes.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 6/Shapes/Shapes.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 7/CustomException/Car.vb b/Code/Chapter 7/CustomException/Car.vb new file mode 100644 index 0000000..0501739 --- /dev/null +++ b/Code/Chapter 7/CustomException/Car.vb @@ -0,0 +1,58 @@ +Public Class Car + ' Constant for maximum speed. + Public Const maxSpeed As Integer = 100 + + ' Internal state data. + Private currSpeed As Integer + Private petName As String + + ' Is the car still operational? + Private carIsDead As Boolean + + ' A car has a radio. + Private theMusicBox As Radio = New Radio() + +#Region "Constructors." + Public Sub New() + End Sub + Public Sub New(ByVal name As String, ByVal currSp As Integer) + currSpeed = currSp + petName = name + End Sub +#End Region + + Public Sub CrankTunes(ByVal state As Boolean) + theMusicBox.TurnOn(state) + End Sub + +#Region "Accelerate method" + ' See if Car has overheated. + Public Sub Accelerate(ByVal delta As Integer) + If delta < 0 Then + Throw New ArgumentOutOfRangeException() + End If + If carIsDead Then + Console.WriteLine("{0} is out of order...", petName) + Else + currSpeed += delta + If currSpeed >= maxSpeed Then + carIsDead = True + currSpeed = 0 + + ' We need to call the HelpLink property, thus we need to + ' create a local variable before throwing the Exception object. + Dim ex As New CarIsDeadException(String.Format("{0} has overheated!", petName)) + ex.HelpLink = "http://www.CarsRUs.com" + ' Stuff in custom data regarding the error. + ex.Data.Add("TimeStamp", _ + String.Format("The car exploded at {0}", DateTime.Now)) + ex.Data.Add("Cause", "You have a lead foot.") + Throw ex + Else + Console.WriteLine("=> CurrSpeed = {0}", currSpeed) + End If + End If + End Sub +#End Region + +End Class diff --git a/Code/Chapter 7/CustomException/CarIsDeadException.vb b/Code/Chapter 7/CustomException/CarIsDeadException.vb new file mode 100644 index 0000000..7475269 --- /dev/null +++ b/Code/Chapter 7/CustomException/CarIsDeadException.vb @@ -0,0 +1,54 @@ +Imports System.Runtime.Serialization + +#Region "CarIsDeadException take one" +'Public Class CarIsDeadException +' Inherits ApplicationException + +' ' Default error message. +' Private messageDetails As String = "Car Error" + +' ' Constructors. +' Public Sub New() +' End Sub +' Public Sub New(ByVal msg As String) +' messageDetails = msg +' End Sub + +' ' Override the Exception.Message property. +' Public Overrides ReadOnly Property Message() As String +' Get +' Return String.Format("Car Error Message: {0}", messageDetails) +' End Get +' End Property +'End Class +#End Region + +#Region "CarIsDeadException take two" +'Public Class CarIsDeadException +' Inherits ApplicationException +' Public Sub New() +' End Sub +' Public Sub New(ByVal msg As String) +' MyBase.New(msg) +' End Sub +'End Class +#End Region + +#Region "CarIsDeadException take three" + _ +Public Class CarIsDeadException + Inherits ApplicationException + Public Sub New() + End Sub + Public Sub New(ByVal message As String) + MyBase.New(message) + End Sub + Public Sub New(ByVal message As String, ByVal inner As System.Exception) + MyBase.New(message, inner) + End Sub + Protected Sub New(ByVal info As SerializationInfo, _ + ByVal context As StreamingContext) + MyBase.New(info, context) + End Sub +End Class +#End Region diff --git a/Code/Chapter 7/CustomException/CustomException.sln b/Code/Chapter 7/CustomException/CustomException.sln new file mode 100644 index 0000000..09307a7 --- /dev/null +++ b/Code/Chapter 7/CustomException/CustomException.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CustomException", "CustomException.vbproj", "{547CAE6C-F6F5-4B84-AC0F-D503BA1A07C9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {547CAE6C-F6F5-4B84-AC0F-D503BA1A07C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {547CAE6C-F6F5-4B84-AC0F-D503BA1A07C9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {547CAE6C-F6F5-4B84-AC0F-D503BA1A07C9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {547CAE6C-F6F5-4B84-AC0F-D503BA1A07C9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 7/CustomException/CustomException.suo b/Code/Chapter 7/CustomException/CustomException.suo new file mode 100644 index 0000000..c477f93 Binary files /dev/null and b/Code/Chapter 7/CustomException/CustomException.suo differ diff --git a/Code/Chapter 7/CustomException/CustomException.vbproj b/Code/Chapter 7/CustomException/CustomException.vbproj new file mode 100644 index 0000000..ee8d33c --- /dev/null +++ b/Code/Chapter 7/CustomException/CustomException.vbproj @@ -0,0 +1,137 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {547CAE6C-F6F5-4B84-AC0F-D503BA1A07C9} + Exe + CustomException.Program + CustomException + CustomException + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + CustomException.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + CustomException.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 7/CustomException/CustomException.vbproj.user b/Code/Chapter 7/CustomException/CustomException.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 7/CustomException/CustomException.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 7/CustomException/My Project/Application.Designer.vb b/Code/Chapter 7/CustomException/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 7/CustomException/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 7/CustomException/My Project/Application.myapp b/Code/Chapter 7/CustomException/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 7/CustomException/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 7/CustomException/My Project/AssemblyInfo.vb b/Code/Chapter 7/CustomException/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..83539ae --- /dev/null +++ b/Code/Chapter 7/CustomException/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/Code/Chapter 7/CustomException/My Project/Resources.Designer.vb b/Code/Chapter 7/CustomException/My Project/Resources.Designer.vb new file mode 100644 index 0000000..8ee8f4f --- /dev/null +++ b/Code/Chapter 7/CustomException/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("CustomException.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/Code/Chapter 7/CustomException/My Project/Resources.resx b/Code/Chapter 7/CustomException/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 7/CustomException/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/Code/Chapter 7/CustomException/My Project/Settings.Designer.vb b/Code/Chapter 7/CustomException/My Project/Settings.Designer.vb new file mode 100644 index 0000000..755d2b4 --- /dev/null +++ b/Code/Chapter 7/CustomException/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CustomException.My.MySettings + Get + Return Global.CustomException.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 7/CustomException/My Project/Settings.settings b/Code/Chapter 7/CustomException/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 7/CustomException/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 7/CustomException/Program.vb b/Code/Chapter 7/CustomException/Program.vb new file mode 100644 index 0000000..b8d8f81 --- /dev/null +++ b/Code/Chapter 7/CustomException/Program.vb @@ -0,0 +1,47 @@ +' This example illustrates how to throw, catch and interact with +' custom exceptions. + +Module Program + Sub Main() + Console.WriteLine("***** Simple Exception Example *****") + Console.WriteLine("=> Creating a car and stepping on it!") + Dim myCar As New Car("Zippy", 20) + myCar.CrankTunes(True) + + Try + For i As Integer = 0 To 10 + myCar.Accelerate(10) + Next + Catch ex As ArgumentOutOfRangeException + Console.WriteLine(ex.Message) + Catch ex As CarIsDeadException + Console.WriteLine("*** Error! ***") + Console.WriteLine("Member name: {0}", ex.TargetSite) + Console.WriteLine("Class defining member: {0}", _ + ex.TargetSite.DeclaringType) + Console.WriteLine("Member type: {0}", ex.TargetSite.MemberType) + Console.WriteLine("Message: {0}", ex.Message) + Console.WriteLine("Source: {0}", ex.Source) + Console.WriteLine("Stack: {0}", ex.StackTrace) + Console.WriteLine("Help Link: {0}", ex.HelpLink) + + ' By default, the data field is empty, so check for Nothing. + Console.WriteLine("-> Custom Data:") + If (ex.Data IsNot Nothing) Then + For Each de As DictionaryEntry In ex.Data + Console.WriteLine("-> {0} : {1}", de.Key, de.Value) + Next + End If + Catch ex As Exception + Console.WriteLine("Some other exception happened!") + Console.WriteLine(ex.Message) + Finally + ' This will always execute, error or not. + myCar.CrankTunes(False) + End Try + + ' The error has been handled, processing continues with the next statement. + Console.WriteLine("***** Out of exception logic *****") + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 7/CustomException/Radio.vb b/Code/Chapter 7/CustomException/Radio.vb new file mode 100644 index 0000000..cdd0154 --- /dev/null +++ b/Code/Chapter 7/CustomException/Radio.vb @@ -0,0 +1,9 @@ +Public Class Radio + Public Sub TurnOn(ByVal state As Boolean) + If state = True Then + Console.WriteLine("Jamming...") + Else + Console.WriteLine("Quiet time...") + End If + End Sub +End Class diff --git a/Code/Chapter 7/SimpleException/Car.vb b/Code/Chapter 7/SimpleException/Car.vb new file mode 100644 index 0000000..52d7716 --- /dev/null +++ b/Code/Chapter 7/SimpleException/Car.vb @@ -0,0 +1,55 @@ +Public Class Car + ' Constant for maximum speed. + Public Const maxSpeed As Integer = 100 + + ' Internal state data. + Private currSpeed As Integer + Private petName As String + + ' Is the car still operational? + Private carIsDead As Boolean + + ' A car has a radio. + Private theMusicBox As New Radio() + +#Region "Constructors." + Public Sub New() + End Sub + Public Sub New(ByVal name As String, ByVal currSp As Integer) + currSpeed = currSp + petName = name + End Sub +#End Region + + Public Sub CrankTunes(ByVal state As Boolean) + theMusicBox.TurnOn(state) + End Sub + +#Region "Accelerate method" + ' See if Car has overheated. + Public Sub Accelerate(ByVal delta As Integer) + If carIsDead Then + Console.WriteLine("{0} is out of order...", petName) + Else + currSpeed += delta + If currSpeed >= maxSpeed Then + carIsDead = True + currSpeed = 0 + + ' We need to call the HelpLink property, thus we need to + ' create a local variable before throwing the Exception object. + Dim ex As New Exception(String.Format("{0} has overheated!", petName)) + ex.HelpLink = "http://www.CarsRUs.com" + ' Stuff in custom data regarding the error. + ex.Data.Add("TimeStamp", _ + String.Format("The car exploded at {0}", DateTime.Now)) + ex.Data.Add("Cause", "You have a lead foot.") + Throw ex + Else + Console.WriteLine("=> CurrSpeed = {0}", currSpeed) + End If + End If + End Sub +#End Region + +End Class diff --git a/Code/Chapter 7/SimpleException/My Project/Application.Designer.vb b/Code/Chapter 7/SimpleException/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 7/SimpleException/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 7/SimpleException/My Project/Application.myapp b/Code/Chapter 7/SimpleException/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 7/SimpleException/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 7/SimpleException/My Project/AssemblyInfo.vb b/Code/Chapter 7/SimpleException/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..83a74f9 --- /dev/null +++ b/Code/Chapter 7/SimpleException/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/Code/Chapter 7/SimpleException/My Project/Resources.Designer.vb b/Code/Chapter 7/SimpleException/My Project/Resources.Designer.vb new file mode 100644 index 0000000..f72b8dc --- /dev/null +++ b/Code/Chapter 7/SimpleException/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("SimpleException.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/Code/Chapter 7/SimpleException/My Project/Resources.resx b/Code/Chapter 7/SimpleException/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 7/SimpleException/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/Code/Chapter 7/SimpleException/My Project/Settings.Designer.vb b/Code/Chapter 7/SimpleException/My Project/Settings.Designer.vb new file mode 100644 index 0000000..f68dbc7 --- /dev/null +++ b/Code/Chapter 7/SimpleException/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SimpleException.My.MySettings + Get + Return Global.SimpleException.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 7/SimpleException/My Project/Settings.settings b/Code/Chapter 7/SimpleException/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 7/SimpleException/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 7/SimpleException/Program.vb b/Code/Chapter 7/SimpleException/Program.vb new file mode 100644 index 0000000..d070a36 --- /dev/null +++ b/Code/Chapter 7/SimpleException/Program.vb @@ -0,0 +1,38 @@ +' This example illustrates how to throw, catch and interact with +' exceptions. +Module Program + Sub Main() + Console.WriteLine("***** Simple Exception Example *****") + Console.WriteLine("=> Creating a car and stepping on it!") + Dim myCar As New Car("Zippy", 20) + myCar.CrankTunes(True) + + Try + For i As Integer = 0 To 10 + myCar.Accelerate(10) + Next + Catch ex As Exception + Console.WriteLine("*** Error! ***") + Console.WriteLine("Member name: {0}", ex.TargetSite) + Console.WriteLine("Class defining member: {0}", _ + ex.TargetSite.DeclaringType) + Console.WriteLine("Member type: {0}", ex.TargetSite.MemberType) + Console.WriteLine("Message: {0}", ex.Message) + Console.WriteLine("Source: {0}", ex.Source) + Console.WriteLine("Stack: {0}", ex.StackTrace) + Console.WriteLine("Help Link: {0}", ex.HelpLink) + + ' By default, the data field is empty, so check for Nothing. + Console.WriteLine("-> Custom Data:") + If (ex.Data IsNot Nothing) Then + For Each de As DictionaryEntry In ex.Data + Console.WriteLine("-> {0} : {1}", de.Key, de.Value) + Next + End If + End Try + + ' The error has been handled, processing continues with the next statement. + Console.WriteLine("***** Out of exception logic *****") + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 7/SimpleException/Radio.vb b/Code/Chapter 7/SimpleException/Radio.vb new file mode 100644 index 0000000..e1075fc --- /dev/null +++ b/Code/Chapter 7/SimpleException/Radio.vb @@ -0,0 +1,10 @@ +Public Class Radio + Public Sub TurnOn(ByVal state As Boolean) + If state = True Then + Console.WriteLine("Jamming...") + Else + Console.WriteLine("Quiet time...") + End If + End Sub +End Class + diff --git a/Code/Chapter 7/SimpleException/SimpleException.sln b/Code/Chapter 7/SimpleException/SimpleException.sln new file mode 100644 index 0000000..d2e20b5 --- /dev/null +++ b/Code/Chapter 7/SimpleException/SimpleException.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SimpleException", "SimpleException.vbproj", "{C05FE71C-CB73-4A4E-99C2-94CB9549EC2C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C05FE71C-CB73-4A4E-99C2-94CB9549EC2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C05FE71C-CB73-4A4E-99C2-94CB9549EC2C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C05FE71C-CB73-4A4E-99C2-94CB9549EC2C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C05FE71C-CB73-4A4E-99C2-94CB9549EC2C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 7/SimpleException/SimpleException.suo b/Code/Chapter 7/SimpleException/SimpleException.suo new file mode 100644 index 0000000..9197243 Binary files /dev/null and b/Code/Chapter 7/SimpleException/SimpleException.suo differ diff --git a/Code/Chapter 7/SimpleException/SimpleException.vbproj b/Code/Chapter 7/SimpleException/SimpleException.vbproj new file mode 100644 index 0000000..3ff377b --- /dev/null +++ b/Code/Chapter 7/SimpleException/SimpleException.vbproj @@ -0,0 +1,136 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {C05FE71C-CB73-4A4E-99C2-94CB9549EC2C} + Exe + SimpleException.Program + SimpleException + SimpleException + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + SimpleException.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SimpleException.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 7/SimpleException/SimpleException.vbproj.user b/Code/Chapter 7/SimpleException/SimpleException.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 7/SimpleException/SimpleException.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 7/Vb6StyleErrorHandling/Car.vb b/Code/Chapter 7/Vb6StyleErrorHandling/Car.vb new file mode 100644 index 0000000..a01d6d9 --- /dev/null +++ b/Code/Chapter 7/Vb6StyleErrorHandling/Car.vb @@ -0,0 +1,58 @@ +Public Class Car + ' Constant for maximum speed. + Public Const maxSpeed As Integer = 100 + + ' Internal state data. + Private currSpeed As Integer + Private petName As String + + ' Is the car still operational? + Private carIsDead As Boolean + + ' A car has a radio. + Private theMusicBox As Radio = New Radio() + +#Region "Constructors." + Public Sub New() + End Sub + Public Sub New(ByVal name As String, ByVal currSp As Integer) + currSpeed = currSp + petName = name + End Sub +#End Region + + Public Sub CrankTunes(ByVal state As Boolean) + theMusicBox.TurnOn(state) + End Sub + +#Region "Accelerate method" + ' See if Car has overheated. + Public Sub Accelerate(ByVal delta As Integer) + If delta < 0 Then + Throw New ArgumentOutOfRangeException() + End If + If carIsDead Then + Console.WriteLine("{0} is out of order...", petName) + Else + currSpeed += delta + If currSpeed >= maxSpeed Then + carIsDead = True + currSpeed = 0 + + ' We need to call the HelpLink property, thus we need to + ' create a local variable before throwing the Exception object. + Dim ex As New CarIsDeadException(String.Format("{0} has overheated!", petName)) + ex.HelpLink = "http://www.CarsRUs.com" + ' Stuff in custom data regarding the error. + ex.Data.Add("TimeStamp", _ + String.Format("The car exploded at {0}", DateTime.Now)) + ex.Data.Add("Cause", "You have a lead foot.") + Throw ex + Else + Console.WriteLine("=> CurrSpeed = {0}", currSpeed) + End If + End If + End Sub +#End Region + +End Class diff --git a/Code/Chapter 7/Vb6StyleErrorHandling/CarIsDeadException.vb b/Code/Chapter 7/Vb6StyleErrorHandling/CarIsDeadException.vb new file mode 100644 index 0000000..898ce80 --- /dev/null +++ b/Code/Chapter 7/Vb6StyleErrorHandling/CarIsDeadException.vb @@ -0,0 +1,18 @@ + _ +Public Class CarIsDeadException + Inherits ApplicationException + Public Sub New() + End Sub + Public Sub New(ByVal message As String) + MyBase.New(message) + End Sub + Public Sub New(ByVal message As String, ByVal inner As System.Exception) + MyBase.New(message, inner) + End Sub + Protected Sub New(ByVal info As System.Runtime.Serialization.SerializationInfo, _ + ByVal context As System.Runtime.Serialization.StreamingContext) + MyBase.New(info, context) + End Sub +End Class + + diff --git a/Code/Chapter 7/Vb6StyleErrorHandling/My Project/Application.Designer.vb b/Code/Chapter 7/Vb6StyleErrorHandling/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 7/Vb6StyleErrorHandling/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 7/Vb6StyleErrorHandling/My Project/Application.myapp b/Code/Chapter 7/Vb6StyleErrorHandling/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 7/Vb6StyleErrorHandling/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 7/Vb6StyleErrorHandling/My Project/AssemblyInfo.vb b/Code/Chapter 7/Vb6StyleErrorHandling/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..a004908 --- /dev/null +++ b/Code/Chapter 7/Vb6StyleErrorHandling/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/Code/Chapter 7/Vb6StyleErrorHandling/My Project/Resources.Designer.vb b/Code/Chapter 7/Vb6StyleErrorHandling/My Project/Resources.Designer.vb new file mode 100644 index 0000000..f8b1c30 --- /dev/null +++ b/Code/Chapter 7/Vb6StyleErrorHandling/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("Vb6StyleErrorHandling.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/Code/Chapter 7/Vb6StyleErrorHandling/My Project/Resources.resx b/Code/Chapter 7/Vb6StyleErrorHandling/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 7/Vb6StyleErrorHandling/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/Code/Chapter 7/Vb6StyleErrorHandling/My Project/Settings.Designer.vb b/Code/Chapter 7/Vb6StyleErrorHandling/My Project/Settings.Designer.vb new file mode 100644 index 0000000..c36ba7d --- /dev/null +++ b/Code/Chapter 7/Vb6StyleErrorHandling/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.Vb6StyleErrorHandling.My.MySettings + Get + Return Global.Vb6StyleErrorHandling.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 7/Vb6StyleErrorHandling/My Project/Settings.settings b/Code/Chapter 7/Vb6StyleErrorHandling/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 7/Vb6StyleErrorHandling/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 7/Vb6StyleErrorHandling/Program.vb b/Code/Chapter 7/Vb6StyleErrorHandling/Program.vb new file mode 100644 index 0000000..1fbcf3c --- /dev/null +++ b/Code/Chapter 7/Vb6StyleErrorHandling/Program.vb @@ -0,0 +1,22 @@ +Module Program + Sub Main() + Console.WriteLine("***** VB 6.0 Style Error Handling *****") + On Error GoTo OOPS + + Dim myCar As New Car("Sven", 80) + For i As Integer = 0 To 10 + myCar.Accelerate(10) + Next +OOPS: + ' Use Err object. + Console.WriteLine("=> Handling error with Err object.") + Console.WriteLine(Err.Description) + Console.WriteLine(Err.Source) + + ' Use Err object to get exception object. + Console.WriteLine("=> Handling error with exception.") + Console.WriteLine(Err.GetException().StackTrace) + Console.WriteLine(Err.GetException().TargetSite) + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 7/Vb6StyleErrorHandling/Radio.vb b/Code/Chapter 7/Vb6StyleErrorHandling/Radio.vb new file mode 100644 index 0000000..cdd0154 --- /dev/null +++ b/Code/Chapter 7/Vb6StyleErrorHandling/Radio.vb @@ -0,0 +1,9 @@ +Public Class Radio + Public Sub TurnOn(ByVal state As Boolean) + If state = True Then + Console.WriteLine("Jamming...") + Else + Console.WriteLine("Quiet time...") + End If + End Sub +End Class diff --git a/Code/Chapter 7/Vb6StyleErrorHandling/Vb6StyleErrorHandling.sln b/Code/Chapter 7/Vb6StyleErrorHandling/Vb6StyleErrorHandling.sln new file mode 100644 index 0000000..1bdd176 --- /dev/null +++ b/Code/Chapter 7/Vb6StyleErrorHandling/Vb6StyleErrorHandling.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Vb6StyleErrorHandling", "Vb6StyleErrorHandling.vbproj", "{61E99007-0366-4995-98AC-58EDC77F64F9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {61E99007-0366-4995-98AC-58EDC77F64F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {61E99007-0366-4995-98AC-58EDC77F64F9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {61E99007-0366-4995-98AC-58EDC77F64F9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {61E99007-0366-4995-98AC-58EDC77F64F9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 7/Vb6StyleErrorHandling/Vb6StyleErrorHandling.suo b/Code/Chapter 7/Vb6StyleErrorHandling/Vb6StyleErrorHandling.suo new file mode 100644 index 0000000..3461172 Binary files /dev/null and b/Code/Chapter 7/Vb6StyleErrorHandling/Vb6StyleErrorHandling.suo differ diff --git a/Code/Chapter 7/Vb6StyleErrorHandling/Vb6StyleErrorHandling.vbproj b/Code/Chapter 7/Vb6StyleErrorHandling/Vb6StyleErrorHandling.vbproj new file mode 100644 index 0000000..2037c92 --- /dev/null +++ b/Code/Chapter 7/Vb6StyleErrorHandling/Vb6StyleErrorHandling.vbproj @@ -0,0 +1,100 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {61E99007-0366-4995-98AC-58EDC77F64F9} + Exe + Vb6StyleErrorHandling.Program + Vb6StyleErrorHandling + Vb6StyleErrorHandling + Console + + + 2.0 + + + + + true + full + true + true + bin\Debug\ + Vb6StyleErrorHandling.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + Vb6StyleErrorHandling.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/Code/Chapter 7/Vb6StyleErrorHandling/Vb6StyleErrorHandling.vbproj.user b/Code/Chapter 7/Vb6StyleErrorHandling/Vb6StyleErrorHandling.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 7/Vb6StyleErrorHandling/Vb6StyleErrorHandling.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 8/FinalizableDisposableClass/FinalizableDisposableClass.sln b/Code/Chapter 8/FinalizableDisposableClass/FinalizableDisposableClass.sln new file mode 100644 index 0000000..ac2661e --- /dev/null +++ b/Code/Chapter 8/FinalizableDisposableClass/FinalizableDisposableClass.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "FinalizableDisposableClass", "FinalizableDisposableClass.vbproj", "{C53439E5-E8F2-4725-BFC7-15B6E40CBC48}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C53439E5-E8F2-4725-BFC7-15B6E40CBC48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C53439E5-E8F2-4725-BFC7-15B6E40CBC48}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C53439E5-E8F2-4725-BFC7-15B6E40CBC48}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C53439E5-E8F2-4725-BFC7-15B6E40CBC48}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 8/FinalizableDisposableClass/FinalizableDisposableClass.suo b/Code/Chapter 8/FinalizableDisposableClass/FinalizableDisposableClass.suo new file mode 100644 index 0000000..873b381 Binary files /dev/null and b/Code/Chapter 8/FinalizableDisposableClass/FinalizableDisposableClass.suo differ diff --git a/Code/Chapter 8/FinalizableDisposableClass/FinalizableDisposableClass.vbproj b/Code/Chapter 8/FinalizableDisposableClass/FinalizableDisposableClass.vbproj new file mode 100644 index 0000000..40944b1 --- /dev/null +++ b/Code/Chapter 8/FinalizableDisposableClass/FinalizableDisposableClass.vbproj @@ -0,0 +1,135 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {C53439E5-E8F2-4725-BFC7-15B6E40CBC48} + Exe + FinalizableDisposableClass.Program + FinalizableDisposableClass + FinalizableDisposableClass + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + FinalizableDisposableClass.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + FinalizableDisposableClass.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 8/FinalizableDisposableClass/FinalizableDisposableClass.vbproj.user b/Code/Chapter 8/FinalizableDisposableClass/FinalizableDisposableClass.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 8/FinalizableDisposableClass/FinalizableDisposableClass.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 8/FinalizableDisposableClass/My Project/Application.Designer.vb b/Code/Chapter 8/FinalizableDisposableClass/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 8/FinalizableDisposableClass/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 8/FinalizableDisposableClass/My Project/Application.myapp b/Code/Chapter 8/FinalizableDisposableClass/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 8/FinalizableDisposableClass/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 8/FinalizableDisposableClass/My Project/AssemblyInfo.vb b/Code/Chapter 8/FinalizableDisposableClass/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..4db0690 --- /dev/null +++ b/Code/Chapter 8/FinalizableDisposableClass/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/Code/Chapter 8/FinalizableDisposableClass/My Project/Resources.Designer.vb b/Code/Chapter 8/FinalizableDisposableClass/My Project/Resources.Designer.vb new file mode 100644 index 0000000..aafaa92 --- /dev/null +++ b/Code/Chapter 8/FinalizableDisposableClass/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("FinalizableDisposableClass.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/Code/Chapter 8/FinalizableDisposableClass/My Project/Resources.resx b/Code/Chapter 8/FinalizableDisposableClass/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 8/FinalizableDisposableClass/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/Code/Chapter 8/FinalizableDisposableClass/My Project/Settings.Designer.vb b/Code/Chapter 8/FinalizableDisposableClass/My Project/Settings.Designer.vb new file mode 100644 index 0000000..0bef60b --- /dev/null +++ b/Code/Chapter 8/FinalizableDisposableClass/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.FinalizableDisposableClass.My.MySettings + Get + Return Global.FinalizableDisposableClass.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 8/FinalizableDisposableClass/My Project/Settings.settings b/Code/Chapter 8/FinalizableDisposableClass/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 8/FinalizableDisposableClass/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 8/FinalizableDisposableClass/MyResourceWrapper.vb b/Code/Chapter 8/FinalizableDisposableClass/MyResourceWrapper.vb new file mode 100644 index 0000000..7018b34 --- /dev/null +++ b/Code/Chapter 8/FinalizableDisposableClass/MyResourceWrapper.vb @@ -0,0 +1,33 @@ +Public Class MyResourceWrapper + Implements IDisposable + + ' Used to determine if Dispose() + ' has already been called. + Private disposed As Boolean = False + + Public Sub Dispose() Implements IDisposable.Dispose + ' Call our helper method. + ' Specifying True signifies that + ' the object user triggered the clean up. + CleanUp(True) + GC.SuppressFinalize(Me) + End Sub + + Private Sub CleanUp(ByVal disposing As Boolean) + ' Be sure we have not already been disposed! + If Not Me.disposed Then + If disposing Then + ' Dispose managed resources. + End If + ' Clean up unmanaged resources here. + End If + disposed = True + End Sub + + Protected Overrides Sub Finalize() + ' Call our helper method. + ' Specifying False signifies that + ' the GC triggered the clean up. + CleanUp(False) + End Sub +End Class diff --git a/Code/Chapter 8/FinalizableDisposableClass/Program.vb b/Code/Chapter 8/FinalizableDisposableClass/Program.vb new file mode 100644 index 0000000..bb6ac15 --- /dev/null +++ b/Code/Chapter 8/FinalizableDisposableClass/Program.vb @@ -0,0 +1,12 @@ +Module Program + + Sub Main() + Console.WriteLine("***** Fun with Finalizers *****") + Console.WriteLine("Hit the return key to shut down this app") + Console.WriteLine("and force the GC to invoke Finalize()") + Console.WriteLine("for finalizable objects created in this AppDomain.") + Console.ReadLine() + Dim rw As New MyResourceWrapper() + End Sub + +End Module diff --git a/Code/Chapter 8/SimpleDispose/My Project/Application.Designer.vb b/Code/Chapter 8/SimpleDispose/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 8/SimpleDispose/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 8/SimpleDispose/My Project/Application.myapp b/Code/Chapter 8/SimpleDispose/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 8/SimpleDispose/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 8/SimpleDispose/My Project/AssemblyInfo.vb b/Code/Chapter 8/SimpleDispose/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..1e055fc --- /dev/null +++ b/Code/Chapter 8/SimpleDispose/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/Code/Chapter 8/SimpleDispose/My Project/Resources.Designer.vb b/Code/Chapter 8/SimpleDispose/My Project/Resources.Designer.vb new file mode 100644 index 0000000..7486324 --- /dev/null +++ b/Code/Chapter 8/SimpleDispose/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("SimpleDispose.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/Code/Chapter 8/SimpleDispose/My Project/Resources.resx b/Code/Chapter 8/SimpleDispose/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 8/SimpleDispose/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/Code/Chapter 8/SimpleDispose/My Project/Settings.Designer.vb b/Code/Chapter 8/SimpleDispose/My Project/Settings.Designer.vb new file mode 100644 index 0000000..5eabffe --- /dev/null +++ b/Code/Chapter 8/SimpleDispose/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SimpleDispose.My.MySettings + Get + Return Global.SimpleDispose.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 8/SimpleDispose/My Project/Settings.settings b/Code/Chapter 8/SimpleDispose/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 8/SimpleDispose/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 8/SimpleDispose/MyResourceWrapper.vb b/Code/Chapter 8/SimpleDispose/MyResourceWrapper.vb new file mode 100644 index 0000000..70014ae --- /dev/null +++ b/Code/Chapter 8/SimpleDispose/MyResourceWrapper.vb @@ -0,0 +1,14 @@ +' Implementing IDisposable. +Class MyResourceWrapper + Implements IDisposable + + ' The object user should call this method + ' when they finished with the object. + Public Sub Dispose() Implements IDisposable.Dispose + ' Clean up unmanaged resources here. + ' Dispose other contained disposable objects. + + ' Just for tracing purposes. + Console.WriteLine("In Dispose method") + End Sub +End Class diff --git a/Code/Chapter 8/SimpleDispose/Program.vb b/Code/Chapter 8/SimpleDispose/Program.vb new file mode 100644 index 0000000..8d8c11c --- /dev/null +++ b/Code/Chapter 8/SimpleDispose/Program.vb @@ -0,0 +1,20 @@ +#Region "Simple Car for testing" +Class Car + Implements IDisposable + Public Sub Dispose() Implements IDisposable.Dispose + Console.WriteLine("In Car Dispose") + End Sub +End Class +#End Region + +Module Program + Sub Main() + Console.WriteLine("***** Fun with Dispose *****") + Using rw As New MyResourceWrapper(), _ + rw2 As New MyResourceWrapper(), _ + myCar As New Car() + ' Use the objects, Dispose() automatically called! + End Using + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 8/SimpleDispose/SimpleDispose.sln b/Code/Chapter 8/SimpleDispose/SimpleDispose.sln new file mode 100644 index 0000000..a1a0d27 --- /dev/null +++ b/Code/Chapter 8/SimpleDispose/SimpleDispose.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SimpleDispose", "SimpleDispose.vbproj", "{D8464D59-3812-4E81-BB73-A2018BD911F4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D8464D59-3812-4E81-BB73-A2018BD911F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D8464D59-3812-4E81-BB73-A2018BD911F4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D8464D59-3812-4E81-BB73-A2018BD911F4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D8464D59-3812-4E81-BB73-A2018BD911F4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 8/SimpleDispose/SimpleDispose.suo b/Code/Chapter 8/SimpleDispose/SimpleDispose.suo new file mode 100644 index 0000000..7cdd777 Binary files /dev/null and b/Code/Chapter 8/SimpleDispose/SimpleDispose.suo differ diff --git a/Code/Chapter 8/SimpleDispose/SimpleDispose.vbproj b/Code/Chapter 8/SimpleDispose/SimpleDispose.vbproj new file mode 100644 index 0000000..58e91cc --- /dev/null +++ b/Code/Chapter 8/SimpleDispose/SimpleDispose.vbproj @@ -0,0 +1,98 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {D8464D59-3812-4E81-BB73-A2018BD911F4} + Exe + SimpleDispose.Program + SimpleDispose + SimpleDispose + Console + + + 2.0 + + + + + true + full + true + true + bin\Debug\ + SimpleDispose.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SimpleDispose.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/Code/Chapter 8/SimpleDispose/SimpleDispose.vbproj.user b/Code/Chapter 8/SimpleDispose/SimpleDispose.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 8/SimpleDispose/SimpleDispose.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 8/SimpleFinalize/My Project/Application.Designer.vb b/Code/Chapter 8/SimpleFinalize/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 8/SimpleFinalize/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 8/SimpleFinalize/My Project/Application.myapp b/Code/Chapter 8/SimpleFinalize/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 8/SimpleFinalize/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 8/SimpleFinalize/My Project/AssemblyInfo.vb b/Code/Chapter 8/SimpleFinalize/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..d71d33c --- /dev/null +++ b/Code/Chapter 8/SimpleFinalize/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/Code/Chapter 8/SimpleFinalize/My Project/Resources.Designer.vb b/Code/Chapter 8/SimpleFinalize/My Project/Resources.Designer.vb new file mode 100644 index 0000000..fe0bebe --- /dev/null +++ b/Code/Chapter 8/SimpleFinalize/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("SimpleFinalize.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/Code/Chapter 8/SimpleFinalize/My Project/Resources.resx b/Code/Chapter 8/SimpleFinalize/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 8/SimpleFinalize/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/Code/Chapter 8/SimpleFinalize/My Project/Settings.Designer.vb b/Code/Chapter 8/SimpleFinalize/My Project/Settings.Designer.vb new file mode 100644 index 0000000..08567af --- /dev/null +++ b/Code/Chapter 8/SimpleFinalize/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SimpleFinalize.My.MySettings + Get + Return Global.SimpleFinalize.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 8/SimpleFinalize/My Project/Settings.settings b/Code/Chapter 8/SimpleFinalize/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 8/SimpleFinalize/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 8/SimpleFinalize/MyResourceWrapper.vb b/Code/Chapter 8/SimpleFinalize/MyResourceWrapper.vb new file mode 100644 index 0000000..68a3d53 --- /dev/null +++ b/Code/Chapter 8/SimpleFinalize/MyResourceWrapper.vb @@ -0,0 +1,13 @@ +Class MyResourceWrapper + ' Override System.Object.Finalize() + Protected Overrides Sub Finalize() + Try + ' Clean up any unmanaged resources here! + + ' Beep when destroyed (testing purposes only!) + Console.Beep() + Finally + MyBase.Finalize() + End Try + End Sub +End Class diff --git a/Code/Chapter 8/SimpleFinalize/Program.vb b/Code/Chapter 8/SimpleFinalize/Program.vb new file mode 100644 index 0000000..bb6ac15 --- /dev/null +++ b/Code/Chapter 8/SimpleFinalize/Program.vb @@ -0,0 +1,12 @@ +Module Program + + Sub Main() + Console.WriteLine("***** Fun with Finalizers *****") + Console.WriteLine("Hit the return key to shut down this app") + Console.WriteLine("and force the GC to invoke Finalize()") + Console.WriteLine("for finalizable objects created in this AppDomain.") + Console.ReadLine() + Dim rw As New MyResourceWrapper() + End Sub + +End Module diff --git a/Code/Chapter 8/SimpleFinalize/SimpleFinalize.sln b/Code/Chapter 8/SimpleFinalize/SimpleFinalize.sln new file mode 100644 index 0000000..21df6e8 --- /dev/null +++ b/Code/Chapter 8/SimpleFinalize/SimpleFinalize.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SimpleFinalize", "SimpleFinalize.vbproj", "{A8DDC511-D074-4148-B91E-0E75BE355326}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A8DDC511-D074-4148-B91E-0E75BE355326}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A8DDC511-D074-4148-B91E-0E75BE355326}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A8DDC511-D074-4148-B91E-0E75BE355326}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A8DDC511-D074-4148-B91E-0E75BE355326}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 8/SimpleFinalize/SimpleFinalize.suo b/Code/Chapter 8/SimpleFinalize/SimpleFinalize.suo new file mode 100644 index 0000000..66151d1 Binary files /dev/null and b/Code/Chapter 8/SimpleFinalize/SimpleFinalize.suo differ diff --git a/Code/Chapter 8/SimpleFinalize/SimpleFinalize.vbproj b/Code/Chapter 8/SimpleFinalize/SimpleFinalize.vbproj new file mode 100644 index 0000000..3d9378a --- /dev/null +++ b/Code/Chapter 8/SimpleFinalize/SimpleFinalize.vbproj @@ -0,0 +1,98 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {A8DDC511-D074-4148-B91E-0E75BE355326} + Exe + SimpleFinalize.Program + SimpleFinalize + SimpleFinalize + Console + + + 2.0 + + + + + true + full + true + true + bin\Debug\ + SimpleFinalize.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SimpleFinalize.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/Code/Chapter 8/SimpleFinalize/SimpleFinalize.vbproj.user b/Code/Chapter 8/SimpleFinalize/SimpleFinalize.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 8/SimpleFinalize/SimpleFinalize.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 8/SimpleGC/Car.vb b/Code/Chapter 8/SimpleGC/Car.vb new file mode 100644 index 0000000..0622703 --- /dev/null +++ b/Code/Chapter 8/SimpleGC/Car.vb @@ -0,0 +1,16 @@ +Public Class Car + Private currSpeed As Integer + Private petName As String + + Public Sub New() + End Sub + + Public Sub New(ByVal name As String, ByVal speed As Integer) + petName = name + currSpeed = speed + End Sub + + Public Overrides Function ToString() As String + Return String.Format("{0} is going {1} MPH", petName, currSpeed) + End Function +End Class diff --git a/Code/Chapter 8/SimpleGC/My Project/Application.Designer.vb b/Code/Chapter 8/SimpleGC/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 8/SimpleGC/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 8/SimpleGC/My Project/Application.myapp b/Code/Chapter 8/SimpleGC/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 8/SimpleGC/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 8/SimpleGC/My Project/AssemblyInfo.vb b/Code/Chapter 8/SimpleGC/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..2554108 --- /dev/null +++ b/Code/Chapter 8/SimpleGC/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/Code/Chapter 8/SimpleGC/My Project/Resources.Designer.vb b/Code/Chapter 8/SimpleGC/My Project/Resources.Designer.vb new file mode 100644 index 0000000..5d8db25 --- /dev/null +++ b/Code/Chapter 8/SimpleGC/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("SimpleGC.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/Code/Chapter 8/SimpleGC/My Project/Resources.resx b/Code/Chapter 8/SimpleGC/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 8/SimpleGC/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/Code/Chapter 8/SimpleGC/My Project/Settings.Designer.vb b/Code/Chapter 8/SimpleGC/My Project/Settings.Designer.vb new file mode 100644 index 0000000..1fc6039 --- /dev/null +++ b/Code/Chapter 8/SimpleGC/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.SimpleGC.My.MySettings + Get + Return Global.SimpleGC.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 8/SimpleGC/My Project/Settings.settings b/Code/Chapter 8/SimpleGC/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 8/SimpleGC/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 8/SimpleGC/Program.vb b/Code/Chapter 8/SimpleGC/Program.vb new file mode 100644 index 0000000..4ca64f6 --- /dev/null +++ b/Code/Chapter 8/SimpleGC/Program.vb @@ -0,0 +1,59 @@ +Module Program + Sub Main() + Console.WriteLine("***** Fun with System.GC *****") + + ' Print out estimated number of bytes on heap. + Console.WriteLine("Estimated bytes on heap: {0}", _ + GC.GetTotalMemory(False)) + + ' MaxGeneration is zero based. + Console.WriteLine("This OS has {0} object generations.", _ + (GC.MaxGeneration + 1)) + + Dim refToMyCar As New Car("Zippy", 100) + Console.WriteLine(refToMyCar.ToString()) + + ' Print out generation of refToMyCar. + Console.WriteLine("Generation of refToMyCar is: {0}", _ + GC.GetGeneration(refToMyCar)) + + ' Make a ton of objects for testing purposes. + Dim tonsOfObjects(5000) As Object + For i As Integer = 0 To UBound(tonsOfObjects) + tonsOfObjects(i) = New Object() + Next + + ' Collect only gen 0 objects. + GC.Collect(0) + GC.WaitForPendingFinalizers() + + ' Print out generation of refToMyCar. + Console.WriteLine("Generation of refToMyCar is: {0}", _ + GC.GetGeneration(refToMyCar)) + + ' See if tonsOfObjects(4000) is still alive. + If (tonsOfObjects(4000) IsNot Nothing) Then + Console.WriteLine("Generation of tonsOfObjects(4000) is: {0}", _ + GC.GetGeneration(tonsOfObjects(4000))) + Else + Console.WriteLine("tonsOfObjects(4000) is no longer alive.") + End If + + ' Print out how many times a generation has been swept. + Console.WriteLine("Gen 0 has been swept {0} times", _ + GC.CollectionCount(0)) + Console.WriteLine("Gen 1 has been swept {0} times", _ + GC.CollectionCount(1)) + Console.WriteLine("Gen 2 has been swept {0} times", _ + GC.CollectionCount(2)) + Console.ReadLine() + End Sub + + Sub MakeACar() + ' If myCar is the only reference to the Car object, + ' it may be destroyed when the method returns. + Dim myCar As New Car() + myCar = Nothing + End Sub + +End Module diff --git a/Code/Chapter 8/SimpleGC/SimpleGC.sln b/Code/Chapter 8/SimpleGC/SimpleGC.sln new file mode 100644 index 0000000..dfd888f --- /dev/null +++ b/Code/Chapter 8/SimpleGC/SimpleGC.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SimpleGC", "SimpleGC.vbproj", "{03ECF294-E536-4A0F-A9E1-CBBCFF75325B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {03ECF294-E536-4A0F-A9E1-CBBCFF75325B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {03ECF294-E536-4A0F-A9E1-CBBCFF75325B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {03ECF294-E536-4A0F-A9E1-CBBCFF75325B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {03ECF294-E536-4A0F-A9E1-CBBCFF75325B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 8/SimpleGC/SimpleGC.suo b/Code/Chapter 8/SimpleGC/SimpleGC.suo new file mode 100644 index 0000000..161e86f Binary files /dev/null and b/Code/Chapter 8/SimpleGC/SimpleGC.suo differ diff --git a/Code/Chapter 8/SimpleGC/SimpleGC.vbproj b/Code/Chapter 8/SimpleGC/SimpleGC.vbproj new file mode 100644 index 0000000..580319b --- /dev/null +++ b/Code/Chapter 8/SimpleGC/SimpleGC.vbproj @@ -0,0 +1,135 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {03ECF294-E536-4A0F-A9E1-CBBCFF75325B} + Exe + SimpleGC.Program + SimpleGC + SimpleGC + Console + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + SimpleGC.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SimpleGC.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + 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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 8/SimpleGC/SimpleGC.vbproj.user b/Code/Chapter 8/SimpleGC/SimpleGC.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 8/SimpleGC/SimpleGC.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 9/CloneablePoint/CloneablePoint.sln b/Code/Chapter 9/CloneablePoint/CloneablePoint.sln new file mode 100644 index 0000000..59919bd --- /dev/null +++ b/Code/Chapter 9/CloneablePoint/CloneablePoint.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CloneablePoint", "CloneablePoint.vbproj", "{A2506E27-E207-4B4E-AD32-3CB3740369BB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A2506E27-E207-4B4E-AD32-3CB3740369BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A2506E27-E207-4B4E-AD32-3CB3740369BB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A2506E27-E207-4B4E-AD32-3CB3740369BB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A2506E27-E207-4B4E-AD32-3CB3740369BB}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 9/CloneablePoint/CloneablePoint.suo b/Code/Chapter 9/CloneablePoint/CloneablePoint.suo new file mode 100644 index 0000000..320381f Binary files /dev/null and b/Code/Chapter 9/CloneablePoint/CloneablePoint.suo differ diff --git a/Code/Chapter 9/CloneablePoint/CloneablePoint.vbproj b/Code/Chapter 9/CloneablePoint/CloneablePoint.vbproj new file mode 100644 index 0000000..eae2f47 --- /dev/null +++ b/Code/Chapter 9/CloneablePoint/CloneablePoint.vbproj @@ -0,0 +1,98 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {A2506E27-E207-4B4E-AD32-3CB3740369BB} + Exe + CloneablePoint.Program + CloneablePoint + CloneablePoint + Console + + + 2.0 + + + + + true + full + true + true + bin\Debug\ + CloneablePoint.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + CloneablePoint.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/Code/Chapter 9/CloneablePoint/CloneablePoint.vbproj.user b/Code/Chapter 9/CloneablePoint/CloneablePoint.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 9/CloneablePoint/CloneablePoint.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 9/CloneablePoint/My Project/Application.Designer.vb b/Code/Chapter 9/CloneablePoint/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 9/CloneablePoint/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 9/CloneablePoint/My Project/Application.myapp b/Code/Chapter 9/CloneablePoint/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 9/CloneablePoint/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 9/CloneablePoint/My Project/AssemblyInfo.vb b/Code/Chapter 9/CloneablePoint/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..2ae37cb --- /dev/null +++ b/Code/Chapter 9/CloneablePoint/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/Code/Chapter 9/CloneablePoint/My Project/Resources.Designer.vb b/Code/Chapter 9/CloneablePoint/My Project/Resources.Designer.vb new file mode 100644 index 0000000..f8f11b0 --- /dev/null +++ b/Code/Chapter 9/CloneablePoint/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("CloneablePoint.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/Code/Chapter 9/CloneablePoint/My Project/Resources.resx b/Code/Chapter 9/CloneablePoint/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 9/CloneablePoint/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/Code/Chapter 9/CloneablePoint/My Project/Settings.Designer.vb b/Code/Chapter 9/CloneablePoint/My Project/Settings.Designer.vb new file mode 100644 index 0000000..f3c3df2 --- /dev/null +++ b/Code/Chapter 9/CloneablePoint/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CloneablePoint.My.MySettings + Get + Return Global.CloneablePoint.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 9/CloneablePoint/My Project/Settings.settings b/Code/Chapter 9/CloneablePoint/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 9/CloneablePoint/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 9/CloneablePoint/Point.vb b/Code/Chapter 9/CloneablePoint/Point.vb new file mode 100644 index 0000000..59b5ff9 --- /dev/null +++ b/Code/Chapter 9/CloneablePoint/Point.vb @@ -0,0 +1,47 @@ +#Region "The Cloneable Point type" +Public Class Point + Implements ICloneable + Public xPos, yPos As Integer + + ' Point ‘has-a’ PointDescription. + Public desc As New PointDescription() + + Sub New() + End Sub + Sub New(ByVal x As Integer, ByVal y As Integer) + xPos = x : yPos = y + End Sub + Sub New(ByVal x As Integer, ByVal y As Integer, ByVal name As String) + xPos = x : yPos = y + desc.petName = name + End Sub + + Public Overrides Function ToString() As String + Return String.Format("X = {0} ; Y = {1} ; Name = {2} : ID = {3}", _ + xPos, yPos, desc.petName, desc.pointID) + End Function + + ' Now we need to adjust for the PointDescription member. + Public Function Clone() As Object Implements System.ICloneable.Clone + Dim newPoint As Point = CType(Me.MemberwiseClone(), Point) + Dim currentDesc As PointDescription = New PointDescription() + currentDesc.petName = Me.desc.petName + currentDesc.pointID = Me.desc.pointID + newPoint.desc = currentDesc + Return newPoint + End Function +End Class +#End Region + +#Region "Class that maintains Point data" +' This class represents data about +' a given Point. +Public Class PointDescription + Public petName As String + Public pointID As Guid + Public Sub New() + Me.petName = "No-name" + pointID = Guid.NewGuid + End Sub +End Class +#End Region \ No newline at end of file diff --git a/Code/Chapter 9/CloneablePoint/Program.vb b/Code/Chapter 9/CloneablePoint/Program.vb new file mode 100644 index 0000000..a5251be --- /dev/null +++ b/Code/Chapter 9/CloneablePoint/Program.vb @@ -0,0 +1,24 @@ +' This example illustrates how to implement ICloneable +' to build types that support 'deep copies' + +Module Program + Sub Main() + Console.WriteLine("***** Fun with ICloneable *****") + Dim p1 As New Point(50, 50, "Brad") + Dim p2 As Point = CType(p1.Clone(), Point) + + Console.WriteLine("Before modification:") + Console.WriteLine("p1: {0} ", p1) + Console.WriteLine("p2: {0} ", p2) + + p2.desc.petName = "This is my second point" + p2.xPos = 9 + Console.WriteLine("Changed p2.desc.petName and p2.x") + + Console.WriteLine("After modification:") + Console.WriteLine("p1: {0} ", p1) + Console.WriteLine("p2: {0} ", p2) + Console.ReadLine() + End Sub +End Module + diff --git a/Code/Chapter 9/CollectionTypes/Car.vb b/Code/Chapter 9/CollectionTypes/Car.vb new file mode 100644 index 0000000..994e489 --- /dev/null +++ b/Code/Chapter 9/CollectionTypes/Car.vb @@ -0,0 +1,129 @@ +Public Class Car + Implements IComparable + +#Region "Nested comparer type" + Public Class PetNameComparer + Implements IComparer + + Public Sub New() + End Sub + Public Function Compare(ByVal x As Object, ByVal y As Object) _ + As Integer Implements System.Collections.IComparer.Compare + Dim t1 As Car = CType(x, Car) + Dim t2 As Car = CType(y, Car) + Return String.Compare(t1.Name, t2.Name) + End Function + End Class +#End Region + + ' Constant for maximum speed. + Public Const maxSpeed As Integer = 100 + + ' Internal state data. + Private currSpeed As Integer + Private petName As String + Private carID As Integer + + ' Is the car still operational? + Private carIsDead As Boolean + + ' A car has a radio. + Private theMusicBox As Radio = New Radio() + + ' Property to return the pet name comparer. + Public Shared ReadOnly Property SortByPetName() As IComparer + Get + Return CType(New PetNameComparer(), IComparer) + End Get + End Property + +#Region "Properties for field data" + Public Property ID() As Integer + Get + Return carID + End Get + Set(ByVal value As Integer) + carID = value + End Set + End Property + Public Property Name() As String + Get + Return petName + End Get + Set(ByVal value As String) + petName = value + End Set + End Property + Public Property Speed() As Integer + Get + Return currSpeed + End Get + Set(ByVal value As Integer) + currSpeed = value + End Set + End Property +#End Region + +#Region "Constructors." + Public Sub New() + End Sub + Public Sub New(ByVal name As String, _ + ByVal currSp As Integer, ByVal id As Integer) + currSpeed = currSp + petName = name + carID = id + End Sub +#End Region + + Public Sub CrankTunes(ByVal state As Boolean) + theMusicBox.TurnOn(state) + End Sub + +#Region "Accelerate method" + ' See if Car has overheated. + Public Sub Accelerate(ByVal delta As Integer) + If delta < 0 Then + Throw New ArgumentOutOfRangeException() + End If + If carIsDead Then + Console.WriteLine("{0} is out of order...", petName) + Else + currSpeed += delta + If currSpeed >= maxSpeed Then + carIsDead = True + currSpeed = 0 + + ' We need to call the HelpLink property, thus we need to + ' create a local variable before throwing the Exception object. + Dim ex As New CarIsDeadException(String.Format("{0} has overheated!", petName)) + ex.HelpLink = "http://www.CarsRUs.com" + ' Stuff in custom data regarding the error. + ex.Data.Add("TimeStamp", _ + String.Format("The car exploded at {0}", DateTime.Now)) + ex.Data.Add("Cause", "You have a lead foot.") + Throw ex + Else + Console.WriteLine("=> CurrSpeed = {0}", currSpeed) + End If + End If + End Sub +#End Region + +#Region "Implementation of IComparable" + ' The iteration of the Car can be ordered + ' based on the carID. + Public Function CompareTo(ByVal obj As Object) As Integer _ + Implements System.IComparable.CompareTo + Dim temp As Car = CType(obj, Car) + If Me.carID > temp.carID Then + Return 1 + End If + If Me.carID < temp.carID Then + Return -1 + Else + Return 0 + End If + End Function +#End Region + +End Class diff --git a/Code/Chapter 9/CollectionTypes/CarIsDeadException.vb b/Code/Chapter 9/CollectionTypes/CarIsDeadException.vb new file mode 100644 index 0000000..867d727 --- /dev/null +++ b/Code/Chapter 9/CollectionTypes/CarIsDeadException.vb @@ -0,0 +1,55 @@ + +#Region "CarIsDeadException take one" +'Public Class CarIsDeadException +' Inherits ApplicationException + +' Private messageDetails As String + +'#Region "Ctors" +' Public Sub New() +' End Sub +' Public Sub New(ByVal msg As String) +' messageDetails = msg +' End Sub +'#End Region + +' ' Override the Exception.Message property. +' Public Overrides ReadOnly Property Message() As String +' Get +' Return String.Format("Car Error Message: {0}", messageDetails) +' End Get +' End Property +'End Class +#End Region + +#Region "CarIsDeadException take two" +'Public Class CarIsDeadException +' Inherits ApplicationException +' Public Sub New() +' End Sub +' Public Sub New(ByVal msg As String) +' MyBase.New(msg) +' End Sub +'End Class +#End Region + +#Region "CarIsDeadException take three" + _ +Public Class CarIsDeadException + Inherits ApplicationException + Public Sub New() + End Sub + Public Sub New(ByVal message As String) + MyBase.New(message) + End Sub + Public Sub New(ByVal message As String, ByVal inner As System.Exception) + MyBase.New(message, inner) + End Sub + Protected Sub New(ByVal info As System.Runtime.Serialization.SerializationInfo, _ + ByVal context As System.Runtime.Serialization.StreamingContext) + MyBase.New(info, context) + End Sub +End Class +#End Region + + diff --git a/Code/Chapter 9/CollectionTypes/CollectionTypes.sln b/Code/Chapter 9/CollectionTypes/CollectionTypes.sln new file mode 100644 index 0000000..6b7370e --- /dev/null +++ b/Code/Chapter 9/CollectionTypes/CollectionTypes.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CollectionTypes", "CollectionTypes.vbproj", "{025F92E3-139C-4208-95F4-ABB1D140D9B1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {025F92E3-139C-4208-95F4-ABB1D140D9B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {025F92E3-139C-4208-95F4-ABB1D140D9B1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {025F92E3-139C-4208-95F4-ABB1D140D9B1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {025F92E3-139C-4208-95F4-ABB1D140D9B1}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 9/CollectionTypes/CollectionTypes.suo b/Code/Chapter 9/CollectionTypes/CollectionTypes.suo new file mode 100644 index 0000000..bd64430 Binary files /dev/null and b/Code/Chapter 9/CollectionTypes/CollectionTypes.suo differ diff --git a/Code/Chapter 9/CollectionTypes/CollectionTypes.vbproj b/Code/Chapter 9/CollectionTypes/CollectionTypes.vbproj new file mode 100644 index 0000000..732c05a --- /dev/null +++ b/Code/Chapter 9/CollectionTypes/CollectionTypes.vbproj @@ -0,0 +1,95 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {025F92E3-139C-4208-95F4-ABB1D140D9B1} + Exe + CollectionTypes.Program + CollectionTypes + CollectionTypes + Console + + + true + full + true + true + bin\Debug\ + CollectionTypes.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + CollectionTypes.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/Code/Chapter 9/CollectionTypes/My Project/Application.Designer.vb b/Code/Chapter 9/CollectionTypes/My Project/Application.Designer.vb new file mode 100644 index 0000000..441e810 --- /dev/null +++ b/Code/Chapter 9/CollectionTypes/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.312 +' +' 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/Code/Chapter 9/CollectionTypes/My Project/Application.myapp b/Code/Chapter 9/CollectionTypes/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 9/CollectionTypes/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 9/CollectionTypes/My Project/AssemblyInfo.vb b/Code/Chapter 9/CollectionTypes/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..4ecf7ae --- /dev/null +++ b/Code/Chapter 9/CollectionTypes/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/Code/Chapter 9/CollectionTypes/My Project/Resources.Designer.vb b/Code/Chapter 9/CollectionTypes/My Project/Resources.Designer.vb new file mode 100644 index 0000000..6093083 --- /dev/null +++ b/Code/Chapter 9/CollectionTypes/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.312 +' +' 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("CollectionTypes.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/Code/Chapter 9/CollectionTypes/My Project/Resources.resx b/Code/Chapter 9/CollectionTypes/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 9/CollectionTypes/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/Code/Chapter 9/CollectionTypes/My Project/Settings.Designer.vb b/Code/Chapter 9/CollectionTypes/My Project/Settings.Designer.vb new file mode 100644 index 0000000..57f0daa --- /dev/null +++ b/Code/Chapter 9/CollectionTypes/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.312 +' +' 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.CollectionTypes.My.MySettings + Get + Return Global.CollectionTypes.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 9/CollectionTypes/My Project/Settings.settings b/Code/Chapter 9/CollectionTypes/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 9/CollectionTypes/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 9/CollectionTypes/Program.vb b/Code/Chapter 9/CollectionTypes/Program.vb new file mode 100644 index 0000000..da53db4 --- /dev/null +++ b/Code/Chapter 9/CollectionTypes/Program.vb @@ -0,0 +1,100 @@ +' This example illustrates working with non-generic collection +' types in the System.Collections namespace. +' Uncomment / comment out function calls to test. + +Module Program + + Sub Main() + Console.WriteLine("***** Fun with non-generic collections *****") + ' ArrayListTest() + ' QueueTest() + StackTest() + Console.ReadLine() + End Sub + +#Region "ArrayList test" + Sub ArrayListTest() + ' Make ArrayList and add a range of Cars. + Dim carArList As ArrayList = New ArrayList + carArList.AddRange(New Car() {New Car("Fred", 90, 10), _ + New Car("Mary", 100, 50), New Car("MB", 190, 11)}) + Console.WriteLine("Items in carArList: {0}", carArList.Count) + + ' Iterate over contents. + For Each c As Car In carArList + Console.WriteLine("Car pet name: {0}", c.Name) + Next + + ' Insert new car. + Console.WriteLine("->Inserting new Car.") + carArList.Insert(2, New Car("TheNewCar", 0, 12)) + Console.WriteLine("Items in carArList: {0}", carArList.Count) + + ' Get the subobjects as an array. + Dim arrayOfCars As Object() = carArList.ToArray() + Dim i As Integer = 0 + + ' Now iterate over array + While i < arrayOfCars.Length + Console.WriteLine("Car pet name: {0}", CType(arrayOfCars(i), Car).Name) + i = i + 1 + End While + Console.WriteLine() + End Sub +#End Region + +#Region "Queue Test" + Public Sub WashCar(ByVal c As Car) + Console.WriteLine("Cleaning {0}", c.Name) + End Sub + + Sub QueueTest() + ' Make a Q with three items. + Dim carWashQ As New Queue() + carWashQ.Enqueue(New Car("FirstCar", 0, 1)) + carWashQ.Enqueue(New Car("SecondCar", 0, 2)) + carWashQ.Enqueue(New Car("ThirdCar", 0, 3)) + + ' Peek at first car in Q. + Console.WriteLine("First in Q is {0}", _ + CType(carWashQ.Peek(), Car).Name) + + ' Remove each item from Q. + WashCar(CType(carWashQ.Dequeue(), Car)) + WashCar(CType(carWashQ.Dequeue(), Car)) + WashCar(CType(carWashQ.Dequeue(), Car)) + + ' Try to de-Q again? + Try + WashCar(CType(carWashQ.Dequeue(), Car)) + Catch ex As Exception + Console.WriteLine("Error!! {0}", ex.Message) + End Try + End Sub +#End Region + +#Region "Stack Test" + Sub StackTest() + Dim stringStack As New Stack() + stringStack.Push("One") + stringStack.Push("Two") + stringStack.Push("Three") + + ' Now look at the top item, pop it, and look again. + Console.WriteLine("Top item is: {0}", stringStack.Peek()) + Console.WriteLine("Popped off {0}", stringStack.Pop()) + Console.WriteLine("Top item is: {0}", stringStack.Peek()) + Console.WriteLine("Popped off {0}", stringStack.Pop()) + Console.WriteLine("Top item is: {0}", stringStack.Peek()) + Console.WriteLine("Popped off {0}", stringStack.Pop()) + + Try + Console.WriteLine("Top item is: {0} ", stringStack.Peek()) + Console.WriteLine("Popped off {0} ", stringStack.Pop()) + Catch ex As Exception + Console.WriteLine("Error!! {0} ", ex.Message) + End Try + End Sub + +#End Region +End Module diff --git a/Code/Chapter 9/CollectionTypes/Radio.vb b/Code/Chapter 9/CollectionTypes/Radio.vb new file mode 100644 index 0000000..592c800 --- /dev/null +++ b/Code/Chapter 9/CollectionTypes/Radio.vb @@ -0,0 +1,9 @@ +Public Class Radio + Public Sub TurnOn(ByVal state As Boolean) + If state = True Then + Console.WriteLine("Jamming...") + Else + Console.WriteLine("Quiet time...") + End If + End Sub +End Class diff --git a/Code/Chapter 9/ComparableCar/Car.vb b/Code/Chapter 9/ComparableCar/Car.vb new file mode 100644 index 0000000..361d520 --- /dev/null +++ b/Code/Chapter 9/ComparableCar/Car.vb @@ -0,0 +1,129 @@ +Public Class Car + Implements IComparable + +#Region "Nested comparer type" + Public Class PetNameComparer + Implements IComparer + + Public Sub New() + End Sub + Public Function Compare(ByVal x As Object, ByVal y As Object) _ + As Integer Implements System.Collections.IComparer.Compare + Dim t1 As Car = CType(x, Car) + Dim t2 As Car = CType(y, Car) + Return String.Compare(t1.Name, t2.Name) + End Function + End Class +#End Region + + ' Constant for maximum speed. + Public Const maxSpeed As Integer = 100 + + ' Internal state data. + Private currSpeed As Integer + Private petName As String + Private carID As Integer + + ' Is the car still operational? + Private carIsDead As Boolean + + ' A car has a radio. + Private theMusicBox As Radio = New Radio() + + ' Property to return the pet name comparer. + Public Shared ReadOnly Property SortByPetName() As IComparer + Get + Return New PetNameComparer() + End Get + End Property + +#Region "Properties for field data" + Public Property ID() As Integer + Get + Return carID + End Get + Set(ByVal value As Integer) + carID = value + End Set + End Property + Public Property Name() As String + Get + Return petName + End Get + Set(ByVal value As String) + petName = value + End Set + End Property + Public Property Speed() As Integer + Get + Return currSpeed + End Get + Set(ByVal value As Integer) + currSpeed = value + End Set + End Property +#End Region + +#Region "Constructors." + Public Sub New() + End Sub + Public Sub New(ByVal name As String, _ + ByVal currSp As Integer, ByVal id As Integer) + currSpeed = currSp + petName = name + carID = id + End Sub +#End Region + + Public Sub CrankTunes(ByVal state As Boolean) + theMusicBox.TurnOn(state) + End Sub + +#Region "Accelerate method" + ' See if Car has overheated. + Public Sub Accelerate(ByVal delta As Integer) + If delta < 0 Then + Throw New ArgumentOutOfRangeException() + End If + If carIsDead Then + Console.WriteLine("{0} is out of order...", petName) + Else + currSpeed += delta + If currSpeed >= maxSpeed Then + carIsDead = True + currSpeed = 0 + + ' We need to call the HelpLink property, thus we need to + ' create a local variable before throwing the Exception object. + Dim ex As New CarIsDeadException(String.Format("{0} has overheated!", petName)) + ex.HelpLink = "http://www.CarsRUs.com" + ' Stuff in custom data regarding the error. + ex.Data.Add("TimeStamp", _ + String.Format("The car exploded at {0}", DateTime.Now)) + ex.Data.Add("Cause", "You have a lead foot.") + Throw ex + Else + Console.WriteLine("=> CurrSpeed = {0}", currSpeed) + End If + End If + End Sub +#End Region + +#Region "Implementation of IComparable" + ' The iteration of the Car can be ordered + ' based on the carID. + Public Function CompareTo(ByVal obj As Object) As Integer _ + Implements System.IComparable.CompareTo + Dim temp As Car = CType(obj, Car) + If Me.carID > temp.carID Then + Return 1 + End If + If Me.carID < temp.carID Then + Return -1 + Else + Return 0 + End If + End Function +#End Region + +End Class diff --git a/Code/Chapter 9/ComparableCar/CarIsDeadException.vb b/Code/Chapter 9/ComparableCar/CarIsDeadException.vb new file mode 100644 index 0000000..66c0acd --- /dev/null +++ b/Code/Chapter 9/ComparableCar/CarIsDeadException.vb @@ -0,0 +1,55 @@ + +#Region "CarIsDeadException take one" +'Public Class CarIsDeadException +' Inherits ApplicationException + +' Private messageDetails As String + +'#Region "Ctors" +' Public Sub New() +' End Sub +' Public Sub New(ByVal msg As String) +' messageDetails = msg +' End Sub +'#End Region + +' ' Override the Exception.Message property. +' Public Overrides ReadOnly Property Message() As String +' Get +' Return String.Format("Car Error Message: {0}", messageDetails) +' End Get +' End Property +'End Class +#End Region + +#Region "CarIsDeadException take two" +'Public Class CarIsDeadException +' Inherits ApplicationException +' Public Sub New() +' End Sub +' Public Sub New(ByVal msg As String) +' MyBase.New(msg) +' End Sub +'End Class +#End Region + +#Region "CarIsDeadException take three" + _ +Public Class CarIsDeadException + Inherits ApplicationException + Public Sub New() + End Sub + Public Sub New(ByVal message As String) + MyBase.New(message) + End Sub + Public Sub New(ByVal message As String, ByVal inner As System.Exception) + MyBase.New(message, inner) + End Sub + Protected Sub New(ByVal info As System.Runtime.Serialization.SerializationInfo, _ + ByVal context As System.Runtime.Serialization.StreamingContext) + MyBase.New(info, context) + End Sub +End Class +#End Region + + diff --git a/Code/Chapter 9/ComparableCar/ComparableCar.sln b/Code/Chapter 9/ComparableCar/ComparableCar.sln new file mode 100644 index 0000000..f1b7dbc --- /dev/null +++ b/Code/Chapter 9/ComparableCar/ComparableCar.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ComparableCar", "ComparableCar.vbproj", "{6E74012B-3C55-4A1E-86B8-65BAE27DF32C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6E74012B-3C55-4A1E-86B8-65BAE27DF32C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6E74012B-3C55-4A1E-86B8-65BAE27DF32C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6E74012B-3C55-4A1E-86B8-65BAE27DF32C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6E74012B-3C55-4A1E-86B8-65BAE27DF32C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 9/ComparableCar/ComparableCar.suo b/Code/Chapter 9/ComparableCar/ComparableCar.suo new file mode 100644 index 0000000..b509340 Binary files /dev/null and b/Code/Chapter 9/ComparableCar/ComparableCar.suo differ diff --git a/Code/Chapter 9/ComparableCar/ComparableCar.vbproj b/Code/Chapter 9/ComparableCar/ComparableCar.vbproj new file mode 100644 index 0000000..a8652e9 --- /dev/null +++ b/Code/Chapter 9/ComparableCar/ComparableCar.vbproj @@ -0,0 +1,101 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {6E74012B-3C55-4A1E-86B8-65BAE27DF32C} + Exe + ComparableCar.Program + ComparableCar + ComparableCar + Console + + + 2.0 + + + + + true + full + true + true + bin\Debug\ + ComparableCar.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + ComparableCar.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/Code/Chapter 9/ComparableCar/ComparableCar.vbproj.user b/Code/Chapter 9/ComparableCar/ComparableCar.vbproj.user new file mode 100644 index 0000000..6a34e7d --- /dev/null +++ b/Code/Chapter 9/ComparableCar/ComparableCar.vbproj.user @@ -0,0 +1,5 @@ + + + ShowAllFiles + + \ No newline at end of file diff --git a/Code/Chapter 9/ComparableCar/My Project/Application.Designer.vb b/Code/Chapter 9/ComparableCar/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 9/ComparableCar/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 9/ComparableCar/My Project/Application.myapp b/Code/Chapter 9/ComparableCar/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 9/ComparableCar/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 9/ComparableCar/My Project/AssemblyInfo.vb b/Code/Chapter 9/ComparableCar/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..192f1cf --- /dev/null +++ b/Code/Chapter 9/ComparableCar/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/Code/Chapter 9/ComparableCar/My Project/Resources.Designer.vb b/Code/Chapter 9/ComparableCar/My Project/Resources.Designer.vb new file mode 100644 index 0000000..ffc8ce4 --- /dev/null +++ b/Code/Chapter 9/ComparableCar/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("ComparableCar.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/Code/Chapter 9/ComparableCar/My Project/Resources.resx b/Code/Chapter 9/ComparableCar/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 9/ComparableCar/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/Code/Chapter 9/ComparableCar/My Project/Settings.Designer.vb b/Code/Chapter 9/ComparableCar/My Project/Settings.Designer.vb new file mode 100644 index 0000000..4c8c085 --- /dev/null +++ b/Code/Chapter 9/ComparableCar/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.ComparableCar.My.MySettings + Get + Return Global.ComparableCar.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 9/ComparableCar/My Project/Settings.settings b/Code/Chapter 9/ComparableCar/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 9/ComparableCar/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 9/ComparableCar/PetNameComparer.vb b/Code/Chapter 9/ComparableCar/PetNameComparer.vb new file mode 100644 index 0000000..225e11a --- /dev/null +++ b/Code/Chapter 9/ComparableCar/PetNameComparer.vb @@ -0,0 +1,16 @@ +' This type is now nested in the Car! + +' This helper class is used to sort an array of Cars by pet name. + +'Public Class PetNameComparer +' Implements IComparer + +' Public Sub New() +' End Sub +' Public Function Compare(ByVal x As Object, ByVal y As Object) _ +' As Integer Implements System.Collections.IComparer.Compare +' Dim t1 As Car = CType(x, Car) +' Dim t2 As Car = CType(y, Car) +' Return String.Compare(t1.Name, t2.Name) +' End Function +'End Class diff --git a/Code/Chapter 9/ComparableCar/Program.vb b/Code/Chapter 9/ComparableCar/Program.vb new file mode 100644 index 0000000..8a2a72d --- /dev/null +++ b/Code/Chapter 9/ComparableCar/Program.vb @@ -0,0 +1,38 @@ +' This example illustrates how to build objects +' which can be sorted in various manners. + +Module Program + Sub Main() + Console.WriteLine("***** Fun with IComparable *****") + + ' Make an array of Car types. + Dim myAutos(4) As Car + myAutos(0) = New Car("Rusty", 80, 1) + myAutos(1) = New Car("Mary", 40, 234) + myAutos(2) = New Car("Viper", 40, 34) + myAutos(3) = New Car("Mel", 40, 4) + myAutos(4) = New Car("Chucky", 40, 5) + + Console.WriteLine("-> Before Sorting:") + For Each c As Car In myAutos + Console.WriteLine("Car {0} is named {1}.", c.ID, c.Name) + Next + Console.WriteLine() + + ' Sort my cars? + Array.Sort(myAutos) + Console.WriteLine("-> After Sorting:") + For Each c As Car In myAutos + Console.WriteLine("Car {0} is named {1}.", c.ID, c.Name) + Next + Console.WriteLine() + + ' Now sort by pet name. + Array.Sort(myAutos, Car.SortByPetName) + Console.WriteLine("-> Ordering by pet name:") + For Each c As Car In myAutos + Console.WriteLine("{0} has the ID of {1}.", c.Name, c.ID) + Next + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 9/ComparableCar/Radio.vb b/Code/Chapter 9/ComparableCar/Radio.vb new file mode 100644 index 0000000..cdd0154 --- /dev/null +++ b/Code/Chapter 9/ComparableCar/Radio.vb @@ -0,0 +1,9 @@ +Public Class Radio + Public Sub TurnOn(ByVal state As Boolean) + If state = True Then + Console.WriteLine("Jamming...") + Else + Console.WriteLine("Quiet time...") + End If + End Sub +End Class diff --git a/Code/Chapter 9/CustomEnumerator/Car.vb b/Code/Chapter 9/CustomEnumerator/Car.vb new file mode 100644 index 0000000..c32f13d --- /dev/null +++ b/Code/Chapter 9/CustomEnumerator/Car.vb @@ -0,0 +1,74 @@ +Public Class Car + ' Constant for maximum speed. + Public Const maxSpeed As Integer = 100 + + ' Internal state data. + Private currSpeed As Integer + Private petName As String + + ' Is the car still operational? + Private carIsDead As Boolean + + ' A car has a radio. + Private theMusicBox As Radio = New Radio() + +#Region "Properties" + Public Property Name() As String + Get + Return petName + End Get + Set(ByVal value As String) + petName = value + End Set + End Property + Public Property Speed() As Integer + Get + Return currSpeed + End Get + Set(ByVal value As Integer) + currSpeed = value + End Set + End Property +#End Region + +#Region "Constructors." + Public Sub New() + End Sub + Public Sub New(ByVal name As String, ByVal currSp As Integer) + currSpeed = currSp + petName = name + End Sub +#End Region + + Public Sub CrankTunes(ByVal state As Boolean) + theMusicBox.TurnOn(state) + End Sub + +#Region "Accelerate method" + ' See if Car has overheated. + Public Sub Accelerate(ByVal delta As Integer) + If carIsDead Then + Console.WriteLine("{0} is out of order...", petName) + Else + currSpeed += delta + If currSpeed >= maxSpeed Then + carIsDead = True + currSpeed = 0 + + ' We need to call the HelpLink property, thus we need to + ' create a local variable before throwing the Exception object. + Dim ex As New Exception(String.Format("{0} has overheated!", petName)) + ex.HelpLink = "http://www.CarsRUs.com" + ' Stuff in custom data regarding the error. + ex.Data.Add("TimeStamp", _ + String.Format("The car exploded at {0}", DateTime.Now)) + ex.Data.Add("Cause", "You have a lead foot.") + Throw ex + Else + Console.WriteLine("=> CurrSpeed = {0}", currSpeed) + End If + End If + End Sub +#End Region + +End Class diff --git a/Code/Chapter 9/CustomEnumerator/CustomEnumerator.sln b/Code/Chapter 9/CustomEnumerator/CustomEnumerator.sln new file mode 100644 index 0000000..2a26065 --- /dev/null +++ b/Code/Chapter 9/CustomEnumerator/CustomEnumerator.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CustomEnumerator", "CustomEnumerator.vbproj", "{8950402A-B417-41DE-B7C4-860673EF027B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8950402A-B417-41DE-B7C4-860673EF027B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8950402A-B417-41DE-B7C4-860673EF027B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8950402A-B417-41DE-B7C4-860673EF027B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8950402A-B417-41DE-B7C4-860673EF027B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 9/CustomEnumerator/CustomEnumerator.suo b/Code/Chapter 9/CustomEnumerator/CustomEnumerator.suo new file mode 100644 index 0000000..daa70b4 Binary files /dev/null and b/Code/Chapter 9/CustomEnumerator/CustomEnumerator.suo differ diff --git a/Code/Chapter 9/CustomEnumerator/CustomEnumerator.vbproj b/Code/Chapter 9/CustomEnumerator/CustomEnumerator.vbproj new file mode 100644 index 0000000..6b4775d --- /dev/null +++ b/Code/Chapter 9/CustomEnumerator/CustomEnumerator.vbproj @@ -0,0 +1,100 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {8950402A-B417-41DE-B7C4-860673EF027B} + Exe + CustomEnumerator.Program + CustomEnumerator + CustomEnumerator + Console + + + 2.0 + + + + + true + full + true + true + bin\Debug\ + CustomEnumerator.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + CustomEnumerator.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/Code/Chapter 9/CustomEnumerator/CustomEnumerator.vbproj.user b/Code/Chapter 9/CustomEnumerator/CustomEnumerator.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 9/CustomEnumerator/CustomEnumerator.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 9/CustomEnumerator/Garage.vb b/Code/Chapter 9/CustomEnumerator/Garage.vb new file mode 100644 index 0000000..27e6582 --- /dev/null +++ b/Code/Chapter 9/CustomEnumerator/Garage.vb @@ -0,0 +1,19 @@ +Public Class Garage + Implements System.Collections.IEnumerable + + Private myCars() As Car = New Car(3) {} + + Public Sub New() + myCars(0) = New Car("Fred", 40) + myCars(1) = New Car("Zippy", 60) + myCars(2) = New Car("Mabel", 0) + myCars(3) = New Car("Max", 80) + End Sub + + Public Function GetEnumerator() As System.Collections.IEnumerator _ + Implements System.Collections.IEnumerable.GetEnumerator + Return myCars.GetEnumerator() + End Function +End Class + + diff --git a/Code/Chapter 9/CustomEnumerator/My Project/Application.Designer.vb b/Code/Chapter 9/CustomEnumerator/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 9/CustomEnumerator/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 9/CustomEnumerator/My Project/Application.myapp b/Code/Chapter 9/CustomEnumerator/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 9/CustomEnumerator/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 9/CustomEnumerator/My Project/AssemblyInfo.vb b/Code/Chapter 9/CustomEnumerator/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..fb55159 --- /dev/null +++ b/Code/Chapter 9/CustomEnumerator/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/Code/Chapter 9/CustomEnumerator/My Project/Resources.Designer.vb b/Code/Chapter 9/CustomEnumerator/My Project/Resources.Designer.vb new file mode 100644 index 0000000..426cf65 --- /dev/null +++ b/Code/Chapter 9/CustomEnumerator/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("CustomEnumerator.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/Code/Chapter 9/CustomEnumerator/My Project/Resources.resx b/Code/Chapter 9/CustomEnumerator/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 9/CustomEnumerator/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/Code/Chapter 9/CustomEnumerator/My Project/Settings.Designer.vb b/Code/Chapter 9/CustomEnumerator/My Project/Settings.Designer.vb new file mode 100644 index 0000000..3e10ec8 --- /dev/null +++ b/Code/Chapter 9/CustomEnumerator/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CustomEnumerator.My.MySettings + Get + Return Global.CustomEnumerator.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 9/CustomEnumerator/My Project/Settings.settings b/Code/Chapter 9/CustomEnumerator/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 9/CustomEnumerator/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 9/CustomEnumerator/Program.vb b/Code/Chapter 9/CustomEnumerator/Program.vb new file mode 100644 index 0000000..f7f5e19 --- /dev/null +++ b/Code/Chapter 9/CustomEnumerator/Program.vb @@ -0,0 +1,22 @@ +' This seems reasonable... +Module Program + Sub Main() + Console.WriteLine("***** Info about my Cars *****") + Dim myCars As New Garage + ' Hand over each car in the collection? + For Each c As Car In myCars + Console.WriteLine("{0} is going {1} MPH", _ + c.Name, c.Speed) + Next + + ' Get IEnumerable directly. + Dim iEnum As IEnumerator + iEnum = myCars.GetEnumerator() + iEnum.Reset() + iEnum.MoveNext() + + Dim firstCar As Car = CType(iEnum.Current, Car) + Console.WriteLine("First car in collection is: {0}", firstCar.Name) + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 9/CustomEnumerator/Radio.vb b/Code/Chapter 9/CustomEnumerator/Radio.vb new file mode 100644 index 0000000..592c800 --- /dev/null +++ b/Code/Chapter 9/CustomEnumerator/Radio.vb @@ -0,0 +1,9 @@ +Public Class Radio + Public Sub TurnOn(ByVal state As Boolean) + If state = True Then + Console.WriteLine("Jamming...") + Else + Console.WriteLine("Quiet time...") + End If + End Sub +End Class diff --git a/Code/Chapter 9/CustomInterface/CustomInterface.sln b/Code/Chapter 9/CustomInterface/CustomInterface.sln new file mode 100644 index 0000000..dc32e14 --- /dev/null +++ b/Code/Chapter 9/CustomInterface/CustomInterface.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CustomInterface", "CustomInterface.vbproj", "{B35D1076-37D3-441D-A79C-D6763B478E4A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B35D1076-37D3-441D-A79C-D6763B478E4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B35D1076-37D3-441D-A79C-D6763B478E4A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B35D1076-37D3-441D-A79C-D6763B478E4A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B35D1076-37D3-441D-A79C-D6763B478E4A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 9/CustomInterface/CustomInterface.suo b/Code/Chapter 9/CustomInterface/CustomInterface.suo new file mode 100644 index 0000000..937cb54 Binary files /dev/null and b/Code/Chapter 9/CustomInterface/CustomInterface.suo differ diff --git a/Code/Chapter 9/CustomInterface/CustomInterface.vbproj b/Code/Chapter 9/CustomInterface/CustomInterface.vbproj new file mode 100644 index 0000000..e8b7d2e --- /dev/null +++ b/Code/Chapter 9/CustomInterface/CustomInterface.vbproj @@ -0,0 +1,103 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {B35D1076-37D3-441D-A79C-D6763B478E4A} + Exe + CustomInterface.Program + CustomInterface + CustomInterface + Console + + + 2.0 + + + + + true + full + true + true + bin\Debug\ + CustomInterface.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + CustomInterface.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/Code/Chapter 9/CustomInterface/CustomInterface.vbproj.user b/Code/Chapter 9/CustomInterface/CustomInterface.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 9/CustomInterface/CustomInterface.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 9/CustomInterface/IPointy.vb b/Code/Chapter 9/CustomInterface/IPointy.vb new file mode 100644 index 0000000..898b265 --- /dev/null +++ b/Code/Chapter 9/CustomInterface/IPointy.vb @@ -0,0 +1,9 @@ +' The pointy behavior as a read-only property. +Public Interface IPointy + ReadOnly Property Points() As Byte +End Interface + +' Models the ability to render a type in stunning 3D. +Public Interface IDraw3D + Sub Draw3D() +End Interface diff --git a/Code/Chapter 9/CustomInterface/My Project/Application.Designer.vb b/Code/Chapter 9/CustomInterface/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 9/CustomInterface/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 9/CustomInterface/My Project/Application.myapp b/Code/Chapter 9/CustomInterface/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 9/CustomInterface/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 9/CustomInterface/My Project/AssemblyInfo.vb b/Code/Chapter 9/CustomInterface/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..0a2f8e8 --- /dev/null +++ b/Code/Chapter 9/CustomInterface/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/Code/Chapter 9/CustomInterface/My Project/Resources.Designer.vb b/Code/Chapter 9/CustomInterface/My Project/Resources.Designer.vb new file mode 100644 index 0000000..f970fc8 --- /dev/null +++ b/Code/Chapter 9/CustomInterface/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("CustomInterface.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/Code/Chapter 9/CustomInterface/My Project/Resources.resx b/Code/Chapter 9/CustomInterface/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 9/CustomInterface/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/Code/Chapter 9/CustomInterface/My Project/Settings.Designer.vb b/Code/Chapter 9/CustomInterface/My Project/Settings.Designer.vb new file mode 100644 index 0000000..9d9b59d --- /dev/null +++ b/Code/Chapter 9/CustomInterface/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.CustomInterface.My.MySettings + Get + Return Global.CustomInterface.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 9/CustomInterface/My Project/Settings.settings b/Code/Chapter 9/CustomInterface/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 9/CustomInterface/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 9/CustomInterface/MyShapes.cd b/Code/Chapter 9/CustomInterface/MyShapes.cd new file mode 100644 index 0000000..a499bed --- /dev/null +++ b/Code/Chapter 9/CustomInterface/MyShapes.cd @@ -0,0 +1,70 @@ + + + + + + + MyShapes.vb + AAAAAAAAAAAAAgAAAAAAAAAEAAAAAAAAAAAAAAAAAAA= + + + + + + + MyShapes.vb + AAAAAAAAAAAAggAAAAAAAAAEAAAAAAAAAAAAAAAAAAA= + + + + + + + MyShapes.vb + AAAAAAAAAAAAAgAAAAAAAAAAAAABAAAAAAAAAAAAAAA= + + + + + + Shape.vb + AAAAIAAAAAAAAgAAAAAAAAAAAAABAAAAAAAAAAAAAAA= + + + + + + Triangle.vb + AAAAAAAAAAAAggAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + + + + + + + OtherPointyItems.vb + AAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + + + + + + + OtherPointyItems.vb + AAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + + + + + + + OtherPointyItems.vb + AAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + + + + + + + + \ No newline at end of file diff --git a/Code/Chapter 9/CustomInterface/MyShapes.vb b/Code/Chapter 9/CustomInterface/MyShapes.vb new file mode 100644 index 0000000..12cefb9 --- /dev/null +++ b/Code/Chapter 9/CustomInterface/MyShapes.vb @@ -0,0 +1,63 @@ +#Region "Circle Class" +' If we did not implement the MustOverride Draw() method, Circle would also be +' considered abstract, and would have to be marked MustInherit! +Public Class Circle + Inherits Shape + Implements IDraw3D + + Public Sub New() + End Sub + Public Sub New(ByVal name As String) + MyBase.New(name) + End Sub + Public Overrides Sub Draw() + Console.WriteLine("Drawing {0} the Circle", shapeName) + End Sub + + Public Sub Draw3D() Implements IDraw3D.Draw3D + Console.WriteLine("Drawing circle in 3D!") + End Sub +End Class +#End Region + +#Region "Hexagon Class" +' Hexagon DOES override Draw(). +Public Class Hexagon + Inherits Shape + Implements IPointy, IDraw3D + + Public Sub New() + End Sub + Public Sub New(ByVal name As String) + MyBase.New(name) + End Sub + Public Overrides Sub Draw() + Console.WriteLine("Drawing {0} the Hexagon", shapeName) + End Sub + + Public ReadOnly Property Points() As Byte Implements IPointy.Points + Get + Return 6 + End Get + End Property + + Public Sub Draw3D() Implements IDraw3D.Draw3D + Console.WriteLine("Drawing Hexagon in 3D!") + End Sub +End Class +#End Region + +#Region "ThreeDCircle Class" +' This class extends Circle and hides the inherited Draw() method. +Public Class ThreeDCircle + Inherits Circle + + ' Hide the shapeName field above me. + Protected Shadows shapeName As String + + ' Hide any Draw() implementation above me. + Public Shadows Sub Draw() + Console.WriteLine("Drawing a 3D Circle") + End Sub +End Class +#End Region \ No newline at end of file diff --git a/Code/Chapter 9/CustomInterface/OtherPointyItems.vb b/Code/Chapter 9/CustomInterface/OtherPointyItems.vb new file mode 100644 index 0000000..2e73790 --- /dev/null +++ b/Code/Chapter 9/CustomInterface/OtherPointyItems.vb @@ -0,0 +1,32 @@ +' These types are just for testing purposes. +' They illustrate how the same interface can be +' supported in unique heirarchies. + +Public Class PitchFork + Implements IPointy + Public ReadOnly Property Points() As Byte Implements IPointy.Points + Get + Return 3 + End Get + End Property +End Class + +Public Class Fork + Implements IPointy + + Public ReadOnly Property Points() As Byte Implements IPointy.Points + Get + Return 4 + End Get + End Property +End Class + +Public Class Knife + Implements IPointy + + Public ReadOnly Property Points() As Byte Implements IPointy.Points + Get + Return 1 + End Get + End Property +End Class \ No newline at end of file diff --git a/Code/Chapter 9/CustomInterface/Program.vb b/Code/Chapter 9/CustomInterface/Program.vb new file mode 100644 index 0000000..3e044ea --- /dev/null +++ b/Code/Chapter 9/CustomInterface/Program.vb @@ -0,0 +1,65 @@ +' This example illustrates how to define and work with .NET interface +' types. + +Module Program + Sub Main() + Console.WriteLine("***** Fun with Interfaces *****") + ' Make an array of Shape-compatible types. + Dim myShapes() As Shape = {New Hexagon("Fred"), New Circle("Angie"), _ + New ThreeDCircle(), New Triangle("Adam")} + + ' Now figure out which ones support IPointy. + Dim itfPointy As IPointy + For Each s As Shape In myShapes + If TypeOf s Is IPointy Then + itfPointy = CType(s, IPointy) + Console.WriteLine("{0} has {1} points.", s.PetName, itfPointy.Points) + Else + Console.WriteLine("{0} does not implement IPointy!", s) + End If + ' Is this item IDraw3D aware? + If TypeOf s Is IDraw3D Then + DrawIn3D(CType(s, IDraw3D)) + End If + Next + + ' Can we extract IPointy from an Array of Integers? + Dim myInts() As Integer = {10, 20, 30} + Dim i As IPointy = ExtractPointyness(myInts) + + ' Nope! + If i Is Nothing Then + Console.WriteLine("Sorry, this object was not IPointy compatible") + End If + + ' This array can only contain types that + ' implement the IPointy interface. + Dim pointyThings() As IPointy = {New Hexagon(), New Knife(), _ + New Triangle(), New Fork(), New PitchFork()} + Console.WriteLine("Here are some more pointy things:") + For Each p As IPointy In pointyThings + Console.WriteLine("Object has {0} points.", p.Points) + Next + + Console.ReadLine() + End Sub + +#Region "Helper methods" + ' This method can receive anything implementing IDraw3D. + Sub DrawIn3D(ByVal itf3d As IDraw3D) + Console.WriteLine("-> Drawing IDraw3D compatible type") + itf3d.Draw3D() + End Sub + + ' This method tests for IPointy-compatibility and, + ' if able, returns an interface reference. + Function ExtractPointyness(ByVal o As Object) As IPointy + If TypeOf o Is IPointy Then + Return CType(o, IPointy) + Else + Return Nothing + End If + End Function +#End Region + +End Module diff --git a/Code/Chapter 9/CustomInterface/Shape.vb b/Code/Chapter 9/CustomInterface/Shape.vb new file mode 100644 index 0000000..bfa12ae --- /dev/null +++ b/Code/Chapter 9/CustomInterface/Shape.vb @@ -0,0 +1,22 @@ +' The abstract base class of the hierarchy. +Public MustInherit Class Shape + Protected shapeName As String + + Public Sub New() + shapeName = "NoName" + End Sub + Public Sub New(ByVal s As String) + shapeName = s + End Sub + + Public MustOverride Sub Draw() + + Public Property PetName() As String + Get + Return shapeName + End Get + Set(ByVal value As String) + shapeName = value + End Set + End Property +End Class diff --git a/Code/Chapter 9/CustomInterface/Triangle.vb b/Code/Chapter 9/CustomInterface/Triangle.vb new file mode 100644 index 0000000..3ea9373 --- /dev/null +++ b/Code/Chapter 9/CustomInterface/Triangle.vb @@ -0,0 +1,20 @@ +Public Class Triangle + Inherits Shape + Implements IPointy + + Public Sub New() + End Sub + Public Sub New(ByVal name As String) + MyBase.New(name) + End Sub + + Public Overrides Sub Draw() + Console.WriteLine("Drawing {0} the Triangle", shapeName) + End Sub + + Public ReadOnly Property Points() As Byte Implements IPointy.Points + Get + Return 3 + End Get + End Property +End Class diff --git a/Code/Chapter 9/EventInterface/Car.vb b/Code/Chapter 9/EventInterface/Car.vb new file mode 100644 index 0000000..e24413e --- /dev/null +++ b/Code/Chapter 9/EventInterface/Car.vb @@ -0,0 +1,64 @@ +Option Explicit On +Option Strict On + +Public Class Car + ' The set of connected client. + Private clientSinks As New ArrayList() + + ' The client calls these methods to connect + ' to, or detatch from, the event notification. + Public Sub Connect(ByVal sink As IEngineEvents) + clientSinks.Add(sink) + End Sub + Public Sub Disconnect(ByVal sink As IEngineEvents) + clientSinks.Remove(sink) + End Sub + + ' Constant for maximum speed. + Public Const maxSpeed As Integer = 100 + + 'Internal state data. + Private currSpeed As Integer + Private petName As String + + 'Is the car still operational? + Private carIsDead As Boolean + + 'A car has a radio. + Private theMusicBox As Radio = New Radio + + ' Constructors. + Public Sub New() + End Sub + Public Sub New(ByVal name As String, ByVal currSp As Integer) + currSpeed = currSp + petName = name + End Sub + + Public Sub CrankTunes(ByVal state As Boolean) + theMusicBox.TurnOn(state) + End Sub + + ' See if Car has overheated. + Public Sub Accelerate(ByVal delta As Integer) + ' If the car is doomed, sent out event to + ' each connected client. + If carIsDead Then + For Each i As IEngineEvents In clientSinks + i.Exploded("Sorry! This car is toast!") + Next + Else + currSpeed += delta + If (maxSpeed - currSpeed) = 10 Then + For Each i As IEngineEvents In clientSinks + i.AboutToBlow("Careful! About to blow!") + Next + End If + If currSpeed >= maxSpeed Then + carIsDead = True + Else + Console.WriteLine("=> CurrSpeed = {0} ", currSpeed) + End If + End If + End Sub +End Class \ No newline at end of file diff --git a/Code/Chapter 9/EventInterface/CarEventSink.vb b/Code/Chapter 9/EventInterface/CarEventSink.vb new file mode 100644 index 0000000..1e2c6d0 --- /dev/null +++ b/Code/Chapter 9/EventInterface/CarEventSink.vb @@ -0,0 +1,18 @@ +' Car event sink. +Public Class CarEventSink + Implements IEngineEvents + Private name As String + + Public Sub New(ByVal sinkName As String) + name = sinkName + End Sub + + Public Sub AboutToBlow(ByVal msg As String) _ + Implements IEngineEvents.AboutToBlow + Console.WriteLine("{0} reporting: {1}", name, msg) + End Sub + Public Sub Exploded(ByVal msg As String) _ + Implements IEngineEvents.Exploded + Console.WriteLine("{0} reporting: {1}", name, msg) + End Sub +End Class diff --git a/Code/Chapter 9/EventInterface/EventInterface.sln b/Code/Chapter 9/EventInterface/EventInterface.sln new file mode 100644 index 0000000..b785a88 --- /dev/null +++ b/Code/Chapter 9/EventInterface/EventInterface.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EventInterface", "EventInterface.vbproj", "{D7E0188D-43F2-479D-9151-AC26D0D25DF5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D7E0188D-43F2-479D-9151-AC26D0D25DF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D7E0188D-43F2-479D-9151-AC26D0D25DF5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D7E0188D-43F2-479D-9151-AC26D0D25DF5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D7E0188D-43F2-479D-9151-AC26D0D25DF5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 9/EventInterface/EventInterface.suo b/Code/Chapter 9/EventInterface/EventInterface.suo new file mode 100644 index 0000000..ee0a2b6 Binary files /dev/null and b/Code/Chapter 9/EventInterface/EventInterface.suo differ diff --git a/Code/Chapter 9/EventInterface/EventInterface.vbproj b/Code/Chapter 9/EventInterface/EventInterface.vbproj new file mode 100644 index 0000000..6956981 --- /dev/null +++ b/Code/Chapter 9/EventInterface/EventInterface.vbproj @@ -0,0 +1,133 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {D7E0188D-43F2-479D-9151-AC26D0D25DF5} + Exe + EventInterface.Program + EventInterface + EventInterface + Console + + + 2.0 + + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + true + bin\Debug\ + EventInterface.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + EventInterface.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 + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + \ No newline at end of file diff --git a/Code/Chapter 9/EventInterface/EventInterface.vbproj.user b/Code/Chapter 9/EventInterface/EventInterface.vbproj.user new file mode 100644 index 0000000..97e11c3 --- /dev/null +++ b/Code/Chapter 9/EventInterface/EventInterface.vbproj.user @@ -0,0 +1,17 @@ + + + ProjectFiles + + + + + + + + + + + en-US + false + + \ No newline at end of file diff --git a/Code/Chapter 9/EventInterface/Interfaces.vb b/Code/Chapter 9/EventInterface/Interfaces.vb new file mode 100644 index 0000000..05298d9 --- /dev/null +++ b/Code/Chapter 9/EventInterface/Interfaces.vb @@ -0,0 +1,5 @@ +' The callback interface. +Public Interface IEngineEvents + Sub AboutToBlow(ByVal msg As String) + Sub Exploded(ByVal msg As String) +End Interface diff --git a/Code/Chapter 9/EventInterface/My Project/Application.Designer.vb b/Code/Chapter 9/EventInterface/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 9/EventInterface/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 9/EventInterface/My Project/Application.myapp b/Code/Chapter 9/EventInterface/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 9/EventInterface/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 9/EventInterface/My Project/AssemblyInfo.vb b/Code/Chapter 9/EventInterface/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..b686469 --- /dev/null +++ b/Code/Chapter 9/EventInterface/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/Code/Chapter 9/EventInterface/My Project/Resources.Designer.vb b/Code/Chapter 9/EventInterface/My Project/Resources.Designer.vb new file mode 100644 index 0000000..2640e41 --- /dev/null +++ b/Code/Chapter 9/EventInterface/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("EventInterface.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/Code/Chapter 9/EventInterface/My Project/Resources.resx b/Code/Chapter 9/EventInterface/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 9/EventInterface/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/Code/Chapter 9/EventInterface/My Project/Settings.Designer.vb b/Code/Chapter 9/EventInterface/My Project/Settings.Designer.vb new file mode 100644 index 0000000..b6febdb --- /dev/null +++ b/Code/Chapter 9/EventInterface/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.EventInterface.My.MySettings + Get + Return Global.EventInterface.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 9/EventInterface/My Project/Settings.settings b/Code/Chapter 9/EventInterface/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 9/EventInterface/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 9/EventInterface/Program.vb b/Code/Chapter 9/EventInterface/Program.vb new file mode 100644 index 0000000..aa06575 --- /dev/null +++ b/Code/Chapter 9/EventInterface/Program.vb @@ -0,0 +1,32 @@ +Module Program + Sub Main() + Console.WriteLine("***** Interfaces as event enablers *****") + Dim myCar As New Car("SlugBug", 10) + + ' Make sink object. + Console.WriteLine("***** Creating Sinks! *****") + Dim sink As New CarEventSink("First Sink") + Dim otherSink As New CarEventSink("Second Sink") + + ' Pass both sinks to car. + myCar.Connect(sink) + myCar.Connect(otherSink) + + ' Speed up (this will trigger the events). + For i As Integer = 0 To 5 + myCar.Accelerate(20) + Next + + ' Detach from first sink. + myCar.Disconnect(sink) + + ' Speed up again (only otherSink will be called). + For i As Integer = 0 To 5 + myCar.Accelerate(20) + Next + + ' Detach from other sink. + myCar.Disconnect(otherSink) + Console.ReadLine() + End Sub +End Module diff --git a/Code/Chapter 9/EventInterface/Radio.vb b/Code/Chapter 9/EventInterface/Radio.vb new file mode 100644 index 0000000..09e9ab4 --- /dev/null +++ b/Code/Chapter 9/EventInterface/Radio.vb @@ -0,0 +1,12 @@ +Option Explicit On +Option Strict On + +Public Class Radio + Public Sub TurnOn(ByVal state As Boolean) + If state = True Then + Console.WriteLine("Jamming...") + Else + Console.WriteLine("Quiet time...") + End If + End Sub +End Class \ No newline at end of file diff --git a/Code/Chapter 9/InterfaceHierarchy/InterfaceHierarchy.sln b/Code/Chapter 9/InterfaceHierarchy/InterfaceHierarchy.sln new file mode 100644 index 0000000..dd82106 --- /dev/null +++ b/Code/Chapter 9/InterfaceHierarchy/InterfaceHierarchy.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "InterfaceHierarchy", "InterfaceHierarchy.vbproj", "{593EB49B-DD75-48E5-AEB7-6181A7AE40DF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {593EB49B-DD75-48E5-AEB7-6181A7AE40DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {593EB49B-DD75-48E5-AEB7-6181A7AE40DF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {593EB49B-DD75-48E5-AEB7-6181A7AE40DF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {593EB49B-DD75-48E5-AEB7-6181A7AE40DF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 9/InterfaceHierarchy/InterfaceHierarchy.suo b/Code/Chapter 9/InterfaceHierarchy/InterfaceHierarchy.suo new file mode 100644 index 0000000..61dc164 Binary files /dev/null and b/Code/Chapter 9/InterfaceHierarchy/InterfaceHierarchy.suo differ diff --git a/Code/Chapter 9/InterfaceHierarchy/InterfaceHierarchy.vbproj b/Code/Chapter 9/InterfaceHierarchy/InterfaceHierarchy.vbproj new file mode 100644 index 0000000..2244fe3 --- /dev/null +++ b/Code/Chapter 9/InterfaceHierarchy/InterfaceHierarchy.vbproj @@ -0,0 +1,99 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {593EB49B-DD75-48E5-AEB7-6181A7AE40DF} + Exe + InterfaceHierarchy.Program + InterfaceHierarchy + InterfaceHierarchy + Console + + + 2.0 + + + + + true + full + true + true + bin\Debug\ + InterfaceHierarchy.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + InterfaceHierarchy.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/Code/Chapter 9/InterfaceHierarchy/InterfaceHierarchy.vbproj.user b/Code/Chapter 9/InterfaceHierarchy/InterfaceHierarchy.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 9/InterfaceHierarchy/InterfaceHierarchy.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 9/InterfaceHierarchy/My Project/Application.Designer.vb b/Code/Chapter 9/InterfaceHierarchy/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 9/InterfaceHierarchy/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 9/InterfaceHierarchy/My Project/Application.myapp b/Code/Chapter 9/InterfaceHierarchy/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 9/InterfaceHierarchy/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 9/InterfaceHierarchy/My Project/AssemblyInfo.vb b/Code/Chapter 9/InterfaceHierarchy/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..1b7aabe --- /dev/null +++ b/Code/Chapter 9/InterfaceHierarchy/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/Code/Chapter 9/InterfaceHierarchy/My Project/Resources.Designer.vb b/Code/Chapter 9/InterfaceHierarchy/My Project/Resources.Designer.vb new file mode 100644 index 0000000..2fee0eb --- /dev/null +++ b/Code/Chapter 9/InterfaceHierarchy/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("InterfaceHierarchy.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/Code/Chapter 9/InterfaceHierarchy/My Project/Resources.resx b/Code/Chapter 9/InterfaceHierarchy/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 9/InterfaceHierarchy/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/Code/Chapter 9/InterfaceHierarchy/My Project/Settings.Designer.vb b/Code/Chapter 9/InterfaceHierarchy/My Project/Settings.Designer.vb new file mode 100644 index 0000000..e514709 --- /dev/null +++ b/Code/Chapter 9/InterfaceHierarchy/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.InterfaceHierarchy.My.MySettings + Get + Return Global.InterfaceHierarchy.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 9/InterfaceHierarchy/My Project/Settings.settings b/Code/Chapter 9/InterfaceHierarchy/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 9/InterfaceHierarchy/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 9/InterfaceHierarchy/MyInterfaces.vb b/Code/Chapter 9/InterfaceHierarchy/MyInterfaces.vb new file mode 100644 index 0000000..ae4761d --- /dev/null +++ b/Code/Chapter 9/InterfaceHierarchy/MyInterfaces.vb @@ -0,0 +1,13 @@ +Public Interface IDrawable + Sub Draw() +End Interface + +Public Interface IPrintable + Inherits IDrawable + Sub Print() +End Interface + +Public Interface IRenderToMemory + Inherits IPrintable + Sub Render() +End Interface diff --git a/Code/Chapter 9/InterfaceHierarchy/Program.vb b/Code/Chapter 9/InterfaceHierarchy/Program.vb new file mode 100644 index 0000000..d7ac219 --- /dev/null +++ b/Code/Chapter 9/InterfaceHierarchy/Program.vb @@ -0,0 +1,19 @@ +' This example illustrates building heirarchies +' of interfaces. + +Module Program + Sub Main() + Console.WriteLine("***** The SuperShape *****") + + ' Call from object level. + Dim myShape As New SuperShape + myShape.Draw() + + ' Get IPrintable explicitly. + ' (and IDrawable implicitly!) + Dim iPrint As IPrintable + iPrint = CType(myShape, IPrintable) + iPrint.Draw() + iPrint.Print() + End Sub +End Module diff --git a/Code/Chapter 9/InterfaceHierarchy/SuperShape.vb b/Code/Chapter 9/InterfaceHierarchy/SuperShape.vb new file mode 100644 index 0000000..3ac66f8 --- /dev/null +++ b/Code/Chapter 9/InterfaceHierarchy/SuperShape.vb @@ -0,0 +1,14 @@ +Public Class SuperShape + Implements IRenderToMemory + Public Sub Draw() Implements IDrawable.Draw + Console.WriteLine("Drawing...") + End Sub + + Public Sub Print() Implements IPrintable.Print + Console.WriteLine("Printing...") + End Sub + + Public Sub Render() Implements IRenderToMemory.Render + Console.WriteLine("Rendering...") + End Sub +End Class diff --git a/Code/Chapter 9/InterfaceNameClash/BlackAndWhiteBitmap.vb b/Code/Chapter 9/InterfaceNameClash/BlackAndWhiteBitmap.vb new file mode 100644 index 0000000..58d47e4 --- /dev/null +++ b/Code/Chapter 9/InterfaceNameClash/BlackAndWhiteBitmap.vb @@ -0,0 +1,17 @@ +' Notice each class method has been defined as Private +' and has been given very a nondescript name. +Public Class BlackAndWhiteBitmap + Implements IDrawToForm, IDrawToMemory, IDrawToPrinter + + Private Sub X() Implements IDrawToForm.Draw + ' Insert interesting code... + End Sub + + Private Sub Y() Implements IDrawToMemory.Draw + ' Insert interesting code... + End Sub + + Private Sub Z() Implements IDrawToPrinter.Draw + ' Insert interesting code... + End Sub +End Class diff --git a/Code/Chapter 9/InterfaceNameClash/InterfaceNameClash.sln b/Code/Chapter 9/InterfaceNameClash/InterfaceNameClash.sln new file mode 100644 index 0000000..1620e37 --- /dev/null +++ b/Code/Chapter 9/InterfaceNameClash/InterfaceNameClash.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "InterfaceNameClash", "InterfaceNameClash.vbproj", "{3B8C68B8-32ED-4E34-96BF-D960523EDF7E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3B8C68B8-32ED-4E34-96BF-D960523EDF7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3B8C68B8-32ED-4E34-96BF-D960523EDF7E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3B8C68B8-32ED-4E34-96BF-D960523EDF7E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3B8C68B8-32ED-4E34-96BF-D960523EDF7E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/Chapter 9/InterfaceNameClash/InterfaceNameClash.suo b/Code/Chapter 9/InterfaceNameClash/InterfaceNameClash.suo new file mode 100644 index 0000000..ca9eaaf Binary files /dev/null and b/Code/Chapter 9/InterfaceNameClash/InterfaceNameClash.suo differ diff --git a/Code/Chapter 9/InterfaceNameClash/InterfaceNameClash.vbproj b/Code/Chapter 9/InterfaceNameClash/InterfaceNameClash.vbproj new file mode 100644 index 0000000..5ee1305 --- /dev/null +++ b/Code/Chapter 9/InterfaceNameClash/InterfaceNameClash.vbproj @@ -0,0 +1,101 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {3B8C68B8-32ED-4E34-96BF-D960523EDF7E} + Exe + InterfaceNameClash.Program + InterfaceNameClash + InterfaceNameClash + Console + + + 2.0 + + + + + true + full + true + true + bin\Debug\ + InterfaceNameClash.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + InterfaceNameClash.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/Code/Chapter 9/InterfaceNameClash/InterfaceNameClash.vbproj.user b/Code/Chapter 9/InterfaceNameClash/InterfaceNameClash.vbproj.user new file mode 100644 index 0000000..a1d742b --- /dev/null +++ b/Code/Chapter 9/InterfaceNameClash/InterfaceNameClash.vbproj.user @@ -0,0 +1,5 @@ + + + ProjectFiles + + \ No newline at end of file diff --git a/Code/Chapter 9/InterfaceNameClash/Line.vb b/Code/Chapter 9/InterfaceNameClash/Line.vb new file mode 100644 index 0000000..3ecf4bf --- /dev/null +++ b/Code/Chapter 9/InterfaceNameClash/Line.vb @@ -0,0 +1,10 @@ +Public Class Line + Implements IDrawToForm, IDrawToMemory, IDrawToPrinter + + ' This single class method defines an implementation for + ' each interface method. + Public Sub Draw() Implements IDrawToForm.Draw, _ + IDrawToMemory.Draw, IDrawToPrinter.Draw + ' Common rendering logic… + End Sub +End Class diff --git a/Code/Chapter 9/InterfaceNameClash/My Project/Application.Designer.vb b/Code/Chapter 9/InterfaceNameClash/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Code/Chapter 9/InterfaceNameClash/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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/Code/Chapter 9/InterfaceNameClash/My Project/Application.myapp b/Code/Chapter 9/InterfaceNameClash/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Code/Chapter 9/InterfaceNameClash/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Code/Chapter 9/InterfaceNameClash/My Project/AssemblyInfo.vb b/Code/Chapter 9/InterfaceNameClash/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..f9134f3 --- /dev/null +++ b/Code/Chapter 9/InterfaceNameClash/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/Code/Chapter 9/InterfaceNameClash/My Project/Resources.Designer.vb b/Code/Chapter 9/InterfaceNameClash/My Project/Resources.Designer.vb new file mode 100644 index 0000000..8b233d0 --- /dev/null +++ b/Code/Chapter 9/InterfaceNameClash/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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("InterfaceNameClash.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/Code/Chapter 9/InterfaceNameClash/My Project/Resources.resx b/Code/Chapter 9/InterfaceNameClash/My Project/Resources.resx new file mode 100644 index 0000000..25a6121 --- /dev/null +++ b/Code/Chapter 9/InterfaceNameClash/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/Code/Chapter 9/InterfaceNameClash/My Project/Settings.Designer.vb b/Code/Chapter 9/InterfaceNameClash/My Project/Settings.Designer.vb new file mode 100644 index 0000000..a5fdd9f --- /dev/null +++ b/Code/Chapter 9/InterfaceNameClash/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' 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.InterfaceNameClash.My.MySettings + Get + Return Global.InterfaceNameClash.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Code/Chapter 9/InterfaceNameClash/My Project/Settings.settings b/Code/Chapter 9/InterfaceNameClash/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Code/Chapter 9/InterfaceNameClash/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Code/Chapter 9/InterfaceNameClash/MyInterfaces.vb b/Code/Chapter 9/InterfaceNameClash/MyInterfaces.vb new file mode 100644 index 0000000..5436681 --- /dev/null +++ b/Code/Chapter 9/InterfaceNameClash/MyInterfaces.vb @@ -0,0 +1,14 @@ +' Draw image to a Form. +Public Interface IDrawToForm + Sub Draw() +End Interface + +' Draw to buffer in memory. +Public Interface IDrawToMemory + Sub Draw() +End Interface + +' Render to the printer +Public Interface IDrawToPrinter + Sub Draw() +End Interface \ No newline at end of file diff --git a/Code/Chapter 9/InterfaceNameClash/Octagon.vb b/Code/Chapter 9/InterfaceNameClash/Octagon.vb new file mode 100644 index 0000000..2e1c5f6 --- /dev/null +++ b/Code/Chapter 9/InterfaceNameClash/Octagon.vb @@ -0,0 +1,15 @@ +Public Class Octagon + Implements IDrawToForm, IDrawToMemory, IDrawToPrinter + + Public Sub Draw() Implements IDrawToForm.Draw + Console.WriteLine("Drawing to the screen") + End Sub + + Public Sub RenderToMemory() Implements IDrawToMemory.Draw + Console.WriteLine("Drawing to off screen memory") + End Sub + + Public Sub Print() Implements IDrawToPrinter.Draw + Console.WriteLine("Printing to printer") + End Sub +End Class diff --git a/Code/Chapter 9/InterfaceNameClash/Program.vb b/Code/Chapter 9/InterfaceNameClash/Program.vb new file mode 100644 index 0000000..b7592fe --- /dev/null +++ b/Code/Chapter 9/InterfaceNameClash/Program.vb @@ -0,0 +1,34 @@ +' This example illustrates how to leverage the Implements +' keyword to resolve name clashes as well as a way to define +' a common shared implemention for interface members. + +Module Program + Sub Main() + Console.WriteLine("***** Fun with Interface Name Clashes *****") + Dim o As New Octagon + + ' Call IDrawToMemory.Draw() + Dim iMem As IDrawToMemory + iMem = CType(o, IDrawToMemory) + iMem.Draw() + + ' Call IDrawToPrinter.Draw() + Dim iPrint As IDrawToPrinter + iPrint = CType(o, IDrawToPrinter) + iPrint.Draw() + + ' Call IDrawToForm.Draw() + Dim iForm As IDrawToForm + iForm = CType(o, IDrawToForm) + iForm.Draw() + + ' BlackAndWhiteBitmap's interface methods + ' are private! + Dim bmp As New BlackAndWhiteBitmap + Dim i As IDrawToForm + i = CType(bmp, IDrawToForm) + i.Draw() + + Console.ReadLine() + End Sub +End Module diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..264a951 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,27 @@ +Freeware License, some rights reserved + +Copyright (c) 2008 Andrew Troelsen + +Permission is hereby granted, free of charge, to anyone obtaining a copy +of this software and associated documentation files (the "Software"), +to work with the Software within the limits of freeware distribution and fair use. +This includes the rights to use, copy, and modify the Software for personal use. +Users are also allowed and encouraged to submit corrections and modifications +to the Software for the benefit of other users. + +It is not allowed to reuse, modify, or redistribute the Software for +commercial use in any way, or for a user’s educational materials such as books +or blog articles without prior permission from the copyright holder. + +The above copyright notice and this permission notice need to be included +in all copies or substantial portions of the software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..95d248d --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +#Apress Source Code + +This repository accompanies [*Pro VB 2008 and the .NET 3.5 Platform*](http://www.apress.com/9781590598221) by Andrew Troelsen (Apress, 2008). + +![Cover image](9781590598221.jpg) + +Download the files as a zip using the green button, or clone the repository to your machine using Git. + +##Releases + +Release v1.0 corresponds to the code in the published book, without corrections or updates. + +##Contributions + +See the file Contributing.md for more information on how you can contribute to this repository. diff --git a/contributing.md b/contributing.md new file mode 100644 index 0000000..f6005ad --- /dev/null +++ b/contributing.md @@ -0,0 +1,14 @@ +# Contributing to Apress Source Code + +Copyright for Apress source code belongs to the author(s). However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers. + +## How to Contribute + +1. Make sure you have a GitHub account. +2. Fork the repository for the relevant book. +3. Create a new branch on which to make your change, e.g. +`git checkout -b my_code_contribution` +4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted. +5. Submit a pull request. + +Thank you for your contribution! \ No newline at end of file