Skip to content

Commit

Permalink
added OnTaskBundleCompletedActionMethod
Browse files Browse the repository at this point in the history
+ ShowMessageBoxOnTaskBundleCompleted
+ AutoCloseFormOnTaskBundleCompleted
  • Loading branch information
jochenwezel committed Nov 12, 2024
1 parent 877323a commit 47d05a8
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>2024.11.12.100</Version>
<Version>2024.11.12.101</Version>
<Copyright>2023-2024 CompuMaster GmbH</Copyright>
<Title>CompuMaster.TaskManagement.UI.WinForms - MIT license edition</Title>
<Company>CompuMaster GmbH</Company>
<Authors>Jochen Wezel</Authors>
<Product>CompuMaster.TaskManagement</Product>
<Copyright>2023-2024 CompuMaster GmbH</Copyright>
<Configurations>Debug;CI_CD;Release</Configurations>
<AnalysisLevel>latest-recommended</AnalysisLevel>
<RootNamespace>CompuMaster.TaskManagement.UI.WinForms</RootNamespace>
Expand Down
62 changes: 47 additions & 15 deletions CompuMaster.TaskManagement.UI.WinForms/MultiTaskProgessForm.vb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ Public Class MultiTaskProgessForm

Public Property TaskBundle As ProgressingTaskBundle

Public Property AutoStartTaskBundleRunner As Boolean

Private Sub MultiTaskProgessForm_Load(sender As Object, e As EventArgs) Handles Me.Load
RefreshAllControls()
If AutoStartTaskBundleRunner Then
Me.ButtonStart_Click(sender, e)
End If
End Sub

Public Sub RefreshAllControls()
Expand Down Expand Up @@ -197,10 +202,33 @@ Public Class MultiTaskProgessForm
)
End Sub

Public Delegate Sub OnTaskBundleCompletedActionMethod(status As ProgressingTaskBundle.ProgressingTaskBundleStatus)

''' <summary>
''' Actions to call on task bundle completed
''' </summary>
''' <returns></returns>
Public Property OnTaskBundleCompletedActions As New List(Of OnTaskBundleCompletedActionMethod)

Protected Overridable Sub OnTaskBundleCompleted(status As ProgressingTaskBundle.ProgressingTaskBundleStatus)
For Each ActionItem In OnTaskBundleCompletedActions
ActionItem(status)
Next
RaiseEvent TaskBundleCompleted(status)
End Sub

''' <summary>
''' Automatically show message box with task bundle status after task bundle completed
''' </summary>
''' <returns></returns>
Public Property ShowMessageBoxOnTaskBundleCompleted As Boolean = True

''' <summary>
''' Automatically close form after task bundle completed
''' </summary>
''' <returns></returns>
Public Property AutoCloseFormOnTaskBundleCompleted As Boolean = False

Check warning on line 230 in CompuMaster.TaskManagement.UI.WinForms/MultiTaskProgessForm.vb

View workflow job for this annotation

GitHub Actions / test (windows-latest)

Member 'AutoCloseFormOnTaskBundleCompleted' is explicitly initialized to its default value (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1805)

Check warning on line 230 in CompuMaster.TaskManagement.UI.WinForms/MultiTaskProgessForm.vb

View workflow job for this annotation

GitHub Actions / test (windows-latest)

Member 'AutoCloseFormOnTaskBundleCompleted' is explicitly initialized to its default value (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1805)

Check warning on line 230 in CompuMaster.TaskManagement.UI.WinForms/MultiTaskProgessForm.vb

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Member 'AutoCloseFormOnTaskBundleCompleted' is explicitly initialized to its default value (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1805)

Check warning on line 230 in CompuMaster.TaskManagement.UI.WinForms/MultiTaskProgessForm.vb

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Member 'AutoCloseFormOnTaskBundleCompleted' is explicitly initialized to its default value (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1805)

Check warning on line 230 in CompuMaster.TaskManagement.UI.WinForms/MultiTaskProgessForm.vb

View workflow job for this annotation

GitHub Actions / test (macos-latest)

Member 'AutoCloseFormOnTaskBundleCompleted' is explicitly initialized to its default value (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1805)

Check warning on line 230 in CompuMaster.TaskManagement.UI.WinForms/MultiTaskProgessForm.vb

View workflow job for this annotation

GitHub Actions / test (macos-latest)

Member 'AutoCloseFormOnTaskBundleCompleted' is explicitly initialized to its default value (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1805)

Check warning on line 230 in CompuMaster.TaskManagement.UI.WinForms/MultiTaskProgessForm.vb

View workflow job for this annotation

GitHub Actions / publish

Member 'AutoCloseFormOnTaskBundleCompleted' is explicitly initialized to its default value (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1805)

Check warning on line 230 in CompuMaster.TaskManagement.UI.WinForms/MultiTaskProgessForm.vb

View workflow job for this annotation

GitHub Actions / publish

Member 'AutoCloseFormOnTaskBundleCompleted' is explicitly initialized to its default value (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1805)

Private Sub MyForm_TaskBundleCompleted(status As ProgressingTaskBundle.ProgressingTaskBundleStatus) Handles Me.TaskBundleCompleted
UITools.TryRun(Me,
Sub()
Expand All @@ -212,22 +240,26 @@ Public Class MultiTaskProgessForm
Sub(switch)
End Sub
)
Select Case status
Case ProgressingTaskBundle.ProgressingTaskBundleStatus.CompletedSuccessfully
MessageBox.Show(Me, "Der Task wurde erfolgreich abgeschlossen.", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
Case ProgressingTaskBundle.ProgressingTaskBundleStatus.FailedNonCritically
Me.ButtonCopyResultsToClipboard.Visible = True
MessageBox.Show(Me, "Der Task wurde mit Fehlern abgeschlossen.", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Case ProgressingTaskBundle.ProgressingTaskBundleStatus.FailedInCriticalState
Me.ButtonCopyResultsToClipboard.Visible = True
MessageBox.Show(Me, "Der Task wurde mit Fehlern abgeschlossen. ACHTUNG: Aufgrund von nicht korrigierbaren Fehlern verbleibt das System in einem undefinierten, kritischen Zustand.", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
Case ProgressingTaskBundle.ProgressingTaskBundleStatus.Aborted
Me.ButtonCopyResultsToClipboard.Visible = True
MessageBox.Show(Me, "Der Task wurde abgebrochen.", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Case Else
MessageBox.Show(Me, "Der Task wurde abgeschlossen: " & status.ToString, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning)
End Select
TimerRefreshAllControls.Enabled = False
If AutoCloseFormOnTaskBundleCompleted Then
Me.Close()
ElseIf ShowMessageBoxOnTaskBundleCompleted Then
Select Case status
Case ProgressingTaskBundle.ProgressingTaskBundleStatus.CompletedSuccessfully
MessageBox.Show(Me, "Der Task wurde erfolgreich abgeschlossen.", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
Case ProgressingTaskBundle.ProgressingTaskBundleStatus.FailedNonCritically
Me.ButtonCopyResultsToClipboard.Visible = True
MessageBox.Show(Me, "Der Task wurde mit Fehlern abgeschlossen.", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Case ProgressingTaskBundle.ProgressingTaskBundleStatus.FailedInCriticalState
Me.ButtonCopyResultsToClipboard.Visible = True
MessageBox.Show(Me, "Der Task wurde mit Fehlern abgeschlossen. ACHTUNG: Aufgrund von nicht korrigierbaren Fehlern verbleibt das System in einem undefinierten, kritischen Zustand.", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
Case ProgressingTaskBundle.ProgressingTaskBundleStatus.Aborted
Me.ButtonCopyResultsToClipboard.Visible = True
MessageBox.Show(Me, "Der Task wurde abgebrochen.", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Case Else
MessageBox.Show(Me, "Der Task wurde abgeschlossen: " & status.ToString, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning)
End Select
End If
End Sub

Private Sub ButtonCancel_Click(sender As Object, e As EventArgs) Handles ButtonCancel.Click
Expand Down
4 changes: 2 additions & 2 deletions CompuMaster.TaskManagement/CompuMaster.TaskManagement.vbproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>2024.11.12.101</Version>
<Copyright>2023-2024 CompuMaster GmbH</Copyright>
<RootNamespace>CompuMaster.TaskManagement</RootNamespace>
<TargetFrameworks>netstandard2.0;net6.0;net48</TargetFrameworks>
<Title>CompuMaster.TaskManagement - MIT license edition</Title>
<Company>CompuMaster GmbH</Company>
<Authors>Jochen Wezel</Authors>
<Product>CompuMaster.TaskManagement</Product>
<Copyright>2023-2024 CompuMaster GmbH</Copyright>
<Version>2024.11.12.100</Version>
<Configurations>Debug;CI_CD;Release</Configurations>
<AnalysisLevel>latest-recommended</AnalysisLevel>
<OptionExplicit>On</OptionExplicit>
Expand Down

0 comments on commit 47d05a8

Please sign in to comment.