mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-11-12 23:32:42 -05:00
Improve lzma progress report
This commit is contained in:
@ -118,6 +118,9 @@ namespace AssetStudioGUI
|
||||
private GUILogger logger;
|
||||
|
||||
private TaskbarManager taskbar = TaskbarManager.Instance;
|
||||
private System.Drawing.Font progressBarTextFont;
|
||||
private Brush progressBarTextBrush;
|
||||
private StringFormat progressBarTextFormat;
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
private static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, uint cbFont, IntPtr pdv, [In] ref uint pcFonts);
|
||||
@ -157,7 +160,16 @@ namespace AssetStudioGUI
|
||||
Logger.Default = logger;
|
||||
writeLogToFileToolStripMenuItem.Checked = Properties.Settings.Default.useFileLogger;
|
||||
|
||||
progressBarTextFont = new System.Drawing.Font(FontFamily.GenericSansSerif, 8);
|
||||
progressBarTextBrush = new SolidBrush(SystemColors.ControlText);
|
||||
progressBarTextFormat = new StringFormat
|
||||
{
|
||||
Alignment = StringAlignment.Center,
|
||||
LineAlignment = StringAlignment.Center,
|
||||
};
|
||||
|
||||
Progress.Default = new Progress<int>(SetProgressBarValue);
|
||||
Progress.SetInstance(index: 1, new Progress<int>(SetProgressBarStringValue));
|
||||
Studio.StatusStripUpdate = StatusStripUpdate;
|
||||
}
|
||||
|
||||
@ -1530,6 +1542,33 @@ namespace AssetStudioGUI
|
||||
}));
|
||||
}
|
||||
|
||||
private void SetProgressBarStringValue(int value)
|
||||
{
|
||||
var str = $"Decompressing LZMA: {value}%";
|
||||
|
||||
if (InvokeRequired)
|
||||
{
|
||||
BeginInvoke(new Action(() =>
|
||||
{
|
||||
using (var graphics = progressBar1.CreateGraphics())
|
||||
{
|
||||
progressBar1.Refresh();
|
||||
var rect = new Rectangle(0, 0, progressBar1.Width, progressBar1.Height);
|
||||
graphics.DrawString(str, progressBarTextFont, progressBarTextBrush, rect, progressBarTextFormat);
|
||||
}
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var graphics = progressBar1.CreateGraphics())
|
||||
{
|
||||
progressBar1.Refresh();
|
||||
var rect = new Rectangle(0, 0, progressBar1.Width, progressBar1.Height);
|
||||
graphics.DrawString(str, progressBarTextFont, progressBarTextBrush, rect, progressBarTextFormat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void StatusStripUpdate(string statusText)
|
||||
{
|
||||
if (InvokeRequired)
|
||||
|
||||
Reference in New Issue
Block a user