Changed DeepL button appearance based on wherever a translation is the main culture
This commit is contained in:
		
							parent
							
								
									b6493da831
								
							
						
					
					
						commit
						7c5ace5b87
					
				| @ -87,7 +87,7 @@ | |||||||
|             this.buttonDeepL.Name = "buttonDeepL"; |             this.buttonDeepL.Name = "buttonDeepL"; | ||||||
|             this.buttonDeepL.Size = new System.Drawing.Size(60, 60); |             this.buttonDeepL.Size = new System.Drawing.Size(60, 60); | ||||||
|             this.buttonDeepL.TabIndex = 2; |             this.buttonDeepL.TabIndex = 2; | ||||||
|             this.toolTip.SetToolTip(this.buttonDeepL, "Auto-generate this text by using DeepL"); |             this.toolTip.SetToolTip(this.buttonDeepL, "Auto-generate this text by using DeepL sourced by the source culture."); | ||||||
|             this.buttonDeepL.UseVisualStyleBackColor = true; |             this.buttonDeepL.UseVisualStyleBackColor = true; | ||||||
|             //  |             //  | ||||||
|             // toolTip |             // toolTip | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| using System.Timers; | using System.Timers; | ||||||
| using DataModel.Database; | using DataModel.Database; | ||||||
| using Processor; | using Processor; | ||||||
|  | using UI_WinForms.Resources; | ||||||
| using Timer = System.Timers.Timer; | using Timer = System.Timers.Timer; | ||||||
| 
 | 
 | ||||||
| namespace UI_WinForms.Components; | namespace UI_WinForms.Components; | ||||||
| @ -10,8 +11,9 @@ public sealed partial class Translation : UserControl | |||||||
|     private readonly string culture = "en-US"; |     private readonly string culture = "en-US"; | ||||||
|     private readonly Timer saveTimer; |     private readonly Timer saveTimer; | ||||||
|      |      | ||||||
|     private int currentTranslationId = -1; |  | ||||||
|     private bool isLoading = false; |     private bool isLoading = false; | ||||||
|  |     private int currentTranslationId = -1; | ||||||
|  |     private bool isDeepLSourceCulture = false; | ||||||
| 
 | 
 | ||||||
|     public Translation() |     public Translation() | ||||||
|     { |     { | ||||||
| @ -19,11 +21,11 @@ public sealed partial class Translation : UserControl | |||||||
|         this.Dock = DockStyle.Top; |         this.Dock = DockStyle.Top; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public Translation(string cultureCode) |     public Translation(AppSettings.CultureInfo cultureInfo) | ||||||
|     { |     { | ||||||
|         this.InitializeComponent(); |         this.InitializeComponent(); | ||||||
|         this.culture = cultureCode; |         this.culture = cultureInfo.Code; | ||||||
|         this.labelHead.Text = $"Culture: {cultureCode}"; |         this.labelHead.Text = $"Culture: {cultureInfo.Code}"; | ||||||
|         this.Dock = DockStyle.Top; |         this.Dock = DockStyle.Top; | ||||||
|         this.saveTimer = new Timer |         this.saveTimer = new Timer | ||||||
|         { |         { | ||||||
| @ -32,12 +34,20 @@ public sealed partial class Translation : UserControl | |||||||
|             AutoReset = false, // runs only once |             AutoReset = false, // runs only once | ||||||
|         }; |         }; | ||||||
|         this.saveTimer.Elapsed += this.SaveChanges; |         this.saveTimer.Elapsed += this.SaveChanges; | ||||||
|         this.Load += async (sender, args) => await this.LateSetup(); |         this.Load += async (sender, args) => await this.LateSetup(cultureInfo); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private async Task LateSetup() |     private async Task LateSetup(AppSettings.CultureInfo cultureInfo) | ||||||
|     { |     { | ||||||
|  |         this.isDeepLSourceCulture = await AppSettings.GetDeepLSourceCultureIndex() == cultureInfo.Index; | ||||||
|         this.buttonDeepL.Visible = await AppSettings.GetDeepLMode() != SettingDeepLMode.DISABLED; |         this.buttonDeepL.Visible = await AppSettings.GetDeepLMode() != SettingDeepLMode.DISABLED; | ||||||
|  |         this.buttonDeepL.Image = this.isDeepLSourceCulture ? Icons.icons8_trigger_1__svg : Icons.deepl_logo_icon_170284; | ||||||
|  | 
 | ||||||
|  |         if (this.isDeepLSourceCulture) | ||||||
|  |         { | ||||||
|  |             this.labelHead.Text = $"Culture: {cultureInfo.Code} (DeepL source culture)"; | ||||||
|  |             this.toolTip.SetToolTip(this.buttonDeepL, "Replaces all other translations by DeepL translations using this culture as source culture.\nWarning: already translated texts will be replaced as well."); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private async void SaveChanges(object? sender, ElapsedEventArgs e) |     private async void SaveChanges(object? sender, ElapsedEventArgs e) | ||||||
|  | |||||||
| @ -46,7 +46,7 @@ public partial class Translations : UserControl | |||||||
| 
 | 
 | ||||||
|         await foreach (var cultureInfo in DesiredOrder()) |         await foreach (var cultureInfo in DesiredOrder()) | ||||||
|         { |         { | ||||||
|             var translationComponent = new Translation(cultureInfo.Code); |             var translationComponent = new Translation(cultureInfo); | ||||||
|             this.translationComponents.Add(cultureInfo.Code, translationComponent); |             this.translationComponents.Add(cultureInfo.Code, translationComponent); | ||||||
|             this.panelTranslations.Controls.Add(translationComponent); |             this.panelTranslations.Controls.Add(translationComponent); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -319,5 +319,15 @@ namespace UI_WinForms.Resources { | |||||||
|                 return ((System.Drawing.Bitmap)(obj)); |                 return ((System.Drawing.Bitmap)(obj)); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |          | ||||||
|  |         /// <summary> | ||||||
|  |         ///   Looks up a localized resource of type System.Drawing.Bitmap. | ||||||
|  |         /// </summary> | ||||||
|  |         internal static System.Drawing.Bitmap icons8_trigger_1__svg { | ||||||
|  |             get { | ||||||
|  |                 object obj = ResourceManager.GetObject("icons8_trigger_1__svg", resourceCulture); | ||||||
|  |                 return ((System.Drawing.Bitmap)(obj)); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -196,4 +196,7 @@ | |||||||
|   <data name="icons8_trash_can_512" type="System.Resources.ResXFileRef, System.Windows.Forms"> |   <data name="icons8_trash_can_512" type="System.Resources.ResXFileRef, System.Windows.Forms"> | ||||||
|     <value>icons8-trash-can-512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> |     <value>icons8-trash-can-512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> | ||||||
|   </data> |   </data> | ||||||
|  |   <data name="icons8_trigger_1__svg" type="System.Resources.ResXFileRef, System.Windows.Forms"> | ||||||
|  |     <value>icons8-trigger(1).svg.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> | ||||||
|  |   </data> | ||||||
| </root> | </root> | ||||||
							
								
								
									
										
											BIN
										
									
								
								I18N Commander/UI WinForms/Resources/icons8-trigger(1).svg.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								I18N Commander/UI WinForms/Resources/icons8-trigger(1).svg.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 3.0 KiB | 
		Loading…
	
		Reference in New Issue
	
	Block a user