diff --git a/VECTO/GUI/F_MAINForm.Designer.vb b/VECTO/GUI/F_MAINForm.Designer.vb index 081a733726cf99e9288e69b5698601eca39e6eb7..62f9303d3a4a50e3fa4064f149a251e592e497cd 100644 --- a/VECTO/GUI/F_MAINForm.Designer.vb +++ b/VECTO/GUI/F_MAINForm.Designer.vb @@ -40,6 +40,7 @@ Partial Class F_MAINForm Me.ToolStripProgBarOverall = New System.Windows.Forms.ToolStripProgressBar() Me.TabControl1 = New System.Windows.Forms.TabControl() Me.TabPageGEN = New System.Windows.Forms.TabPage() + Me.Button2 = New System.Windows.Forms.Button() Me.LbDecl = New System.Windows.Forms.Label() Me.PictureBox1 = New System.Windows.Forms.PictureBox() Me.BtGENdown = New System.Windows.Forms.Button() @@ -47,8 +48,8 @@ Partial Class F_MAINForm Me.LbAutoShDown = New System.Windows.Forms.Label() Me.ChBoxAllGEN = New System.Windows.Forms.CheckBox() Me.LvGEN = New System.Windows.Forms.ListView() - Me.ColGENpath = CType(New System.Windows.Forms.ColumnHeader(),System.Windows.Forms.ColumnHeader) - Me.ColGENstatus = CType(New System.Windows.Forms.ColumnHeader(),System.Windows.Forms.ColumnHeader) + Me.ColGENpath = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ColGENstatus = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) Me.ButtonGENopt = New System.Windows.Forms.Button() Me.ButtonGENremove = New System.Windows.Forms.Button() Me.Button1 = New System.Windows.Forms.Button() @@ -129,7 +130,6 @@ Partial Class F_MAINForm Me.OpenWithToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.OpenInGraphWindowToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.ShowInFolderToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() - Me.Button2 = New System.Windows.Forms.Button() Me.StatusBAR.SuspendLayout() Me.TabControl1.SuspendLayout() Me.TabPageGEN.SuspendLayout() @@ -224,6 +224,18 @@ Partial Class F_MAINForm Me.TabPageGEN.Text = "Job Files" Me.TabPageGEN.UseVisualStyleBackColor = True ' + 'Button2 + ' + Me.Button2.Image = Global.VECTO.My.Resources.Resources.Play_icon + Me.Button2.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft + Me.Button2.Location = New System.Drawing.Point(6, 100) + Me.Button2.Name = "Button2" + Me.Button2.Size = New System.Drawing.Size(105, 41) + Me.Button2.TabIndex = 20 + Me.Button2.Text = "START V3" + Me.Button2.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText + Me.Button2.UseVisualStyleBackColor = True + ' 'LbDecl ' Me.LbDecl.AutoSize = True @@ -1012,18 +1024,6 @@ Partial Class F_MAINForm Me.ShowInFolderToolStripMenuItem.Size = New System.Drawing.Size(198, 22) Me.ShowInFolderToolStripMenuItem.Text = "Show in Folder" ' - 'Button2 - ' - Me.Button2.Image = Global.VECTO.My.Resources.Resources.Play_icon - Me.Button2.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft - Me.Button2.Location = New System.Drawing.Point(6, 100) - Me.Button2.Name = "Button2" - Me.Button2.Size = New System.Drawing.Size(105, 41) - Me.Button2.TabIndex = 20 - Me.Button2.Text = "START V3" - Me.Button2.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText - Me.Button2.UseVisualStyleBackColor = True - ' 'F_MAINForm ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) diff --git a/VECTO/GUI/F_MAINForm.vb b/VECTO/GUI/F_MAINForm.vb index e4d0810089d66a89c923d7e937a875269d66157b..1b1dc30088d35034a62b059810b0c3e40fe36da7 100644 --- a/VECTO/GUI/F_MAINForm.vb +++ b/VECTO/GUI/F_MAINForm.vb @@ -10,13 +10,16 @@ ' See the LICENSE.txt for the specific language governing permissions and limitations. Imports System.Collections.Generic +Imports System.ComponentModel +Imports System.Linq +Imports System.Threading ''' <summary> ''' Main application form. Loads at application start. Closing form ends application. ''' </summary> ''' <remarks></remarks> -Public Class F_MAINForm + Public Class F_MAINForm Private JobListView As cFileListView Private CycleListView As cFileListView @@ -50,7 +53,7 @@ Public Class F_MAINForm #Region "SLEEP Control - Prevent sleep while VECTO is running" - Private Declare Function SetThreadExecutionState Lib "kernel32" (ByVal esFlags As Long) As Long + Private Declare Function SetThreadExecutionState Lib "kernel32"(ByVal esFlags As Long) As Long Private Sub AllowSleepOFF() #If Not PLATFORM = "x86" Then @@ -158,11 +161,11 @@ Public Class F_MAINForm Me.LvGEN.SelectedItems.Clear() 'If more than 100 calculations, ask whether to write by-second results - If Cfg.BatchMode And ((Me.LvGEN.CheckedItems.Count) * (Me.LvDRI.CheckedItems.Count) > 100) And Me.ChBoxModOut.Checked _ + If Cfg.BatchMode And ((Me.LvGEN.CheckedItems.Count)*(Me.LvDRI.CheckedItems.Count) > 100) And Me.ChBoxModOut.Checked _ Then Select Case _ MsgBox( - "You are about to run Batch Mode with " & (Me.LvGEN.CheckedItems.Count) * (Me.LvDRI.CheckedItems.Count) & + "You are about to run Batch Mode with " & (Me.LvGEN.CheckedItems.Count)*(Me.LvDRI.CheckedItems.Count) & " calculations!" & ChrW(10) & "Do you still want to write modal results?", MsgBoxStyle.YesNoCancel) Case MsgBoxResult.No Me.ChBoxModOut.Checked = False @@ -228,6 +231,9 @@ Public Class F_MAINForm Me.LvDRI.LabelEdit = Not Lock Me.ChBoxAllDRI.Enabled = Not Lock + Button1.Enabled = Not Lock + Button2.Enabled = Not Lock + If DEV.Enabled Then Me.LvDEVoptions.Enabled = Not Lock End If @@ -241,7 +247,7 @@ Public Class F_MAINForm JobFileList.Clear() CheckedItems.Clear() - x = -1 + x = - 1 For Each LV0 In Me.LvGEN.CheckedItems x += 1 LV0.SubItems(1).Text = "" @@ -280,13 +286,14 @@ Public Class F_MAINForm 'Reset Msg-output ClearMSG() + 'Disable Options + LockGUI(True) + 'Button switch + Button1.Enabled = True Me.Button1.Text = "STOP" Me.Button1.Image = My.Resources.Stop_icon - 'Disable Options - LockGUI(True) - 'ProgBars start If ProgOverallEnabled Then Me.ToolStripProgBarOverall.Value = 0 @@ -393,8 +400,7 @@ Public Class F_MAINForm 'Options enable / GUI reset LockGUI(False) - Me.Button1.Enabled = True - Me.Button1.Text = "START" + Me.Button1.Text = "START V2.2" Me.Button1.Image = My.Resources.Play_icon Status(LastModeName & " Mode") @@ -467,15 +473,24 @@ Public Class F_MAINForm LoadOptions() 'Resize columns ... after Loading the @file-lists - Me.LvGEN.Columns(1).Width = -2 - Me.LvDRI.Columns(1).Width = -2 - Me.LvMsg.Columns(2).Width = -2 + Me.LvGEN.Columns(1).Width = - 2 + Me.LvDRI.Columns(1).Width = - 2 + Me.LvMsg.Columns(2).Width = - 2 'Initialize BackgroundWorker VECTOworker = Me.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() @@ -503,6 +518,97 @@ Public Class F_MAINForm DeclOnOff() End Sub + Private Sub VectoWorkerV3_OnRunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) + Dim Result As tCalcResult + + 'Progbar reset + ToolStripProgBarOverall.Visible = False + ToolStripProgBarOverall.Style = ProgressBarStyle.Continuous + ToolStripProgBarOverall.Value = 0 + ProgSecStop() + + 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()) + End If + + 'Options enable / GUI reset + LockGUI(False) + Button2.Text = "START V3" + Button2.Image = My.Resources.Play_icon + Status(LastModeName & " Mode") + + 'SLEEP reactivate + AllowSleepON() + End Sub + + Private Sub VectoWorkerV3_OnProgressChanged(sender As Object, e As ProgressChangedEventArgs) + 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 + Me.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 + Me.LvDRI.CheckedItems(x.FileIndex).SubItems(1).Text = x.Msg + Catch ex As Exception + End Try + + Case tWorkMsgType.InitProgBar + Me.ToolStripProgBarOverall.Style = ProgressBarStyle.Continuous + + Case Else ' tWorkMsgType.Abort + JobAbort() + + End Select + End Sub + + Private Sub VectoWorkerV3_OnDoWork(sender As Object, e As DoWorkEventArgs) + AllowSleepOFF() + Dim WorkProg As New cWorkProg(tWorkMsgType.StatusListBox) + WorkProg.ID = tMsgID.Normal + WorkProg.Msg = "Test 0%" + WorkProg.Source = "VectoWorkerV3_OnDoWork" + WorkProg.Link = "" + VECTOworkerV3.ReportProgress(0, WorkProg) + Thread.Sleep(1000) + + WorkProg.ID = tMsgID.Normal + WorkProg.Msg = "Test 50%" + WorkProg.Source = "VectoWorkerV3_OnDoWork" + WorkProg.Link = "" + VECTOworkerV3.ReportProgress(50, WorkProg) + Thread.Sleep(1000) + + WorkProg.ID = tMsgID.Normal + WorkProg.Msg = "Test 100%" + WorkProg.Source = "VectoWorkerV3_OnDoWork" + WorkProg.Link = "" + VECTOworkerV3.ReportProgress(100, WorkProg) + Thread.Sleep(1000) + + e.Result = True + End Sub + 'Declaration mode GUI settings Private Sub DeclOnOff() @@ -526,7 +632,8 @@ Public Class F_MAINForm If DEV.Enabled Then If Not Cfg.DeclMode Then - If Not Me.TabControl1.TabPages.Contains(DEVpage) Then Me.TabControl1.TabPages.Insert(Me.TabControl1.TabPages.Count, DEVpage) + If Not Me.TabControl1.TabPages.Contains(DEVpage) Then _ + Me.TabControl1.TabPages.Insert(Me.TabControl1.TabPages.Count, DEVpage) LoadDEVconfigs() Else If Me.TabControl1.TabPages.Contains(DEVpage) Then Me.TabControl1.Controls.Remove(DEVpage) @@ -831,7 +938,7 @@ Public Class F_MAINForm lastindx = LvGEN.SelectedIndices(LvGEN.SelectedItems.Count - 1) - For i = UBound(SelIx) To 0 Step -1 + For i = UBound(SelIx) To 0 Step - 1 LvGEN.Items.RemoveAt(SelIx(i)) Next @@ -891,7 +998,7 @@ Public Class F_MAINForm Dim p As Int16 Dim f As Int16 Dim fList As String() - Dim fListDim As Int16 = -1 + Dim fListDim As Int16 = - 1 Dim ListViewItem0 As ListViewItem 'If VECTO runs: Cancel operation (because Mode-change during calculation is not very clever) @@ -946,7 +1053,7 @@ Public Class F_MAINForm ListViewItem0.Selected = True Me.LvGEN.Items.Add(ListViewItem0) ListViewItem0.EnsureVisible() -lbFound: + lbFound: Next Me.LvGEN.EndUpdate() @@ -1110,7 +1217,7 @@ lbFound: lastindx = LvDRI.SelectedIndices(LvDRI.SelectedItems.Count - 1) - For i = UBound(SelIx) To 0 Step -1 + For i = UBound(SelIx) To 0 Step - 1 LvDRI.Items.RemoveAt(SelIx(i)) Next @@ -1168,7 +1275,7 @@ lbFound: ListViewItem0.SubItems.Add(" ") ListViewItem0.Checked = True Me.LvDRI.Items.Add(ListViewItem0) -lbFound: + lbFound: Next Me.LvDRI.EndUpdate() @@ -1303,7 +1410,8 @@ lbFound: End If End Sub - Private Sub ReportBugViaCITnetToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ReportBugViaCITnetToolStripMenuItem.Click + Private Sub ReportBugViaCITnetToolStripMenuItem_Click(sender As Object, e As EventArgs) _ + Handles ReportBugViaCITnetToolStripMenuItem.Click F_JIRA.ShowDialog() End Sub @@ -1479,6 +1587,48 @@ lbFound: End If End Sub + Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click + If Not VECTOworkerV3.IsBusy Then + 'Save Lists for Crash + SaveFileLists() + + LvGEN.SelectedItems.Clear() + + Status("Launching VECTO V3...") + + JobFileList.Clear() + JobFileList.AddRange(From listViewItem In LvGEN.CheckedItems Select fFileRepl(listViewItem.SubItems(0).Text)) + + If JobFileList.Count = 0 Then + GUImsg(tMsgID.Err, "No job file selected!") + Exit Sub + End If + + SetOptions() + Cfg.ConfigSAVE() + ClearMSG() + + LockGUI(True) + Button2.Enabled = True + Button2.Text = "STOP" + Button2.Image = My.Resources.Stop_icon + + ToolStripProgBarOverall.Value = 0 + ToolStripProgBarOverall.Style = ProgressBarStyle.Marquee + ToolStripProgBarOverall.Visible = True + + ProgBarCtrl.ProgJobInt = 0 + ProgSecStart() + + VECTOworkerV3.RunWorkerAsync() + Else + Button2.Enabled = False + Button2.Text = "Aborting..." + Button2.Image = My.Resources.Play_icon_gray + VECTOworkerV3.CancelAsync() + End If + End Sub + 'Mode Change (STANDARD/BATCH) Private Sub CbBatch_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles CbBatch.CheckedChanged ModeUpdate() @@ -1738,9 +1888,9 @@ lbFound: Me.ToolStripProgBarJob.Value = .ProgJobInt - If .ProgOverallStartInt > -1 Then + If .ProgOverallStartInt > - 1 Then Me.ToolStripProgBarOverall.Value = - CInt(.ProgOverallStartInt + (.PgroOverallEndInt - .ProgOverallStartInt) * .ProgJobInt / 100) + CInt(.ProgOverallStartInt + (.PgroOverallEndInt - .ProgOverallStartInt)*.ProgJobInt/100) End If End With @@ -1756,7 +1906,7 @@ lbFound: Me.ChBoxCyclDistCor.Checked = Cfg.DistCorr Me.ChBoxUseGears.Checked = Cfg.GnUfromCycle Me.ChBoxModOut.Checked = Cfg.ModOut - CbBOmode.SelectedIndex = -1 + CbBOmode.SelectedIndex = - 1 Select Case UCase(Cfg.BATCHoutpath) Case sKey.JobPath CbBOmode.SelectedIndex = 0 @@ -1832,7 +1982,7 @@ lbFound: Me.LvDEVoptions.Items.Clear() - i = -1 + i = - 1 For Each Config0 In DEV.Options i += 1 @@ -1895,7 +2045,7 @@ lbFound: CmDEV.Items.Clear() - i = -1 + i = - 1 For Each str In Config0.Modes i += 1 CmDEV.Items.Add("(" & i & ") " & str) @@ -2217,7 +2367,7 @@ lbFound: MyForm.LvMsg.Items.Insert(RowLim - 4, Space(ColLim - 30) & " " & Space(10) & "*| |*") End Select Exit Sub -LbRace: + LbRace: PRbAlt = Not PRbAlt @@ -2245,17 +2395,17 @@ LbRace: sAbort() Exit Sub End If - Scr += 5 * DiffLvl + Scr += 5*DiffLvl End If Scr += DiffLvl DiffC += 1 'Erhöhe Schwierigkeitsgrad - If DiffC = (DiffLvl + 3) * 4 Then + If DiffC = (DiffLvl + 3)*4 Then DiffC = 0 DiffLvl += 1 - If DiffLvl > 2 And DiffLvl < 7 Then MyForm.TmProgSec.Interval = 300 - (DiffLvl) * 30 + If DiffLvl > 2 And DiffLvl < 7 Then MyForm.TmProgSec.Interval = 300 - (DiffLvl)*30 Scr += 100 Select Case DiffLvl Case 3 @@ -2339,10 +2489,10 @@ LbRace: Ctrls(RowLim + 1) = 0 CtrlC += 1 If CtrlC < CtrlCL Then Exit Sub - Select Case CInt(Int((CtrlRnd * Rnd()) + 1)) + Select Case CInt(Int((CtrlRnd*Rnd()) + 1)) Case 1, 2 CtrlC = 0 - x = CInt(Int((7 * Rnd()) + 1)) + x = CInt(Int((7*Rnd()) + 1)) Ctrls(RowLim + 1) = x Case Else End Select @@ -2386,7 +2536,7 @@ LbRace: s = s.Insert(Ctrls(RowLim + 1) + 1, "X") End If Select Case xPanel - Pnls(RowLim) - Case -1 + Case - 1 s = Replace(s, "|", "\") Case 1 s = Replace(s, "|", "/") @@ -2398,15 +2548,15 @@ LbRace: PnDirC += 1 If PnDirC < PnDirCL Then GoTo Lb1 PnDirC = 0 - Select Case CInt(Int((PnDirRnd * Rnd()) + 1)) + Select Case CInt(Int((PnDirRnd*Rnd()) + 1)) Case 1 PnDir = 1 Case 2 - PnDir = -1 + PnDir = - 1 Case Else PnDir = 0 End Select -Lb1: + Lb1: xPanel += PnDir If xPanel > ColLim Then xPanel = ColLim @@ -2451,5 +2601,4 @@ Lb1: End Sub #End Region - End Class diff --git a/VECTO/VECTO_Global.vb b/VECTO/VECTO_Global.vb index 057c4efb9d6a32b82d9f1665c1508fa8d8ec3394..19c8369f170a6f4843797e8a689493ac166a57cf 100644 --- a/VECTO/VECTO_Global.vb +++ b/VECTO/VECTO_Global.vb @@ -22,6 +22,7 @@ Module VECTO_Global 'BackgroundWorker Public VECTOworker As System.ComponentModel.BackgroundWorker + Public VECTOworkerV3 As System.ComponentModel.BackgroundWorker 'Log/Msg Public MSGerror As Integer