diff --git a/AuxillaryTestHarness/Dashboard.Designer.vb b/AuxillaryTestHarness/Dashboard.Designer.vb index b55d73a0fd01e4e564631b2ca399e08d13cfa818..1b0cf9fe4d12a693f71f149ebfbdd42b43f7f278 100644 --- a/AuxillaryTestHarness/Dashboard.Designer.vb +++ b/AuxillaryTestHarness/Dashboard.Designer.vb @@ -69,6 +69,8 @@ Partial Class Dashboard Me.btnForward = New System.Windows.Forms.Button() Me.btnBack = New System.Windows.Forms.Button() Me.btnStart = New System.Windows.Forms.Button() + Me.resultCardContextMenu = New System.Windows.Forms.ContextMenuStrip(Me.components) + Me.DeleteToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.tabMain.SuspendLayout Me.tabGeneralConfig.SuspendLayout Me.tabElectricalConfig.SuspendLayout @@ -78,6 +80,7 @@ Partial Class Dashboard CType(Me.gvElectricalConsumables,System.ComponentModel.ISupportInitialize).BeginInit CType(Me.brcElecConsumers,System.ComponentModel.ISupportInitialize).BeginInit Me.Panel1.SuspendLayout + Me.resultCardContextMenu.SuspendLayout Me.SuspendLayout ' 'tabMain @@ -104,7 +107,7 @@ Partial Class Dashboard Me.tabGeneralConfig.Location = New System.Drawing.Point(4, 22) Me.tabGeneralConfig.Name = "tabGeneralConfig" Me.tabGeneralConfig.Padding = New System.Windows.Forms.Padding(3) - Me.tabGeneralConfig.Size = New System.Drawing.Size(886, 571) + Me.tabGeneralConfig.Size = New System.Drawing.Size(886, 610) Me.tabGeneralConfig.TabIndex = 0 Me.tabGeneralConfig.Text = "GeneralConfig" Me.tabGeneralConfig.UseVisualStyleBackColor = true @@ -415,7 +418,7 @@ Partial Class Dashboard ' Me.tabPneumaticConfig.Location = New System.Drawing.Point(4, 22) Me.tabPneumaticConfig.Name = "tabPneumaticConfig" - Me.tabPneumaticConfig.Size = New System.Drawing.Size(886, 571) + Me.tabPneumaticConfig.Size = New System.Drawing.Size(886, 610) Me.tabPneumaticConfig.TabIndex = 2 Me.tabPneumaticConfig.Text = "PneumaticConfig" Me.tabPneumaticConfig.UseVisualStyleBackColor = true @@ -424,7 +427,7 @@ Partial Class Dashboard ' Me.tabHVACConfig.Location = New System.Drawing.Point(4, 22) Me.tabHVACConfig.Name = "tabHVACConfig" - Me.tabHVACConfig.Size = New System.Drawing.Size(886, 571) + Me.tabHVACConfig.Size = New System.Drawing.Size(886, 610) Me.tabHVACConfig.TabIndex = 3 Me.tabHVACConfig.Text = "HVACConfig" Me.tabHVACConfig.UseVisualStyleBackColor = true @@ -433,7 +436,7 @@ Partial Class Dashboard ' Me.tabPlayground.Location = New System.Drawing.Point(4, 22) Me.tabPlayground.Name = "tabPlayground" - Me.tabPlayground.Size = New System.Drawing.Size(886, 571) + Me.tabPlayground.Size = New System.Drawing.Size(886, 610) Me.tabPlayground.TabIndex = 4 Me.tabPlayground.Text = "Playground" Me.tabPlayground.UseVisualStyleBackColor = true @@ -497,6 +500,18 @@ Partial Class Dashboard Me.btnStart.Text = "|< Start" Me.btnStart.UseVisualStyleBackColor = true ' + 'resultCardContextMenu + ' + Me.resultCardContextMenu.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.DeleteToolStripMenuItem}) + Me.resultCardContextMenu.Name = "resultCardContextMenu" + Me.resultCardContextMenu.Size = New System.Drawing.Size(108, 26) + ' + 'DeleteToolStripMenuItem + ' + Me.DeleteToolStripMenuItem.Name = "DeleteToolStripMenuItem" + Me.DeleteToolStripMenuItem.Size = New System.Drawing.Size(107, 22) + Me.DeleteToolStripMenuItem.Text = "Delete" + ' 'Dashboard ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6!, 13!) @@ -516,6 +531,7 @@ Partial Class Dashboard CType(Me.gvElectricalConsumables,System.ComponentModel.ISupportInitialize).EndInit CType(Me.brcElecConsumers,System.ComponentModel.ISupportInitialize).EndInit Me.Panel1.ResumeLayout(false) + Me.resultCardContextMenu.ResumeLayout(false) Me.ResumeLayout(false) End Sub @@ -553,4 +569,6 @@ End Sub Friend WithEvents btnStart As System.Windows.Forms.Button Friend WithEvents brcElecConsumers As System.Windows.Forms.BindingSource Public WithEvents gvResultsCardIdle As System.Windows.Forms.DataGridView + Friend WithEvents resultCardContextMenu As System.Windows.Forms.ContextMenuStrip + Friend WithEvents DeleteToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem End Class diff --git a/AuxillaryTestHarness/Dashboard.resx b/AuxillaryTestHarness/Dashboard.resx index 332cfeb6850508bf4127de3f33180596101df163..702f81310cdfe7d71238d5d19483ad09b68bc1b5 100644 --- a/AuxillaryTestHarness/Dashboard.resx +++ b/AuxillaryTestHarness/Dashboard.resx @@ -120,6 +120,9 @@ <metadata name="brcElecConsumers.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>17, 17</value> </metadata> + <metadata name="resultCardContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>168, 3</value> + </metadata> <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>25</value> </metadata> diff --git a/AuxillaryTestHarness/Dashboard.vb b/AuxillaryTestHarness/Dashboard.vb index 35c24938b410c2f8820070ff1a8636754ff1e999..4c797ae27422f0b6a98e75afe81572913386b3e6 100644 --- a/AuxillaryTestHarness/Dashboard.vb +++ b/AuxillaryTestHarness/Dashboard.vb @@ -58,7 +58,12 @@ Private Sub SetupControls() gvElectricalConsumables.Columns(cIndex).Width = 50 'ResultCard Grids + + 'Handler for deleting rows. + + 'IDLE + cIndex = gvResultsCardIdle.Columns.Add("Amps", "Amps") gvResultsCardIdle.Columns(cIndex).DataPropertyName = "Amps" gvResultsCardIdle.Columns(cIndex).Width = 65 @@ -112,18 +117,23 @@ Private Sub CreateBindings() Dim idleBinding = new BindingList(Of SmartResult) idleBinding = New BindingList(Of SmartResult)(auxEnvironment.ElectricalUserInputsConfig.ResultCardIdle) idleBinding.AllowNew=true + idleBinding.AllowRemove=True gvResultsCardIdle.DataSource=idleBinding + + 'TRACTION Dim tractionBinding As BindingList(Of SmartResult) tractionBinding = New BindingList(Of SmartResult)(auxEnvironment.ElectricalUserInputsConfig.ResultCardTraction) tractionBinding.AllowNew=true + tractionBinding.AllowRemove=true gvResultsCardTraction.DataSource = tractionBinding 'OVERRUN Dim overrunBinding As BindingList(Of SmartResult) overrunBinding = New BindingList(Of SmartResult)(auxEnvironment.ElectricalUserInputsConfig.ResultCardOverrun) overrunBinding.AllowNew=true + overrunBinding.AllowRemove=true gvResultsCardOverrun.DataSource=overrunBinding @@ -131,9 +141,6 @@ Private Sub CreateBindings() End Sub - - - Private Sub gvElectricalConsumables_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles gvElectricalConsumables.CellEndEdit End Sub @@ -143,70 +150,99 @@ End Sub Private Sub gvElectricalConsumables_CellValidating(sender As Object, e As DataGridViewCellValidatingEventArgs) Handles gvElectricalConsumables.CellValidating - Dim column As DataGridViewColumn = gvElectricalConsumables.Columns(e.ColumnIndex) - Dim message As String = String.Empty - - If Not column.ReadOnly Then - e.Cancel = Not IsValidElectricalConsumableEdit(column, e.FormattedValue, message) - End If + Dim s As Single - - - - -End Sub - - -Private Function IsValidElectricalConsumableEdit(column As DataGridViewColumn, val As String, ByRef message As String) As Boolean - - Dim s As Single - - Dim tip = column.CellType + If column.ReadOnly Then return Select Case column.Name Case "NominalConsumptionAmps" - Return True + If Not IsNumeric(e.FormattedValue) Then + MessageBox.Show("This value must be numeric") + e.Cancel=true + End if Case "NumberInActualVehicle" - If Not IsNumeric(val) Then + If Not IsNumeric(e.FormattedValue) Then MessageBox.Show("This value must be numeric") - Return False + e.Cancel=true Else - s = Single.Parse(val) + s = Single.Parse(e.FormattedValue) End If If s Mod 1 > 0 OrElse s < 0 Then MessageBox.Show("This value must be a positive whole number ( Integer ) ") - Return False + e.Cancel=true End If Case "PhaseIdle_TractionOn" - If Not IsNumeric(val) Then + If Not IsNumeric(e.FormattedValue) Then MessageBox.Show("This value must be numeric") - Return False + e.Cancel=true Else - s = Single.Parse(val) + s = Single.Parse(e.FormattedValue) End If If s < 0 OrElse s > 1 Then MessageBox.Show("This must be a value between 0 and 1 ") - Return False + e.Cancel=true End If End Select +End Sub - Return True - -End Function +Private Sub SmartResult_CellValidating( sender As Object, e As DataGridViewCellValidatingEventArgs) Handles gvResultsCardIdle.CellValidating + Dim column As DataGridViewColumn = gvElectricalConsumables.Columns(e.ColumnIndex) -Private Sub Panel1_Paint( sender As Object, e As PaintEventArgs) Handles Panel1.Paint + If Not IsNumeric(e.FormattedValue) Then + MessageBox.Show("This value must be numeric") + e.Cancel=true + End If End Sub + + + + private sub resultCard_CellMouseUp( sender As Object, e as DataGridViewCellMouseEventArgs) Handles gvResultsCardIdle.CellMouseUp, gvResultsCardTraction.CellMouseUp, gvResultsCardOverrun.CellMouseUp + + Dim dgv As DataGridView = CType( sender, DataGridView) + + + if e.Button = MouseButtons.Right then + + dgv.Rows(e.RowIndex).Selected = true + Dim rowIndex As Integer = e.RowIndex + dgv.CurrentCell = dgv.Rows(e.RowIndex).Cells(1) + resultCardContextMenu.Show(dgv, e.Location) + resultCardContextMenu.Show(Cursor.Position) + + End if + + + end sub + + private sub resultCardContextMenu_Click( sender As object, e as EventArgs) Handles resultCardContextMenu.Click + + Dim menu As ContextMenuStrip = CType( sender, ContextMenuStrip) + + Dim grid as DataGridView = DirectCast( menu.SourceControl, DataGridView) + + 'DirectCast(menu.SourceControl,System.Windows.Forms.DataGridView).SelectedRows(0).IsNewRow + + If Not grid.SelectedRows(0).IsNewRow then + + grid.Rows.RemoveAt(grid.SelectedRows(0).Index) + + End if + + end sub + + + End Class \ No newline at end of file