Copyright 2006 - Fab-Con Inc. (FabLab) By: Seth Eden Hollingsead 
Imports System
Imports System.IO
Imports System.Resources
Imports System.Collections
Imports System.Windows.Forms
Imports Microsoft.VisualBasic
Public Class FabLab
#Region "Varables"
'Global SS As AcadSelectionSet 'for selecting the walls
Dim Sel As AutoCAD.AcadSelectionSet
Dim ConfigHasBeenRun As Boolean = False

'Global File name for the current drawing, includes the full path.
'Might consider making this a property
Dim myFile As String = Nothing
'Status Flag to show if walls are hidden or showing
Dim WallsHidden As Boolean = False

'Dialog boxes
Dim About As New About
Dim AddRoofSegDlg As New AddRoofSegDlg
Dim RemRoofSegDlg As New RemRoofSegDlg
Dim PathOverrideSelectTool As New PathOverRideSelect

'The width and height for the main window
Dim WinHeight As Double = 0.0
Dim WinWidth As Double = 0.0

'Texture tool
Dim TexTool As New Textures
'Configuration stuff for FabLab Close and Save settings
Dim FabLabCfgTool As New FabLabConfig
#End Region
#Region "Properties"
'Listbox control, need to make sure we have this
Public _ListBoxTool As New ListBoxCtrl
'Sidewalk Listbox control
Public _SidewalkListBoxTool As New SidewalkListCtrl
'Landscape Listbox control
Public _LandscapeListBoxTool As New LandscapeListCtrl
'Custom Views Listbox control
Public _CustomViewsListBoxTool As New CustomViewsListBoxCtrl
'ParkingLot Listbox control
Public _ParkingLotListBoxTool As New ParkingLotSegListboxCtrl
'Application Path
Public _ApplicationPath As String
'Current File Path
Public _DrawingPath As String
'Current Drawing Document Object
Public _MyDoc As AutoCAD.AcadDocument

'Listbox control property
Public Property ListBoxTool() As ListBoxCtrl
Get
Return _ListBoxTool
End Get
Set(ByVal value As ListBoxCtrl)
_ListBoxTool = value
'Make sure to initialize the class varable with the form listbox
ListBoxTool.Initialize(RoofSegList)
End Set
End Property

'Sidewalk Listbox control property
Public Property SidewalkListBoxTool() As SidewalkListCtrl
Get
Return _SidewalkListBoxTool
End Get
Set(ByVal value As SidewalkListCtrl)
_SidewalkListBoxTool = value
'Make sure to initialize the class varable with the form listbox
SidewalkListBoxTool.Initialize(SidewalkSegList)
End Set
End Property

'Landscape Listbox control property
Public Property LandscapeListBoxTool() As LandscapeListCtrl
Get
Return _LandscapeListBoxTool
End Get
Set(ByVal value As LandscapeListCtrl)
_LandscapeListBoxTool = value
'Make sure to initialize the class varable with the form listbox
LandscapeListBoxTool.Initialize(LandscapeListBox)
End Set
End Property

'CustomView Listbox control property
Public Property CustomViewsListBoxTool() As CustomViewsListBoxCtrl
Get
Return _CustomViewsListBoxTool
End Get
Set(ByVal value As CustomViewsListBoxCtrl)
_CustomViewsListBoxTool = value
'Make sure to initialize the class varable with the form listbox
CustomViewsListBoxTool.InitializeViews(CustViewsListBox)
End Set
End Property

'ParkingLot Listbox control property
Public Property ParkingLotListBoxTool() As ParkingLotSegListboxCtrl
Get
Return _ParkingLotListBoxTool
End Get
Set(ByVal value As ParkingLotSegListboxCtrl)
_ParkingLotListBoxTool = value
'Make sure to initialize the class varable with the form listbox
ParkingLotListBoxTool.Initialize(ParkingSegListbox)
End Set
End Property

'Application Path
Public Property ApplicationPath() As String
Get
Return _ApplicationPath
End Get
Set(ByVal value As String)
_ApplicationPath = value
End Set
End Property

'Drawing Path
Public Property DrawingPath() As String
Get
Return _DrawingPath
End Get
Set(ByVal value As String)
_DrawingPath = value
End Set
End Property

'Current Drawing Object
Public Property MyDoc() As AutoCAD.AcadDocument
Get
Return _MyDoc
End Get
Set(ByVal value As AutoCAD.AcadDocument)
_MyDoc = value
End Set
End Property

'Selection tool for working directly with the AutoCAD interface through the acRender class
Dim SelTool As New acRender
'Visability tool for controlling object visibility within AutoCAD
Dim VisTool As New FabLabObjSetVis
'Render tool object for working with the FabRender Class to control rendering options in AutoCAD
Dim RendTool As New FabRender
'Tool for accessing backend functions of the application
Dim MyAppTool As New FabLabBackend
'Tool for accessing backend functions for the windowsNDoors class for managing data elements in the WinDoorsTable
Dim WinDoorTool As New WindowsNDoorsTable
'Tool for working with Bands
Dim FinishTool As New Finishes
'Tool for working with Sidewalks
Dim SidewalkTool As New SidewalkSeg
'Tool for working with Landscape Items
Dim LandscapeTool As New LandscapeListCtrl
'Tool for working with Custom Views
Dim CustomViewsTool As New CustomViewsListBoxCtrl
'Tool for working with Parking Lots
Dim ParkingLotTool As New ParkingLotSegListboxCtrl
#End Region
#Region "Application Subs"
'Initialization function for this entire program.
'This is the first thing that gets executed before any user input can happen.
'************************************************************************************************
'IMPORTANT!!!!!!!!!!!!!
'BEGIN APPLICATION SUBS
'************************************************************************************************
Private Sub FabLab_Load(ByVal sender As System.ObjectByVal e As System.EventArgsHandles MyBase.Load
  FabLabInit(RoofSegListSidewalkSegListLandscapeListBoxCustViewsListBoxParkingSegListbox)
End Sub

'to make GUI changes, must disable the call to this in the VB Designer Code Fab-Lab Class Initialization
Sub FabLabInit(ByVal MyListBox As ListBoxByVal MySidewalkListBox As ListBoxByVal MyLandscapeListBox As ListBox_
    ByVal MyCustViewsListBox As ListBoxByVal ParkingSegListbox As ListBox)
  Dim ListBoxTool As New ListBoxCtrl
  Dim SidewalkListBoxTool As New SidewalkListCtrl
  Dim LandscapeListBoxTool As New LandscapeListCtrl
  Dim CustomViewsListBoxTool As New CustomViewsListBoxCtrl
  Me._ListBoxTool = ListBoxTool
  Me._SidewalkListBoxTool = SidewalkListBoxTool
  Me._LandscapeListBoxTool = LandscapeListBoxTool
  Me._CustomViewsListBoxTool = CustomViewsListBoxTool
  Me._ListBoxTool.Initialize(MyListBox)
  Me._SidewalkListBoxTool.Initialize(MySidewalkListBox)
  Me._LandscapeListBoxTool.Initialize(MyLandscapeListBox)
  'Me._LandscapeListBoxTool.InitializeLandscapeLayer()
  Me._CustomViewsListBoxTool.InitializeViews(MyCustViewsListBox)
  Me._ParkingLotListBoxTool.Initialize(ParkingSegListbox)

  'PreConfigure AutoCAD Automatically
  'Add the layers necessary
  If SelTool.AcadHasWindowActive() = True Then
    SelTool.LoadAutoCAD()
    'need to determine if there are wall objects in the drawing
    Dim MyIterator As Integer = 0
    MyIterator = SelTool.NumOfWalls()
    If MyIterator > 0 AndAlso ConfigHasBeenRun = False AndAlso ConfigHasBeenRun = Nothing Then
      MyAppTool.PreConfigAutoCAD()
      'Make the sidewalk layer as well
      SidewalkTool.MakeSidewalkLayers()
      ParkingLotTool.InitializeParkingLotLayers()
      LandscapeTool.InitializeLandscapeLayer()
      ConfigHasBeenRun = True
    End If
    'End configuration
  End If
  'End Active Document check
  'Set all the default GUI buttons to disabled as appropriate
  PickAndBuildSeg.Enabled = False
  SidewalkBuilder.Enabled = False
  FiltRad.Enabled = False
  SidewalkElevationTextBox.Enabled = False
  AutoApplyTex.Enabled = False

  'All of this stuff needs to be handled in the PathOverRideSelect class
  Me._ApplicationPath = PathOverrideSelectTool.AutoCorrectPath(Application.StartupPath.ToString())
  'Save the installed path for the user controlled path system
  PathOverrideSelectTool._FabLabInstallPath = Me._ApplicationPath
  PathOverrideSelectTool.AddPath("FabLabInstallPath"Me._ApplicationPath)
  'make sure the revert is set to false.
  PathOverrideSelectTool.InitRevert()
  CloseBuildingFile.Enabled = False
  'need to save the Windows and Doors Class objects so we can work with them from the FabLabBackend Class.
  MyAppTool._WinDoorTool._SquareWinTextBox = SquareWinTextBox
  MyAppTool._WinDoorTool._SquareWindowPic = SquareWindowPic
  MyAppTool._WinDoorTool._HorzWinTextBox = HorzWinTextBox
  MyAppTool._WinDoorTool._HorzWinPic = HorzWinPic
  MyAppTool._WinDoorTool._VertWinTextBox = VertWinTextBox
  MyAppTool._WinDoorTool._VertWinPic = VertWinPic
  MyAppTool._WinDoorTool._DockDoorTextBox = DockDoorTextBox
  MyAppTool._WinDoorTool._DockDoorPic = DockDoorPic
  MyAppTool._WinDoorTool._GarageDoorTextBox = GarageTextBox
  MyAppTool._WinDoorTool._GarageDoorPic = GaragePic
  MyAppTool._WinDoorTool._FireDoorTextBox = FireDoorTextBox
  MyAppTool._WinDoorTool._FireDoorPic = FireDoorPic
  MyAppTool._WinDoorTool._SecDoor1TextBox = SecDoor1TextBox
  MyAppTool._WinDoorTool._SecDoor1Pic = SecDoor1Pic
  MyAppTool._WinDoorTool._SecDoor2TextBox = SecDoor2TextBox
  MyAppTool._WinDoorTool._SecDoor2Pic = SecDoor2Pic
  MyAppTool._WinDoorTool._GlassDoorTextBox = GlassDoorTextBox
  MyAppTool._WinDoorTool._GlassDoorPic = GlassDoorPic
  MyAppTool._WinDoorTool._DoubleDoorsTextBox = DoubleDoorsTextBox
  MyAppTool._WinDoorTool._DoubleDoorsPic = DoubleDoorsPic

  MyAppTool._ShrubsNTreesTool._ShrubTextBox = ShrubDescription
  MyAppTool._ShrubsNTreesTool._ShrubPic = ShrubPic
  MyAppTool._ShrubsNTreesTool._DawnRedwoodTextBox = DawnRedwoodDescription
  MyAppTool._ShrubsNTreesTool._DawnRedwoodPic = DawnRedwoodPic
  MyAppTool._ShrubsNTreesTool._EasternPalmTextBox = EasternPalmDescription
  MyAppTool._ShrubsNTreesTool._EasternPalmPic = EasternPalmPic
  MyAppTool._ShrubsNTreesTool._NorwayMapleFallTextBox = NorwayMapleFallDescription
  MyAppTool._ShrubsNTreesTool._NorwayMapleFallPic = NorwayMapleFallPic
  MyAppTool._ShrubsNTreesTool._QuakingAspenTextBox = QuakingAspenDescription
  MyAppTool._ShrubsNTreesTool._QuakingAspenPic = QuakingAspenPic
  MyAppTool._ShrubsNTreesTool._SweetgumSummerTextBox = SweetgumSummerDescription
  MyAppTool._ShrubsNTreesTool._SweetgumSummerPic = SweetgumSummerPic
  Me.Activate()
End Sub

'The FabLab application is closing...We need to do some house keeping on the Combo Box Control and the FabLabINI.resx File
'the path representing the current drawing needs to be removed. Unless it is user defined of course, in which case it won't
'matter because we just won't even check for that.
'**************************************************************************************************************************
'This is the important deciding factor, if the default is set to the current folder then how should it be handled?
'Do we leave it and always set the default to the current drawing file? Or do we revert back to the current application path?
'Maybe I will implement both systems and set a config option on the config tab, that way the user can decide which
'type of behavior they want when the application is closed to save the option of outputing to the drawing folder each time
'Or to revert each time. We still don't have a meeting set, and I still don't have any additional finishes to work on.
'So I think I will play with this option for awhile, esspecially if I can get just one of them implemented.
Private Sub FabLab_FormClosing(ByVal sender As ObjectByVal e As System.Windows.Forms.FormClosingEventArgs_
    Handles Me.FormClosing
  'Need to check the empty string as it might not be set when it's first installed.
  If FabLabCfgTool.GetExitSetting() = "True" OrElse FabLabCfgTool.GetExitSetting() = "" Then
    ExitFabLab.ShowDialog()
    'Need to check and see if the check box in the dialog box was set. If it was then we need to adjust some
    'settings
    If ExitFabLab.ExitCheckBox.Checked = True Then
      'Save the setting that it should not display again, unless the setting is adjusted else were.
      FabLabCfgTool.SetExitSetting("False")
    End If
  End If
  If ExitFabLab.DialogResult = Windows.Forms.DialogResult.Cancel AndAlso FabLabCfgTool.GetExitSetting() = "False" AndAlso _
      ExitFabLab.ExitCheckBox.Checked = True Then
    Exit Sub                           'Just get out of here, and close the damned program! The user won't care in this case!
  End If
  If ExitFabLab.DialogResult = Windows.Forms.DialogResult.Cancel Then
    e.Cancel = True                    'The user has decided not to close
  End If
End Sub

'The user has selected yes to close, and we are definately going to close at this point.
Private Sub FabLab_FormClosed(ByVal sender As ObjectByVal e As System.Windows.Forms.FormClosedEventArgs_
    Handles Me.FormClosed
  'first check to see if there really as an active document
  If Me._MyDoc IsNot Nothing Then
    'Get the setting from the resx file to determine if we even show the dialog box.
    'Need to check the empty string as it might not be set when it's first installed.
    If FabLabCfgTool.GetCloseDWGSetting() = "True" OrElse FabLabCfgTool.GetCloseDWGSetting() = "" Then
      CloseDWG.ShowDialog()
      'Need to check and see if the check box in the dialog box was set. If it was then we need to adjust some
      'settings
      If CloseDWG.CloseDWGCheckBox.Checked = True Then
        'Save the setting that it should not display again, unless the setting is adjusted else were.
        FabLabCfgTool.SetCloseDWGSetting("False")
      End If
      If CloseDWG.DialogResult = Windows.Forms.DialogResult.OK Then
        'We know the user has selected "OK", and we should save that setting to the resx file.
        FabLabCfgTool.SetCloseDWGControl("True")
      ElseIf CloseDWG.DialogResult = Windows.Forms.DialogResult.Cancel Then
        'We know the user has selected "Cancel", and we should save that setting to the resx file.
        FabLabCfgTool.SetCloseDWGControl("False")
      End If
    ElseIf FabLabCfgTool.GetCloseDWGSetting = "False" Then
      'Otherwise the setting shows that we don't even show the dialog box. So we therefore need to determind
      'What the default should be, according to what the user set the last time they did make a selection from
      'that CloseDWG dialog box.
      If FabLabCfgTool.GetCloseDWGControl = "True" OrElse FabLabCfgTool.GetCloseDWGControl = "" Then
        'Make sure to test for the empty string because it could be nothing after just being installed
        'Case that the user selected ok last time they made a selection from the CloseDWG dialog box
        CloseDWG.DialogResult = Windows.Forms.DialogResult.OK
      ElseIf FabLabCfgTool.GetCloseDWGControl = "False" Then
        'Case that the user selected no last time they made a selection from the CloseDWG dialog box
        CloseDWG.DialogResult = Windows.Forms.DialogResult.Cancel
      End If
    End If
  End If
  If CloseDWG.DialogResult = Windows.Forms.DialogResult.OK Then
    If ConfigHasBeenRun = True Then
      'Still have to check for the empty string as it could be empty from a fresh install.
      If FabLabCfgTool.GetSaveDWGSetting() = "True" OrElse FabLabCfgTool.GetSaveDWGSetting() = "" Then
        If Me._MyDoc IsNot Nothing Then
          SaveChanges.ShowDialog()
        End If
        'Need to check and see if the check box in the dialog box was set. If it was then we need to adjust some
        'settings
        If SaveChanges.SaveChangesCheckBox.Checked = True Then
          'Save the setting that it should not display again, unless the setting is adjusted else were.
          FabLabCfgTool.SetSaveDWGSetting("False")
        End If
        If SaveChanges.DialogResult = Windows.Forms.DialogResult.OK Then
          'We know the user has selected "OK", and we should save that setting to the resx file.
          FabLabCfgTool.SetSaveDWGControl("True")
        ElseIf SaveChanges.DialogResult = Windows.Forms.DialogResult.Cancel Then
          'We know the user has selected "Cancel", and we should save that setting to the resx file.
          FabLabCfgTool.SetSaveDWGControl("False")
        End If
      ElseIf FabLabCfgTool.GetSaveDWGSetting() = "False" Then
        'This is the case that the setting has been set so that we don't need to display the SaveChanges
        'Dialog box. So we just need to determine what the user selected the last time
        'this dialog box was run.
        If FabLabCfgTool.GetSaveDWGControl() = "True" OrElse FabLabCfgTool.GetSaveDWGControl() = "" Then
          'Still need to check for the empty string just incase this is a fresh install.
          'this is the case that the user selected OK the last time the SaveChanges Dialog box was run.
          SaveChanges.DialogResult = Windows.Forms.DialogResult.OK
        ElseIf FabLabCfgTool.GetSaveDWGControl() = "False" Then
          'This is the case that the user selected Cancel the last time the SaveChanges Dialog box was run.
          SaveChanges.DialogResult = Windows.Forms.DialogResult.Cancel
        End If
      End If
      If SaveChanges.DialogResult = Windows.Forms.DialogResult.Cancel Then
        Try
        If Me._MyDoc IsNot Nothing Then
          Me._MyDoc.Close(False)       'Don't bother to save it, just exit
        End If
        'Otherwise there isn't anything to do, because it doesn't even exist.
        Catch ex As Exception
        MsgBox("Error Saving the file! Your Data will be lost!"MsgBoxStyle.Critical"FabLab File Error")
        End Try
      ElseIf SaveChanges.DialogResult = Windows.Forms.DialogResult.OK Then
        Try
        Me._MyDoc.Close(True)          'Save the file and exit
        Catch ex As Exception
        MsgBox("Error Saving the file! Your Data will be lost!"MsgBoxStyle.Critical"FabLab File Error")
        End Try
        Exit Sub
      End If
    Else
      Try
      Me._MyDoc.Close(False)           'Don't bother to save it, just exit
      Catch ex As Exception
      MsgBox("Error Saving the file! Your Data will be lost!"MsgBoxStyle.Critical"FabLab File Error")
      End Try
    End If
  End If
  'Call the FabLabConfig.resx file again to determin if we are supposed to even show this dialog box.
  'Need to check the empty string incase it's empty after it was just installed.
  If FabLabCfgTool.GetCloseACADSetting() = "True" OrElse FabLabCfgTool.GetCloseACADSetting = "" Then
    CloseAutoCAD.ShowDialog()
    'Need to check and see if the check box in the dialog box was set. If it was then we need to adjust some
    'settings
    If CloseAutoCAD.CloseACADCheckBox.Checked = True Then
      'Save the setting that it should not display again, unless the setting is adjusted else were.
      FabLabCfgTool.SetCloseACADSetting("False")
    End If
    If CloseAutoCAD.DialogResult = Windows.Forms.DialogResult.OK Then
      'We know the user has selected "OK", and we should save that setting to the resx file.
      FabLabCfgTool.SetCloseACADControl("True")
    ElseIf CloseAutoCAD.DialogResult = Windows.Forms.DialogResult.Cancel Then
      'We know the user has selected "Cancel", and we should save that setting to the resx file.
      FabLabCfgTool.SetCloseACADControl("True")
    End If
  ElseIf FabLabCfgTool.GetCloseACADSetting() = "False" Then
    'Here the setting file says we are not even showing the dialog box, so we need to determine what the user
    'clicked as a response the last time they did make a selection from this dialog box.
    If FabLabCfgTool.GetCloseACADControl() = "True" OrElse FabLabCfgTool.GetCloseACADControl() = "" Then
      'Make sure to test for that empty string again as it could be nothing after a fresh install.
      'This is the case that the user selected Yes last time the user made a selection from this dialog box.
      CloseAutoCAD.DialogResult = Windows.Forms.DialogResult.OK
      'In this case AutoCAD will automatically close
    ElseIf FabLabCfgTool.GetCloseACADControl() = "False" Then
      'This is the case that the user selected no last time the user made a selection from this dialog box.
      CloseAutoCAD.DialogResult = Windows.Forms.DialogResult.Cancel
      'In this case AutoCAD will automatically stay open
    End If
  Else
  End If
  If CloseAutoCAD.DialogResult = Windows.Forms.DialogResult.OK Then
    SelTool.LoadAutoCAD()
    SelTool.AcadApp.Application.Quit()
  End If
  PathOverrideSelectTool.RemDrawingPath()
End Sub
'************************************************************************************************
'IMPORTANT!!!!!!!!!!!!!
'END APPLICATION SUBS
'************************************************************************************************
#End Region
#Region "Menu Controls"
'************************************************************************************************
'BEGIN MENU CONTROLS
'************************************************************************************************
'Main menu, File
Private Sub FileToolStripMenuItem_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles FileToolStripMenuItem.Click
  If UserPathToolStripMenuItem.Checked = True Then
    SetRenderOutputPathToolStripMenuItem.Enabled = True
  ElseIf UserPathToolStripMenuItem.Checked = False Then
    SetRenderOutputPathToolStripMenuItem.Enabled = False
  End If
End Sub

'User has Selected to Enable the User Defined Path from the menu
Private Sub UserPathToolStripMenuItem_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles UserPathToolStripMenuItem.Click
  If UserPathToolStripMenuItem.Checked = True Then
    SetRenderOutputPathToolStripMenuItem.Enabled = True
    RenderPathOverride.Enabled = True
    EnablePath.Checked = True
  ElseIf UserPathToolStripMenuItem.Checked = False Then
    SetRenderOutputPathToolStripMenuItem.Enabled = False
    RenderPathOverride.Enabled = False
    EnablePath.Checked = False
  ElseIf EnablePath.Checked = False Then
    SetRenderOutputPathToolStripMenuItem.Enabled = False
    RenderPathOverride.Enabled = False
    UserPathToolStripMenuItem.Checked = False
  End If
End Sub

'User selected Exit from the Menu Control, All the closing/saving/exit dialog boxes are called after after this sub.
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles ExitToolStripMenuItem.Click
  Me.Close()
End Sub

'User selected PathOverRide from the Menu
Private Sub SetRenderOutputPathToolStripMenuItem_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles SetRenderOutputPathToolStripMenuItem.Click
  'here we change the path to what the user selects.
  'need a dialog box to select just the path, similar to the folder loader in winamp.
  PathOverrideSelectTool.ShowDialog()
End Sub

'User is looking at the menu option for the save/close/exit settings, need to load them from the resx file,
'and check the ones that should be checked, ect...
Private Sub SaveCloseOptionsToolStripMenuItem_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles SaveCloseOptionsToolStripMenuItem.Click
  If FabLabCfgTool.GetCloseDWGSetting() = "True" Then
    AskForClosingDWGToolStripMenuItem.Checked = True
  ElseIf FabLabCfgTool.GetCloseDWGSetting() = "False" Then
    AskForClosingDWGToolStripMenuItem.Checked = False
  Else
    AskForClosingDWGToolStripMenuItem.Checked = False
  End If
  If FabLabCfgTool.GetSaveDWGSetting() = "True" Then
    AskForSavingDWGToolStripMenuItem.Checked = True
  ElseIf FabLabCfgTool.GetSaveDWGSetting() = "False" Then
    AskForSavingDWGToolStripMenuItem.Checked = False
  Else
    AskForSavingDWGToolStripMenuItem.Checked = False
  End If
  If FabLabCfgTool.GetCloseACADSetting() = "True" Then
    AskForClosingAutoCADToolStripMenuItem.Checked = True
  ElseIf FabLabCfgTool.GetCloseACADSetting() = "False" Then
    AskForClosingAutoCADToolStripMenuItem.Checked = False
  Else
    AskForClosingAutoCADToolStripMenuItem.Checked = False
  End If
  If FabLabCfgTool.GetExitSetting() = "True" Then
    AskForExitToolStripMenuItem.Checked = True
  ElseIf FabLabCfgTool.GetExitSetting() = "False" Then
    AskForExitToolStripMenuItem.Checked = False
  Else
    AskForExitToolStripMenuItem.Checked = False
  End If
  If FabLabCfgTool.GetSaveDWGControl() = "True" Then
    AlwaysSaveOnCloseToolStripMenuItem.Checked = True
  ElseIf FabLabCfgTool.GetSaveDWGControl() = "False" Then
    AlwaysSaveOnCloseToolStripMenuItem.Checked = False
  Else
    AlwaysSaveOnCloseToolStripMenuItem.Checked = False
  End If
  If FabLabCfgTool.GetCloseACADControl() = "True" Then
    AlwaysCloseAutoCADOnExitToolStripMenuItem.Checked = True
  ElseIf FabLabCfgTool.GetCloseACADControl() = "False" Then
    AlwaysCloseAutoCADOnExitToolStripMenuItem.Checked = False
  Else
    AlwaysCloseAutoCADOnExitToolStripMenuItem.Checked = False
  End If
  If FabLabCfgTool.GetCloseDWGControl() = "True" Then
    AlwaysCloseDWGToolStripMenuItem.Checked = True
  ElseIf FabLabCfgTool.GetCloseDWGControl() = "Faslse" Then
    AlwaysCloseDWGToolStripMenuItem.Checked = False
  Else
    AlwaysCloseDWGToolStripMenuItem.Checked = False
  End If
End Sub

'User has selected the menu item for resetting all the save/close/exit settings
Private Sub ResetOptionsToolStripMenuItem_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles ResetOptionsToolStripMenuItem.Click
  FabLabCfgTool.ResetAllSettings()
End Sub

'User has selected the menu item for clearing all the save/close/exit settings
Private Sub ClearAllOptions_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles ClearAllOptions.Click
  FabLabCfgTool.ClearAllSettings()
End Sub

'User toggeled the AskForClosingDWG menu item
Private Sub AskForClosingDWGToolStripMenuItem_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles AskForClosingDWGToolStripMenuItem.Click
  If AskForClosingDWGToolStripMenuItem.Checked = False Then
    FabLabCfgTool.SetCloseDWGSetting("True")
    AskForClosingDWGToolStripMenuItem.Checked = True
  ElseIf AskForClosingDWGToolStripMenuItem.Checked = True Then
    FabLabCfgTool.SetCloseDWGSetting("False")
    AskForClosingDWGToolStripMenuItem.Checked = False
  End If
End Sub

'User toggeled the AskForSavingDWG menu item
Private Sub AskForSavingDWGToolStripMenuItem_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles AskForSavingDWGToolStripMenuItem.Click
  If AskForSavingDWGToolStripMenuItem.Checked = False Then
    FabLabCfgTool.SetSaveDWGSetting("True")
    AskForSavingDWGToolStripMenuItem.Checked = True
  ElseIf AskForSavingDWGToolStripMenuItem.Checked = True Then
    FabLabCfgTool.SetSaveDWGSetting("False")
    AskForSavingDWGToolStripMenuItem.Checked = False
  End If
End Sub

'User toggeled the AskForClosingAutoCAD menu time
Private Sub AskForClosingAutoCADToolStripMenuItem_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles AskForClosingAutoCADToolStripMenuItem.Click
  If AskForClosingAutoCADToolStripMenuItem.Checked = False Then
    FabLabCfgTool.SetCloseACADSetting("True")
    AskForClosingAutoCADToolStripMenuItem.Checked = True
  ElseIf AskForClosingAutoCADToolStripMenuItem.Checked = True Then
    FabLabCfgTool.SetCloseACADSetting("False")
    AskForClosingAutoCADToolStripMenuItem.Checked = False
  End If
End Sub

'User toggeled the AskForExit menu item
Private Sub AskForExitToolStripMenuItem_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles AskForExitToolStripMenuItem.Click
  If AskForExitToolStripMenuItem.Checked = False Then
    FabLabCfgTool.SetExitSetting("True")
    AskForExitToolStripMenuItem.Checked = True
  ElseIf AskForExitToolStripMenuItem.Checked = True Then
    FabLabCfgTool.SetExitSetting("False")
    AskForExitToolStripMenuItem.Checked = False
  End If
End Sub

'User toggeled the AlwaysSaveOnClose menu item
Private Sub AlwaysSaveOnCloseToolStripMenuItem_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles AlwaysSaveOnCloseToolStripMenuItem.Click
  If AlwaysSaveOnCloseToolStripMenuItem.Checked = False Then
    FabLabCfgTool.SetSaveDWGControl("True")
    AlwaysSaveOnCloseToolStripMenuItem.Checked = True
  ElseIf AlwaysSaveOnCloseToolStripMenuItem.Checked = True Then
    FabLabCfgTool.SetSaveDWGControl("False")
    AlwaysSaveOnCloseToolStripMenuItem.Checked = False
  End If
End Sub

'User toggeled the AlwayscloseAutoCADOnExit menu item
Private Sub AlwaysCloseAutoCADOnExitToolStripMenuItem_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles AlwaysCloseAutoCADOnExitToolStripMenuItem.Click
  If AlwaysCloseAutoCADOnExitToolStripMenuItem.Checked = False Then
    FabLabCfgTool.SetCloseACADControl("True")
    AlwaysCloseAutoCADOnExitToolStripMenuItem.Checked = True
  ElseIf AlwaysCloseAutoCADOnExitToolStripMenuItem.Checked = True Then
    FabLabCfgTool.SetCloseACADControl("False")
    AlwaysCloseAutoCADOnExitToolStripMenuItem.Checked = False
  End If
End Sub

'User toggeled the AlwaysCloseDWG menu item
Private Sub AlwaysCloseDWGToolStripMenuItem_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles AlwaysCloseDWGToolStripMenuItem.Click
  If AlwaysCloseDWGToolStripMenuItem.Checked = False Then
    FabLabCfgTool.SetCloseDWGControl("True")
    AlwaysCloseDWGToolStripMenuItem.Checked = True
  ElseIf AlwaysCloseDWGToolStripMenuItem.Checked = True Then
    FabLabCfgTool.SetCloseDWGControl("False")
    AlwaysCloseDWGToolStripMenuItem.Checked = False
  End If
End Sub

'User has selected to open a drawing file from the menu. Same as the Load Building button
Private Sub OpenADrawingToolStripMenuItem_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles OpenADrawingToolStripMenuItem.Click
  Dim DefaultPath As String
  DefaultPath = PathOverrideSelectTool._CurSelPath
  If DefaultPath IsNot Nothing Then
    'Just need to swap the folder slashes around
    DefaultPath = PathOverrideSelectTool.ReverseSlashes(DefaultPath)
  Else
    DefaultPath = "C:/"
  End If
  MyAppTool.OpenBuildingFile(Me._MyDocmyFileMe._DrawingPathDefaultPathMeWinHeightWinWidth)
  If Me._MyDoc IsNot Nothing Then
    CloseBuildingFile.Enabled = True   'Enable the close drawing button.
    ConfigHasBeenRun = True
  End If
  Me.Activate()
End Sub

'User has selected to close the current drawing file from the menu. Sas as the Close Building Button
Private Sub CloseTheDrawingToolStripMenuItem_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles CloseTheDrawingToolStripMenuItem.Click
  MyAppTool.CloseBuildingFile(Me._MyDocConfigHasBeenRun)
  Me._ListBoxTool.ClearAllRoofList(Sel)
  Me._SidewalkListBoxTool.ClearAllSidewalkList(Sel)
  RoofObjHeight.Text = ""
  SidewalkElevationTextBox.Text = ""
  RoofObjHeight.Enabled = False
  SidewalkElevationTextBox.Enabled = False
  CloseBuildingFile.Enabled = False    'Disable the close drawing button.
End Sub

'Menu Control -> About
Private Sub AboutFabLabToolStripMenuItem_Click_1(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles AboutFabLabToolStripMenuItem.Click
  About.ShowDialog()
End Sub
'************************************************************************************************
'END MENU CONTROLS
'************************************************************************************************
#End Region
#Region "Application Subs"
'************************************************************************************************
'BEGIN MAIN BUTTONS
'************************************************************************************************
'Shrink Window
Private Sub ShrinkFabLab_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles ShrinkFabLab.Click
  If Me.Size.Height <> 58 Then
    WinHeight = Me.Size.Height
    WinWidth = Me.Size.Width
    Me.Size = New Size(Me.Size.Width58)
    Me.WindowState = FormWindowState.Normal
    Me.Update()
  End If
End Sub

'Expand Window
Private Sub ExpandFabLab_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles ExpandFabLab.Click
  If WinWidth <> 0.0 AndAlso WinHeight <> 0.0 Then
    Me.Size = New Size(WinWidthWinHeight)
    Me.WindowState = FormWindowState.Normal
    Me.Update()
  End If
End Sub

'User has checked the checkbox to enable the User Defined Path
Private Sub EnablePath_CheckedChanged(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles EnablePath.CheckedChanged
  If EnablePath.Checked = True Then
    SetRenderOutputPathToolStripMenuItem.Enabled = True
    RenderPathOverride.Enabled = True
    UserPathToolStripMenuItem.Checked = True
  ElseIf UserPathToolStripMenuItem.Checked = False Then
    SetRenderOutputPathToolStripMenuItem.Enabled = False
    RenderPathOverride.Enabled = False
    EnablePath.Checked = False
  ElseIf EnablePath.Checked = False Then
    SetRenderOutputPathToolStripMenuItem.Enabled = False
    RenderPathOverride.Enabled = False
    UserPathToolStripMenuItem.Checked = False
  End If
End Sub

'Load the File into AutoCAD
Private Sub LoadBuilding_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles LoadBuilding.Click
  Dim DefaultPath As String
  DefaultPath = PathOverrideSelectTool._CurSelPath
  If DefaultPath IsNot Nothing Then
    'Just need to swap the folder slashes around
    DefaultPath = PathOverrideSelectTool.ReverseSlashes(DefaultPath)
  Else
    DefaultPath = "C:/"
  End If
  MyAppTool.OpenBuildingFile(Me._MyDocmyFileMe._DrawingPathDefaultPathMeWinHeightWinWidth)
  If Me._MyDoc IsNot Nothing Then
    CloseBuildingFile.Enabled = True   'Enable the close drawing button.
    ConfigHasBeenRun = True
  End If
  Me.Activate()
End Sub

'Close the current AutoCAD file
Private Sub CloseBuildingFile_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles CloseBuildingFile.Click
  'This is not clearing the class varables and entities in the list boxes. Must Clear that stuff out of memory!!!
  MyAppTool.CloseBuildingFile(Me._MyDocConfigHasBeenRun)
  'We need to clean up the class varables here and empty the list boxes.
  'NOTE: the building file has already been closed so going through and clearing all the class varables to nothing
  'is all we really need to do.
  'NOTE: DO NOT delete the AutoCAD objects this will cause an error as there is no longer an active drawing with
  'objects to which we can referance for a delete command, and even if there is an active window the pointers
  'could possibly now point to the wrong objects which would screw up someone elses drawing file....NOT A GOOD IDEA!
  'We wouldn't want to delete the objects even if the window didn't close. Therefore it may be important to
  'implement an undo feature, or have some way of skipping over this if the drawing is still active....ect...
  Me._ListBoxTool.ClearAllRoofList(Sel)
  Me._SidewalkListBoxTool.ClearAllSidewalkList(Sel)
  RoofObjHeight.Text = ""
  SidewalkElevationTextBox.Text = ""
  RoofObjHeight.Enabled = False
  SidewalkElevationTextBox.Enabled = False
  CloseBuildingFile.Enabled = False    'Disable the close drawing button.
End Sub

'Pre-Configure AutoCAD for layers and other things
Private Sub AutoConfig_Click(ByVal sender As System.ObjectByVal e As System.EventArgs)
  If SelTool.AcadHasWindowActive() = True Then
    Dim MyIterator As Integer = 0
    MyIterator = SelTool.NumOfWalls()
    If MyIterator > 0 Then
      MyAppTool.PreConfigAutoCAD()
      'Make the sidewalk layer as well
      SidewalkTool.MakeSidewalkLayers()
      ParkingLotTool.InitializeParkingLotLayers()
      LandscapeTool.InitializeLandscapeLayer()
      ConfigHasBeenRun = True
    Else
      MsgBox("The active AutoCAD document must contain Fab-Wall Panel Objects"MsgBoxStyle.Critical_
          "FabLab Config Error")
    End If
  Else
    MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
  End If
End Sub

'Build the Default Roof Button
Private Sub BuildRoof_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles BuildRoof.Click
  Sel = Nothing                        'Clear the selection set
  If SelTool.AcadHasWindowActive() = True Then
    SelTool.LoadAutoCAD()
    Dim MyIterator As Integer
    MyIterator = SelTool.NumOfWalls()
    If MyIterator > 0 AndAlso ConfigHasBeenRun = False Then
      MyAppTool.PreConfigAutoCAD()
      'Make the sidewalk layer as well
      SidewalkTool.MakeSidewalkLayers()
      ParkingLotTool.InitializeParkingLotLayers()
      LandscapeTool.InitializeLandscapeLayer()
      ConfigHasBeenRun = True
      VisTool.ShowFabWallBaseLines()
      '=====================
      '|| Important stuff ||
      '=====================
      'Build the default roof
      SelTool.AcadApp.ZoomExtents()
      'Add the name of the Roof Segment to the ListBox, This will do all the work for adding the segment
      'to the array and doing all the control work in the RoofCtrl Class, and RoofSeg Class
      If ListBoxTool._RoofControl Is Nothing Then
        'We got a problem because all the referances where previously destroyed
        'We need to reinitialize them.
        FabLabInit(RoofSegListSidewalkSegListLandscapeListBoxCustViewsListBoxParkingSegListbox)
        Sel = Nothing                  'Clear the selection set again just in case
        Sel = SelTool.SelectFabWallBaseLines(Sel)
        ListBoxTool.ListBoxAddSeg(Sel"Default")
      Else
        Sel = Nothing                  'Clear the selection set again just in case
        Sel = SelTool.SelectFabWallBaseLines(Sel)
        ListBoxTool.ListBoxAddSeg(Sel"Default")
      End If

      VisTool.HideAllConstLines()
      VisTool.HideRoofRegions()
      '**********************************
      'Begin the View change to isometric
      '**********************************
      RendTool.SetSWIsometricWrkView()
      'Render shaded mode in the viewport
      RendTool.SetShadedMode()
      'Put the name of the object into the list
      ListBoxTool.SelListBoxItemByName("Default")
    ElseIf ConfigHasBeenRun = True Then
      VisTool.ShowFabWallBaseLines()

      '=====================
      '|| Important stuff ||
      '=====================
      'Build the default roof

      SelTool.AcadApp.ZoomExtents()
      'Add the name of the Roof Segment to the ListBox, This will do all the work for adding the segment
      'to the array and doing all the control work in the RoofCtrl Class, and RoofSeg Class
      If ListBoxTool._RoofControl Is Nothing Then
        'We got a problem because all the referances where previously destroyed
        'We need to reinitialize them.
        FabLabInit(RoofSegListSidewalkSegListLandscapeListBoxCustViewsListBoxParkingSegListbox)
        Sel = Nothing                  'Clear the selection set again just in case
        Sel = SelTool.SelectFabWallBaseLines(Sel)
        ListBoxTool.ListBoxAddSeg(Sel"Default")
      Else
        Sel = Nothing                  'Clear the selection set again just in case
        Sel = SelTool.SelectFabWallBaseLines(Sel)
        ListBoxTool.ListBoxAddSeg(Sel"Default")
      End If

      VisTool.HideAllConstLines()
      VisTool.HideRoofRegions()
      '**********************************
      'Begin the View change to isometric
      '**********************************
      RendTool.SetSWIsometricWrkView()
      'Render shaded mode in the viewport
      RendTool.SetShadedMode()
      'Put the name of the object into the list
      ListBoxTool.SelListBoxItemByName("Default")
    Else
      MsgBox("The active document must contain Fab-Wall Panel Objects."MsgBoxStyle.Critical_
          "FabLab File Error")
    End If
  Else
    MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
  End If
End Sub

'User changed the PathOverRide checkbox
Private Sub RenderPathOverride_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles RenderPathOverride.Click
  'here we change the path to what the user selects.
  'need a dialog box to select just the path, similar to the folder loader in winamp.
  PathOverrideSelectTool.ShowDialog()
End Sub

'Button to show or hide the walls
Private Sub WallVis_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles WallVis.Click
  If WallsHidden = False Then
    VisTool.HideWalls()
    WallsHidden = True
    SelTool.RefreshAll()
  Else
    VisTool.ShowWalls()
    WallsHidden = False
    SelTool.RefreshAll()
  End If
End Sub

'User has clicked the button to open the ViewSettings Dialogbox
Private Sub VisualSettingsButton_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles VisualSettingsButton.Click
  ViewSettings.ShowDialog()
End Sub
'************************************************************************************************
'END MAIN BUTTONS
'************************************************************************************************
#End Region
#Region "Solid Segments Tab"
'************************************************************************************************
'BEGIN SOLID SEGMENTS TAB
'************************************************************************************************
#Region "Roof Stuff"
'&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
'^^^Roof Stuff^^^
'&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
'Add a new segment to the list of roof segments
Private Sub AddSeg_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles AddSeg.Click
  If SelTool.AcadHasWindowActive() = True Then
    AddRoofSegDlg.ShowDialog()
    If AddRoofSegDlg.DialogResult = Windows.Forms.DialogResult.OK Then
      'then we are ready to add it to the list
      'Check for duplicate records first
      'Check for empty text
      If AddRoofSegDlg.RoofSegName.Text <> "" Then
        ListBoxTool.ListBoxAddSeg(AddRoofSegDlg.RoofSegName.Text)  'Already checks for duplicates
        RoofObjHeight.Text = ""
        RoofObjHeight.Enabled = False
        AddRoofSegDlg.RoofSegName.Text = Nothing  'Clear the dialog value for the next time it is loaded
      Else
        MsgBox("You must enter a segment name!!!"MsgBoxStyle.Critical"FabLab Segment Name Error")
        Exit Sub
      End If
    Else
      Exit Sub
    End If
  Else
    MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
    Exit Sub
  End If
End Sub

'Remove the segment from the list of roof segments
Private Sub RemSeg_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles RemSeg.Click
  If SelTool.AcadHasWindowActive() = True Then
    'Should check to see if we even have any selected list items.
    If Me._ListBoxTool.SelListCount >= 1 Then
      RemRoofSegDlg.ShowDialog()
      'Dim ListCtrl As New ListBoxCtrl
      If RemRoofSegDlg.DialogResult = Windows.Forms.DialogResult.OK Then
        'then we are ready to remove all the selected items from the list
        'Remove the Selected items
        Me._ListBoxTool.ListBoxRemSel()
        'The list box class should manage everything.
        SelTool.RefreshAll()
      End If
    Else
      MsgBox("There is nothing to remove! You must first select an item from the Roof Segment Listbox for removal"_
          MsgBoxStyle.Critical"Listbox Roof Control Error")
    End If
  Else
    MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
  End If
End Sub

'Select the Line objects that form a loop for building the Roof Segment
Private Sub PickAndBuildSeg_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles PickAndBuildSeg.Click
  If SelTool.AcadHasWindowActive() = True Then
    If ConfigHasBeenRun = True Then
      'Need to make sure they only have one object selected at this time.
      'We can only build one roof segment at a time. As much as I would like to be able to generate them
      'all with a single click, it's just not quite there yet. <grin>
      SelTool.LoadAutoCAD()
      Sel = Nothing                    'Clear the selection set

      'Prompt the user to select objects
      'and add them to the selection set.
      'To finish selecting, press ENTER.

      Dim RoofSegment As New RoofSeg
      'Need this to build the next LoopSeg
      'First get the name of the segment that is selected
      Dim SelCollection As ListBox.SelectedObjectCollection
      SelCollection = ListBoxTool.GetSel()  'Put the Selection into a collection
      If SelCollection.Count = 0 Then
        Me.Activate()
        MsgBox("You need to select A Roof segment to use."MsgBoxStyle.Critical_
            "FabLab AddSeg Error")
      ElseIf SelCollection.Count = 1 Then
        Me.MinimizeBox = True
        AppActivate(SelTool.AcadApp.Caption)
        SelTool.AcadDoc.Activate()
        'Configure the user interface for loop selection
        RendTool.ConfigureForLoopSelect()
        Try
        Sel = SelTool.AcadDoc.SelectionSets.Add("SSx")
        Catch ex As Exception
        'The selectionset must already exist, therefore we could just continue
        Sel = SelTool.AcadDoc.SelectionSets.Item("SSx")
        End Try
        Sel.SelectOnScreen()
        If ListBoxTool.LineCount(Sel= 0 Then
          Me.MinimizeBox = False
          Me.Activate()
          MsgBox("You need to select some lines to use for building the roof segment."_
              MsgBoxStyle.Critical"FabLab AddSeg Error")
          RendTool.UnConfigureForLoopSelect()
          SelTool.RefreshAll()
          Exit Sub
        End If

        'Make sure to delete the selection set when we are done, so it doesn't error out next time
        'we go through this process
        RendTool.UnConfigureForLoopSelect()
        Me.MinimizeBox = False
        SelTool.RefreshAll()
        Me.Activate()
        '**************
        'Sel should now contain all the lines we intend to build the next roof segment out of.
        'This is the case that we actually build the roof
        'Need to get the name of the selected ListBox item
        Dim Name As String = Nothing
        Name = ListBoxTool.GetSegName()
        If ListBoxTool._RoofControl Is Nothing AndAlso Name Is Nothing Then
          Try
          ListBoxTool.ListBoxAddSeg(Sel"Default")
          Catch ex As Exception
          MsgBox("Error Creating Roof Object! -ListBoxAddSeg-"_
              MsgBoxStyle.Critical"FabLab AddSeg Error")
          End Try
        Else
          Try
          ListBoxTool.ListBoxAddSeg(SelName)
          Catch ex As Exception
          MsgBox("Error Creating Roof Object! -ListBoxAddSeg-"_
              MsgBoxStyle.Critical"FabLab AddSeg Error")
          End Try
        End If
        SelTool.AcadDoc.SelectionSets.Item("SSx").Delete()
        RoofObjHeight.Text = ListBoxTool.GetSelSegHeight().ToString
        If RoofObjHeight.Text <> "" Then
          RoofObjHeight.Enabled = True
        End If
        VisTool.HideAllConstLines()
        VisTool.HideRoofRegions()
        SelTool.RefreshAll()
      ElseIf SelCollection.Count > 1 Then
        Me.Activate()
        MsgBox("You need to select only ONE Roof segment to use."MsgBoxStyle.Critical_
            "FabLab AddSeg Error")
      End If
      Sel = Nothing                    'Clear the selection set when we are done
    Else
      MsgBox("AutoCAD has Not been properly configured for this application yet."MsgBoxStyle.Critical_
          "FabLab Config Error")
    End If
  Else
    MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
  End If
End Sub

'Hide the Selected Segments
Private Sub HideSeg_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles HideSeg.Click
  ListBoxTool.ListBoxHideSeg()
  SelTool.RefreshAll()
End Sub

'Show the selected Segments
Private Sub ShowSeg_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles ShowSeg.Click
  ListBoxTool.ListBoxShowSeg()
  SelTool.RefreshAll()
End Sub

'Show ALL the construction lines
Private Sub ShowConstLines_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles ShowConstLines.Click
  VisTool.ShowAllConstLines()
  VisTool.ShowRoofRegions()
End Sub

'Hide ALL the construction lines
Private Sub HideConstLines_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles HideConstLines.Click
  VisTool.HideAllConstLines()
  VisTool.HideRoofRegions()
End Sub

'User highlighted something in the list, should highlight these entities in AutoCAD
'To show which objects are being used. If unselected, then un-highlight these entities in AutoCAD
Private Sub RoofSegList_SelectedIndexChanged(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles RoofSegList.SelectedIndexChanged
  'Update the count in the class object first
  Me._ListBoxTool._SelListCount = RoofSegList.SelectedItems.Count
  'We can alow the user to change more than one Roof at a time
  'but the field RoofObjHeight should not show a value if the values are different
  If Me._ListBoxTool._SelListCount > 1 Then
    'Should check to see if the selected objects in the listbox have different height values
    'If they are different, then display nothing
    'If they are the same, then put that value in the RoofObjHeight text box, so the user can
    'choose to edit it if he so chooses
    If Me._ListBoxTool.IsSelSameHeight() = False Then
      RoofObjHeight.Enabled = False
      RoofObjHeight.Text = ""
      PickAndBuildSeg.Enabled = False
    Else
      RoofObjHeight.Enabled = True
      RoofObjHeight.Text = Me._ListBoxTool.GetSelSegHeight().ToString
      PickAndBuildSeg.Enabled = False
    End If
    RemSeg.Enabled = True
    HideSeg.Enabled = True
    ShowSeg.Enabled = True
  ElseIf Me._ListBoxTool._SelListCount = 1 Then
    'Make sure to adjust the height value in the Roof Object Height textbox
    RoofObjHeight.Enabled = True
    RoofObjHeight.Text = Me._ListBoxTool.GetSelSegHeight().ToString
    PickAndBuildSeg.Enabled = True
    'Need to set this value
    RemSeg.Enabled = True
    HideSeg.Enabled = True
    ShowSeg.Enabled = True
  ElseIf Me._ListBoxTool._SelListCount = 0 Then
    RoofObjHeight.Enabled = False
    RoofObjHeight.Text = ""
    PickAndBuildSeg.Enabled = False
    RemSeg.Enabled = False
    HideSeg.Enabled = False
    ShowSeg.Enabled = False
  End If
  'refresh the display
  RoofSegList.Refresh()
  RoofSegList.Update()
End Sub

'User Double clicked on the Roof Segment Listbox, option to rename if only one list item selected
Private Sub RoofSegList_MouseDoubleClick(ByVal sender As ObjectByVal e As _
    System.Windows.Forms.MouseEventArgsHandles RoofSegList.MouseDoubleClick
  Me._ListBoxTool._SelListCount = RoofSegList.SelectedItems.Count
  'Allow the user the rename the segment if there is only one item selected
  If Me._ListBoxTool._SelListCount = 1 Then
    'there is just one selected item, lets let the user rename it.
    RenameRoofSegment.ShowDialog()
    If RenameRoofSegment.DialogResult = Windows.Forms.DialogResult.OK Then
      Dim NewRoofName As String
      NewRoofName = RenameRoofSegment.NewSegName.Text
      Me._ListBoxTool.ListBoxRenameSeg(NewRoofName)
      RenameRoofSegment.NewSegName.Text = Nothing  'Clear the field in the dialog box for the next time
    End If
  End If
End Sub

'Manually changed the roof height from the text box
Private Sub RoofObjHeight_KeyPress(ByVal sender As ObjectByVal e As System.Windows.Forms.KeyPressEventArgs_
    Handles RoofObjHeight.KeyPress
  Dim mychar As Char
  mychar = e.KeyChar.ToString
  If mychar = Chr(13Then
    If SelTool.AcadHasWindowActive() = True Then
      SelTool.LoadAutoCAD()
      'User has entered a new number into this field and it needs to be changed for all the selected objects
      'Also involves moving the roof object to the new height
      Dim NewHeight As Double = Double.Parse(RoofObjHeight.Text)  'Get the value entered by the user
      'Use it to assign this new height value into all the class varables, and move all the objects by the
      'difference between the current roof height and the new roof height
      ListBoxTool.SetSelSegHeight(NewHeight)
      SelTool.RefreshAll()
    Else
      MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
    End If
  End If
End Sub
#End Region
#Region "Bands Stuff"
'&&&&&&&&&&&&&&&&&&&&&&&&&
'^^^^Bands Stuff^^^^
'&&&&&&&&&&&&&&&&&&&&&&&&&
'User selected to have all the bands auto extruded
Private Sub ExtrudeBands_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles ExtrudeBands.Click
  'Need to get the system to autoselect all the band objects.
  SelTool.LoadAutoCAD()
  Dim BandLayer As AutoCAD.AcadLayer
  Try
  Sel = SelTool.AcadDoc.SelectionSets.Add("SSx")
  Catch ex As Exception
  'The selectionset must already exist, therefore we could just continue
  Sel = SelTool.AcadDoc.SelectionSets.Item("SSx")
  End Try
  Sel.Clear()
  Sel = SelTool.GetBands()
  'Now lets put them on their own band layer.
  BandLayer = FinishTool._BandsTool.CreateBandLayer(Sel)
  'Make sure to set the current layer to the bands layer
  SelTool.AcadDoc.ActiveLayer = BandLayer
  'Now lets step through each ent and extrude it.
  'Should auto extude to the outward direction automatically, because I think Mark has already setup the normals
  'to be facing outwards.
  FinishTool._BandsTool.ExtrudeBands(Sel)
  SelTool.RefreshAll()
End Sub
#End Region
#Region "Sidewalk Stuff"
'&&&&&&&&&&&&&&&&&&&&&&&&&
'^^^^Sidewalk Stuff^^^^
'&&&&&&&&&&&&&&&&&&&&&&&&&
'User selected the button create a new sidewalk list object in our application
Private Sub AddSidewalkSeg_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles AddSidewalkSeg.Click
  If SelTool.AcadHasWindowActive() = True Then
    'Still need to give it a proper name, and alow the user to input their own name
    AddSidewalkSegDlg.ShowDialog()
    'Check the dialog results
    If AddSidewalkSegDlg.DialogResult = Windows.Forms.DialogResult.OK Then
      Dim SidewalkSegmentName As String
      SidewalkSegmentName = AddSidewalkSegDlg.SidewalkSegName.Text
      'Check for empty name
      If SidewalkSegmentName <> "" Then
        Me._SidewalkListBoxTool.ListBoxAddSeg(SidewalkSegmentName)
        'Going to need a system here to manage if the fillet radius is the same for
        'multiple selected sidewalk segments because this is implemented on a per-object basis.
        '**************************************
        'Taking the fillet Radius out for now
        '**************************************
        'FiltRad.Text = Me._SidewalkListBoxTool.GetSegmentFilletRadius(SidewalkSegmentName).ToString()
        '**************************************
        'Taking the fillet Radius out for now
        '**************************************
        'Figure out what the height should be and put it into the text box for the item in the GUI.
        'this call also saves it in the class varable.
        SidewalkElevationTextBox.Text = Me._SidewalkListBoxTool.GetSegmentHeight(SidewalkSegmentName).ToString()
        AddSidewalkSegDlg.SidewalkSegName.Text = Nothing  'Clear the dialog value for the next time it is loaded
        SidewalkElevationTextBox.Text = ""
        SidewalkElevationTextBox.Enabled = False
      Else
        MsgBox("You must enter a segment name!!!"MsgBoxStyle.Critical"FabLab Segment Name Error")
        Exit Sub
      End If
    Else
      Exit Sub
    End If
  Else
    MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
  End If
End Sub

'User clicked the button to remove a sidewalk from the list box, and so we need to do all the work to also
'remove all the class varables
Private Sub RemSidewalkSeg_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles RemSidewalkSeg.Click
  If SelTool.AcadHasWindowActive() = True Then
    'Should check to see if we even have any selected list items.
    If Me._SidewalkListBoxTool.SelListCount >= 1 Then
      'should ask the user if they are certain they want to remove the objects before deleting them from AutoCAD.
      RemSidewalkSegDlg.ShowDialog()
      If RemSidewalkSegDlg.DialogResult = Windows.Forms.DialogResult.OK Then
        'then we are ready to remove all the selected items from the list
        'Remove the Selected items
        Me._SidewalkListBoxTool.ListBoxRemSeg()
        SidewalkElevationTextBox.Text = ""
        SidewalkElevationTextBox.Enabled = False
      End If
    Else
      MsgBox("There is nothing to remove! You must first select an item from the Sidewalk Seg Listbox for removal"_
          MsgBoxStyle.Critical"Listbox Sidewalk Control Error")
    End If
  Else
    MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
  End If
End Sub

'User selected the button to pick and build the new sidewalk
Private Sub SidewalkBuilder_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles SidewalkBuilder.Click
  If SelTool.AcadHasWindowActive() = True Then
    If ConfigHasBeenRun = True Then
      Sel = Nothing                    'Clear the selection set
      SelTool.LoadAutoCAD()
      'Prompt the user to select objects that we will use to build the sidewalk
      'and add them to the selection set.
      'To finish selecting, press ENTER.
      Me.MinimizeBox = True
      AppActivate(SelTool.AcadApp.Caption)
      SelTool.AcadDoc.Activate()
      'Configure the user interface for loop selection
      RendTool.ConfigureForSideWalkSelect()
      Try
      Sel = SelTool.AcadDoc.SelectionSets.Add("SSx")
      Catch ex As Exception
      'The selectionset must already exist, therefore we could just continue
      Sel = SelTool.AcadDoc.SelectionSets.Item("SSx")
      End Try
      Sel.SelectOnScreen()
      If ListBoxTool.LineCount(Sel= 0 Then
        Me.MinimizeBox = False
        Me.Activate()
        MsgBox("You need to select some lines to use for building the roof segment."_
            MsgBoxStyle.Critical"FabLab AddSeg Error")
        RendTool.UnConfigureForSidewalkSelect()
        SelTool.RefreshAll()
        Exit Sub
      End If

      'Make sure to delete the selection set when we are done, so it doesn't error out next time
      'we go through this process
      RendTool.UnConfigureForSidewalkSelect()
      Me.MinimizeBox = False
      SelTool.RefreshAll()
      Me.Activate()
      '**************
      'Sel should now contain all the lines we intend to build the next sidewalk segment out of.
      'This is the case that we actually build the sidewalk
      Dim SidewalkName As String
      SidewalkName = Me._SidewalkListBoxTool._SidewalkSegList.SelectedItem.ToString()
      'Need to make sure that this segment name actually exists in the little database system we have going.
      'Also note that the Selection set items have not been modified yet from the original drawing,
      'We will need to copy the AutoCAD lines over to a new layer and probably set their height.
      'Or we may build the new loop then set it's height
      'Probably better to set the height first other wise we may get those lines mixed up with the lines that are
      'going to be used for building the sidewalk region.
      'In fact we may want to add these building adjacent sidewalk segment construction line entities into
      'a seperate class varable so that we know which ones not to fillet on....and that IS a good idea!
      Try
      Me._SidewalkListBoxTool.BuildSidewalkSeg(SelSidewalkName)
      Catch ex As Exception
      MsgBox("Error Creating Sidewalk Object! -BuildSidewalkSeg-"_
          MsgBoxStyle.Critical"FabLab BuildSidewalkSeg Error")
      End Try
      SidewalkElevationTextBox.Text = Me._SidewalkListBoxTool.GetSegmentHeight(SidewalkName).ToString()
      If SidewalkElevationTextBox.Text <> "" Then
        SidewalkElevationTextBox.Enabled = True
      End If
      VisTool.HideAllConstLines()
      VisTool.HideSidewalkRegion()
      '**********************************
      'Begin the View change to isometric
      '**********************************
      RendTool.SetSWIsometricWrkView()
      'Render shaded mode in the viewport
      RendTool.SetShadedMode()
      'Put the name of the object into the list
      Me._SidewalkListBoxTool.SelListBoxItemByName(SidewalkName)
      Sel.Clear()
      'Load the AutoCAD Render
      RendTool.LoadRend()
    Else
      MsgBox("AutoCAD has Not been properly configured for this application yet."MsgBoxStyle.Critical_
          "FabLab Config Error")
    End If
  Else
    MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
  End If
End Sub

Private Sub SidewalkSegList_MouseDoubleClick(ByVal sender As ObjectByVal e As System.Windows.Forms.MouseEventArgs_
    Handles SidewalkSegList.MouseDoubleClick
  Me._SidewalkListBoxTool._SelListCount = SidewalkSegList.SelectedItems.Count
  'Allow the user to rename the segment if there is only one item selected
  If Me._SidewalkListBoxTool.SelListCount = 1 Then
    'Still need to display the dialog box for letting the user input a new name.
    RenameSidewalkSegment.ShowDialog()
    If RenameSidewalkSegment.DialogResult = Windows.Forms.DialogResult.OK Then
      Dim NewSidewalkName As String
      NewSidewalkName = RenameSidewalkSegment.NewSegName.Text
      Me._SidewalkListBoxTool.ListBoxRenameSeg(NewSidewalkName)
      RenameSidewalkSegment.NewSegName.Text = Nothing  'Clear the field in the dialog box for the next time.
    End If
  End If
End Sub

Private Sub SidewalkSegList_SelectedIndexChanged(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles SidewalkSegList.SelectedIndexChanged
  'Update the count in the class object first
  Me._SidewalkListBoxTool._SelListCount = SidewalkSegList.SelectedItems.Count
  'We can alow the user to change more than one Sidewalk at a time
  'but the field SidewalkObjHeight should not show a value if the values are different
  'Same goes for the fillet radius
  If Me._SidewalkListBoxTool._SelListCount > 1 Then
    'Should check to see if the selected objects in the listbox have different height values
    'If they are different, then display nothing
    'If they are the same, then put that value in the SidewalkSegHeight text box, so the user can
    'choose to edit it if he so chooses
    If Me._SidewalkListBoxTool.IsSelSameHeight() = False Then
      SidewalkBuilder.Enabled = False
      'Same goes for the fillet radius
      '**************************************
      'Taking the fillet Radius out for now
      '**************************************
      'FiltRad.Enabled = False
      '**************************************
      'Taking the fillet Radius out for now
      '**************************************
      SidewalkElevationTextBox.Text = ""
      SidewalkElevationTextBox.Enabled = False
    Else
      SidewalkBuilder.Enabled = True
      'Same goes for the fillet radius
      '**************************************
      'Taking the fillet Radius out for now
      '**************************************
      'FiltRad.Enabled = True
      '**************************************
      'Taking the fillet Radius out for now
      '**************************************
      SidewalkElevationTextBox.Text = Me._SidewalkListBoxTool.GetSelSegHeight().ToString()
      SidewalkElevationTextBox.Enabled = True
    End If
    RemSidewalkSeg.Enabled = True
    HideSidewalkSeg.Enabled = True
    ShowSidewalkSeg.Enabled = True
  ElseIf Me._SidewalkListBoxTool._SelListCount = 1 Then
    'Make sure to adjust the height value in the Roof Object Height textbox
    SidewalkBuilder.Enabled = True
    'Same goes for the fillet radius
    '**************************************
    'Taking the fillet Radius out for now
    '**************************************
    'FiltRad.Enabled = True
    '**************************************
    'Taking the fillet Radius out for now
    '**************************************
    SidewalkElevationTextBox.Text = Me._SidewalkListBoxTool.GetSelSegHeight().ToString()
    SidewalkElevationTextBox.Enabled = True
    RemSidewalkSeg.Enabled = True
    HideSidewalkSeg.Enabled = True
    ShowSidewalkSeg.Enabled = True
  ElseIf Me._SidewalkListBoxTool._SelListCount = 0 Then
    SidewalkBuilder.Enabled = False
    'Same goes for the fillet radius
    '**************************************
    'Taking the fillet Radius out for now
    '**************************************
    'FiltRad.Enabled = False
    '**************************************
    'Taking the fillet Radius out for now
    '**************************************
    SidewalkElevationTextBox.Text = ""
    SidewalkElevationTextBox.Enabled = False
    RemSidewalkSeg.Enabled = False
    HideSidewalkSeg.Enabled = False
    ShowSidewalkSeg.Enabled = False
  End If
  'refresh the display
  SidewalkSegList.Refresh()
  SidewalkSegList.Update()
End Sub

'User has pressed enter to change the value for sidewalk segment fillet radius
'**************************************
'Taking the fillet Radius out for now
'**************************************
Private Sub FiltRad_KeyPress(ByVal sender As System.ObjectByVal e As System.Windows.Forms.KeyPressEventArgs_
    Handles FiltRad.KeyPress

End Sub

'User has pressed enter to change the value for the sidewalk segment height
Private Sub SidewalkElevationTextBox_KeyPress(ByVal sender As System.ObjectByVal e _
    As System.Windows.Forms.KeyPressEventArgsHandles SidewalkElevationTextBox.KeyPress
  Dim mychar As Char
  mychar = e.KeyChar.ToString
  If mychar = Chr(13Then
    If SelTool.AcadHasWindowActive() = True Then
      SelTool.LoadAutoCAD()
      'User has entered a new number into this field and it needs to be changed for all the selected objects
      'Also involves moving the roof object to the new height
      Dim NewHeight As Double = Double.Parse(SidewalkElevationTextBox.Text)  'Get the value entered by the user
      'Use it to assign this new height value into all the class varables, and move all the objects by the
      'difference between the current roof height and the new roof height
      Me._SidewalkListBoxTool.SetSelSegHeight(NewHeight)
      SelTool.RefreshAll()
    Else
      MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
    End If
  End If
End Sub

'User has clicked the button to hide the sidewalk segments
Private Sub HideSidewalkSeg_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles HideSidewalkSeg.Click
  SidewalkListBoxTool.ListBoxHideSeg()
  SelTool.RefreshAll()
End Sub

'user has clicked the button to show the sidewalk segments
Private Sub ShowSidewalkSeg_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles ShowSidewalkSeg.Click
  SidewalkListBoxTool.ListBoxShowSeg()
  SelTool.RefreshAll()
End Sub
#End Region
#Region "Parking Lot Stuff"
'User has double clicked on one of the items in the ParkingSegListbox,
'therefore we need to show the RenameParkingSegDlg Dialog box
Private Sub ParkingSegListbox_MouseDoubleClick(ByVal sender As ObjectByVal e As _
    System.Windows.Forms.MouseEventArgsHandles ParkingSegListbox.MouseDoubleClick
  Me._ParkingLotListBoxTool._SelListCount = ParkingSegListbox.SelectedItems.Count
  'Allow the user the rename the ParkingLot if there is only one item selected
  If Me._ParkingLotListBoxTool._SelListCount = 1 Then
    'there is just one selected item, lets let the user rename it.
    RenameParkingLot.ShowDialog()
    If RenameParkingLot.DialogResult = Windows.Forms.DialogResult.OK Then
      Dim NewParkingLotName As String
      NewParkingLotName = RenameParkingLot.NewLotName.Text
      Me._ParkingLotListBoxTool.ListBoxRenameLot(NewParkingLotName)
      RenameParkingLot.NewLotName.Text = Nothing  'Clear the field in the dialog box for the next time
    End If
  End If
End Sub

'User or program has selected or unselected some objects in the ParkingSegListbox, we need to make some updates here.
Private Sub ParkingSegListbox_SelectedIndexChanged(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles ParkingSegListbox.SelectedIndexChanged
  'Update the count in the class object first
  Me._ParkingLotListBoxTool._SelListCount = ParkingSegListbox.SelectedItems.Count
  'We can alow the user to change more than one ParkingLot at a time
  'but the field ParkingLotElevationTextBox should not show a value if the values are different
  'Same goes for the fillet radius***NOT IMPLEMENTED YET!!!
  If Me._ParkingLotListBoxTool._SelListCount > 1 Then
    'Should check to see if the selected objects in the listbox have different elevation values
    'If they are different, then display nothing
    'If they are the same, then put that value in the ParkingLotElevation text box, so the user can
    'choose to edit it if he so chooses
    If Me._ParkingLotListBoxTool.IsSelSameElevation() = False Then
      PickBuildParkingSeg.Enabled = False
      'Same goes for the fillet radius
      '**************************************
      'Taking the fillet Radius out for now
      '**************************************
      'ParkingLotFiltRad.Enabled = False
      '**************************************
      'Taking the fillet Radius out for now
      '**************************************
      ParkingLotElevationTextBox.Text = ""
      ParkingLotElevationTextBox.Enabled = False
    Else
      PickBuildParkingSeg.Enabled = True
      'Same goes for the fillet radius
      '**************************************
      'Taking the fillet Radius out for now
      '**************************************
      'ParkingLotFiltRad.Enabled = True
      '**************************************
      'Taking the fillet Radius out for now
      '**************************************
      ParkingLotElevationTextBox.Text = Me._SidewalkListBoxTool.GetSelSegHeight().ToString()
      ParkingLotElevationTextBox.Enabled = True
    End If
    RemParkingSeg.Enabled = True
    HideParkingSeg.Enabled = True
    ShowParkingSeg.Enabled = True
  ElseIf Me._ParkingLotListBoxTool._SelListCount = 1 Then
    'Make sure to adjust the elevation value in the ParkingLot Elevation textbox
    PickBuildParkingSeg.Enabled = True
    'Same goes for the fillet radius
    '**************************************
    'Taking the fillet Radius out for now
    '**************************************
    'ParkingLotFiltRad.Enabled = True
    '**************************************
    'Taking the fillet Radius out for now
    '**************************************
    ParkingLotElevationTextBox.Text = Me._ParkingLotListBoxTool.GetSelLotElevation().ToString()
    ParkingLotElevationTextBox.Enabled = True
    RemParkingSeg.Enabled = True
    HideParkingSeg.Enabled = True
    ShowParkingSeg.Enabled = True
  ElseIf Me._ParkingLotListBoxTool._SelListCount = 0 Then
    PickBuildParkingSeg.Enabled = False
    'Same goes for the fillet radius
    '**************************************
    'Taking the fillet Radius out for now
    '**************************************
    'ParkingLotFiltRad.Enabled = False
    '**************************************
    'Taking the fillet Radius out for now
    '**************************************
    ParkingLotElevationTextBox.Text = ""
    ParkingLotElevationTextBox.Enabled = False
    RemParkingSeg.Enabled = False
    HideParkingSeg.Enabled = False
    ShowParkingSeg.Enabled = False
  End If
  'refresh the display
  ParkingSegListbox.Refresh()
  ParkingSegListbox.Update()
End Sub

'User has clicked the button to build a new Parking Lot Object
Private Sub PickBuildParkingSeg_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles PickBuildParkingSeg.Click
  If SelTool.AcadHasWindowActive() = True Then
    If ConfigHasBeenRun = True Then
      Dim PlineTool As New PlineSort2
      'We are going to need to setup for this.
      Sel = Nothing                    'Clear the selection set
      SelTool.LoadAutoCAD()

      Me.MinimizeBox = True
      AppActivate(SelTool.AcadApp.Caption)
      SelTool.AcadDoc.Activate()

      RendTool.ConfigureForSideWalkSelect()
      Try
      Sel = SelTool.AcadDoc.SelectionSets.Add("SSx")
      Catch ex As Exception
      'The selectionset must already exist, therefore we could just continue
      Sel = SelTool.AcadDoc.SelectionSets.Item("SSx")
      End Try
      Sel = Nothing                    'Clear the Selection Set, just to make sure
      'first we need to get the selected name, because that's the one we are going to be building for.
      Dim MyLotName As String = Nothing
      MyLotName = Me._ParkingLotListBoxTool.GetLotName()
      'Now call the function to build the ParkingLot construction lines
      If MyLotName IsNot Nothing Then
        Me._ParkingLotListBoxTool.BuildParkingLot(SelMyLotName)
      End If
      'Ok it's been created!
      RendTool.UnConfigureForSidewalkSelect()
      VisTool.HideConstParkingLotLines()
      Me.MinimizeBox = False
      SelTool.RefreshAll()
      Me.Activate()
      'Update the field for the height
      ParkingLotElevationTextBox.Text = Me._ParkingLotListBoxTool.GetSelLotElevation().ToString()
      If ParkingLotElevationTextBox.Text <> "" Then
        ParkingLotElevationTextBox.Enabled = True
      End If
    Else
      MsgBox("AutoCAD has Not been properly configured for this application yet."MsgBoxStyle.Critical_
          "FabLab Config Error")
    End If
  Else
    MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
  End If
End Sub

'User has clicked the button to add a new parking lot to the list box
Private Sub AddParkingSeg_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles AddParkingSeg.Click
  If SelTool.AcadHasWindowActive() = True Then
    'Still need to give it a proper name, and alow the user to input their own name
    AddParkingLotDlg.ShowDialog()
    'Check the dialog results
    If AddParkingLotDlg.DialogResult = Windows.Forms.DialogResult.OK Then
      Dim ParkingLotName As String
      ParkingLotName = AddParkingLotDlg.ParkingLotName.Text
      'Check for empty name
      If ParkingLotName <> "" Then
        Me._ParkingLotListBoxTool.ListBoxAddLot(ParkingLotName)
        'Going to need a system here to manage if the fillet radius is the same for multiple
        'selected parking lots because this is implemented on a per-object basis.
        '**************************************
        'Taking the fillet Radius out for now
        '**************************************
        'FiltRad.Text = Me._ParkingLotListBoxTool.GetLotFilletRadius(ParkingLotName).ToString()
        '**************************************
        'Taking the fillet Radius out for now
        '**************************************
        ParkingLotElevationTextBox.Text = ""
        ParkingLotElevationTextBox.Enabled = False
        AddParkingLotDlg.ParkingLotName.Text = Nothing  'Clear the dialog value for the next time it is loaded
      Else
        MsgBox("You must enter a segment name!!!"MsgBoxStyle.Critical"FabLab Segment Name Error")
        Exit Sub
      End If
    Else
      Exit Sub
    End If
  Else
    MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
  End If
End Sub

'User has clicked the button to remove the selected Parking Segments
Private Sub RemParkingSeg_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles RemParkingSeg.Click
  'First check to make sure there is an AutoCAD window that is active.
  If SelTool.AcadHasWindowActive() = True Then
    'Should check to see if we even have any selected list items.
    If Me._ParkingLotListBoxTool.SelListCount >= 1 Then
      'should ask the user if they are certain they want to remove the objects before deleting them from AutoCAD.
      RemParkingLotDlg.ShowDialog()
      If RemParkingLotDlg.DialogResult = Windows.Forms.DialogResult.OK Then
        'then we are ready to remove all the selected items from the list
        'Remove the Selected items
        Me._ParkingLotListBoxTool.ListBoxRemLot()
        ParkingLotElevationTextBox.Text = ""
        ParkingLotElevationTextBox.Enabled = False
      End If
    Else
      MsgBox("There is nothing to remove! You must first select an item from the ParkingLot Listbox for removal"_
          MsgBoxStyle.Critical"Listbox ParkingLot Control Error")
    End If
  Else
    MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
  End If
End Sub

'User changed the height of the Parking Lot, I could see this for Lots at different elevations
Private Sub ParkingLotElevationTextBox_KeyPress(ByVal sender As ObjectByVal e As _
    System.Windows.Forms.KeyPressEventArgsHandles ParkingLotElevationTextBox.KeyPress
  Dim mychar As Char
  mychar = e.KeyChar.ToString
  If mychar = Chr(13Then
    If SelTool.AcadHasWindowActive() = True Then
      SelTool.LoadAutoCAD()
      'User has entered a new number into this field and it needs to be changed for all the selected objects
      'Also involves moving the ParkingLot to the new elevation
      Dim NewHeight As Double = Double.Parse(ParkingLotElevationTextBox.Text)  'Get the value entered by the user
      'Use it to assign this new height value into all the class varables, and move all the objects by the
      'difference between the current roof height and the new roof height
      Me._ParkingLotListBoxTool.SetSelLotElevation(NewHeight)
      SelTool.RefreshAll()
    Else
      MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
    End If
  End If
End Sub

'User clicked the button to hide the currently selected parking lots
Private Sub HideParkingSeg_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles HideParkingSeg.Click
  Me._ParkingLotListBoxTool.ListBoxHideLot()
  SelTool.RefreshAll()
End Sub

'User clicked the button to show the currently selected parking lots
Private Sub ShowParkingSeg_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles ShowParkingSeg.Click
  Me._ParkingLotListBoxTool.ListBoxShowLot()
  SelTool.RefreshAll()
End Sub
#End Region
#Region "Joint Stuff"
'Probably going to implement Joint stuff later, focusing on perspective view for now
#End Region
'************************************************************************************************
'END SOLID SEGMENTS TAB
'************************************************************************************************
#End Region
#Region "Windows and Doors Tab"
'************************************************************************************************
'BEGIN WINDOWS AND DOORS TAB
'************************************************************************************************
Private Sub WinDoorSelection_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles WinDoorSelection.Click
  If SelTool.AcadHasWindowActive() = True Then
    If ConfigHasBeenRun = True Then
      SelTool.LoadAutoCAD()
      Sel = Nothing                    'Clear the selection set
      Me.MinimizeBox = True
      AppActivate(SelTool.AcadApp.Caption)

      'Prompt the user to select objects
      'and add them to the selection set.
      'To finish selecting, press ENTER.
      'RendTool.ConfigureForWinDoorSelect()
      'Still need to turn off all the other layers except the blockouts layers.
      VisTool.HideAllLayersBut("BLOCKOUT""HorzWin""VertWin""SquareWin""DockDoor""GarageDoor"_
          "FireDoor""SecDoor1""SecDoor2""GlasDor""DubDoors")
      Try
      Sel = SelTool.AcadDoc.SelectionSets.Add("xMM")
      Sel = SelTool.AcadDoc.SelectionSets.Item("xMM")
      Catch ex As Exception
      'The selectionset must already exist, therefore we could just continue
      Sel = SelTool.AcadDoc.SelectionSets.Item("xMM")
      End Try
      'Need to figure out which texture we are going to apply
      Dim WinDoorSelEnt As String
      WinDoorSelEnt = MyAppTool._WinDoorTool.DeterminSelWinDoor()
      Sel.SelectOnScreen()
      If ListBoxTool.LineCount(Sel= 0 Then
        'The user didn't pick anything
        Me.MinimizeBox = False
        Me.Activate()
        MsgBox("You need to select some windows or doors."_
            MsgBoxStyle.Critical"FabLab AddSeg Error")
        RendTool.UnConfigureForWinDoorSelect()

        SelTool.AllLayersOn()
        'Load the Autocad render
        RendTool.LoadRend()
        'make the calls to apply the wall texture here
        SelTool.RefreshAll()
        Exit Sub
      End If
      'Determine which one is selected now
      Select Case WinDoorSelEnt
        Case "SquareWin"
          TexTool.ApplyWinDoorTex(Sel"SqWin")
        Case "HorzWin"
          TexTool.ApplyWinDoorTex(Sel"HorzWin")
        Case "VertWin"
          TexTool.ApplyWinDoorTex(Sel"VertWin")
        Case "DockDoor"
          TexTool.ApplyWinDoorTex(Sel"DockDoor")
        Case "Garage"
          TexTool.ApplyWinDoorTex(Sel"Garage")
        Case "FireDoor"
          TexTool.ApplyWinDoorTex(Sel"FireDoor")
        Case "SecDoor1"
          TexTool.ApplyWinDoorTex(Sel"SecDoor1")
        Case "SecDoor2"
          TexTool.ApplyWinDoorTex(Sel"SecDoor2")
        Case "GlasDor"
          TexTool.ApplyWinDoorTex(Sel"GlasDor")
        Case "DubDoors"
          TexTool.ApplyWinDoorTex(Sel"DubDoors")
      End Select
      Me.MinimizeBox = False
      Me.Activate()
      RendTool.UnConfigureForWinDoorSelect()

      SelTool.AllLayersOn()
      'Load the Autocad render
      RendTool.LoadRend()
      'make the calls to apply the wall texture here
      SelTool.RefreshAll()
    Else
      MsgBox("AutoCAD has Not been properly configured for this application yet."_
          MsgBoxStyle.Critical"FabLab Config Error")
    End If
  Else
    MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
  End If
End Sub

'User selected the Window Textbox
Private Sub SquareWinTextBox_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles SquareWinTextBox.Click
  MyAppTool._WinDoorTool.ToggleSelection("SquareWin")
End Sub

'User selected the Window Picture Box
Private Sub SquareWindowPic_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles SquareWindowPic.Click
  MyAppTool._WinDoorTool.ToggleSelection("SquareWin")
End Sub

'User selected the Horizontal Window Textbox
Private Sub HorzWinTextBox_Click(ByVal sender As ObjectByVal e As System.EventArgsHandles HorzWinTextBox.Click
  MyAppTool._WinDoorTool.ToggleSelection("HorzWin")
End Sub

'User selected the Horizontal Window Picture Box
Private Sub HorzWinPic_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles HorzWinPic.Click
  MyAppTool._WinDoorTool.ToggleSelection("HorzWin")
End Sub

'User selected the Vertical Window Textbox
Private Sub VertWinPic_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles VertWinPic.Click
  MyAppTool._WinDoorTool.ToggleSelection("VertWin")
End Sub

'User selected the Vertical Window Picture Box
Private Sub VertWinTextBox_Click(ByVal sender As ObjectByVal e As System.EventArgsHandles VertWinTextBox.Click
  MyAppTool._WinDoorTool.ToggleSelection("VertWin")
End Sub

'User selected the Dock Door Textbox
Private Sub DockDoorTextBox_Click(ByVal sender As ObjectByVal e As System.EventArgs_
    Handles DockDoorTextBox.Click
  MyAppTool._WinDoorTool.ToggleSelection("DockDoor")
End Sub

'User selected the Dock Door Picture Box
Private Sub DockDoorPic_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles DockDoorPic.Click
  MyAppTool._WinDoorTool.ToggleSelection("DockDoor")
End Sub

'User selected the Garage Door Textbox
Private Sub GarageTextBox_Click(ByVal sender As ObjectByVal e As System.EventArgs_
    Handles GarageTextBox.Click
  MyAppTool._WinDoorTool.ToggleSelection("Garage")
End Sub

'User selected the Garage Door Picture Box
Private Sub GaragePic_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles GaragePic.Click
  MyAppTool._WinDoorTool.ToggleSelection("Garage")
End Sub

'User selected the Fire Door Textbox
Private Sub FireDoorTextBox_Click(ByVal sender As ObjectByVal e As System.EventArgs_
    Handles FireDoorTextBox.Click
  MyAppTool._WinDoorTool.ToggleSelection("FireDoor")
End Sub

'User selected the Fire Door Picture Box
Private Sub FireDoorPic_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles FireDoorPic.Click
  MyAppTool._WinDoorTool.ToggleSelection("FireDoor")
End Sub

'User selected the Security Door 1 Textbox
Private Sub SecDoor1TextBox_Click(ByVal sender As ObjectByVal e As System.EventArgs_
    Handles SecDoor1TextBox.Click
  MyAppTool._WinDoorTool.ToggleSelection("SecDoor1")
End Sub

'User selected the Security Door 1 Picture Box
Private Sub SecDoor1Pic_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles SecDoor1Pic.Click
  MyAppTool._WinDoorTool.ToggleSelection("SecDoor1")
End Sub

'User selected the Security Door 2 Textbox
Private Sub SecDoor2TextBox_Click(ByVal sender As ObjectByVal e As System.EventArgs_
    Handles SecDoor2TextBox.Click
  MyAppTool._WinDoorTool.ToggleSelection("SecDoor2")
End Sub

'User selected the Security Door 2 Picture Box
Private Sub SecDoor2Pic_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles SecDoor2Pic.Click
  MyAppTool._WinDoorTool.ToggleSelection("SecDoor2")
End Sub

'User selected the Glass Door Textbox
Private Sub GlassDoorTextBox_Click(ByVal sender As ObjectByVal e As System.EventArgs_
    Handles GlassDoorTextBox.Click
  MyAppTool._WinDoorTool.ToggleSelection("GlasDor")
End Sub

'User selected the Glass Door Picture Box
Private Sub GlassDoorPic_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles GlassDoorPic.Click
  MyAppTool._WinDoorTool.ToggleSelection("GlasDor")
End Sub

'User selected the Double Doors Textbox
Private Sub DoubleDoorsTextBox_Click(ByVal sender As ObjectByVal e As System.EventArgs_
    Handles DoubleDoorsTextBox.Click
  MyAppTool._WinDoorTool.ToggleSelection("DubDoors")
End Sub

'User selected the Double Doors Picture Box
Private Sub DoubleDoorsPic_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles DoubleDoorsPic.Click
  MyAppTool._WinDoorTool.ToggleSelection("DubDoors")
End Sub
'************************************************************************************************
'END WINDOWS AND DOORS TAB
'************************************************************************************************
#End Region
#Region "Textures Tab"
'************************************************************************************************
'BEGIN TEXTURES TAB
'************************************************************************************************
'Apply the Roof Texture
Private Sub ApplyRoofTex_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles ApplyRoofTex.Click
  If SelTool.AcadHasWindowActive() = True Then
    If ConfigHasBeenRun = True Then
      'Load the Autocad render
      RendTool.LoadRend()
      TexTool.ApplyDefaultRoofTex()
    Else
      MsgBox("AutoCAD has Not been properly configured for this application yet."_
          MsgBoxStyle.Critical"FabLab Config Error")
    End If
  Else
    MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
  End If
End Sub

'Apply the Parking Lot Texture
Private Sub ApplyParkingLotTex_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles ApplyParkingLotTex.Click
  If SelTool.AcadHasWindowActive() = True Then
    If ConfigHasBeenRun = True Then
      'Load the Autocad render
      RendTool.LoadRend()
      TexTool.ApplyDefaultParkingLotTex()
    Else
      MsgBox("AutoCAD has Not been properly configured for this application yet."_
          MsgBoxStyle.Critical"FabLab Config Error")
    End If
  Else
    MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
  End If
End Sub

'Select and Apply Button on the Textures Tab
Private Sub ApplyWallTex_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles ApplyWallTex.Click
  Dim SelectedTex As String = Nothing
  If SelTool.AcadHasWindowActive() = True Then
    If ConfigHasBeenRun = True Then
      'Load the Autocad render
      RendTool.LoadRend()
      'make the calls to apply the wall texture here

      SelectedTex = TextureSelector1.SelectedItem.ToString()
      TexTool.ApplySelWallTex(SelectedTex)
    Else
      MsgBox("AutoCAD has Not been properly configured for this application yet."_
          MsgBoxStyle.Critical"FabLab Config Error")
    End If
  Else
    MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
  End If
End Sub

'Apply the selected Band Texture
Private Sub ApplyBandTex_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles ApplyBandTex.Click
  Dim SelectedTex As String = Nothing
  If SelTool.AcadHasWindowActive() = True Then
    If ConfigHasBeenRun = True Then
      'Load the AutoCAD Render
      RendTool.LoadRend()
      'make the calls to apply the band texture here
      SelectedTex = BandTexSelector.SelectedItem.ToString()
      'need to figure out which objects the user wants to apply this texture to.
      Sel = Nothing                    'Clear the selection set
      Me.MinimizeBox = True
      AppActivate(SelTool.AcadApp.Caption)
      SelTool.AcadDoc.Activate()

      'Prompt the user to select objects
      'and add them to the selection set.
      'To finish selecting, press ENTER.

      'RendTool.ConfigureForWinDoorSelect()
      'Still need to turn off all the other layers except the blockouts layers.
      VisTool.HideAllLayersBut("Bands""RedBroom""GreenBroom""BlueBroom""WhiteBroom""RakeBand"_
          "RibBand""AggRibBand""AggRibCementBand""FlatAggBand""FormSandBlastedBand""GreyAggFlatBand"_
          "RakeNewBand""RandAggRibBand""RandRibPaintedBand""RedAggBrickStampBand""RedAggFlatBand"_
          "RedBrickCementStampBand""RevealsPaintedBand""SmallSquareStampBand""SquareRibAggBand"_
          "SquareStampAggBand""StampedBrickAggBand""WideRakePaintedBand")
      Try
      Sel = SelTool.AcadDoc.SelectionSets.Add("xMM")
      Sel = SelTool.AcadDoc.SelectionSets.Item("xMM")
      Catch ex As Exception
      'The selectionset must already exist, therefore we could just continue
      Sel = SelTool.AcadDoc.SelectionSets.Item("xMM")
      End Try
      Sel.SelectOnScreen()
      If ListBoxTool.LineCount(Sel= 0 Then
        SelTool.AllLayersOn()
        Me.MinimizeBox = False
        Me.Activate()
        MsgBox("You need to select some windows or doors."_
            MsgBoxStyle.Critical"FabLab AddSeg Error")
        RendTool.UnConfigureForWinDoorSelect()
        SelTool.RefreshAll()
        Exit Sub
      End If
      TexTool.ApplySelBandTex(SelSelectedTex)
      RendTool.UnConfigureForWinDoorSelect()

      SelTool.AllLayersOn()
      Me.MinimizeBox = False
      SelTool.RefreshAll()
      Me.Activate()
    Else
      MsgBox("AutoCAD has Not been properly configured for this application yet."_
          MsgBoxStyle.Critical"Fablab Config Error")
    End If
  Else
    MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
  End If
End Sub

'Apply the selected Sidewalk Texture
Private Sub ApplySidewalkTex_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles ApplySidewalkTex.Click
  Dim SelectedTex As String = Nothing
  If SelTool.AcadHasWindowActive() = True Then
    If ConfigHasBeenRun = True Then
      'Load the AutoCAD Render
      RendTool.LoadRend()
      'make the calls to apply the sidewalk texture here
      SelectedTex = SidewalkTexSelector.SelectedItem.ToString()
      'need to figure out which objects the user wants to apply this texture to.
      Sel = Nothing                    'Clear the selection set
      Me.MinimizeBox = True
      AppActivate(SelTool.AcadApp.Caption)
      SelTool.AcadDoc.Activate()

      'Prompt the user to select objects
      'and add them to the selection set.
      'To finish selecting, press ENTER.
      'RendTool.ConfigureForSideWalkSelect()
      VisTool.HideAllLayersBut("BrkSiWlk""CobStn""Sidewalk""FabWallBaseLine")
      Try
      Sel = SelTool.AcadDoc.SelectionSets.Add("xMM")
      Sel = SelTool.AcadDoc.SelectionSets.Item("xMM")
      Catch ex As Exception
      'The selectionset must already exist, therefore we could just continue
      Sel = SelTool.AcadDoc.SelectionSets.Item("xMM")
      End Try
      Sel.SelectOnScreen()
      If ListBoxTool.LineCount(Sel= 0 Then
        SelTool.AllLayersOn()
        Me.MinimizeBox = False
        Me.Activate()
        MsgBox("You need to select some windows or doors."_
            MsgBoxStyle.Critical"FabLab AddSeg Error")
        RendTool.UnConfigureForSidewalkSelect()
        SelTool.AllLayersOn()
        SelTool.RefreshAll()
        Exit Sub
      End If
      TexTool.ApplySelSidewalkTex(SelSelectedTex)
      RendTool.UnConfigureForSidewalkSelect()

      SelTool.AllLayersOn()
      Me.MinimizeBox = False
      SelTool.RefreshAll()
      Me.Activate()
    Else
      MsgBox("AutoCAD has Not been properly configured for this application yet."_
          MsgBoxStyle.Critical"Fablab Config Error")
    End If
  Else
    MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
  End If
End Sub

'AutoApply Textures Checkbox
Private Sub AutoApply_CheckedChanged(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles AutoApply.CheckedChanged
  If Me.AutoApply.Checked = True Then
    TextureSelector1.Enabled = False
    ApplyWallTex.Enabled = False
    ApplyRoofTex.Enabled = False
    AutoApplyTex.Enabled = True
  ElseIf Me.AutoApply.Checked = False Then
    TextureSelector1.Enabled = True
    ApplyWallTex.Enabled = True
    ApplyRoofTex.Enabled = True
    AutoApplyTex.Enabled = False
  End If
End Sub

'Auto Apply the textures
Private Sub AutoApplyTex_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles AutoApplyTex.Click
  If SelTool.AcadHasWindowActive() = True Then
    If ConfigHasBeenRun = True Then
      'Load the Autocad render
      RendTool.LoadRend()
      TexTool.ApplyDefaultTex()
    Else
      MsgBox("AutoCAD has Not been properly configured for this application yet."_
          MsgBoxStyle.Critical"FabLab Config Error")
    End If
  Else
    MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
  End If
End Sub

'Set the Joint Lines
Private Sub SetJoints_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles SetJoints.Click
  'Mark suggested that I just set the lines on the wall panel objects to be visible in the rendering, that way
  'It would just look like there are joints.
End Sub
'************************************************************************************************
'END TEXTURES TAB
'************************************************************************************************
#End Region
#Region "Rendering Tab"
'************************************************************************************************
'BEGIN RENDERING TAB
'************************************************************************************************
'Switch to a shaded view mode
Private Sub SetShaded_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles SetShaded.Click
  RendTool.SetShadedMode()
End Sub

'Switch to Wireframe view mode
Private Sub SetWireFrame_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles SetWireFrame.Click
  RendTool.SetWireMode()
End Sub

'Render the current view
Private Sub Render_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Render.Click
  RendTool.SetBackground()
  RendTool.RayTrace()
End Sub

'Render the output to a file
Private Sub Render2File_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Render2File.Click
  If SelTool.AcadHasWindowActive() = True Then
    Dim FileName As String = Nothing

    'myFile = myFile this line makes no sense at all, and I'm not even sure why it's in here! LOL
    If myFile IsNot Nothing Then
      FileName = PathOverrideSelectTool.AutoSetOutputPath(myFile".dwg")
    Else
      'Special Case!
      'this is the case that the program has been run without loading a file, and it is being used on an
      'AutoCAD window that was already opened when the program was started.
      'I'm wondering if we can hack the system here and get the path that the current file is being worked from
      'Then assign it to the proper varable here to make everything just peachy!
      Dim MyActiveDoc As AutoCAD.AcadDocument
      MyActiveDoc = SelTool.AcadApp.ActiveDocument
      myFile = MyActiveDoc.FullName
      FileName = PathOverrideSelectTool.AutoSetOutputPath(myFile".dwg")
    End If

    'need to check and see if this file exists already, if it does then we need to pop-up a dialog box
    'and ask the user if they want to over write the existing file.
    If File.Exists(FileName= True Then
      OverwriteFile.ShowDialog()
      If OverwriteFile.DialogResult = Windows.Forms.DialogResult.OK Then
        FileName = FileName.Replace("\""/")
        RendTool.SetBackground()
        RendTool.RayTrace2File(FileName)
      End If
    Else
      FileName = FileName.Replace("\""/")
      RendTool.SetBackground()
      RendTool.RayTrace2File(FileName)
    End If
  Else
    MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
  End If
End Sub

'Switch to the top-Down view
Private Sub TopView_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles TopView.Click
  RendTool.SetTopView()
End Sub

'User clicked the view button from the North West Isometric view angle
Private Sub NWWrkView_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles NWWrkView.Click
  RendTool.SetNWIsometricWrkView()
End Sub

'User clicked the view button from the North West hill-top marketing view angle
Private Sub NWMarketView_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles NWMarketView.Click
  RendTool.SetNWMarketingView()
End Sub

'User clicked the view button from the North East Isometric view angle
Private Sub NEWrkView_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles NEWrkView.Click
  RendTool.SetNEIsometricWrkView()
End Sub

'User clicked the view button from the North East hill-top marketing view angle
Private Sub NEMarketView_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles NEMarketView.Click
  RendTool.SetNEMarketingView()
End Sub

'User clicked the view button from the South East Isometric view angle
Private Sub SEWrkView_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles SEWrkView.Click
  RendTool.SetSEIsometricWrkView()
End Sub

'User clicked the view button from the South East hill-top marketing view angle
Private Sub SEMarketView_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles SEMarketView.Click
  RendTool.SetSEMarketingView()
End Sub

'User clicked the view button from the North West low view angle
Private Sub NWLowView_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles NWLowView.Click
  RendTool.SetNWLowView()
End Sub

'User clicked the view button from the North East low view angle
Private Sub NELowView_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles NELowView.Click
  RendTool.SetNELowView()
End Sub

'User clicked the view button from the South East low view angle
Private Sub SELowView_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles SELowView.Click
  RendTool.SetSELowView()
End Sub

'User clicked the view button from the South Weat low view angle
Private Sub SWLowView_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles SWLowView.Click
  RendTool.SetSWLowView()
End Sub

'Switch to an isometric view
Private Sub IsoView_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles IsoView.Click
  RendTool.SetSWIsometricWrkView()
End Sub

'Switch to the marketing view
Private Sub SetMarketView_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles SetMarketView.Click
  RendTool.SetSWMarketingView()
End Sub

'User has clicked the button to turn switch to the Perspective View
Private Sub CreateView_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles CreateView.Click
  SelTool.LoadAutoCAD()
  Dim CamPt(2As Double
  'need to get the X and Y coordinates of the base point from the user
  'We will set the Z coordinate manually in here for now, and later from code.
  Dim TargetPt(2As Double
  Me.MinimizeBox = True
  AppActivate(SelTool.AcadApp.Caption)
  SelTool.AcadDoc.Activate()
  'Configure the user interface for loop selection
  RendTool.ConfigureForLoopSelect()
  TargetPt = SelTool.AcadDoc.Utility.GetPoint(, "Target Point: ")
  CamPt = SelTool.AcadDoc.Utility.GetPoint(, "Camera Point: ")
  Me.MinimizeBox = False
  RendTool.UnConfigureForLoopSelect()
  Me.Activate()

  'Set Default elevations for the camera and the target
  TargetPt(2= 1200
  CamPt(2= 1575

  CameraElevation.Text = TargetPt(2).ToString()
  TargetElevation.Text = CamPt(2).ToString()
  'user has set a new camera object so we need to add it to the list now
  Me._CustomViewsListBoxTool.AddCustomView(CamPtTargetPt)  'Generate the name from inside the class

End Sub

'User has pressed a key in the CameraElevation field, we should check to see if it was the enter key
Private Sub CameraElevation_KeyPress(ByVal sender As ObjectByVal e As System.Windows.Forms.KeyPressEventArgsHandles CameraElevation.KeyPress
  Dim mychar As Char
  mychar = e.KeyChar.ToString
  If mychar = Chr(13Then             'Check to see if it was the enter key, then we do the work
    If SelTool.AcadHasWindowActive() = True Then

      Dim NewCamElev As Double
      NewCamElev = Double.Parse(CameraElevation.Text)

      'just call the CustomViewListBoxTool to make the modifications to the selected Items, and redraw the
      'current camera view if necessary
      Me._CustomViewsListBoxTool.ModifyCustomViewCamElev(NewCamElev)
    Else
      MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
    End If
  End If
End Sub

'User has pressed a key in the TargetElevation field, we should check to see if it was the enter key
Private Sub TargetElevation_KeyPress(ByVal sender As ObjectByVal e As System.Windows.Forms.KeyPressEventArgsHandles TargetElevation.KeyPress
  Dim mychar As Char
  mychar = e.KeyChar.ToString
  If mychar = Chr(13Then             'Check to see if it was the enter key, then we do the work
    If SelTool.AcadHasWindowActive() = True Then
      Dim NewCamTargetElev As Double
      NewCamTargetElev = Double.Parse(TargetElevation.Text)

      'Just call the CustomViewListBoxTool to make the modifications to the selected Items, and redraw the
      'current camera view if necessary
      Me._CustomViewsListBoxTool.ModifyCustomViewCamTargetElev(NewCamTargetElev)
    Else
      MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
    End If
  End If
End Sub

'User has double clicked on an item, therefore the camera view should be renamed, call the RenameView DialogBox
Private Sub CustViewsListBox_MouseDoubleClick(ByVal sender As ObjectByVal e As System.Windows.Forms.MouseEventArgs_
    Handles CustViewsListBox.MouseDoubleClick
  'Should first check to see if there is one or more than one selected item.
  If Me._CustomViewsListBoxTool._CustomViewsList.SelectedItems.Count = 1 Then
    Dim MyNewCamName As String = Nothing
    'Now lets call the dialog box to get the new name from the user
    RenameCustomView.ShowDialog()
    If RenameCustomView.DialogResult = Windows.Forms.DialogResult.OK Then
      If RenameCustomView.NewViewName.Text IsNot "" Then
        MyNewCamName = RenameCustomView.NewViewName.Text
        RenameCustomView.NewViewName.Text = ""
      Else
        Exit Sub
      End If
    End If
    If MyNewCamName IsNot "" OrElse MyNewCamName IsNot Nothing Then
      Me._CustomViewsListBoxTool.RenameCustomView(MyNewCamName)  'Should automatically identify which Item
      'is selected.
    End If
  End If
End Sub

'User or program has changed the selection of list items in the Custom Views Listbox, we should now check to see
'if the camera height and target height of all the selected items is the same, then adjust the enable feature of
'these fields as appropriate.
Private Sub CustViewsListBox_SelectedIndexChanged(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles CustViewsListBox.SelectedIndexChanged
  'We need to update everything here, AutoCAD needs to be refreshed to the currently selected view.
  'All the fields need to be updated, ect...
  '************************
  'Just proceed with development here, and we will see how well it works.
  'Update the count in the class object first
  Me._CustomViewsListBoxTool._SelListCount = Me._CustomViewsListBoxTool._CustomViewsList.SelectedItems.Count
  'We can alow the user to change more than one CustomView at a time
  'but the field CameraElev should not show a value if the values are different
  'ALSO
  'The field CameraTargetElev should not show a value if the values are different,
  'just like the landscapeItems height and elevation figures
  If Me._CustomViewsListBoxTool._SelListCount > 1 Then
    'Should check to see if the selected objects in the listbox have different elevation values
    'If they are different, then display nothing
    'If they are the same, then put that value in the CameraElevation text box and enable it,
    'so the user can choose to edit it if he so chooses
    If Me._CustomViewsListBoxTool.IsSelCamsSameElev() = False Then
      CameraElevation.Enabled = False
      CameraElevation.Text = ""
    Else
      CameraElevation.Enabled = True
      CameraElevation.Text = Me._CustomViewsListBoxTool.GetSelCamElev().ToString()
    End If
    'Now we need to check the Camera Targets elevation
    If Me._CustomViewsListBoxTool.IsSelCamTargetsSameElev() = False Then
      TargetElevation.Enabled = False
      TargetElevation.Text = ""
    Else
      TargetElevation.Enabled = True
      TargetElevation.Text = Me._CustomViewsListBoxTool.GetSelCamTargetElev().ToString()
    End If
    ModifyView.Enabled = False         'Still can't enable this, because it is only possible
    'to modify one custom view at a time.
    DeleteViews.Enabled = True
  ElseIf Me._CustomViewsListBoxTool._SelListCount = 1 Then  'just one selected list object
    'Make sure to adjust the elevation value in both the Camera Elevation textbox,
    'And the Camera Targets Elevation textbox
    'We don't have to worry about them being the same elevation here because
    'We know there is only one object selected
    CameraElevation.Enabled = True
    CameraElevation.Text = Me._CustomViewsListBoxTool.GetSelCamElev().ToString()
    TargetElevation.Enabled = True
    TargetElevation.Text = Me._CustomViewsListBoxTool.GetSelCamTargetElev().ToString()
    ModifyView.Enabled = True          'Now there is only one object selected, and since only one camera object can be
    'modified at a time, then it makes sense to enable the modification button
    DeleteViews.Enabled = True
    'We should also set the one single Item as the current view to make it more interactive, that way
    'the user doesn't need to select the Recall button for just a single selection,
    'and we might even be able to completely get rid of the recall button
    Me._CustomViewsListBoxTool.RefreshCurrentSelView()
  ElseIf Me._CustomViewsListBoxTool._SelListCount = 0 Then  'Nothing is selected
    CameraElevation.Enabled = False
    CameraElevation.Text = ""
    TargetElevation.Enabled = False
    TargetElevation.Text = ""
    ModifyView.Enabled = False         'now there is nothing selected, so it makes sense that there is nothing to modify.
    DeleteViews.Enabled = False        'nothing to delete either
  End If
End Sub

'User has clicked the button to delete the currently selected custom view objects
Private Sub DeleteViews_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles DeleteViews.Click
  'First make sure that there is something selected
  If Me._CustomViewsListBoxTool.SelListCount > 0 Then
    'Should first check if the user is certain they want to delete the currently selected views from the list box.
    RemCustViewDlg.ShowDialog()
    If RemCustViewDlg.DialogResult = Windows.Forms.DialogResult.OK Then
      Me._CustomViewsListBoxTool.DelCustomViews()
    End If
  End If
End Sub

'User has clicked the button to modify the currently selected custom view.
'So the user wants to redefine the custom view camera coordinates
Private Sub ModifyView_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles ModifyView.Click
  SelTool.LoadAutoCAD()
  Dim CamPt(2As Double
  'need to get the X and Y coordinates of the base point from the user
  'We will set the Z coordinate manually in here for now, and later from code.
  Dim TargetPt(2As Double
  Me.MinimizeBox = True
  AppActivate(SelTool.AcadApp.Caption)
  SelTool.AcadDoc.Activate()
  'Configure the user interface for loop selection
  RendTool.ConfigureForLoopSelect()
  TargetPt = SelTool.AcadDoc.Utility.GetPoint(, "Target Point: ")
  CamPt = SelTool.AcadDoc.Utility.GetPoint(, "Camera Point: ")
  Me.MinimizeBox = False
  RendTool.UnConfigureForLoopSelect()
  Me.Activate()

  'Remember that now we are just modifying the X and Y coordinate based on what the user provided for coordinates,
  'for both the camera location and the camera target location
  Me._CustomViewsListBoxTool.ModifyCustomView(CamPtTargetPt)
End Sub

'Render Isometric Work View Button on the Render Tab
Private Sub RenderWrkView_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles RenderWrkView.Click
  If SelTool.AcadHasWindowActive() = True Then
    RendTool.SetSWIsometricWrkView()
    RendTool.RayTrace()
  Else
    MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
  End If
End Sub

'Render Market View Button on the Render Tab
Private Sub RenderMarketView_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles RenderMarketView.Click
  If SelTool.AcadHasWindowActive() = True Then
    RendTool.SetSWMarketingView()
    RendTool.RayTrace()
  Else
    MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
  End If
End Sub
'************************************************************************************************
'END RENDERING TAB
'************************************************************************************************
#End Region
#Region "Trees N Shrubs Tab"
'************************************************************************************************
'BEGIN TREES N SHRUBS TAB
'************************************************************************************************
'User has decided to add the selected item from the ShrubsNTreesTool Table.
Private Sub InsertLandscapeItem_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles InsertLandscapeItem.Click
  If SelTool.AcadHasWindowActive() = True Then
    If ConfigHasBeenRun = True Then
      SelTool.LoadAutoCAD()
      Sel = Nothing                    'Clear the selection set

      'Prompt the user to pick an insertion location
      'To finish selecting, press ENTER.
      Try
      Sel = SelTool.AcadDoc.SelectionSets.Add("xMM")
      Sel = SelTool.AcadDoc.SelectionSets.Item("xMM")
      Catch ex As Exception
      'The selectionset must already exist, therefore we could just continue
      Sel = SelTool.AcadDoc.SelectionSets.Item("xMM")
      End Try
      'Need to figure out which texture we are going to apply
      'But first figure out what point the user wants to use.
      Dim ShrubsNTreesSelEnt As String
      'LEFT OFF HERE FOR THE WEEKEND!!!!
      ShrubsNTreesSelEnt = MyAppTool._ShrubsNTreesTool.DeterminSelShrubsNTrees()
      If ShrubsNTreesSelEnt Is Nothing Then
        Me.MinimizeBox = False
        Me.Activate()
        MsgBox("You need to select a type of object to insert from the list."MsgBoxStyle.Critical_
            "Selection Error in ShrubsNTrees List")
        Exit Sub
      Else
        'Hide the Application window, we are about to ask the user to select an insertion point.
        'And we know that a type is selected, so lets do it!
        Me.MinimizeBox = True
        AppActivate(SelTool.AcadApp.Caption)
      End If
      Dim InsertPt(2As Double
      RendTool.ConfigureForShrubsNTrees()
      Try
      InsertPt = SelTool.AcadDoc.Utility.GetPoint(, _
          "Pick an insertion point for inserting the selected Landscape Item.")
      Catch ex As Exception

      End Try
      If InsertPt(0= 0 AndAlso InsertPt(1= 0 AndAlso InsertPt(2= 0 Then
        'The user didn't pick anything, ...or maybe they did..., and they just happened to click
        'on exactly the origin by pure chance.
        Me.MinimizeBox = False
        Me.Activate()
        MsgBox("You need to select a point."_
            MsgBoxStyle.Critical"FabLab AddSeg Error")
        SelTool.RefreshAll()
        RendTool.LoadRend()
        SelTool.AllLayersOn()
        RendTool.SetSWIsometricWrkView()
        'Render shaded mode in the viewport
        RendTool.SetShadedMode()
        RendTool.UnConfigureForShrubsNTrees()
        Me.MinimizeBox = False
        SelTool.RefreshAll()
        Me.Activate()
        Exit Sub
      Else
        'The user did pick a point
        Me.MinimizeBox = False
        Me.Activate()
        SelTool.RefreshAll()
        RendTool.LoadRend()
        SelTool.AllLayersOn()
        RendTool.SetSWIsometricWrkView()
        'Render shaded mode in the viewport
        RendTool.SetShadedMode()
        RendTool.UnConfigureForShrubsNTrees()
        Me.MinimizeBox = False
        SelTool.RefreshAll()
        Me.Activate()
      End If
      'Determine which one is selected now
      Dim NewItemName As String = Nothing
      Select Case ShrubsNTreesSelEnt
        Case "Shrub"
          NewItemName = Me._LandscapeListBoxTool.GenName("Shrub")
        Case "DawnRedwood"
          NewItemName = Me._LandscapeListBoxTool.GenName("DawnRedwood")
        Case "EasternPalm"
          NewItemName = Me._LandscapeListBoxTool.GenName("EasternPalm")
        Case "NorwayMapleFall"
          NewItemName = Me._LandscapeListBoxTool.GenName("NorwayMapleFall")
        Case "QuakingAspen"
          NewItemName = Me._LandscapeListBoxTool.GenName("QuakingAspen")
        Case "SweetgumSummer"
          NewItemName = Me._LandscapeListBoxTool.GenName("SweetgumSummer")
      End Select
      'NewItemName now contains the new name of the item the user has selected to add.
      'It should automatically append the name.
      Me._LandscapeListBoxTool.ListBoxAddItem(SelNewItemNameInsertPt)
      'We also need to make sure the new item is in Sel then also create the new layer and move that object
      'make the call to ShurbsNTrees to do all of this backend work, since it's already implemented there.
    Else
      MsgBox("AutoCAD has Not been properly configured for this application yet."_
          MsgBoxStyle.Critical"FabLab Config Error")
    End If
  Else
    MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
  End If
End Sub

'User has double clicked on an item in the Landscape Item List Box and this means the user wants ot rename the item.
Private Sub LandscapeListBox_MouseDoubleClick(ByVal sender As ObjectByVal e As System.Windows.Forms.MouseEventArgs_
    Handles LandscapeListBox.MouseDoubleClick
  Me._LandscapeListBoxTool._SelListCount = Me._LandscapeListBoxTool._LandscapeItemList.SelectedItems.Count()
  'Allow the user to rename the segment if there is only one item selected
  If Me._LandscapeListBoxTool._SelListCount = 1 Then
    'Still need to display the dialog box for letting the user input a new name.
    RenameLandscapeItem.ShowDialog()
    If RenameLandscapeItem.DialogResult = Windows.Forms.DialogResult.OK Then
      Dim NewItemName As String
      NewItemName = RenameLandscapeItem.NewSegName.Text
      Me._LandscapeListBoxTool.ListBoxRenameItem(NewItemName)
      RenameLandscapeItem.NewSegName.Text = Nothing  'Clear the field in the dialog box for the next time.
    End If
  End If
End Sub

'The user changed the Landscape Items selected in the list box
Private Sub LandscapeListBox_SelectedIndexChanged(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles LandscapeListBox.SelectedIndexChanged
  'This is the component that drives what gets set in the Item height field
  Me._LandscapeListBoxTool._SelListCount = Me._LandscapeListBoxTool._LandscapeItemList.SelectedItems.Count()
  'Only display the number in the Height if the Height values for all the selected items is exactly the same
  'First need to determine if there is more than one item selected
  If Me._LandscapeListBoxTool._SelListCount = 0 Then
    'No Landscape Items selected
    LandscapeItemHeight.Enabled = False
    LandscapeItemElevation.Enabled = False
    LandscapeItemHeight.Text = ""      'clear it out since there is nothing selected, therefore nothing to show
    LandscapeItemElevation.Text = ""
  ElseIf Me._LandscapeListBoxTool._SelListCount = 1 Then
    'Just one Landscape Item selected
    LandscapeItemHeight.Enabled = True
    LandscapeItemElevation.Enabled = True
    LandscapeItemHeight.Text = Me._LandscapeListBoxTool.GetSelItemHeight()
    LandscapeItemElevation.Text = Me._LandscapeListBoxTool.GetSelItemElevation()
  ElseIf Me._LandscapeListBoxTool._SelListCount > 1 Then
    'Many Selected Landscape Items!
    'Now we determine if they are the same height or not
    If Me._LandscapeListBoxTool.IsSelSameHeight() = True Then
      LandscapeItemHeight.Text = Me._LandscapeListBoxTool.GetSelItemHeight()
    Else
      LandscapeItemHeight.Text = ""
      LandscapeItemHeight.Enabled = False
    End If
    'Now we determine if they are the same elevation or not
    If Me._LandscapeListBoxTool.IsSelSameElevation() = True Then
      LandscapeItemElevation.Text = Me._LandscapeListBoxTool.GetSelItemElevation()
    Else
      LandscapeItemElevation.Text = ""
      LandscapeItemElevation.Enabled = False
    End If
  End If
End Sub

'The user changed the Landscape selected Items height
Private Sub LandscapeItemHeight_KeyPress(ByVal sender As System.Object_
    ByVal e As System.Windows.Forms.KeyPressEventArgsHandles LandscapeItemHeight.KeyPress
  Dim mychar As Char
  mychar = e.KeyChar.ToString
  If mychar = Chr(13Then
    If SelTool.AcadHasWindowActive() = True Then
      'We have to change the height for all the selected objects.
      'I'm thinking it may be eaiser just to remove them one by one and replace them with copies of the new height.
      Dim NewHeight As Double
      NewHeight = Double.Parse(LandscapeItemHeight.Text)
      '****************************
      'Something is happening in the below function call.
      'When it is called then the class varables are full of data, after the call, and even while in the function
      'The data is completely gone!
      Me._LandscapeListBoxTool.ChangeSelLandscapeItemHeight(NewHeight)
      LandscapeItemHeight.Text = Me._LandscapeListBoxTool.GetSelItemHeight()
      SelTool.RefreshAll()
    Else
      MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
    End If
  End If
End Sub

'The user changed the Landscape selected Items elevation
Private Sub LandscapeItemElevation_KeyPress(ByVal sender As System.Object_
    ByVal e As System.Windows.Forms.KeyPressEventArgsHandles LandscapeItemElevation.KeyPress
  Dim mychar As Char
  mychar = e.KeyChar.ToString
  If mychar = Chr(13Then
    If SelTool.AcadHasWindowActive() = True Then
      'Elevation is much eaiser to change because we can just move the object we don't need to scale it.
      Dim NewElevation As Double
      NewElevation = Double.Parse(LandscapeItemElevation.Text)
      Me._LandscapeListBoxTool.ChangeSelLandscapeItemsElevation(NewElevation)
      LandscapeItemElevation.Text = Me._LandscapeListBoxTool.GetSelItemElevation().ToString()
      SelTool.RefreshAll()
    Else
      MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
    End If
  End If
End Sub

'User clicked the button to Hide the selected Landscape Item(s)
Private Sub HideSelLandscapeItem_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles HideSelLandscapeItem.Click
  Me._LandscapeListBoxTool.HideSelLandscapeItems()
  SelTool.RefreshAll()
End Sub

'User clicked the button to Show the selected Landscape Item(s)
Private Sub ShowSelLandscapeItem_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles ShowSelLandscapeItem.Click
  Me._LandscapeListBoxTool.ShowSelLandscapeItems()
  SelTool.RefreshAll()
End Sub

'User clicked the button to select all Items of the selected type in the Listbox
'We could have a problem here because the user may have multiple types selected
Private Sub SelLandscapeItemByType_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles SelLandscapeItemByType.Click
  'Need to first Identify what types of objects are selected
  Dim SelCollection As Collection
  SelCollection = Me._LandscapeListBoxTool.IdentifySelTypes()
  'SelCollection now contains a list of unique item types that where selected.
  'Now we need to go through a list of all objects in the LandscapeListBoxTool
  'and check each one for it's type to see if it's type matches one of the types in the SelCollection
  Me._LandscapeListBoxTool.SelAllItemsOfTypes(SelCollection)
End Sub

'The user clicked the button to delete the current Landscape Item
Private Sub DelSelLandscapeItem_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles DelSelLandscapeItem.Click
  If SelTool.AcadHasWindowActive() = True Then
    'Should check to see if we even have any selected list items.
    If Me._LandscapeListBoxTool._SelListCount >= 1 Then
      RemLandscapeItemDlg.ShowDialog()
      If RemLandscapeItemDlg.DialogResult = Windows.Forms.DialogResult.OK Then
        'then we are ready to remove all the selected items from the list
        'Remove the Selected items
        Me._LandscapeListBoxTool.ListBoxRemItem()
        LandscapeItemHeight.Text = ""
        LandscapeItemHeight.Enabled = False
      End If
    Else
      MsgBox("There is nothing to remove! You must first select an item from the Sidewalk Seg Listbox for removal"_
          MsgBoxStyle.Critical"Listbox Sidewalk Control Error")
    End If
  Else
    MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
  End If
  'Don't forget to refresh!
  SelTool.RefreshAll()
End Sub

'User selected the Shrub Picture Box
Private Sub ShrubPic_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles ShrubPic.Click
  MyAppTool._ShrubsNTreesTool.ToggleSelection("Shrub")
End Sub

'User selected the Shrub Textbox
Private Sub ShrubDescription_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles ShrubDescription.Click
  MyAppTool._ShrubsNTreesTool.ToggleSelection("Shrub")
End Sub

'User selected the DawnRedwood Picture Box
Private Sub DawnRedwoodPic_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles DawnRedwoodPic.Click
  MyAppTool._ShrubsNTreesTool.ToggleSelection("DawnRedwood")
End Sub

'User selected the DawnRedwood Textbox
Private Sub DawnRedwoodDescription_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles DawnRedwoodDescription.Click
  MyAppTool._ShrubsNTreesTool.ToggleSelection("DawnRedwood")
End Sub

'User selected the EasternPalm Picture Box
Private Sub EasternPalmPic_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles EasternPalmPic.Click
  MyAppTool._ShrubsNTreesTool.ToggleSelection("EasternPalm")
End Sub

'User selected the EasternPalm Textbox
Private Sub EasternPalmDescription_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles EasternPalmDescription.Click
  MyAppTool._ShrubsNTreesTool.ToggleSelection("EasternPalm")
End Sub

'User selected the NorwayMapleFall Picture Box
Private Sub NorwayMapleFallPic_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles NorwayMapleFallPic.Click
  MyAppTool._ShrubsNTreesTool.ToggleSelection("NorwayMapleFall")
End Sub

'User selected the NorwayMapleFall Textbox
Private Sub NorwayMapleFallDescription_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles NorwayMapleFallDescription.Click
  MyAppTool._ShrubsNTreesTool.ToggleSelection("NorwayMapleFall")
End Sub

'User selected the QuakingAspen Picture Box
Private Sub QuakingAspenPic_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles QuakingAspenPic.Click
  MyAppTool._ShrubsNTreesTool.ToggleSelection("QuakingAspen")
End Sub

'User selected the QuakingAspen Textbox
Private Sub QuakingAspenDescription_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles QuakingAspenDescription.Click
  MyAppTool._ShrubsNTreesTool.ToggleSelection("QuakingAspen")
End Sub

'User selected the SweetgumSummer Picture Box
Private Sub SweetgumSummerPic_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles SweetgumSummerPic.Click
  MyAppTool._ShrubsNTreesTool.ToggleSelection("SweetgumSummer")
End Sub

'User selected the SweetgumSummer Textbox
Private Sub SweetgumSummerDescription_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles SweetgumSummerDescription.Click
  MyAppTool._ShrubsNTreesTool.ToggleSelection("SweetgumSummer")
End Sub

'************************************************************************************************
'END TREES N SHRUBS TAB
'************************************************************************************************
#End Region
#Region "Config Tab"
'************************************************************************************************
'BEGIN CONFIG TAB
'************************************************************************************************
'Help for the User Selection Roof Line Option
'Config tab
Private Sub UserSelRoofQButton_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles UserSelRoofQButton.Click
  UserSelRoofQDlg.ShowDialog()
End Sub

'Help for the Auto Selection Roof Line Option
'Config Tab
Private Sub AutoLoopRoofSegQButton_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles AutoLoopRoofSegQButton.Click
  AutoSelRoofQDlg.ShowDialog()
End Sub
'************************************************************************************************
'END CONFIG TAB
'************************************************************************************************
#End Region

Private Sub ApplyAsphaultTex_Click(ByVal sender As System.ObjectByVal e As System.EventArgs_
    Handles ApplyAsphaultTex.Click
  Dim SelectedTex As String = Nothing
  If SelTool.AcadHasWindowActive() = True Then
    If ConfigHasBeenRun = True Then
      'Load the AutoCAD Render
      RendTool.LoadRend()
      'make the calls to apply the Asphault texture here
      SelectedTex = AsphaultTexSelector.SelectedItem.ToString()
      'need to figure out which objects the user wants to apply this texture to.
      Sel = Nothing                    'Clear the selection set
      Me.MinimizeBox = True
      AppActivate(SelTool.AcadApp.Caption)
      SelTool.AcadDoc.Activate()

      'Prompt the user to select objects
      'and add them to the selection set.
      'To finish selecting, press ENTER.
      'RendTool.ConfigureForSideWalkSelect()
      VisTool.HideAllLayersBut("ParkingLot""Asphalt")
      Try
      Sel = SelTool.AcadDoc.SelectionSets.Add("xMM")
      Sel = SelTool.AcadDoc.SelectionSets.Item("xMM")
      Catch ex As Exception
      'The selectionset must already exist, therefore we could just continue
      Sel = SelTool.AcadDoc.SelectionSets.Item("xMM")
      End Try
      Sel.SelectOnScreen()
      If ListBoxTool.LineCount(Sel= 0 Then
        SelTool.AllLayersOn()
        Me.MinimizeBox = False
        Me.Activate()
        MsgBox("You need to select some windows or doors."_
            MsgBoxStyle.Critical"FabLab AddSeg Error")
        RendTool.UnConfigureForSidewalkSelect()
        SelTool.AllLayersOn()
        SelTool.RefreshAll()
        Exit Sub
      End If
      TexTool.ApplySelSidewalkTex(SelSelectedTex)
      RendTool.UnConfigureForSidewalkSelect()

      SelTool.AllLayersOn()
      Me.MinimizeBox = False
      SelTool.RefreshAll()
      Me.Activate()
    Else
      MsgBox("AutoCAD has Not been properly configured for this application yet."_
          MsgBoxStyle.Critical"Fablab Config Error")
    End If
  Else
    MsgBox("You must load a drawing file first"MsgBoxStyle.Critical"FabLab File Error")
  End If
End Sub
End Class


Generated using PrettyCode.Encoder