Newer
Older
' This file is part of VECTO.
'
' Copyright © 2012-2016 European Union
'
' Developed by Graz University of Technology,
' Institute of Internal Combustion Engines and Thermodynamics,
' Institute of Technical Informatics
'
' VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved
' by the European Commission - subsequent versions of the EUPL (the "Licence");
' You may not use VECTO except in compliance with the Licence.
' You may obtain a copy of the Licence at:
'
' https://joinup.ec.europa.eu/community/eupl/og_page/eupl
'
' Unless required by applicable law or agreed to in writing, VECTO
' distributed under the Licence is distributed on an "AS IS" basis,
' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
' See the Licence for the specific language governing permissions and
' limitations under the Licence.
'
' Authors:
' Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology
' Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology
' Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology
' Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology
' Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology
' Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
Imports System.Collections.Generic

Michael KRISPER
committed
Imports System.Collections.ObjectModel
Imports System.ComponentModel

Michael KRISPER
committed
Imports System.Globalization
Imports System.IO
Imports System.Linq
Imports TUGraz.VectoCore.Models.Simulation.Impl

Markus Quaritsch
committed
Imports TUGraz.VectoCore.InputData.FileIO.JSON

Michael KRISPER
committed
Imports System.Text.RegularExpressions

Markus Quaritsch
committed
Imports TUGraz.VectoCommon.InputData
Imports TUGraz.VectoCommon.Models

Markus Quaritsch
committed
Imports TUGraz.VectoCommon.Utils

Markus Quaritsch
committed
Imports TUGraz.VectoCore.OutputData
Imports TUGraz.VectoCore.OutputData.FileIO
Imports TUGraz.VectoCore.Utils
''' <summary>
''' Main application form. Loads at application start. Closing form ends application.
''' </summary>
''' <remarks></remarks>
Public Class F_MAINForm
Private JobListView As cFileListView
Private CycleListView As cFileListView
Private LastModeName As String
Private ConMenTarget As ListView
Private ConMenTarJob As Boolean
Private MODpath As String
Private MODVehList As Int32()
Private CycleTabPage As TabPage
Private CycleTabPageVisible As Boolean
Private ComLineShutDown As Boolean
Private CheckedItems As List(Of ListViewItem)
Private DEVpage As TabPage
Private CmDEVitem As ListViewItem
Private CheckLock As Boolean
Private GENchecked As Integer
Private DRIchecked As Integer
Private GENcheckAllLock As Boolean
Private DRIcheckAllLock As Boolean
Private CbDeclLock As Boolean = False
#Region "SLEEP Control - Prevent sleep while VECTO is running"

Michael KRISPER
committed
Private Declare Function SetThreadExecutionState Lib "kernel32" (esFlags As Long) As Long
#If Not PLATFORM = "x86" Then
SetThreadExecutionState(tEXECUTION_STATE.ES_CONTINUOUS Or tEXECUTION_STATE.ES_SYSTEM_REQUIRED)
#If Not PLATFORM = "x86" Then
SetThreadExecutionState(tEXECUTION_STATE.ES_CONTINUOUS)
Private Enum tEXECUTION_STATE As Integer
''' Informs the system that the state being set should remain in effect until the next call that uses ES_CONTINUOUS and one of the other state flags is cleared.
ES_CONTINUOUS = &H80000000
''' Forces the display to be on by resetting the display idle timer.
ES_DISPLAY_REQUIRED = &H2
''' Forces the system to be in the working state by resetting the system idle timer.
ES_SYSTEM_REQUIRED = &H1
End Enum
#End Region
#Region "FileBrowser Init/Close"
Private Sub FB_Initialize()
FB_Init = False
Try

Michael KRISPER
committed
COREvers = Assembly.LoadFrom("VectoCore.dll").GetName().Version.ToString()
Catch ex As Exception
LogFile.WriteToLog(tMsgID.Err, ex.StackTrace)
End Try
fbFolder = New cFileBrowser("WorkDir", True)
fbFileLists = New cFileBrowser("FileLists")
fbVECTO = New cFileBrowser("vecto")
fbVEH = New cFileBrowser("vveh")
fbMAP = New cFileBrowser("vmap")
fbDRI = New cFileBrowser("vdri")
fbFLD = New cFileBrowser("vfld")
fbENG = New cFileBrowser("veng")
fbGBX = New cFileBrowser("vgbx")
fbACC = New cFileBrowser("vacc")
fbAUX = New cFileBrowser("vaux")
fbGBS = New cFileBrowser("vgbs")
fbRLM = New cFileBrowser("vrlm")
fbTLM = New cFileBrowser("vtlm")
fbTCC = New cFileBrowser("vtcc")
fbCDx = New cFileBrowser("vcdx")
fbDfVelocityDrop = New cFileBrowser("DfVelocityDrop")
fbDfTargetSpeed = New cFileBrowser("DfTargetSpeed")
fbDfVelocityDrop.Extensions = New String() {"csv"}
fbDfTargetSpeed.Extensions = New String() {"csv"}
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
fbVMOD = New cFileBrowser("vmod")
'-------------------------------------------------------
fbFileLists.Extensions = New String() {"txt"}
fbVECTO.Extensions = New String() {"vecto"}
fbVEH.Extensions = New String() {"vveh"}
fbMAP.Extensions = New String() {"vmap"}
fbDRI.Extensions = New String() {"vdri"}
fbFLD.Extensions = New String() {"vfld"}
fbENG.Extensions = New String() {"veng"}
fbGBX.Extensions = New String() {"vgbx"}
fbACC.Extensions = New String() {"vacc"}
fbAUX.Extensions = New String() {"vaux"}
fbGBS.Extensions = New String() {"vgbs"}
fbRLM.Extensions = New String() {"vrlm"}
fbTLM.Extensions = New String() {"vtlm"}
fbTCC.Extensions = New String() {"vtcc"}
fbCDx.Extensions = New String() {"vcdv", "vcdb"}
fbVMOD.Extensions = New String() {"vmod"}
End Sub
Private Sub FB_Close()
fbFolder.Close()
fbFileLists.Close()
fbVECTO.Close()
fbVEH.Close()
fbMAP.Close()
fbDRI.Close()
fbFLD.Close()
fbENG.Close()
fbGBX.Close()
fbACC.Close()
fbAUX.Close()
fbGBS.Close()
fbRLM.Close()
fbTLM.Close()
fbTCC.Close()
fbCDx.Close()
fbVMOD.Close()
End Sub
'VECTO-Launcher
Public Sub VECTO_Launcher()
Dim ProgOverall As Boolean
Dim GEN0 As cVECTO
'Called when VECTO already running
If VECTOworker.IsBusy Then
GUImsg(tMsgID.Err, "VECTO is already running!")
Exit Sub
End If
'Delete GENlist-Selection

Michael KRISPER
committed
LvGEN.SelectedItems.Clear()
'If more than 100 calculations, ask whether to write by-second results
If _

Michael KRISPER
committed
Cfg.BatchMode And ((LvGEN.CheckedItems.Count) * (LvDRI.CheckedItems.Count) > 100) And
ChBoxModOut.Checked _
Then
Select Case _
MsgBox(
"You are about to run Batch Mode with " &

Michael KRISPER
committed
(LvGEN.CheckedItems.Count) * (LvDRI.CheckedItems.Count) &
" calculations!" & ChrW(10) & "Do you still want to write modal results?", MsgBoxStyle.YesNoCancel)
Case MsgBoxResult.No

Michael KRISPER
committed
ChBoxModOut.Checked = False
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
Case MsgBoxResult.Cancel
GUImsg(tMsgID.Normal, "Aborted by User")
Exit Sub
End Select
End If
'Status
Status("Launching VECTO...")
'Define Job-0list
'Define File / Cycle list
SetJobList()
'Zyklus-Liste definieren (falls nicht BATCH-Modus wird in SetCycleList nur die Liste gelöscht und nicht neu belegt) |@@| Define Cycle-list (if not BATCH mode in SetCycleList deleted only the list and not reassigned)
SetCycleList()
If JobFileList.Count = 0 Then
GUImsg(tMsgID.Err, "No job file selected!")
Exit Sub
End If
'Check whether Overall-progbar is needed
If Cfg.BatchMode Or JobFileList.Count > 1 Or Cfg.DeclMode Then
ProgOverall = True
Else
GEN0 = New cVECTO
GEN0.FilePath = JobFileList(0)
If Not GEN0.ReadFile Then
GUImsg(tMsgID.Err, "Failed to job file (" & fFILE(JobFileList(0), True) & ")!")
Exit Sub
End If
ProgOverall = (GEN0.CycleFiles.Count > 1)
End If
'Launch through Job_Launcher
Job_Launcher(ProgOverall)
End Sub
'Lock certain GUI elements while VECTO is running

Michael KRISPER
committed
Private Sub LockGUI(Lock As Boolean)

Michael KRISPER
committed
PanelOptAllg.Enabled = Not Lock
GrBoxSTD.Enabled = Not Lock
GrBoxBATCH.Enabled = Not Lock

Michael KRISPER
committed
BtGENup.Enabled = Not Lock
BtGENdown.Enabled = Not Lock
ButtonGENadd.Enabled = Not Lock
ButtonGENremove.Enabled = Not Lock
LvGEN.LabelEdit = Not Lock
ChBoxAllGEN.Enabled = Not Lock

Michael KRISPER
committed
BtDRIup.Enabled = Not Lock
BtDRIdown.Enabled = Not Lock
ButtonDRIadd.Enabled = Not Lock
ButtonDRIremove.Enabled = Not Lock
LvDRI.LabelEdit = Not Lock
ChBoxAllDRI.Enabled = Not Lock
Button1.Enabled = Not Lock
btStartV3.Enabled = Not Lock
If DEV.Enabled Then

Michael KRISPER
committed
LvDEVoptions.Enabled = Not Lock
End If
End Sub
'Define job file list
Private Sub SetJobList()
Dim LV0 As ListViewItem
Dim x As Integer
JobFileList.Clear()
CheckedItems.Clear()

Michael KRISPER
committed
x = -1

Michael KRISPER
committed
For Each LV0 In LvGEN.CheckedItems
x += 1
LV0.SubItems(1).Text = ""
CheckedItems.Add(LV0)
SetCheckedItemColor(x, tJobStatus.Queued)
JobFileList.Add(fFileRepl(LV0.SubItems(0).Text))
Next
End Sub
'Define cycle list (BATCH mode only)
Private Sub SetCycleList()
Dim LV0 As ListViewItem
JobCycleList.Clear()
If Cfg.BatchMode Then

Michael KRISPER
committed
For Each LV0 In LvDRI.CheckedItems
JobCycleList.Add(fFileRepl(LV0.SubItems(0).Text))
Next
End If
End Sub
'Job Launcher

Michael KRISPER
committed
Private Sub Job_Launcher(ProgOverallEnabled As Boolean)
If VECTOworker.IsBusy Then Exit Sub
'Load Options from Options Tab
SetOptions()
'Save Config

Michael KRISPER
committed
Cfg.Save()
If DEV.Enabled Then DEV.SaveToFile()
'Reset Msg-output
ClearMSG()
'Disable Options
LockGUI(True)
'Button switch
Button1.Enabled = True

Michael KRISPER
committed
Button1.Text = "STOP"
Button1.Image = My.Resources.Stop_icon
'ProgBars start
If ProgOverallEnabled Then

Michael KRISPER
committed
ToolStripProgBarOverall.Value = 0
ToolStripProgBarOverall.Style = ProgressBarStyle.Marquee
ToolStripProgBarOverall.Visible = True
End If
ProgBarCtrl.ProgJobInt = 0
ProgSecStart()
'BG-Worker start
VECTOworker.RunWorkerAsync()
End Sub
'Abort Job
Private Sub JobAbort()

Michael KRISPER
committed
Button1.Enabled = False
Button1.Text = "Aborting..."
Button1.Image = My.Resources.Play_icon_gray
VECTOworker.CancelAsync()
End Sub

Michael KRISPER
committed
Private Sub BackgroundWorker1_DoWork(sender As Object, e As DoWorkEventArgs) _
Handles BackgroundWorker1.DoWork
'Prevent SLEEP
AllowSleepOFF()
If SetCulture Then
Try

Michael KRISPER
committed
Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US")
Catch ex As Exception
GUImsg(tMsgID.Err, "Failed to set thread culture 'en-US'! Check system decimal- and group- separators!")
End Try
End If
e.Result = VECTO()
End Sub
'Progress Report - Progressbar, Messages, etc.

Michael KRISPER
committed
Private Sub BackgroundWorker1_ProgressChanged(sender As Object,
e As ProgressChangedEventArgs) _
Handles BackgroundWorker1.ProgressChanged
Dim x As cWorkProg
x = e.UserState
Select Case x.Target
Case tWorkMsgType.StatusListBox
MSGtoForm(e.UserState.ID, e.UserState.Msg, x.Source, x.Link)
Case tWorkMsgType.StatusBar
Status(e.UserState.Msg)
Case tWorkMsgType.ProgBars

Michael KRISPER
committed
ToolStripProgBarOverall.Value = e.ProgressPercentage
ProgSecStart()
Case tWorkMsgType.JobStatus
CheckedItems(x.FileIndex).SubItems(1).Text = x.Msg
SetCheckedItemColor(x.FileIndex, x.Status)
Case tWorkMsgType.CycleStatus
Try

Michael KRISPER
committed
LvDRI.CheckedItems(x.FileIndex).SubItems(1).Text = x.Msg
Catch ex As Exception
End Try
Case tWorkMsgType.InitProgBar

Michael KRISPER
committed
ToolStripProgBarOverall.Style = ProgressBarStyle.Continuous
Case Else ' tWorkMsgType.Abort
JobAbort()
End Select
End Sub
'Work completed

Michael KRISPER
committed
Private Sub BackgroundWorker1_RunWorkerCompleted(sender As Object,
e As RunWorkerCompletedEventArgs) _
Handles BackgroundWorker1.RunWorkerCompleted
Dim Result As tCalcResult
'Progbar reset

Michael KRISPER
committed
ToolStripProgBarOverall.Visible = False
ToolStripProgBarOverall.Style = ProgressBarStyle.Continuous
ToolStripProgBarOverall.Value = 0
ProgSecStop()
'So ListView-Item Colors (Warning = Yellow, etc..) are correctly visible

Michael KRISPER
committed
LvGEN.SelectedIndices.Clear()
Result = e.Result
'ShutDown when Unexpected Error
If e.Error IsNot Nothing Then
MsgBox("An Unexpected Error occurred!" & ChrW(10) & ChrW(10) &
e.Error.Message.ToString, MsgBoxStyle.Critical, "Unexpected Error")
LogFile.WriteToLog(tMsgID.Err, ">>>Unexpected Error:" & e.Error.ToString())

Michael KRISPER
committed
Close()
End If
'Options enable / GUI reset
LockGUI(False)

Michael KRISPER
committed
Button1.Text = "START V2.2"
Button1.Image = My.Resources.Play_icon
Status(LastModeName & " Mode")
'Command Line Shutdown

Michael KRISPER
committed
If ComLineShutDown Then Close()

Michael KRISPER
committed
If ChBoxAutoSD.Checked Then
ChBoxAutoSD.Checked = False
If Not Result = tCalcResult.Abort Then
If F_ShutDown.ShutDown Then
GUImsg(tMsgID.Warn, "Shutting down...")

Michael KRISPER
committed
Close()
End If
End If
End If
'SLEEP reactivate
AllowSleepON()
End Sub
#End Region
#End Region
#Region "Form Init/Close"

Michael KRISPER
committed
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
GUIlocked = False
CheckLock = False
GENcheckAllLock = False
DRIcheckAllLock = False
DRIchecked = 0
GENchecked = 0
CheckedItems = New List(Of ListViewItem)
'Load Tabs properly (otherwise problem with ListViews)

Michael KRISPER
committed
For x = 0 To TabControl1.TabCount - 1
TabControl1.TabPages(x).Show()

Michael KRISPER
committed
CycleTabPage = TabPageDRI

Michael KRISPER
committed
DEVpage = TabPageDEV
'TabControl1.Controls.Remove(DEVpage)

Michael KRISPER
committed
Text = "VECTO " & VECTOvers & " / VectoCore " & COREvers
'FileLists
JobListView = New cFileListView(MyConfPath & "joblist.txt")

Michael KRISPER
committed
JobListView.LVbox = LvGEN
CycleListView = New cFileListView(MyConfPath & "cyclelist.txt")

Michael KRISPER
committed
CycleListView.LVbox = LvDRI
JobListView.LoadList()
'Load GUI Options (here, the GEN/ADV/DRI lists are loaded)
LoadOptions()
'Resize columns ... after Loading the @file-lists

Michael KRISPER
committed
LvGEN.Columns(1).Width = -2
LvDRI.Columns(1).Width = -2
LvMsg.Columns(2).Width = -2
'Initialize BackgroundWorker

Michael KRISPER
committed
VECTOworker = BackgroundWorker1
VECTOworker.WorkerReportsProgress = True
VECTOworker.WorkerSupportsCancellation = True
VECTOworkerV3 = New BackgroundWorker()
AddHandler VECTOworkerV3.DoWork, AddressOf VectoWorkerV3_OnDoWork
AddHandler VECTOworkerV3.ProgressChanged, AddressOf VectoWorkerV3_OnProgressChanged
AddHandler VECTOworkerV3.RunWorkerCompleted, AddressOf VectoWorkerV3_OnRunWorkerCompleted
VECTOworkerV3.WorkerReportsProgress = True
VECTOworkerV3.WorkerSupportsCancellation = True
'Set mode (Batch/Standard)
ModeUpdate()
If LicCheck And Not Lic.LICcheck() Then
MsgBox("License File invalid!" & vbCrLf & vbCrLf & Lic.FailMsg)
If Lic.CreateActFile(MyAppPath & "ActivationCode.dat") Then
MsgBox("Activation File created.")
Else
MsgBox("Failed to create Activation File! Is Directory Read-Only?")
End If

Michael KRISPER
committed
Close()
Else
GUImsg(tMsgID.Normal, "License File validated.")
If Lic.TimeWarn Then GUImsg(tMsgID.Warn, "License expiring date (y/m/d): " & Lic.ExpTime)
End If
DEV.Enabled = True ' Lic.LicFeature(9)
If DEV.Enabled Then
DEV.LoadFromFile()
LoadDEVconfigs()
End If
DeclOnOff()
End Sub
Public Shared Sub LogMethod(level As String, message As String)
Try
If level = "Warn" Then
VECTOworkerV3.ReportProgress(100, New With {.Target = "ListBoxWarning", .Message = message})
ElseIf level = "Error" Or level = "Fatal" Then
VECTOworkerV3.ReportProgress(100, New With {.Target = "ListBoxError", .Message = message})
End If
Catch e As InvalidOperationException
End Try
End Sub
'Declaration mode GUI settings
Private Sub DeclOnOff()
If Cfg.DeclMode Then

Michael KRISPER
committed
Text = "VECTO " & VECTOvers & " / VectoCore " & COREvers & " - Declaration Mode"
CbBatch.Checked = False

Michael KRISPER
committed
Text = "VECTO " & VECTOvers & " / VectoCore " & COREvers
End If
If Cfg.DeclMode Then
LastModeName = "Declaration"
Else
If Cfg.BatchMode Then
LastModeName = "Batch"
Else
LastModeName = "Engineering"
End If
End If
If DEV.Enabled Then
If Not Cfg.DeclMode Then

Michael KRISPER
committed
If Not TabControl1.TabPages.Contains(DEVpage) Then _
TabControl1.TabPages.Insert(TabControl1.TabPages.Count, DEVpage)

Michael KRISPER
committed
If TabControl1.TabPages.Contains(DEVpage) Then TabControl1.Controls.Remove(DEVpage)
DEV.SetDefault()
End If
End If
Status(LastModeName & " Mode")

Michael KRISPER
committed
LoadOptions()

Michael KRISPER
committed
LbDecl.Visible = Cfg.DeclMode

Michael KRISPER
committed
PnDeclOpt.Enabled = Not Cfg.DeclMode
End Sub
'Shown Event (Form-Load finished) ... here StartUp Forms are loaded (DEV, GEN/ADV- Editor ..)

Michael KRISPER
committed
Private Sub F01_MAINForm_Shown(sender As Object, e As EventArgs) Handles Me.Shown
Dim fwelcome As F_Welcome
'DEV Form
'If DEV.Enabled And Not Cfg.DeclMode Then

Michael KRISPER
committed
' TabControl1.TabPages.Insert(TabControl1.TabPages.Count, DEVpage)
'End If
'VECTO Init
Declaration.Init()
'Command Line Args
If Command() <> "" Then
CmdLineCtrl(My.Application.CommandLineArgs)
Else
If Cfg.FirstRun Then
Cfg.FirstRun = False
fwelcome = New F_Welcome
fwelcome.ShowDialog()
End If
End If
End Sub
'Open file

Michael KRISPER
committed
Private Sub CmdLineCtrl(ComLineArgs As ReadOnlyCollection(Of String))
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
Dim bBATCH As Boolean
Dim bRUN As Boolean
Dim x As Object
Dim str As String
Dim ComFile As String = ""
Dim vecFiles As New List(Of String)
Dim driFiles As New List(Of String)
bBATCH = False
bRUN = False
ComFile = sKey.NoFile
'Read Command-Line Args
For Each x In ComLineArgs
str = Trim(Replace(x.ToString, ChrW(34), ""))
Select Case UCase(str)
Case "-BATCH"
bBATCH = True
Case "-CLOSE"
ComLineShutDown = True
Case "-RUN"
bRUN = True
Case Else
Select Case UCase(fEXT(str))
Case ".VECTO"
vecFiles.Add(fFileRepl(str))
Case ".VDRI"
driFiles.Add(fFileRepl(str))
Case Else
ComFile = fFileRepl(str)
End Select
End Select
Next
'Mode switch and load Driving Cycles
If bBATCH Then

Michael KRISPER
committed
CbBatch.Checked = True
If driFiles.Count > 0 Then
LvDRI.Items.Clear()
AddToCycleListView(driFiles.ToArray)
End If
Else

Michael KRISPER
committed
CbBatch.Checked = False
End If
'Load Vecto files or open editor (if only one file)
If vecFiles.Count > 0 Then
If vecFiles.Count > 1 Or bRUN Then
LvGEN.Items.Clear()
AddToJobListView(vecFiles.ToArray)
Else
ComFile = vecFiles(0)
End If
End If
'Run or open file editor if file is specified
If bRUN Then
VECTO_Launcher()
Else
If ComFile <> sKey.NoFile Then OpenVectoFile(ComFile)
End If
End Sub
'Close

Michael KRISPER
committed
Private Sub F01_MAINForm_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
'Save File-Lists
SaveFileLists()
'Close log
LogFile.CloseLog()
'Config save
SetOptions()

Michael KRISPER
committed
Cfg.Save()
If DEV.Enabled Then DEV.SaveToFile()
'File browser instances close
FB_Close()
End Sub
'Open file - Job, vehicle, engine, gearbox or signature file

Michael KRISPER
committed
Public Sub OpenVectoFile(File As String)
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
782
783
784
785
786
787
788
If Not IO.File.Exists(File) Then
GUImsg(tMsgID.Err, "File not found! (" & File & ")")
MsgBox("File not found! (" & File & ")", MsgBoxStyle.Critical)
Else
Select Case UCase(fEXT(File))
Case ".VGBX"
If Not F_GBX.Visible Then
F_GBX.Show()
Else
F_GBX.JobDir = ""
If F_GBX.WindowState = FormWindowState.Minimized Then F_GBX.WindowState = FormWindowState.Normal
F_GBX.BringToFront()
End If
F_GBX.openGBX(File)
Case ".VVEH"
If Not F_VEH.Visible Then
F_VEH.Show()
Else
F_VEH.JobDir = ""
If F_VEH.WindowState = FormWindowState.Minimized Then F_VEH.WindowState = FormWindowState.Normal
F_VEH.BringToFront()
End If
F_VEH.openVEH(File)
Case ".VENG"
If Not F_ENG.Visible Then
F_ENG.Show()
Else
F_ENG.JobDir = ""
If F_ENG.WindowState = FormWindowState.Minimized Then F_ENG.WindowState = FormWindowState.Normal
F_ENG.BringToFront()
End If
F_ENG.openENG(File)
Case ".VECTO"
OpenVECTOeditor(File)
Case ".VSIG"
OpenSigFile(File)
Case Else
MsgBox("Type '" & fEXT(File) & "' unknown!", MsgBoxStyle.Critical)
End Select
End If
End Sub

Michael KRISPER
committed
Private Sub ButtonGENremove_Click(sender As Object, e As EventArgs) _
Handles ButtonGENremove.Click
RemoveJobFile()
End Sub

Michael KRISPER
committed
Private Sub ButtonGENadd_Click(sender As Object, e As EventArgs) _
Handles ButtonGENadd.Click
AddJobFile()
End Sub

Michael KRISPER
committed
Private Sub ButtonGENoptions_Click(sender As Object, e As EventArgs) _

Michael KRISPER
committed
ConMenTarget = LvGEN
ConMenTarJob = True
'Locked functions show/hide

Michael KRISPER
committed
LoadListToolStripMenuItem.Enabled = Not GUIlocked
LoadDefaultListToolStripMenuItem.Enabled = Not GUIlocked
ClearListToolStripMenuItem.Enabled = Not GUIlocked

Michael KRISPER
committed
ConMenFilelist.Show(MousePosition)

Michael KRISPER
committed
Private Sub ListViewGEN_KeyDown(sender As Object, e As KeyEventArgs) _
Handles LvGEN.KeyDown
Select Case e.KeyCode
Case Keys.Delete, Keys.Back
If Not GUIlocked Then RemoveJobFile()
Case Keys.Enter
OpenJobFile()
End Select
End Sub

Michael KRISPER
committed
Private Sub ListViewGEN_DoubleClick(sender As Object, e As EventArgs) Handles LvGEN.DoubleClick
If LvGEN.SelectedItems.Count > 0 Then
LvGEN.SelectedItems(0).Checked = Not LvGEN.SelectedItems(0).Checked
OpenJobFile()
End If
End Sub

Michael KRISPER
committed
Private Sub LvGEN_ItemChecked(sender As Object, e As ItemCheckedEventArgs) _
Handles LvGEN.ItemChecked
If e.Item.Checked Then
GENchecked += 1
Else
GENchecked -= 1
End If
If CheckLock Then Exit Sub
UpdateJobTabText()
End Sub

Michael KRISPER
committed
Private Sub ChBoxAllGEN_CheckedChanged(sender As Object, e As EventArgs) _
Handles ChBoxAllGEN.CheckedChanged

Michael KRISPER
committed
If GENcheckAllLock And ChBoxAllGEN.CheckState = CheckState.Indeterminate Then Exit Sub

Michael KRISPER
committed
CheckAllGEN(ChBoxAllGEN.Checked)

Michael KRISPER
committed
Private Sub CheckAllGEN(Check As Boolean)
Dim x As ListViewItem
CheckLock = True

Michael KRISPER
committed
LvGEN.BeginUpdate()

Michael KRISPER
committed
For Each x In LvGEN.Items

Michael KRISPER
committed
LvGEN.EndUpdate()

Michael KRISPER
committed
GENchecked = LvGEN.CheckedItems.Count
UpdateJobTabText()
End Sub

Michael KRISPER
committed
Private Sub ListGEN_DragEnter(sender As Object, e As DragEventArgs) _
Handles LvGEN.DragEnter
If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
e.Effect = DragDropEffects.Copy
End If
End Sub

Michael KRISPER
committed
Private Sub ListGEN_DragDrop(sender As Object, e As DragEventArgs) _
Handles LvGEN.DragDrop
Dim f As String()
f = CType(e.Data.GetData(DataFormats.FileDrop), Array)
AddToJobListView(f)
End Sub

Michael KRISPER
committed
Private Sub BtGENup_Click(sender As Object, e As EventArgs) Handles BtGENup.Click
MoveItem(LvGEN, True)
End Sub

Michael KRISPER
committed
Private Sub BtGENdown_Click(sender As Object, e As EventArgs) Handles BtGENdown.Click
MoveItem(LvGEN, False)
End Sub
'Remove selected file(s) from job list
Private Sub RemoveJobFile()
Dim lastindx As Integer
Dim SelIx() As Integer
Dim i As Integer

Michael KRISPER
committed
If LvGEN.SelectedItems.Count < 1 Then
If LvGEN.Items.Count = 1 Then
LvGEN.Items(0).Selected = True
Else
Exit Sub
End If
End If
LvGEN.BeginUpdate()
CheckLock = True
ReDim SelIx(LvGEN.SelectedItems.Count - 1)
LvGEN.SelectedIndices.CopyTo(SelIx, 0)
lastindx = LvGEN.SelectedIndices(LvGEN.SelectedItems.Count - 1)

Michael KRISPER
committed
For i = UBound(SelIx) To 0 Step -1
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
LvGEN.Items.RemoveAt(SelIx(i))
Next
If lastindx < LvGEN.Items.Count Then
LvGEN.Items(lastindx).Selected = True
Else
If LvGEN.Items.Count > 0 Then LvGEN.Items(LvGEN.Items.Count - 1).Selected = True
End If
LvGEN.EndUpdate()
CheckLock = False
GENchecked = LvGEN.CheckedItems.Count
UpdateJobTabText()
End Sub
'Browse for job file(s) and add to job list with AddToJobListView
Private Sub AddJobFile()
Dim x As String()
Dim Chck As Boolean = False
x = New String() {""}
'STANDARD/BATCH
If fbVECTO.OpenDialog("", True, "vecto") Then
Chck = True
x = fbVECTO.Files
End If
If Chck Then AddToJobListView(x)
End Sub
'Open file in list
Private Sub OpenJobFile()
Dim f As String

Michael KRISPER
committed
If LvGEN.SelectedItems.Count < 1 Then
If LvGEN.Items.Count = 1 Then
LvGEN.Items(0).Selected = True
Else
Exit Sub
End If
End If

Michael KRISPER
committed
f = LvGEN.SelectedItems(0).SubItems(0).Text

Michael KRISPER
committed
If Not File.Exists(f) Then
MsgBox(f & " not found!")
Else
OpenVECTOeditor(f)
End If
End Sub
'Add File to job listview (multiple files)

Michael KRISPER
committed
Private Sub AddToJobListView(Path As String(), Optional ByVal Txt As String = " ")
Dim pDim As Int16
Dim p As Int16
Dim f As Int16
Dim fList As String()

Michael KRISPER
committed
Dim fListDim As Int16 = -1
Dim ListViewItem0 As ListViewItem
'If VECTO runs: Cancel operation (because Mode-change during calculation is not very clever)
If VECTOworker.IsBusy Then Exit Sub
pDim = UBound(Path)
ReDim fList(0) 'um Nullverweisausnahme-Warnung zu verhindern
'******************************************* Begin Update '*******************************************

Michael KRISPER
committed
LvGEN.BeginUpdate()

Michael KRISPER
committed
LvGEN.SelectedIndices.Clear()

Michael KRISPER
committed
fListDim = LvGEN.Items.Count - 1
ReDim fList(fListDim)
For f = 0 To fListDim

Michael KRISPER
committed
fList(f) = fFileRepl(LvGEN.Items(f).SubItems(0).Text)