Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 2bb5ffce authored by Terry Burns's avatar Terry Burns Committed by Kostis ANAGNOSTOPOULOS
Browse files
parent d74b6166
Branches
Tags
No related merge requests found
......@@ -7,65 +7,17 @@ Imports System.ComponentModel
Public Class Form1
Private Const ALLONLIST As String = "SSMTechBenefitsALLON.CSV"
Private genInputs As ISSMGenInputs = New SSMGenInputs(True)
Private ssmTechList As ISSMTechList = New SSMTechList(ALLONLIST, genInputs)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If ssmTechList.Initialise() = False Then MsgBox("Failed to initalise list")
Dim frm As New frmHVACTool("BusDatabase.csv", "ssmDelete.ahsm")
SetUpControls
SetUpBindings
frm.Show
End Sub
Public Sub SetUpControls()
Dim cIndex As Integer = 0
gvTechBenefits.AutoGenerateColumns = False
'BenefitName As String
''LowFloor As BusFloorLow
'ElectricalConsumerGrid
'Columns
cIndex = gvTechBenefits.Columns.Add("BenefitName", "BenefitName")
gvTechBenefits.Columns(cIndex).DataPropertyName = "BenefitName"
gvTechBenefits.Columns(cIndex).MinimumWidth = 150
gvTechBenefits.Columns(cIndex).ReadOnly = false
gvTechBenefits.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter
gvTechBenefits.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1)
cIndex = gvTechBenefits.Columns.Add("LowFloorV" ,"LowFloorV")
gvTechBenefits.Columns(cIndex).DataPropertyName = "LowFloorV"
gvTechBenefits.Columns(cIndex).MinimumWidth = 70
gvTechBenefits.Columns(cIndex).ReadOnly = false
gvTechBenefits.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter
gvTechBenefits.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1)
End Sub
Public Sub SetUpBindings()
'Dim electricalConsumerBinding As New BindingList(Of IElectricalConsumer)(auxConfig.ElectricalUserInputsConfig.ElectricalConsumers.Items)
'gvElectricalConsumables.DataSource = electricalConsumerBinding
'Electrical ConsumablesGrid
Dim techListBinding As New BindingList(Of ITechListBenefitLine)(ssmTechList.TechLines)
gvTechBenefits.DataSource = techListBinding
End Sub
End Class
......@@ -6,7 +6,7 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C34CFD60-2081-4EA3-AC18-6769291FBDBD}</ProjectGuid>
<OutputType>WinExe</OutputType>
<StartupObject>Sub Main</StartupObject>
<StartupObject>VectoAuxiliaries.Main</StartupObject>
<RootNamespace>VectoAuxiliaries</RootNamespace>
<AssemblyName>HVACTOOL</AssemblyName>
<FileAlignment>512</FileAlignment>
......
......@@ -6,7 +6,7 @@ Sub main()
Dim frm As New frmHVACTool("BusDatabase.csv", "ssmDelete.ahsm")
frm.ShowDialog
frm.ShowDialog()
End Sub
......
......@@ -54,10 +54,10 @@ Implements ISSMTOOL
End Sub
Sub New(filePath As String)
Sub New(filePath As String, Optional useTestValues As Boolean = false)
Me.filePath = filePath
genInputs = New SSMGenInputs()
genInputs = New SSMGenInputs(useTestValues)
techList = New SSMTechList(filePath, genInputs)
End Sub
......
......@@ -162,6 +162,9 @@ Partial Class frmHVACTool
Me.lblUnitstxtEC_EnviromentalTemperature = New System.Windows.Forms.Label()
Me.lblUnitstxtEC_Solar = New System.Windows.Forms.Label()
Me.tabTechBenefits = New System.Windows.Forms.TabPage()
Me.btnClearForm = New System.Windows.Forms.Button()
Me.lblIndex = New System.Windows.Forms.Label()
Me.txtIndex = New System.Windows.Forms.TextBox()
Me.btnUpdate = New System.Windows.Forms.Button()
Me.lblLineType = New System.Windows.Forms.Label()
Me.chkActiveVC = New System.Windows.Forms.CheckBox()
......@@ -196,11 +199,8 @@ Partial Class frmHVACTool
Me.cboUnits = New System.Windows.Forms.ComboBox()
Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
Me.ErrorProvider1 = New System.Windows.Forms.ErrorProvider(Me.components)
Me.txtIndex = New System.Windows.Forms.TextBox()
Me.lblIndex = New System.Windows.Forms.Label()
Me.btnSave = New System.Windows.Forms.Button()
Me.btnCancel = New System.Windows.Forms.Button()
Me.btnClearForm = New System.Windows.Forms.Button()
Me.tabMain.SuspendLayout
Me.tabGeneralInputsBP.SuspendLayout
Me.GroupBox1.SuspendLayout
......@@ -1791,6 +1791,32 @@ Partial Class frmHVACTool
Me.tabTechBenefits.Text = " Tech List Input "
Me.tabTechBenefits.UseVisualStyleBackColor = true
'
'btnClearForm
'
Me.btnClearForm.Location = New System.Drawing.Point(814, 100)
Me.btnClearForm.Name = "btnClearForm"
Me.btnClearForm.Size = New System.Drawing.Size(75, 23)
Me.btnClearForm.TabIndex = 34
Me.btnClearForm.Text = "Clear Form"
Me.btnClearForm.UseVisualStyleBackColor = true
'
'lblIndex
'
Me.lblIndex.AutoSize = true
Me.lblIndex.Location = New System.Drawing.Point(29, 18)
Me.lblIndex.Name = "lblIndex"
Me.lblIndex.Size = New System.Drawing.Size(33, 13)
Me.lblIndex.TabIndex = 33
Me.lblIndex.Text = "Index"
'
'txtIndex
'
Me.txtIndex.Location = New System.Drawing.Point(81, 15)
Me.txtIndex.Name = "txtIndex"
Me.txtIndex.ReadOnly = true
Me.txtIndex.Size = New System.Drawing.Size(58, 20)
Me.txtIndex.TabIndex = 32
'
'btnUpdate
'
Me.btnUpdate.Location = New System.Drawing.Point(814, 18)
......@@ -2085,23 +2111,6 @@ Partial Class frmHVACTool
'
Me.ErrorProvider1.ContainerControl = Me
'
'txtIndex
'
Me.txtIndex.Location = New System.Drawing.Point(81, 15)
Me.txtIndex.Name = "txtIndex"
Me.txtIndex.ReadOnly = true
Me.txtIndex.Size = New System.Drawing.Size(58, 20)
Me.txtIndex.TabIndex = 32
'
'lblIndex
'
Me.lblIndex.AutoSize = true
Me.lblIndex.Location = New System.Drawing.Point(29, 18)
Me.lblIndex.Name = "lblIndex"
Me.lblIndex.Size = New System.Drawing.Size(33, 13)
Me.lblIndex.TabIndex = 33
Me.lblIndex.Text = "Index"
'
'btnSave
'
Me.btnSave.Location = New System.Drawing.Point(721, 694)
......@@ -2120,21 +2129,11 @@ Partial Class frmHVACTool
Me.btnCancel.Text = "Cancel"
Me.btnCancel.UseVisualStyleBackColor = true
'
'btnClearForm
'
Me.btnClearForm.Location = New System.Drawing.Point(814, 100)
Me.btnClearForm.Name = "btnClearForm"
Me.btnClearForm.Size = New System.Drawing.Size(75, 23)
Me.btnClearForm.TabIndex = 34
Me.btnClearForm.Text = "Clear Form"
Me.btnClearForm.UseVisualStyleBackColor = true
'
'frmHVACTool
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6!, 13!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.AutoValidate = System.Windows.Forms.AutoValidate.EnableAllowFocusChange
Me.CausesValidation = false
Me.ClientSize = New System.Drawing.Size(965, 729)
Me.Controls.Add(Me.btnCancel)
Me.Controls.Add(Me.btnSave)
......
......@@ -10,12 +10,15 @@ Public Class frmHVACTool
Private ahsmFilePath As String
Private buses As IBusDatabase
Private ssmTOOL As SSMTOOL
Private originalssmTOOL As SSMTOOL
Private TabColors As Dictionary(Of TabPage, Color) = New Dictionary(Of TabPage, Color)()
Private editTechLine As ITechListBenefitLine = New TechListBenefitLine(Nothing)
Private gvTechListBinding As BindingList(Of ITechListBenefitLine)
Private DefaultCategories As String() = {"Cooling","Heating","Insulation","Ventiliation"}
Private vectoFile As String = String.Empty
Private vectoPath As String = String.Empty
Private UserHitCancel As Boolean = false
Public UD As String = "Hello"
public Sub UpdateButtonText()
......@@ -33,7 +36,17 @@ Public Class frmHVACTool
end sub
Private Function ValidateSSMTOOLFileName( filename As String ) As Boolean
Dim message As String = String.Empty
If Not FilePathUtils.ValidateFilePath(filename,".ahsm", message) then
MessageBox.Show ( message )
End If
Return true
End Function
Private sub BindGrid( )
......@@ -75,12 +88,21 @@ Public Class frmHVACTool
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
'Validate ashm FILENAME
If Not ValidateSSMTOOLFileName( ahsmFilePath ) then
Me.DialogResult=Windows.Forms.DialogResult.Abort
Me.Close
End If
Me.busDatabasePath = busDatabasePath
Me.ahsmFilePath = ahsmFilePath
ssmTOOL = New SSMTOOL(ahsmFilePath)
originalssmTOOL = New SSMTOOL( ahsmFilePath)
ssmTOOL.Load(ahsmFilePath)
originalssmTOOL.Clone( ssmTOOL)
' ssmTOOL.techList.in("SSMTechBenefitsALLON.csv")
......@@ -212,7 +234,7 @@ End Sub
BindGrid()
'Bus Parameterisation
'txtBusModel.DataBindings.Add("Text", ssmTOOL.genInputs, "BP_BusModel", False, DataSourceUpdateMode.OnPropertyChanged)
txtBusModel.DataBindings.Add("Text", ssmTOOL.genInputs, "BP_BusModel", False, DataSourceUpdateMode.OnPropertyChanged)
txtRegisteredPassengers.DataBindings.Add("Text", ssmTOOL.genInputs, "BP_NumberOfPassengers", False, DataSourceUpdateMode.OnPropertyChanged)
txtBusFloorType.DataBindings.Add("Text", ssmTOOL.genInputs, "BP_BusFloorType", False, DataSourceUpdateMode.OnPropertyChanged)
txtBusFloorSurfaceArea.DataBindings.Add("Text", ssmTOOL.genInputs, "BP_BusFloorSurfaceArea", False, DataSourceUpdateMode.OnPropertyChanged)
......@@ -478,13 +500,11 @@ End Function
Return result
End Function
Public Sub Validating_TechLineEdit(sender As Object, e As CancelEventArgs) 'Handles txtSemiLowFloorV.Validating, txtSemiLowFloorH.Validating, txtSemiLowFloorC.Validating, txtRaisedFloorV.Validating, txtRaisedFloorH.Validating, txtRaisedFloorC.Validating, txtLowFloorV.Validating, txtLowFloorH.Validating, txtLowFloorC.Validating, txtBenefitName.Validating, chkOnVehicle.Validating, chkActiveVV.Validating, chkActiveVH.Validating, chkActiveVC.Validating, cboUnits.Validating, cboLineType.Validating, cboCategory.Validating
e.Cancel = Not Validate_TechLineEdit()
End Sub
Public Function Validate_TechLineEdit() As Boolean
Dim result As Boolean = True
......@@ -531,8 +551,6 @@ End Function
End If
End sub
Private Function IsPostiveInteger(ByVal test As String) As Boolean
'Is this numeric sanity check.
......@@ -654,7 +672,6 @@ End Function
End Using
End Sub
Private Sub EnsureBinding()
With tabMain
Dim lastSelectedTabIndex As Integer = .SelectedIndex
......@@ -666,7 +683,7 @@ End Function
End With
End Sub
'Form/Control Events
Private Sub frmHVACTool_Load( sender As Object, e As EventArgs) Handles MyBase.Load
'Required for OwnerDraw, this is required in order to color the tabs when a validation error occurs to draw
......@@ -685,46 +702,49 @@ End Function
gvTechBenefitLines.ClearSelection()
Dim r As DialogResult = Me.DialogResult
End Sub
Private Sub frmHVACTool_FormClosing( sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
If UserHitCancel then return
Dim result As DialogResult
If Not ssmTOOL.IsEqualTo( originalssmTOOL )
Private Sub FillTechLineEditPanel( index As Integer)
result = (MessageBox.Show("Would you like to save changes before closing?","Save Changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
Dim techline As ITechListBenefitLine
Dim benefitName , category As String
benefitName = gvTechBenefitLines.Rows(index).Cells("BenefitName").Value
category = gvTechBenefitLines.Rows(index).Cells("Category").Value
Select Case result
techline = ssmTOOL.techList.TechLines.First( Function(f) f.BenefitName=benefitName AndAlso f.Category=category)
case DialogResult.Yes:
'save
If NOT ssmTOOL.Save(ahsmFilePath) then
e.Cancel=true
End If
txtIndex.Text=index
cboCategory.Text= techline.Category
txtBenefitName.Text=techline.BenefitName
cboUnits.Text = techline.Units
cboLineType.Text = If( techline.LineType=0, "Normal","ActiveVentilation")
txtLowFloorH .Text = techline.LowFloorH
txtLowFloorV .Text = techline.LowFloorV
txtLowFloorC .Text = techline.LowFloorC
txtSemiLowFloorH.Text = techline.SemiLowFloorH
txtSemiLowFloorV.Text = techline.SemiLowFloorV
txtSemiLowFloorC.Text = techline.SemiLowFloorC
txtRaisedFloorH .Text = techline.RaisedFloorH
txtRaisedFloorV .Text = techline.RaisedFloorV
txtRaisedFloorC .Text = techline.RaisedFloorC
chkActiveVH.Checked = techline.ActiveVH
chkActiveVV.Checked = techline.ActiveVV
chkActiveVC.Checked = techline.ActiveVC
chkOnVehicle.Checked = techline.OnVehicle
case DialogResult.No:
'just allow the form to close
'without saving
Me.DialogResult=Windows.Forms.DialogResult.Cancel
case DialogResult.Cancel:
'cancel the close
e.Cancel = true
Me.DialogResult=Windows.Forms.DialogResult.Cancel
End Sub
end select
End If
UserHitCancel=false
End Sub
'Grid Events
Private Sub gvTechBenefitLines_DoubleClick( sender As Object, e As EventArgs) Handles gvTechBenefitLines.DoubleClick
If gvTechBenefitLines.SelectedCells.Count<1 then Return
......@@ -745,60 +765,38 @@ Private Sub gvTechBenefitLines_DoubleClick( sender As Object, e As EventArgs) H
End Sub
Private Sub gvTechBenefitLines_CellClick( sender As Object, e As DataGridViewCellEventArgs) Handles gvTechBenefitLines.CellClick
If e.ColumnIndex<0 OrElse e.RowIndex<0 then Return
private function GetTechLineFromPanel() as ITechListBenefitLine
Dim tl As ITechListBenefitLine = New TechListBenefitLine( ssmTOOL.genInputs)
If gvTechBenefitLines.Columns( e.ColumnIndex).Name="Delete" then
Dim benefit As String = gvTechBenefitLines.Rows( e.RowIndex).Cells(1).Value
Dim category As String = gvTechBenefitLines.Rows( e.RowIndex).Cells(0).Value
Dim feedback As String = String.Empty
tl.Category = StrConv(cboCategory.Text, vbProperCase)
tl.BenefitName = txtBenefitName.Text
tl.Units = cboUnits.Text
tl.LineType = If( cboLineType.Text= "Normal",0,3)
tl.LowFloorH = txtLowFloorH .Text
tl.LowFloorV = txtLowFloorV .Text
tl.LowFloorC = txtLowFloorC .Text
tl.SemiLowFloorH = txtSemiLowFloorH .Text
tl.SemiLowFloorV = txtSemiLowFloorV .Text
tl.SemiLowFloorC = txtSemiLowFloorC .Text
tl.RaisedFloorH = txtRaisedFloorH .Text
tl.RaisedFloorV = txtRaisedFloorV .Text
tl.RaisedFloorC = txtRaisedFloorC .Text
tl.ActiveVH = chkActiveVH .Checked
tl.ActiveVV = chkActiveVV .Checked
tl.ActiveVC = chkActiveVC .Checked
tl.OnVehicle = chkOnVehicle .Checked
Dim dr As DialogResult = MessageBox.Show(String.Format("Do you want to delete benefit '{0}' ?", benefit),"", MessageBoxButtons.YesNo)
If dr= Windows.Forms.DialogResult.Yes then
Return tl
If ssmTOOL.techList.Delete( New TechListBenefitLine With {.BenefitName= benefit, .Category=category}, feedback) then
End Function
BindGrid
Private Sub ClearEditPanel()
End If
txtIndex.Text = String.Empty
cboCategory.SelectedIndex=0
txtBenefitName.Text = String.Empty
cboUnits.SelectedIndex=0
cboLineType.SelectedIndex=0
txtLowFloorH .Text = String.Empty
txtLowFloorV .Text = String.Empty
txtLowFloorC .Text = String.Empty
txtSemiLowFloorH .Text = String.Empty
txtSemiLowFloorV .Text = String.Empty
txtSemiLowFloorC .Text = String.Empty
txtRaisedFloorH .Text = String.Empty
txtRaisedFloorV .Text = String.Empty
txtRaisedFloorC .Text = String.Empty
chkActiveVH .Checked = False
chkActiveVV .Checked = False
chkActiveVC .Checked = False
chkOnVehicle .Checked = False
End If
End If
End Sub
'Button Event Handlers
Private Sub btnUpdate_Click( sender As Object, e As EventArgs) Handles btnUpdate.Click
Dim feedback As String = String.Empty
......@@ -832,56 +830,114 @@ Private Sub btnUpdate_Click( sender As Object, e As EventArgs) Handles btnUpdat
End If
End Sub
Private Sub btnSave_Click( sender As Object, e As EventArgs) Handles btnSave.Click
If( ssmTOOL.Save( ahsmFilePath )) then
Me.Close
Private Sub btnSave_Click( sender As Object, e As EventArgs) Handles btnSave.Click
End If
ssmTOOL.Save( ahsmFilePath )
End Sub
Private Sub btnClearForm_Click( sender As Object, e As EventArgs) Handles btnClearForm.Click
ClearEditPanel()
UpdateButtonText()
End Sub
End Sub
Private Sub gvTechBenefitLines_CellClick( sender As Object, e As DataGridViewCellEventArgs) Handles gvTechBenefitLines.CellClick
If e.ColumnIndex<0 OrElse e.RowIndex<0 then Return
'TechList Helpers
Private Sub FillTechLineEditPanel( index As Integer)
Dim techline As ITechListBenefitLine
Dim benefitName , category As String
benefitName = gvTechBenefitLines.Rows(index).Cells("BenefitName").Value
category = gvTechBenefitLines.Rows(index).Cells("Category").Value
If gvTechBenefitLines.Columns( e.ColumnIndex).Name="Delete" then
techline = ssmTOOL.techList.TechLines.First( Function(f) f.BenefitName=benefitName AndAlso f.Category=category)
Dim benefit As String = gvTechBenefitLines.Rows( e.RowIndex).Cells(1).Value
Dim category As String = gvTechBenefitLines.Rows( e.RowIndex).Cells(0).Value
Dim feedback As String = String.Empty
txtIndex.Text=index
cboCategory.Text= techline.Category
txtBenefitName.Text=techline.BenefitName
cboUnits.Text = techline.Units
cboLineType.Text = If( techline.LineType=0, "Normal","ActiveVentilation")
txtLowFloorH .Text = techline.LowFloorH
txtLowFloorV .Text = techline.LowFloorV
txtLowFloorC .Text = techline.LowFloorC
txtSemiLowFloorH.Text = techline.SemiLowFloorH
txtSemiLowFloorV.Text = techline.SemiLowFloorV
txtSemiLowFloorC.Text = techline.SemiLowFloorC
txtRaisedFloorH .Text = techline.RaisedFloorH
txtRaisedFloorV .Text = techline.RaisedFloorV
txtRaisedFloorC .Text = techline.RaisedFloorC
chkActiveVH.Checked = techline.ActiveVH
chkActiveVV.Checked = techline.ActiveVV
chkActiveVC.Checked = techline.ActiveVC
chkOnVehicle.Checked = techline.OnVehicle
Dim dr As DialogResult = MessageBox.Show(String.Format("Do you want to delete benefit '{0}' ?", benefit),"", MessageBoxButtons.YesNo)
If dr= Windows.Forms.DialogResult.Yes then
If ssmTOOL.techList.Delete( New TechListBenefitLine With {.BenefitName= benefit, .Category=category}, feedback) then
End Sub
private function GetTechLineFromPanel() as ITechListBenefitLine
BindGrid
Dim tl As ITechListBenefitLine = New TechListBenefitLine( ssmTOOL.genInputs)
End If
tl.Category = StrConv(cboCategory.Text, vbProperCase)
tl.BenefitName = txtBenefitName.Text
tl.Units = cboUnits.Text
tl.LineType = If( cboLineType.Text= "Normal",0,3)
tl.LowFloorH = txtLowFloorH .Text
tl.LowFloorV = txtLowFloorV .Text
tl.LowFloorC = txtLowFloorC .Text
tl.SemiLowFloorH = txtSemiLowFloorH .Text
tl.SemiLowFloorV = txtSemiLowFloorV .Text
tl.SemiLowFloorC = txtSemiLowFloorC .Text
tl.RaisedFloorH = txtRaisedFloorH .Text
tl.RaisedFloorV = txtRaisedFloorV .Text
tl.RaisedFloorC = txtRaisedFloorC .Text
tl.ActiveVH = chkActiveVH .Checked
tl.ActiveVV = chkActiveVV .Checked
tl.ActiveVC = chkActiveVC .Checked
tl.OnVehicle = chkOnVehicle .Checked
End If
Return tl
End Function
Private Sub ClearEditPanel()
End If
txtIndex.Text = String.Empty
cboCategory.SelectedIndex=0
txtBenefitName.Text = String.Empty
cboUnits.SelectedIndex=0
cboLineType.SelectedIndex=0
txtLowFloorH .Text = String.Empty
txtLowFloorV .Text = String.Empty
txtLowFloorC .Text = String.Empty
txtSemiLowFloorH .Text = String.Empty
txtSemiLowFloorV .Text = String.Empty
txtSemiLowFloorC .Text = String.Empty
txtRaisedFloorH .Text = String.Empty
txtRaisedFloorV .Text = String.Empty
txtRaisedFloorC .Text = String.Empty
chkActiveVH .Checked = False
chkActiveVV .Checked = False
chkActiveVC .Checked = False
chkOnVehicle .Checked = False
End Sub
Private Sub btnCancel_Click( sender As Object, e As EventArgs) Handles btnCancel.Click
Private Sub btnClearForm_Click( sender As Object, e As EventArgs) Handles btnClearForm.Click
ClearEditPanel()
UpdateButtonText()
UserHitCancel=True
Me.Close
End Sub
......
......@@ -563,13 +563,7 @@ End Sub
const filePath as string = "SSMTOOLTestSaveRetreive.json"
Dim gen As ISSMGenInputs = New SSMGenInputs(true)
Dim saved As new SSMTOOL
Dim target As SSMTOOL = New SSMTOOL(filePath )
Dim target As SSMTOOL = New SSMTOOL(filePath, True )
target.Save(filePath)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment