Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
' Copyright 2014 European Union.
' Licensed under the EUPL (the 'Licence');
'
' * You may not use this work except in compliance with the Licence.
' * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
' * Unless required by applicable law or agreed to in writing,
' software distributed under the Licence is distributed on an "AS IS" basis,
' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
'
' See the LICENSE.txt for the specific language governing permissions and limitations.
Option Infer On
Imports System.IO
Imports System.Linq
Imports System.Text.RegularExpressions
Imports TUGraz.VectoCommon.Models
''' <summary>
''' Vehicle Editor.
''' </summary>
Public Class F_VEH
Private _axlDlog As F_VEH_Axle
Private _hdVclass As String
Private _vehFile As String
Private _changed As Boolean = False
Private _cmFiles As String()
Public AutoSendTo As Boolean = False
Public JobDir As String = ""
'Close - Check for unsaved changes
Private Sub F_VEH_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
If e.CloseReason <> CloseReason.ApplicationExitCall And e.CloseReason <> CloseReason.WindowsShutDown Then
e.Cancel = ChangeCheckCancel()
End If
End Sub
'Initialise form
Private Sub F05_VEH_Load(sender As Object, e As EventArgs) Handles MyBase.Load
TbLoadingMax.Text = "-"
PnLoad.Enabled = Not Cfg.DeclMode
ButAxlAdd.Enabled = Not Cfg.DeclMode
ButAxlRem.Enabled = Not Cfg.DeclMode
CbCdMode.Enabled = Not Cfg.DeclMode
PnWheelDiam.Enabled = Not Cfg.DeclMode
gbPTO.Enabled = Not Cfg.DeclMode
_axlDlog = New F_VEH_Axle
cbPTOType.Items.AddRange(PtoTypeStrings.Values.Cast (Of Object).ToArray())
_changed = False
NewVehicle()
End Sub
'Set HDVclasss
Private Sub SetHdVclass()
Dim vehC = CType(CbCat.SelectedIndex, tVehCat)
Dim axlC = CType(CbAxleConfig.SelectedIndex, tAxleConf)
Dim maxMass = CSng(fTextboxToNumString(TbMassMass.Text))
Dim segmentEntry As cSegmentTableEntry = Declaration.SegmentTable.SetRef(vehC, axlC, maxMass)
_hdVclass = "-"
If Not segmentEntry Is Nothing Then
_hdVclass = segmentEntry.HDVclass
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
End If
TbHDVclass.Text = _hdVclass
PicVehicle.Image = Image.FromFile(cDeclaration.ConvPicPath(_hdVclass, False))
End Sub
'Set generic values for Declaration mode
Private Sub DeclInit()
If Not Cfg.DeclMode Then Exit Sub
Dim vehC = CType(CbCat.SelectedIndex, tVehCat)
Dim axlC = CType(CbAxleConfig.SelectedIndex, tAxleConf)
Dim maxMass = CSng(fTextboxToNumString(TbMassMass.Text))
Dim s0 = Declaration.SegmentTable.SetRef(vehC, axlC, maxMass)
If Not s0 Is Nothing Then
_hdVclass = s0.HDVclass
Dim axleCount As Short = s0.AxleShares(s0.Missions(0)).Count
Dim i0 = LvRRC.Items.Count
If axleCount > i0 Then
For i = 1 To axleCount - LvRRC.Items.Count
Dim lvi = New ListViewItem
lvi.SubItems(0).Text = (i + i0).ToString
lvi.SubItems.Add("-")
lvi.SubItems.Add("no")
lvi.SubItems.Add("")
lvi.SubItems.Add("")
lvi.SubItems.Add("-")
lvi.SubItems.Add("-")
LvRRC.Items.Add(lvi)
Next
ElseIf axleCount < LvRRC.Items.Count Then
For i = axleCount To LvRRC.Items.Count - 1
LvRRC.Items.RemoveAt(LvRRC.Items.Count - 1)
Next
End If
PnAll.Enabled = True
Else
PnAll.Enabled = False
_hdVclass = "-"
End If
TbMassExtra.Text = "-"
TbLoad.Text = "-"
CbCdMode.SelectedIndex = CType(tCdMode.CdOfVdecl, Integer)
TbCdFile.Text = ""
Dim rdyn As Single
rdyn = - 1
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
If rdyn < 0 Then
TBrdyn.Text = "-"
Else
TBrdyn.Text = rdyn
End If
End Sub
#Region "Toolbar"
'New
Private Sub ToolStripBtNew_Click(sender As Object, e As EventArgs) Handles ToolStripBtNew.Click
NewVehicle()
End Sub
'Open
Private Sub ToolStripBtOpen_Click(sender As Object, e As EventArgs) Handles ToolStripBtOpen.Click
If fbVEH.OpenDialog(_vehFile) Then OpenVehicle(fbVEH.Files(0))
End Sub
'Save
Private Sub ToolStripBtSave_Click(sender As Object, e As EventArgs) Handles ToolStripBtSave.Click
SaveOrSaveAs(False)
End Sub
'Save As
Private Sub ToolStripBtSaveAs_Click(sender As Object, e As EventArgs) Handles ToolStripBtSaveAs.Click
SaveOrSaveAs(True)
End Sub
'Send to VECTO Editor
Private Sub ToolStripBtSendTo_Click(sender As Object, e As EventArgs) Handles ToolStripBtSendTo.Click
If ChangeCheckCancel() Then Exit Sub
If _vehFile = "" Then
If MsgBox("Save file now?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
If Not SaveOrSaveAs(True) Then Exit Sub
Else
Exit Sub
End If
End If
If Not F_VECTO.Visible Then
JobDir = ""
F_VECTO.Show()
F_VECTO.VECTOnew()
Else
F_VECTO.WindowState = FormWindowState.Normal
End If
F_VECTO.TbVEH.Text = fFileWoDir(_vehFile, JobDir)
End Sub
'Help
Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ToolStripButton1.Click
If File.Exists(MyAppPath & "User Manual\help.html") Then
Dim registryString = My.Computer.Registry.ClassesRoot.OpenSubKey("\http\shell\open\command\").GetValue("").ToString
Dim defaultBrowserPath = Regex.Match(registryString, "(\"".*?\"")").Captures(0).ToString
Process.Start(defaultBrowserPath, String.Format("""{0}{1}""", MyAppPath, "User Manual\help.html#vehicle-editor"))
Else
MsgBox("User Manual not found!", MsgBoxStyle.Critical)
End If
End Sub
#End Region
'Save and Close
Private Sub ButOK_Click(sender As Object, e As EventArgs) Handles ButOK.Click
If SaveOrSaveAs(False) Then Close()
End Sub
'Cancel
Private Sub ButCancel_Click(sender As Object, e As EventArgs) Handles ButCancel.Click
Close()
End Sub
'Save or Save As function = true if file is saved
Private Function SaveOrSaveAs(saveAs As Boolean) As Boolean
If _vehFile = "" Or saveAs Then
If fbVEH.SaveDialog(_vehFile) Then
_vehFile = fbVEH.Files(0)
Else
Return False
End If
End If
Return SaveVehicle(_vehFile)
End Function
'New VEH
Private Sub NewVehicle()
If ChangeCheckCancel() Then Exit Sub
TbMass.Text = ""
TbLoad.Text = ""
TBrdyn.Text = ""
TBcdA.Text = ""
CbCdMode.SelectedIndex = 0
TbCdFile.Text = ""
CbRtType.SelectedIndex = 0
TbRtRatio.Text = ""
TbRtPath.Text = ""
CbRtType.SelectedIndex = 0
TbRtRatio.Text = ""
TbRtPath.Text = ""
CbCat.SelectedIndex = 0
LvRRC.Items.Clear()
TbMassMass.Text = ""
TbMassExtra.Text = ""
CbAxleConfig.SelectedIndex = 0
cbPTOType.SelectedIndex = 0
tbPTOLossMap.Text = ""
DeclInit()
_vehFile = ""
Text = "VEH Editor"
LbStatus.Text = ""
_changed = False
End Sub
'Open VEH
Sub OpenVehicle(file As String)
Dim inertia As Single
If ChangeCheckCancel() Then Exit Sub
Dim veh = New cVEH
veh.FilePath = file
If Not veh.ReadFile Then
MsgBox("Cannot read " & file & "!")
Exit Sub
End If
If Cfg.DeclMode <> veh.SavedInDeclMode Then
Select Case WrongMode()
Case 1
Close()
F_MAINForm.RbDecl.Checked = Not F_MAINForm.RbDecl.Checked
F_MAINForm.OpenVectoFile(file)
Case - 1
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
Exit Sub
End Select
End If
TbMass.Text = veh.Mass
TbMassExtra.Text = veh.MassExtra
TbLoad.Text = veh.Loading
TBrdyn.Text = veh.rdyn
CbCdMode.SelectedIndex = CType(veh.CdMode, Integer)
TbCdFile.Text = veh.CdFile.OriginalPath
CbRtType.SelectedIndex = CType(veh.RtType, Integer)
TbRtRatio.Text = veh.RtRatio
TbRtPath.Text = veh.RtFile.OriginalPath
cbAngularGearType.SelectedIndex = CType(veh.AngularGearType, Integer)
tbAngularGearRatio.Text = veh.AngularGearRatio
tbAngularGearLossMapPath.Text = veh.AngularGearLossMapFile.OriginalPath
CbCat.SelectedIndex = CType(veh.VehCat, Integer)
LvRRC.Items.Clear()
Dim i = 0
For Each a0 In veh.Axles
i += 1
Dim lvi = New ListViewItem
lvi.SubItems(0).Text = i.ToString
If Cfg.DeclMode Then
lvi.SubItems.Add("-")
Else
lvi.SubItems.Add(a0.Share)
End If
If a0.TwinTire Then
lvi.SubItems.Add("yes")
Else
lvi.SubItems.Add("no")
End If
lvi.SubItems.Add(a0.RRC)
lvi.SubItems.Add(a0.FzISO)
lvi.SubItems.Add(a0.Wheels)
If Cfg.DeclMode Then
inertia = Declaration.WheelsInertia(a0.Wheels)
If inertia < 0 Then
lvi.SubItems.Add("-")
Else
lvi.SubItems.Add(inertia)
End If
Else
lvi.SubItems.Add(a0.Inertia)
End If
LvRRC.Items.Add(lvi)
Next
TbMassMass.Text = veh.MassMax
TbMassExtra.Text = veh.MassExtra
CbAxleConfig.SelectedIndex = CType(veh.AxleConf, Integer)
TBcdA.Text = veh.CdA0
cbPTOType.SelectedIndex = CType(veh.PTOType, Integer)
tbPTOLossMap.Text = veh.PTOLossMap.OriginalPath
tbPTOCycle.Text = veh.PTOCycle.OriginalPath
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
DeclInit()
fbVEH.UpdateHistory(file)
Text = fFILE(file, True)
LbStatus.Text = ""
_vehFile = file
Activate()
_changed = False
End Sub
'Save VEH
Private Function SaveVehicle(file As String) As Boolean
Dim veh = New cVEH
veh.FilePath = file
veh.Mass = CSng(fTextboxToNumString(TbMass.Text))
veh.MassExtra = CSng(fTextboxToNumString(TbMassExtra.Text))
veh.Loading = CSng(fTextboxToNumString(TbLoad.Text))
veh.CdA0 = CSng(fTextboxToNumString(TBcdA.Text))
veh.CdA02 = veh.CdA0
Dim vehC = CType(CbCat.SelectedIndex, tVehCat)
Dim axlC = CType(CbAxleConfig.SelectedIndex, tAxleConf)
Dim maxMass = CSng(fTextboxToNumString(TbMassMass.Text))
Dim s0 As cSegmentTableEntry = Declaration.SegmentTable.SetRef(vehC, axlC, maxMass)
If Not s0 Is Nothing Then
If s0.HDVclass = "2" Then
' CdA Addition for T1 Trailer
veh.CdA02 += 1.1
End If
If s0.HDVclass = "4" OrElse s0.HDVclass = "9" Then
' CdA Addition for T2 Trailer
veh.CdA02 += 0.6
End If
End If
veh.rdyn = CSng(fTextboxToNumString(TBrdyn.Text))
veh.CdMode = CType(CbCdMode.SelectedIndex, tCdMode)
veh.CdFile.Init(fPATH(file), TbCdFile.Text)
veh.RtType = CType(CbRtType.SelectedIndex, tRtType)
veh.RtRatio = CSng(fTextboxToNumString(TbRtRatio.Text))
veh.RtFile.Init(fPATH(file), TbRtPath.Text)
veh.AngularGearType = CType(cbAngularGearType.SelectedIndex, AngularGearType)
veh.AngularGearRatio = CSng(fTextboxToNumString(tbAngularGearRatio.Text))
veh.AngularGearLossMapFile.Init(fPATH(file), tbAngularGearLossMapPath.Text)
veh.VehCat = CType(CbCat.SelectedIndex, tVehCat)
Dim axleShareCheck As Double
For Each LV0 In LvRRC.Items
Dim a0 = New cVEH.cAxle
a0.Share = fTextboxToNumString(LV0.SubItems(1).Text)
axleShareCheck += a0.Share
a0.TwinTire = (LV0.SubItems(2).Text = "yes")
a0.RRC = fTextboxToNumString(LV0.SubItems(3).Text)
a0.FzISO = fTextboxToNumString(LV0.SubItems(4).Text)
a0.Wheels = LV0.SubItems(5).Text
a0.Inertia = fTextboxToNumString(LV0.SubItems(6).Text)
veh.Axles.Add(a0)
Next
veh.PTOType = CType(cbPTOType.SelectedIndex, tPTOType)
veh.PTOLossMap.Init(fPATH(file), tbPTOLossMap.Text)
veh.PTOCycle.Init(fPATH(file), tbPTOCycle.Text)
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
If Not Cfg.DeclMode AndAlso Math.Abs(axleShareCheck - 1) > 0.000001 Then
MsgBox("Relative axle loads must sum up to 1.0. Current value: " & axleShareCheck, MsgBoxStyle.Critical)
Return False
End If
veh.MassMax = CSng(fTextboxToNumString(TbMassMass.Text))
veh.MassExtra = CSng(fTextboxToNumString(TbMassExtra.Text))
veh.AxleConf = CType(CbAxleConfig.SelectedIndex, tAxleConf)
'---------------------------------------------------------------------------------
If Not veh.SaveFile Then
MsgBox("Cannot safe to " & file, MsgBoxStyle.Critical)
Return False
End If
If AutoSendTo Then
If F_VECTO.Visible Then
If UCase(fFileRepl(F_VECTO.TbVEH.Text, JobDir)) <> UCase(file) Then F_VECTO.TbVEH.Text = fFileWoDir(file, JobDir)
F_VECTO.UpdatePic()
End If
End If
fbVEH.UpdateHistory(file)
Text = fFILE(file, True)
LbStatus.Text = ""
_changed = False
Return True
End Function
#Region "Cd"
'Cd Mode Change
Private Sub CbCdMode_SelectedIndexChanged(sender As Object, e As EventArgs) _
Handles CbCdMode.SelectedIndexChanged
Dim bEnabled As Boolean
Select Case CType(CbCdMode.SelectedIndex, tCdMode)
Case tCdMode.CdOfBeta
bEnabled = True
LbCdMode.Text = "Input file: Yaw Angle [°], Cd Scaling Factor [-]"
Case tCdMode.CdOfVeng
bEnabled = True
LbCdMode.Text = "Input file: Vehicle Speed [km/h], Cd Scaling Factor [-]"
Case Else ' tCdMode.ConstCd0, tCdMode.CdOfVdecl
bEnabled = False
LbCdMode.Text = ""
End Select
If Not Cfg.DeclMode Then
TbCdFile.Enabled = bEnabled
BtCdFileBrowse.Enabled = bEnabled
BtCdFileOpen.Enabled = bEnabled
End If
Change()
End Sub
'Cd File Browse
Private Sub BtCdFileBrowse_Click(sender As Object, e As EventArgs) Handles BtCdFileBrowse.Click
Dim ex As String
If CbCdMode.SelectedIndex = 1 Then
ex = "vcdv"
Else
ex = "vcdb"
End If
If fbCDx.OpenDialog(fFileRepl(TbCdFile.Text, fPATH(_vehFile)), False, ex) Then _
TbCdFile.Text = fFileWoDir(fbCDx.Files(0), fPATH(_vehFile))
End Sub
'Open Cd File
Private Sub BtCdFileOpen_Click(sender As Object, e As EventArgs) Handles BtCdFileOpen.Click
OpenFiles(fFileRepl(TbCdFile.Text, fPATH(_vehFile)))
End Sub
#End Region
#Region "Retarder"
'Rt Type Change
Private Sub CbRtType_SelectedIndexChanged(sender As Object, e As EventArgs) _
Handles CbRtType.SelectedIndexChanged
Select Case CbRtType.SelectedIndex
Case 1 'Primary
LbRtRatio.Text = "Ratio to engine speed"
PnRt.Enabled = True
Case 2 'Secondary
LbRtRatio.Text = "Ratio to cardan shaft speed"
TbRtPath.Enabled = True
BtRtBrowse.Enabled = True
PnRt.Enabled = True
Case Else '0 None
LbRtRatio.Text = "Ratio"
PnRt.Enabled = False
End Select
Change()
End Sub
'Rt File Browse
Private Sub BtRtBrowse_Click(sender As Object, e As EventArgs) Handles BtRtBrowse.Click
If fbRLM.OpenDialog(fFileRepl(TbRtPath.Text, fPATH(_vehFile))) Then _
TbRtPath.Text = fFileWoDir(fbRLM.Files(0), fPATH(_vehFile))
End Sub
#End Region
#Region "Track changes"
Private Sub Change()
If Not _changed Then
LbStatus.Text = "Unsaved changes in current file"
_changed = True
End If
End Sub
' "Save changes? "... Returns True if user aborts
Private Function ChangeCheckCancel() As Boolean
If _changed Then
Select Case MsgBox("Save changes ?", MsgBoxStyle.YesNoCancel)
Case MsgBoxResult.Yes
Return Not SaveOrSaveAs(False)
Case MsgBoxResult.Cancel
Return True
Case Else 'MsgBoxResult.No
_changed = False
Return False
End Select
Return False
End If
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
End Function
Private Sub TBmass_TextChanged(sender As Object, e As EventArgs) Handles TbMass.TextChanged
SetMaxLoad()
Change()
End Sub
Private Sub TBcw_TextChanged(sender As Object, e As EventArgs) _
Handles TbLoad.TextChanged, TBrdyn.TextChanged, TBcdA.TextChanged, TbCdFile.TextChanged, TbRtRatio.TextChanged,
cbAngularGearType.SelectedIndexChanged, TbRtPath.TextChanged, tbAngularGearLossMapPath.TextChanged,
tbAngularGearRatio.TextChanged, tbPTOLossMap.TextChanged
Change()
End Sub
Private Sub CbCat_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CbCat.SelectedIndexChanged
Change()
SetHdVclass()
DeclInit()
End Sub
Private Sub TbMassTrailer_TextChanged(sender As Object, e As EventArgs) Handles TbMassExtra.TextChanged
SetMaxLoad()
Change()
End Sub
Private Sub TbMassMax_TextChanged(sender As Object, e As EventArgs) Handles TbMassMass.TextChanged
SetMaxLoad()
Change()
SetHdVclass()
DeclInit()
End Sub
Private Sub CbAxleConfig_SelectedIndexChanged(sender As Object, e As EventArgs) _
Handles CbAxleConfig.SelectedIndexChanged
Change()
SetHdVclass()
DeclInit()
End Sub
#End Region
'Update maximum load when truck/trailer mass was changed
Private Sub SetMaxLoad()
If Not Cfg.DeclMode Then
If IsNumeric(TbMass.Text) And IsNumeric(TbMassExtra.Text) And IsNumeric(TbMassMass.Text) Then
TbLoadingMax.Text = CStr(CSng(TbMassMass.Text)*1000 - CSng(TbMass.Text) - CSng(TbMassExtra.Text))
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
Else
TbLoadingMax.Text = ""
End If
End If
End Sub
#Region "Axle Configuration"
Private Sub ButAxlAdd_Click(sender As Object, e As EventArgs) Handles ButAxlAdd.Click
Dim lv0 As ListViewItem
_axlDlog.Clear()
If _axlDlog.ShowDialog = DialogResult.OK Then
lv0 = New ListViewItem
lv0.SubItems(0).Text = LvRRC.Items.Count + 1
lv0.SubItems.Add(Trim(_axlDlog.TbAxleShare.Text))
If _axlDlog.CbTwinT.Checked Then
lv0.SubItems.Add("yes")
Else
lv0.SubItems.Add("no")
End If
lv0.SubItems.Add(Trim(_axlDlog.TbRRC.Text))
lv0.SubItems.Add(Trim(_axlDlog.TbFzISO.Text))
lv0.SubItems.Add(Trim(_axlDlog.CbWheels.Text))
lv0.SubItems.Add(Trim(_axlDlog.TbI_wheels.Text))
LvRRC.Items.Add(lv0)
Change()
DeclInit()
End If
End Sub
Private Sub ButAxlRem_Click(sender As Object, e As EventArgs) Handles ButAxlRem.Click
RemoveAxleItem()
End Sub
Private Sub LvAxle_DoubleClick(sender As Object, e As EventArgs) Handles LvRRC.DoubleClick
EditAxleItem()
End Sub
Private Sub LvAxle_KeyDown(sender As Object, e As KeyEventArgs) Handles LvRRC.KeyDown
Select Case e.KeyCode
Case Keys.Delete, Keys.Back
If Not Cfg.DeclMode Then RemoveAxleItem()
Case Keys.Enter
EditAxleItem()
End Select
End Sub
Private Sub RemoveAxleItem()
Dim lv0 As ListViewItem
Dim i As Integer
If LvRRC.SelectedItems.Count = 0 Then
If LvRRC.Items.Count = 0 Then
Exit Sub
Else
LvRRC.Items(LvRRC.Items.Count - 1).Selected = True
End If
End If
LvRRC.SelectedItems(0).Remove()
If LvRRC.Items.Count > 0 Then
i = 0
For Each lv0 In LvRRC.Items
i += 1
lv0.SubItems(0).Text = i.ToString
Next
LvRRC.Items(LvRRC.Items.Count - 1).Selected = True
LvRRC.Focus()
End If
Change()
End Sub
Private Sub EditAxleItem()
If LvRRC.SelectedItems.Count = 0 Then Exit Sub
Dim lv0 = LvRRC.SelectedItems(0)
_axlDlog.TbAxleShare.Text = lv0.SubItems(1).Text
_axlDlog.CbTwinT.Checked = (lv0.SubItems(2).Text = "yes")
_axlDlog.TbRRC.Text = lv0.SubItems(3).Text
_axlDlog.TbFzISO.Text = lv0.SubItems(4).Text
_axlDlog.TbI_wheels.Text = lv0.SubItems(6).Text
_axlDlog.CbWheels.Text = lv0.SubItems(5).Text
If _axlDlog.ShowDialog = DialogResult.OK Then
lv0.SubItems(1).Text = _axlDlog.TbAxleShare.Text
If _axlDlog.CbTwinT.Checked Then
lv0.SubItems(2).Text = "yes"
Else
lv0.SubItems(2).Text = "no"
End If
lv0.SubItems(3).Text = _axlDlog.TbRRC.Text
lv0.SubItems(4).Text = _axlDlog.TbFzISO.Text
lv0.SubItems(5).Text = _axlDlog.CbWheels.Text
lv0.SubItems(6).Text = _axlDlog.TbI_wheels.Text
Change()
DeclInit()
End If
End Sub
#End Region
#Region "Open File Context Menu"
Private Sub OpenFiles(ParamArray files() As String)
If files.Length = 0 Then Exit Sub
_cmFiles = files
OpenWithToolStripMenuItem.Text = "Open with " & Cfg.OpenCmdName
CmOpenFile.Show(Cursor.Position)
End Sub
Private Sub OpenWithToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles OpenWithToolStripMenuItem.Click
If Not FileOpenAlt(_cmFiles(0)) Then MsgBox("Failed to open file!")
End Sub
Private Sub ShowInFolderToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles ShowInFolderToolStripMenuItem.Click
If File.Exists(_cmFiles(0)) Then
Try
Process.Start("explorer", "/select,""" & _cmFiles(0) & "")
Catch ex As Exception
MsgBox("Failed to open file!")
End Try
Else
MsgBox("File not found!")
End If
End Sub
#End Region
#Region "Angular Gear"
Private Sub cbAngularGearType_SelectedIndexChanged(sender As Object, e As EventArgs) _
Handles cbAngularGearType.SelectedIndexChanged
Select Case cbAngularGearType.SelectedIndex
Case 1 'Separate Angular Gear
pnAngularGearFields.Enabled = True
tbAngularGearRatio.Text = "1.0"
Case Else 'Losses included in Transmission, None
tbAngularGearRatio.Text = ""
tbAngularGearLossMapPath.Text = ""
pnAngularGearFields.Enabled = False
End Select
Change()
End Sub
Private Sub btAngularGearLossMapBrowse_Click(sender As Object, e As EventArgs) Handles btAngularGearLossMapBrowse.Click
If fbTLM.OpenDialog(fFileRepl(TbRtPath.Text, fPATH(_vehFile))) Then _
tbAngularGearLossMapPath.Text = fFileWoDir(fbTLM.Files(0), fPATH(_vehFile))
End Sub
#End Region
Private Sub cbPTOType_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbPTOType.SelectedIndexChanged
If (cbPTOType.SelectedIndex = 0) Then
pnPTO.Enabled = False
tbPTOLossMap.Text = ""
Else
pnPTO.Enabled = True
End If
Change()
End Sub
Private Sub btPTOLossMapBrowse_Click(sender As Object, e As EventArgs) Handles btPTOLossMapBrowse.Click
If fbPTOLM.OpenDialog(fFileRepl(tbPTOLossMap.Text, fPATH(_vehFile))) Then
tbPTOLossMap.Text = fFileWoDir(fbPTOLM.Files(0), fPATH(_vehFile))

Markus Quaritsch
committed
End If
End Sub
Private Sub btPTOCycle_Click(sender As Object, e As EventArgs) Handles btPTOCycle.Click
If fbDRI.OpenDialog(fFileRepl(tbPTOCycle.Text, fPATH(_vehFile))) Then
tbPTOCycle.Text = fFileWoDir(fbDRI.Files(0), fPATH(_vehFile))
End If
End Sub
End Class