Defined a component for any single translation
This commit is contained in:
parent
421589b633
commit
5ced6c3107
123
I18N Commander/UI WinForms/Components/Translation.Designer.cs
generated
Normal file
123
I18N Commander/UI WinForms/Components/Translation.Designer.cs
generated
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
namespace UI_WinForms.Components
|
||||||
|
{
|
||||||
|
sealed partial class Translation
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Component Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
|
this.tableLayout = new System.Windows.Forms.TableLayoutPanel();
|
||||||
|
this.labelHead = new System.Windows.Forms.Label();
|
||||||
|
this.textBox = new System.Windows.Forms.TextBox();
|
||||||
|
this.buttonDeepL = new System.Windows.Forms.Button();
|
||||||
|
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||||
|
this.tableLayout.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// tableLayout
|
||||||
|
//
|
||||||
|
this.tableLayout.ColumnCount = 2;
|
||||||
|
this.tableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 366F));
|
||||||
|
this.tableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
|
this.tableLayout.Controls.Add(this.labelHead, 0, 0);
|
||||||
|
this.tableLayout.Controls.Add(this.textBox, 0, 1);
|
||||||
|
this.tableLayout.Controls.Add(this.buttonDeepL, 1, 0);
|
||||||
|
this.tableLayout.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.tableLayout.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.tableLayout.Name = "tableLayout";
|
||||||
|
this.tableLayout.RowCount = 2;
|
||||||
|
this.tableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 66F));
|
||||||
|
this.tableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
|
this.tableLayout.Size = new System.Drawing.Size(820, 279);
|
||||||
|
this.tableLayout.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// labelHead
|
||||||
|
//
|
||||||
|
this.labelHead.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.labelHead.Location = new System.Drawing.Point(3, 0);
|
||||||
|
this.labelHead.Name = "labelHead";
|
||||||
|
this.labelHead.Size = new System.Drawing.Size(360, 66);
|
||||||
|
this.labelHead.TabIndex = 0;
|
||||||
|
this.labelHead.Text = "header";
|
||||||
|
this.labelHead.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
|
//
|
||||||
|
// textBox
|
||||||
|
//
|
||||||
|
this.tableLayout.SetColumnSpan(this.textBox, 2);
|
||||||
|
this.textBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.textBox.Location = new System.Drawing.Point(3, 69);
|
||||||
|
this.textBox.Multiline = true;
|
||||||
|
this.textBox.Name = "textBox";
|
||||||
|
this.textBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||||
|
this.textBox.Size = new System.Drawing.Size(814, 207);
|
||||||
|
this.textBox.TabIndex = 1;
|
||||||
|
this.textBox.TextChanged += new System.EventHandler(this.textBox_TextChanged);
|
||||||
|
//
|
||||||
|
// buttonDeepL
|
||||||
|
//
|
||||||
|
this.buttonDeepL.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonDeepL.AutoSize = true;
|
||||||
|
this.buttonDeepL.FlatAppearance.BorderSize = 0;
|
||||||
|
this.buttonDeepL.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||||
|
this.buttonDeepL.Image = global::UI_WinForms.Resources.Icons.icons8_bot_512;
|
||||||
|
this.buttonDeepL.Location = new System.Drawing.Point(757, 3);
|
||||||
|
this.buttonDeepL.Name = "buttonDeepL";
|
||||||
|
this.buttonDeepL.Size = new System.Drawing.Size(60, 60);
|
||||||
|
this.buttonDeepL.TabIndex = 2;
|
||||||
|
this.toolTip.SetToolTip(this.buttonDeepL, "Auto-generate this text by using DeepL");
|
||||||
|
this.buttonDeepL.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// toolTip
|
||||||
|
//
|
||||||
|
this.toolTip.AutoPopDelay = 30000;
|
||||||
|
this.toolTip.InitialDelay = 500;
|
||||||
|
this.toolTip.ReshowDelay = 100;
|
||||||
|
this.toolTip.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info;
|
||||||
|
this.toolTip.ToolTipTitle = "Help";
|
||||||
|
//
|
||||||
|
// Translation
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(120F, 120F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||||
|
this.Controls.Add(this.tableLayout);
|
||||||
|
this.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.Name = "Translation";
|
||||||
|
this.Size = new System.Drawing.Size(820, 279);
|
||||||
|
this.tableLayout.ResumeLayout(false);
|
||||||
|
this.tableLayout.PerformLayout();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private TableLayoutPanel tableLayout;
|
||||||
|
private Label labelHead;
|
||||||
|
private TextBox textBox;
|
||||||
|
private Button buttonDeepL;
|
||||||
|
private ToolTip toolTip;
|
||||||
|
}
|
||||||
|
}
|
55
I18N Commander/UI WinForms/Components/Translation.cs
Normal file
55
I18N Commander/UI WinForms/Components/Translation.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
using System.Timers;
|
||||||
|
using Processor;
|
||||||
|
using Timer = System.Timers.Timer;
|
||||||
|
|
||||||
|
namespace UI_WinForms.Components;
|
||||||
|
|
||||||
|
public sealed partial class Translation : UserControl
|
||||||
|
{
|
||||||
|
private readonly string culture = "en-US";
|
||||||
|
private readonly Timer saveTimer;
|
||||||
|
|
||||||
|
private int currentTranslationId = -1;
|
||||||
|
|
||||||
|
public Translation()
|
||||||
|
{
|
||||||
|
this.InitializeComponent();
|
||||||
|
this.Dock = DockStyle.Top;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Translation(string cultureCode)
|
||||||
|
{
|
||||||
|
this.InitializeComponent();
|
||||||
|
this.culture = cultureCode;
|
||||||
|
this.labelHead.Text = $"Culture: {cultureCode}";
|
||||||
|
this.Dock = DockStyle.Top;
|
||||||
|
this.saveTimer = new Timer
|
||||||
|
{
|
||||||
|
Enabled = false, // disable timer for now,
|
||||||
|
Interval = 1_000, // 1 second
|
||||||
|
AutoReset = false, // runs only once
|
||||||
|
};
|
||||||
|
this.saveTimer.Elapsed += this.SaveChanges;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void SaveChanges(object? sender, ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
if (this.currentTranslationId > -1)
|
||||||
|
await TranslationProcessor.SaveChangedTranslation(this.currentTranslationId, this.textBox.Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Configure(DataModel.Database.Translation translation)
|
||||||
|
{
|
||||||
|
this.currentTranslationId = translation.Id;
|
||||||
|
this.textBox.Multiline = translation.TextElement.IsMultiLine;
|
||||||
|
this.textBox.Text = translation.Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void textBox_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if(this.saveTimer.Enabled)
|
||||||
|
this.saveTimer.Stop();
|
||||||
|
|
||||||
|
this.saveTimer.Start();
|
||||||
|
}
|
||||||
|
}
|
63
I18N Commander/UI WinForms/Components/Translation.resx
Normal file
63
I18N Commander/UI WinForms/Components/Translation.resx
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
Loading…
Reference in New Issue
Block a user