Show sidecar creation progress in GUI.

This commit is contained in:
2019-04-20 20:46:00 +01:00
parent 14c815e703
commit d18690b0e1
2 changed files with 81 additions and 3 deletions

View File

@@ -42,8 +42,11 @@
</StackLayout>
<StackLayout Orientation="Vertical" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
ID="stkProgress" Visible="False">
<StackLayoutItem HorizontalAlignment="Center" Expand="True">
<Label ID="lblStatus" Visible="False"/>
</StackLayoutItem>
<StackLayout Orientation="Vertical" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
ID="stkProgress1">
ID="stkProgress1" Visible="False">
<StackLayoutItem HorizontalAlignment="Center" Expand="True">
<Label ID="lblProgress"/>
</StackLayoutItem>
@@ -52,7 +55,7 @@
</StackLayoutItem>
</StackLayout>
<StackLayout Orientation="Vertical" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
ID="stkProgress2">
ID="stkProgress2" Visible="False">
<StackLayoutItem HorizontalAlignment="Center" Expand="True">
<Label ID="lblProgress2"/>
</StackLayoutItem>

View File

@@ -81,9 +81,17 @@ namespace DiscImageChef.Gui.Forms
btnStop.Enabled = true;
stkProgress.Visible = true;
btnDestination.Visible = false;
lblStatus.Visible = true;
});
sidecarClass = new Sidecar(inputFormat, imageSource, filterId, encoding);
sidecarClass = new Sidecar(inputFormat, imageSource, filterId, encoding);
sidecarClass.UpdateStatusEvent += UpdateStatus;
sidecarClass.InitProgressEvent += InitProgress;
sidecarClass.UpdateProgressEvent += UpdateProgress;
sidecarClass.EndProgressEvent += EndProgress;
sidecarClass.InitProgressEvent2 += InitProgress2;
sidecarClass.UpdateProgressEvent2 += UpdateProgress2;
sidecarClass.EndProgressEvent2 += EndProgress2;
CICMMetadataType sidecar = sidecarClass.Create();
DicConsole.WriteLine("Writing metadata sidecar");
@@ -99,11 +107,77 @@ namespace DiscImageChef.Gui.Forms
btnClose.Visible = true;
btnStop.Visible = false;
stkProgress.Visible = false;
lblStatus.Visible = false;
});
Statistics.AddCommand("create-sidecar");
}
void EndProgress2()
{
Application.Instance.Invoke(() => { stkProgress2.Visible = false; });
}
void UpdateProgress2(string text, long current, long maximum)
{
Application.Instance.Invoke(() =>
{
lblProgress2.Text = text;
prgProgress2.Indeterminate = false;
prgProgress2.MinValue = 0;
if(maximum > int.MaxValue)
{
prgProgress2.MaxValue = (int)(maximum / int.MaxValue);
prgProgress2.Value = (int)(current / int.MaxValue);
}
else
{
prgProgress2.MaxValue = (int)maximum;
prgProgress2.Value = (int)current;
}
});
}
void InitProgress2()
{
Application.Instance.Invoke(() => { stkProgress2.Visible = true; });
}
void EndProgress()
{
Application.Instance.Invoke(() => { stkProgress1.Visible = false; });
}
void UpdateProgress(string text, long current, long maximum)
{
Application.Instance.Invoke(() =>
{
lblProgress.Text = text;
prgProgress.Indeterminate = false;
prgProgress.MinValue = 0;
if(maximum > int.MaxValue)
{
prgProgress.MaxValue = (int)(maximum / int.MaxValue);
prgProgress.Value = (int)(current / int.MaxValue);
}
else
{
prgProgress.MaxValue = (int)maximum;
prgProgress.Value = (int)current;
}
});
}
void InitProgress()
{
Application.Instance.Invoke(() => { stkProgress1.Visible = true; });
}
void UpdateStatus(string text)
{
Application.Instance.Invoke(() => { lblStatus.Text = text; });
}
protected void OnBtnClose(object sender, EventArgs e)
{
Close();
@@ -147,6 +221,7 @@ namespace DiscImageChef.Gui.Forms
Button btnStart;
Button btnClose;
Button btnStop;
Label lblStatus;
#endregion
}
}