From cb718b990ece943d5ea78fec89af147b62c99147 Mon Sep 17 00:00:00 2001 From: Amrit Panesar Date: Thu, 2 Apr 2015 00:03:23 -0700 Subject: [PATCH] Add Class examples from 04/01/2015 Signed-off-by: Amrit Panesar --- .../WinForm-04-01-2015/WinForm.sln | 22 ++ .../WinformExample/App.config | 6 + .../My Project/Application.Designer.vb | 38 ++++ .../My Project/Application.myapp | 10 + .../WinformExample/My Project/AssemblyInfo.vb | 35 +++ .../My Project/Resources.Designer.vb | 62 ++++++ .../WinformExample/My Project/Resources.resx | 117 ++++++++++ .../My Project/Settings.Designer.vb | 73 ++++++ .../My Project/Settings.settings | 7 + .../WinformExample/Person.vb | 4 + .../WinformExample/Statename.vb | 16 ++ .../WinformExample/Student.vb | 3 + .../WinformExample/TimerForm.Designer.vb | 82 +++++++ .../WinformExample/TimerForm.resx | 120 ++++++++++ .../WinformExample/TimerForm.vb | 63 ++++++ .../WinformExample/Week2.Designer.vb | 207 ++++++++++++++++++ .../WinformExample/Week2.resx | 126 +++++++++++ .../WinformExample/Week2.vb | 126 +++++++++++ .../WinformExample/WinformExample.vbproj | 139 ++++++++++++ COM350/WinForm | 1 - 20 files changed, 1256 insertions(+), 1 deletion(-) create mode 100644 COM350/ClassExamples/WinForm-04-01-2015/WinForm.sln create mode 100644 COM350/ClassExamples/WinForm-04-01-2015/WinformExample/App.config create mode 100644 COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/Application.Designer.vb create mode 100644 COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/Application.myapp create mode 100644 COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/AssemblyInfo.vb create mode 100644 COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/Resources.Designer.vb create mode 100644 COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/Resources.resx create mode 100644 COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/Settings.Designer.vb create mode 100644 COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/Settings.settings create mode 100644 COM350/ClassExamples/WinForm-04-01-2015/WinformExample/Person.vb create mode 100644 COM350/ClassExamples/WinForm-04-01-2015/WinformExample/Statename.vb create mode 100644 COM350/ClassExamples/WinForm-04-01-2015/WinformExample/Student.vb create mode 100644 COM350/ClassExamples/WinForm-04-01-2015/WinformExample/TimerForm.Designer.vb create mode 100644 COM350/ClassExamples/WinForm-04-01-2015/WinformExample/TimerForm.resx create mode 100644 COM350/ClassExamples/WinForm-04-01-2015/WinformExample/TimerForm.vb create mode 100644 COM350/ClassExamples/WinForm-04-01-2015/WinformExample/Week2.Designer.vb create mode 100644 COM350/ClassExamples/WinForm-04-01-2015/WinformExample/Week2.resx create mode 100644 COM350/ClassExamples/WinForm-04-01-2015/WinformExample/Week2.vb create mode 100644 COM350/ClassExamples/WinForm-04-01-2015/WinformExample/WinformExample.vbproj delete mode 160000 COM350/WinForm diff --git a/COM350/ClassExamples/WinForm-04-01-2015/WinForm.sln b/COM350/ClassExamples/WinForm-04-01-2015/WinForm.sln new file mode 100644 index 0000000..ca58700 --- /dev/null +++ b/COM350/ClassExamples/WinForm-04-01-2015/WinForm.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30723.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "WinformExample", "WinformExample\WinformExample.vbproj", "{25D1C422-EEE7-4325-91F5-824B6F89BC8C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {25D1C422-EEE7-4325-91F5-824B6F89BC8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {25D1C422-EEE7-4325-91F5-824B6F89BC8C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {25D1C422-EEE7-4325-91F5-824B6F89BC8C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {25D1C422-EEE7-4325-91F5-824B6F89BC8C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/App.config b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/App.config new file mode 100644 index 0000000..bc3672d --- /dev/null +++ b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/Application.Designer.vb b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/Application.Designer.vb new file mode 100644 index 0000000..e7de8d2 --- /dev/null +++ b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.34014 +' +' Changes 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.WinformExample.Week2 + End Sub + End Class +End Namespace diff --git a/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/Application.myapp b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/Application.myapp new file mode 100644 index 0000000..8e5443a --- /dev/null +++ b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + Week2 + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/AssemblyInfo.vb b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..3542752 --- /dev/null +++ b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/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/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/Resources.Designer.vb b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/Resources.Designer.vb new file mode 100644 index 0000000..b12b386 --- /dev/null +++ b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.34014 +' +' Changes 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("WinformExample.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/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/Resources.resx b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/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/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/Settings.Designer.vb b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/Settings.Designer.vb new file mode 100644 index 0000000..79b900f --- /dev/null +++ b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.34014 +' +' Changes 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.WinformExample.My.MySettings + Get + Return Global.WinformExample.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/Settings.settings b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/Person.vb b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/Person.vb new file mode 100644 index 0000000..6ac890f --- /dev/null +++ b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/Person.vb @@ -0,0 +1,4 @@ +Public Class Person + Public Property FirstName As String + Public Property LastName As String +End Class diff --git a/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/Statename.vb b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/Statename.vb new file mode 100644 index 0000000..3e81c3e --- /dev/null +++ b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/Statename.vb @@ -0,0 +1,16 @@ +Public Class Statename + + Public Property Abbreviation As String + Public Property Statename As String + + Public Sub New(abbr As String, state As String) + Abbreviation = abbr + Statename = state + End Sub + + Public Overrides Function ToString() As String + Return String.Format("{0} is the abbreviation for {1}", _ + Abbreviation, Statename) + End Function + +End Class diff --git a/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/Student.vb b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/Student.vb new file mode 100644 index 0000000..511810e --- /dev/null +++ b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/Student.vb @@ -0,0 +1,3 @@ +Public Class Student : Inherits Person + Public Property StudentId As String +End Class diff --git a/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/TimerForm.Designer.vb b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/TimerForm.Designer.vb new file mode 100644 index 0000000..b5565b6 --- /dev/null +++ b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/TimerForm.Designer.vb @@ -0,0 +1,82 @@ + _ +Partial Class TimerForm + 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.textboxImplicit = New System.Windows.Forms.TextBox() + Me.textboxExplicit = New System.Windows.Forms.TextBox() + Me.Label1 = New System.Windows.Forms.Label() + Me.Label2 = New System.Windows.Forms.Label() + Me.SuspendLayout() + ' + 'textboxImplicit + ' + Me.textboxImplicit.Location = New System.Drawing.Point(196, 39) + Me.textboxImplicit.Name = "textboxImplicit" + Me.textboxImplicit.Size = New System.Drawing.Size(100, 20) + Me.textboxImplicit.TabIndex = 0 + ' + 'textboxExplicit + ' + Me.textboxExplicit.Location = New System.Drawing.Point(196, 101) + Me.textboxExplicit.Name = "textboxExplicit" + Me.textboxExplicit.Size = New System.Drawing.Size(100, 20) + Me.textboxExplicit.TabIndex = 1 + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(54, 45) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(64, 13) + Me.Label1.TabIndex = 2 + Me.Label1.Text = "Explicit Cast" + ' + 'Label2 + ' + Me.Label2.AutoSize = True + Me.Label2.Location = New System.Drawing.Point(54, 104) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(63, 13) + Me.Label2.TabIndex = 3 + Me.Label2.Text = "Implicit Cast" + ' + 'TimerForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(353, 261) + Me.Controls.Add(Me.Label2) + Me.Controls.Add(Me.Label1) + Me.Controls.Add(Me.textboxExplicit) + Me.Controls.Add(Me.textboxImplicit) + Me.Name = "TimerForm" + Me.Text = "TimerForm" + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents textboxImplicit As System.Windows.Forms.TextBox + Friend WithEvents textboxExplicit As System.Windows.Forms.TextBox + Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents Label2 As System.Windows.Forms.Label +End Class diff --git a/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/TimerForm.resx b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/TimerForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/TimerForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/TimerForm.vb b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/TimerForm.vb new file mode 100644 index 0000000..f90eccd --- /dev/null +++ b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/TimerForm.vb @@ -0,0 +1,63 @@ +Public Class TimerForm + + Private executionTimer As New Stopwatch() + Private index As Integer + Private objVariable As Object + Private strVariable As String + Private dtVariable As DateTime + + ' Explict = 20.0916 + Private Sub TimerForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load + + textboxImplicit.Text = RunImplicit.ToString() + textboxExplicit.Text = RunExplicit.ToString() + + 'Dim myStudent As Student = New Student() + 'myStudent.FirstName = "Joe" + 'myStudent.LastName = "Smith" + 'Dim p As Person = DirectCast(myStudent, Person) + + 'Dim p As Object = New Person With {.FirstName = "Joe", .LastName = "Smith"} + 'Dim s As Student = CType(p, Student) + + + + + + End Sub + + Private Function RunImplicit() As Double + If objVariable Is Nothing Then + objVariable = New Object() + End If + executionTimer.Start() + + For i As Integer = 0 To 100000 + strVariable = "About Visual Basic" & Chr(i Mod 64) + dtVariable = #12/11/2012# + ' objVariable.AddSeconds(1) + Next + + executionTimer.Stop() + + Return executionTimer.Elapsed.TotalMilliseconds() + End Function + + Private Function RunExplicit() As Double + executionTimer.Start() + + For i As Integer = 0 To 100000 + objVariable = "About Visual Basic" & Chr(i Mod 64) + objVariable = #12/11/2012# + objVariable.AddSeconds(1) + Next + + executionTimer.Stop() + + Return executionTimer.Elapsed.TotalMilliseconds() + End Function + + Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click + + End Sub +End Class \ No newline at end of file diff --git a/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/Week2.Designer.vb b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/Week2.Designer.vb new file mode 100644 index 0000000..4fea52f --- /dev/null +++ b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/Week2.Designer.vb @@ -0,0 +1,207 @@ + _ +Partial Class Week2 + 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.fbdSelector = New System.Windows.Forms.FolderBrowserDialog() + Me.textboxStartingLocation = New System.Windows.Forms.TextBox() + Me.buttonLauncher = New System.Windows.Forms.Button() + Me.buttonWhatever = New System.Windows.Forms.Button() + Me.comboBoxColors = New System.Windows.Forms.ComboBox() + Me.comboBoxManual = New System.Windows.Forms.ComboBox() + Me.comboBoxGenerics = New System.Windows.Forms.ComboBox() + Me.comboBoxStates = New System.Windows.Forms.ComboBox() + Me.textboxIndex = New System.Windows.Forms.TextBox() + Me.textboxValue = New System.Windows.Forms.TextBox() + Me.MenuStrip1 = New System.Windows.Forms.MenuStrip() + Me.FileToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.NewToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.ToolStripSeparator1 = New System.Windows.Forms.ToolStripSeparator() + Me.ExitToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.EditToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.LaunchTimerToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.MenuStrip1.SuspendLayout() + Me.SuspendLayout() + ' + 'textboxStartingLocation + ' + Me.textboxStartingLocation.Location = New System.Drawing.Point(13, 28) + Me.textboxStartingLocation.Name = "textboxStartingLocation" + Me.textboxStartingLocation.Size = New System.Drawing.Size(258, 20) + Me.textboxStartingLocation.TabIndex = 0 + ' + 'buttonLauncher + ' + Me.buttonLauncher.Location = New System.Drawing.Point(404, 25) + Me.buttonLauncher.Name = "buttonLauncher" + Me.buttonLauncher.Size = New System.Drawing.Size(79, 23) + Me.buttonLauncher.TabIndex = 1 + Me.buttonLauncher.Text = "Launch" + Me.buttonLauncher.UseVisualStyleBackColor = True + ' + 'buttonWhatever + ' + Me.buttonWhatever.Location = New System.Drawing.Point(404, 72) + Me.buttonWhatever.Name = "buttonWhatever" + Me.buttonWhatever.Size = New System.Drawing.Size(79, 23) + Me.buttonWhatever.TabIndex = 2 + Me.buttonWhatever.Text = "Whatever" + Me.buttonWhatever.UseVisualStyleBackColor = True + ' + 'comboBoxColors + ' + Me.comboBoxColors.FormattingEnabled = True + Me.comboBoxColors.Items.AddRange(New Object() {"Red", "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet"}) + Me.comboBoxColors.Location = New System.Drawing.Point(13, 75) + Me.comboBoxColors.Name = "comboBoxColors" + Me.comboBoxColors.Size = New System.Drawing.Size(258, 21) + Me.comboBoxColors.TabIndex = 3 + ' + 'comboBoxManual + ' + Me.comboBoxManual.FormattingEnabled = True + Me.comboBoxManual.Location = New System.Drawing.Point(13, 119) + Me.comboBoxManual.Name = "comboBoxManual" + Me.comboBoxManual.Size = New System.Drawing.Size(258, 21) + Me.comboBoxManual.TabIndex = 4 + ' + 'comboBoxGenerics + ' + Me.comboBoxGenerics.FormattingEnabled = True + Me.comboBoxGenerics.Location = New System.Drawing.Point(13, 162) + Me.comboBoxGenerics.Name = "comboBoxGenerics" + Me.comboBoxGenerics.Size = New System.Drawing.Size(258, 21) + Me.comboBoxGenerics.TabIndex = 5 + ' + 'comboBoxStates + ' + Me.comboBoxStates.FormattingEnabled = True + Me.comboBoxStates.Location = New System.Drawing.Point(13, 211) + Me.comboBoxStates.Name = "comboBoxStates" + Me.comboBoxStates.Size = New System.Drawing.Size(258, 21) + Me.comboBoxStates.TabIndex = 6 + ' + 'textboxIndex + ' + Me.textboxIndex.Location = New System.Drawing.Point(277, 212) + Me.textboxIndex.Name = "textboxIndex" + Me.textboxIndex.Size = New System.Drawing.Size(76, 20) + Me.textboxIndex.TabIndex = 7 + ' + 'textboxValue + ' + Me.textboxValue.Location = New System.Drawing.Point(388, 212) + Me.textboxValue.Name = "textboxValue" + Me.textboxValue.Size = New System.Drawing.Size(76, 20) + Me.textboxValue.TabIndex = 8 + ' + 'MenuStrip1 + ' + Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.FileToolStripMenuItem, Me.EditToolStripMenuItem}) + Me.MenuStrip1.Location = New System.Drawing.Point(0, 0) + Me.MenuStrip1.Name = "MenuStrip1" + Me.MenuStrip1.Size = New System.Drawing.Size(539, 24) + Me.MenuStrip1.TabIndex = 9 + Me.MenuStrip1.Text = "MenuStrip1" + ' + 'FileToolStripMenuItem + ' + Me.FileToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.NewToolStripMenuItem, Me.ToolStripSeparator1, Me.ExitToolStripMenuItem}) + Me.FileToolStripMenuItem.Name = "FileToolStripMenuItem" + Me.FileToolStripMenuItem.Size = New System.Drawing.Size(37, 20) + Me.FileToolStripMenuItem.Text = "&File" + ' + 'NewToolStripMenuItem + ' + Me.NewToolStripMenuItem.Name = "NewToolStripMenuItem" + Me.NewToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.N), System.Windows.Forms.Keys) + Me.NewToolStripMenuItem.Size = New System.Drawing.Size(152, 22) + Me.NewToolStripMenuItem.Text = "&New" + ' + 'ToolStripSeparator1 + ' + Me.ToolStripSeparator1.Name = "ToolStripSeparator1" + Me.ToolStripSeparator1.Size = New System.Drawing.Size(149, 6) + ' + 'ExitToolStripMenuItem + ' + Me.ExitToolStripMenuItem.Name = "ExitToolStripMenuItem" + Me.ExitToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.F4), System.Windows.Forms.Keys) + Me.ExitToolStripMenuItem.Size = New System.Drawing.Size(152, 22) + Me.ExitToolStripMenuItem.Text = "E&xit" + ' + 'EditToolStripMenuItem + ' + Me.EditToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.LaunchTimerToolStripMenuItem}) + Me.EditToolStripMenuItem.Name = "EditToolStripMenuItem" + Me.EditToolStripMenuItem.Size = New System.Drawing.Size(39, 20) + Me.EditToolStripMenuItem.Text = "&Edit" + ' + 'LaunchTimerToolStripMenuItem + ' + Me.LaunchTimerToolStripMenuItem.Name = "LaunchTimerToolStripMenuItem" + Me.LaunchTimerToolStripMenuItem.Size = New System.Drawing.Size(152, 22) + Me.LaunchTimerToolStripMenuItem.Text = "&Launch Timer" + ' + 'Week2 + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(539, 282) + Me.Controls.Add(Me.textboxValue) + Me.Controls.Add(Me.textboxIndex) + Me.Controls.Add(Me.comboBoxStates) + Me.Controls.Add(Me.comboBoxGenerics) + Me.Controls.Add(Me.comboBoxManual) + Me.Controls.Add(Me.comboBoxColors) + Me.Controls.Add(Me.buttonWhatever) + Me.Controls.Add(Me.buttonLauncher) + Me.Controls.Add(Me.textboxStartingLocation) + Me.Controls.Add(Me.MenuStrip1) + Me.MainMenuStrip = Me.MenuStrip1 + Me.Name = "Week2" + Me.Text = "Form1" + Me.MenuStrip1.ResumeLayout(False) + Me.MenuStrip1.PerformLayout() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents fbdSelector As System.Windows.Forms.FolderBrowserDialog + Friend WithEvents textboxStartingLocation As System.Windows.Forms.TextBox + Friend WithEvents buttonLauncher As System.Windows.Forms.Button + Friend WithEvents buttonWhatever As System.Windows.Forms.Button + Friend WithEvents comboBoxColors As System.Windows.Forms.ComboBox + Friend WithEvents comboBoxManual As System.Windows.Forms.ComboBox + Friend WithEvents comboBoxGenerics As System.Windows.Forms.ComboBox + Friend WithEvents comboBoxStates As System.Windows.Forms.ComboBox + Friend WithEvents textboxIndex As System.Windows.Forms.TextBox + Friend WithEvents textboxValue As System.Windows.Forms.TextBox + Friend WithEvents MenuStrip1 As System.Windows.Forms.MenuStrip + Friend WithEvents FileToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Friend WithEvents NewToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Friend WithEvents ToolStripSeparator1 As System.Windows.Forms.ToolStripSeparator + Friend WithEvents ExitToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Friend WithEvents EditToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Friend WithEvents LaunchTimerToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + +End Class diff --git a/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/Week2.resx b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/Week2.resx new file mode 100644 index 0000000..683ee55 --- /dev/null +++ b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/Week2.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 131, 17 + + \ No newline at end of file diff --git a/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/Week2.vb b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/Week2.vb new file mode 100644 index 0000000..82d0d7c --- /dev/null +++ b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/Week2.vb @@ -0,0 +1,126 @@ +Public Class Week2 + + Public formHeight As Integer + Public startingLocation As String = String.Empty + + Private Sub buttonLauncher_Click(sender As Object, e As EventArgs) Handles buttonLauncher.Click + + If fbdSelector.ShowDialog() = Windows.Forms.DialogResult.OK Then + startingLocation = fbdSelector.SelectedPath + textboxStartingLocation.Text = startingLocation + End If + + End Sub + + Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load + Me.Text = "Week 2" + formHeight = Me.Height + + 'MessageBox.Show("The form height is: " & formHeight, "Caption", _ + ' MessageBoxButtons.OK, MessageBoxIcon.Information) + Dim startingYValue As Integer = formHeight - (23 + 45) + Dim defaultSize As Size = New Size(75, 23) + Dim buttonDynamic As Button = New Button() + buttonDynamic.Location = New Point(10, startingYValue) + buttonDynamic.Size = defaultSize + buttonDynamic.Text = "Dynamic" + buttonDynamic.Name = "buttonDynamic" + buttonDynamic.Visible = True + + Me.Controls.Add(buttonDynamic) + + comboBoxManual.Items.Add("Greenland") + comboBoxManual.Items.Add("Iceland") + comboBoxManual.Items.Add("Finland") + comboBoxManual.Items.Add("Ireland") + comboBoxManual.Items.Add("Poland") + comboBoxManual.Items.Add("England") + + Dim arrayOfStrings As String() = {"one", "two", "three", "four", "five"} + comboBoxGenerics.Items.Insert(0, "-- SELECT -- ") + comboBoxGenerics.DataSource = arrayOfStrings + + + comboBoxStates.DataSource = LoadStates() + comboBoxStates.DisplayMember = "StateName" + comboBoxStates.ValueMember = "StateAbbreviation" + + + End Sub + + Private Function LoadData() As String() + Return {"six", "seven", "eight", "nine", "ten"} + End Function + + Private Sub comboBoxStates_SelectedIndexChanged(sender As Object, e As EventArgs) Handles comboBoxStates.SelectedIndexChanged + + textboxIndex.Text = comboBoxStates.SelectedIndex.ToString() + Dim currentState As State = CType(comboBoxStates.SelectedItem, State) + ' Dim currentState As State = DirectCast(comboBoxStates.SelectedItem, State) + ' textboxValue.Text = currentState.StateAbbreviation + + End Sub + + Private Function LoadStates() As List(Of State) + Dim listOfStates As List(Of State) = New List(Of State)() + + listOfStates.Add(New State With { + .StateAbbreviation = "OH", + .StateName = "Ohio" + }) + listOfStates.Add(New State With { + .StateAbbreviation = "NY", + .StateName = "New York" + }) + listOfStates.Add(New State With { + .StateAbbreviation = "GA", + .StateName = "Georgia" + }) + listOfStates.Add(New State With { + .StateAbbreviation = "WY", + .StateName = "Wyoming" + }) + listOfStates.Add(New State With { + .StateAbbreviation = "HI", + .StateName = "Hawaii" + }) + + Return listOfStates + End Function + + Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click + Application.Exit() + End Sub + + Private Sub LaunchTimerToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LaunchTimerToolStripMenuItem.Click + Dim frmTimerForm As TimerForm = New TimerForm() + frmTimerForm.ShowDialog() + End Sub +End Class + +' Type, Data Type, Custom Type, Custom Class +Public Class State + +#Region "Members and Properties" + Private _stateAbbreviation As String + Public Property StateAbbreviation() As String + Get + Return _stateAbbreviation + End Get + Set(ByVal value As String) + _stateAbbreviation = value + End Set + End Property + + Private _stateName As String + Public Property StateName() As String + Get + Return _stateName + End Get + Set(ByVal value As String) + _stateName = value + End Set + End Property +#End Region + +End Class diff --git a/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/WinformExample.vbproj b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/WinformExample.vbproj new file mode 100644 index 0000000..c3894e8 --- /dev/null +++ b/COM350/ClassExamples/WinForm-04-01-2015/WinformExample/WinformExample.vbproj @@ -0,0 +1,139 @@ + + + + + Debug + AnyCPU + {25D1C422-EEE7-4325-91F5-824B6F89BC8C} + WinExe + WinformExample.My.MyApplication + WinformExample + WinformExample + 512 + WindowsForms + v4.5 + + + AnyCPU + true + full + true + true + bin\Debug\ + WinformExample.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + AnyCPU + pdbonly + false + true + true + bin\Release\ + WinformExample.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TimerForm.vb + + + Form + + + Form + + + Week2.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + TimerForm.vb + + + Week2.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/COM350/WinForm b/COM350/WinForm deleted file mode 160000 index 18f3193..0000000 --- a/COM350/WinForm +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 18f319396c32a5ec3f1d693949a4e199f5fe73dd