diff --git a/I18N Commander/UI WinForms/Components/TranslationProgress.Designer.cs b/I18N Commander/UI WinForms/Components/TranslationProgress.Designer.cs new file mode 100644 index 0000000..14a037e --- /dev/null +++ b/I18N Commander/UI WinForms/Components/TranslationProgress.Designer.cs @@ -0,0 +1,65 @@ +namespace UI_WinForms.Components +{ + sealed partial class TranslationProgress + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.nxProgressBar = new UI_WinForms.Components.NXProgressBar(); + this.SuspendLayout(); + // + // nxProgressBar + // + this.nxProgressBar.AppendPercentageToText = true; + this.nxProgressBar.BackColor = System.Drawing.Color.LightSkyBlue; + this.nxProgressBar.Dock = System.Windows.Forms.DockStyle.Fill; + this.nxProgressBar.Font = new System.Drawing.Font("Segoe UI", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.nxProgressBar.InformationText = "Overall translation progress"; + this.nxProgressBar.Location = new System.Drawing.Point(0, 0); + this.nxProgressBar.Margin = new System.Windows.Forms.Padding(3, 0, 3, 0); + this.nxProgressBar.Name = "nxProgressBar"; + this.nxProgressBar.Padding = new System.Windows.Forms.Padding(3, 0, 0, 0); + this.nxProgressBar.PercentFloat = 0F; + this.nxProgressBar.PercentInt = 0; + this.nxProgressBar.Size = new System.Drawing.Size(832, 68); + this.nxProgressBar.TabIndex = 0; + // + // TranslationProgress + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.nxProgressBar); + this.Name = "TranslationProgress"; + this.Size = new System.Drawing.Size(832, 68); + this.ResumeLayout(false); + + } + + #endregion + + private NXProgressBar nxProgressBar; + } +} diff --git a/I18N Commander/UI WinForms/Components/TranslationProgress.cs b/I18N Commander/UI WinForms/Components/TranslationProgress.cs new file mode 100644 index 0000000..c7bd9a2 --- /dev/null +++ b/I18N Commander/UI WinForms/Components/TranslationProgress.cs @@ -0,0 +1,38 @@ +using Processor; + +namespace UI_WinForms.Components; + +public sealed partial class TranslationProgress : UserControl +{ + public TranslationProgress() + { + this.InitializeComponent(); + + this.DoubleBuffered = true; + this.Load += this.OnLoad; + AppEvents.WhenTranslationChanged += async (_, _) => await this.TranslationChanged(); + } + + private async void OnLoad(object? sender, EventArgs e) => await this.CalculateTranslationProgress(); + + private async Task TranslationChanged() => await this.CalculateTranslationProgress(); + + private async Task CalculateTranslationProgress() + { + var result = await TranslationProcessor.CalculateTranslationProgress(); + if (this.nxProgressBar.InvokeRequired) + this.nxProgressBar.Invoke(() => SetProgress(result)); + else + SetProgress(result); + + void SetProgress(ProcessorResult resultData) + { + if (resultData.Successful) + this.nxProgressBar.PercentInt = resultData.Result; + else + this.nxProgressBar.PercentInt = 0; + + this.nxProgressBar.Refresh(); + } + } +} \ No newline at end of file diff --git a/I18N Commander/UI WinForms/Components/TranslationProgress.resx b/I18N Commander/UI WinForms/Components/TranslationProgress.resx new file mode 100644 index 0000000..b5ae26c --- /dev/null +++ b/I18N Commander/UI WinForms/Components/TranslationProgress.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file