Skip to content

Commit 6200e1c

Browse files
author
LAB02 Research
committed
v2023.3.16.0
1 parent 529050a commit 6200e1c

38 files changed

+927
-511
lines changed

src/DeepLClient/Controls/DocumentsPage.cs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
using System.Diagnostics;
2-
using System.Diagnostics.CodeAnalysis;
1+
using System.Diagnostics.CodeAnalysis;
32
using DeepL;
43
using DeepL.Model;
54
using DeepLClient.Enums;
6-
using DeepLClient.Forms;
5+
using DeepLClient.Forms.Dialogs;
76
using DeepLClient.Functions;
87
using DeepLClient.Managers;
98
using Serilog;
10-
using Syncfusion.Windows.Forms;
119

1210
namespace DeepLClient.Controls
1311
{
@@ -139,7 +137,7 @@ internal async Task<bool> ProcessSelectedDocumentAsync(string file)
139137
// does it exist?
140138
if (!File.Exists(file))
141139
{
142-
MessageBoxAdv.Show(this, "The selected document doesn't exist (anymore).\r\n\r\nPlease select a new one.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
140+
MessageBoxAdv2.Show("The selected document doesn't exist (anymore).\r\n\r\nPlease select a new one.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
143141
LblState.Text = string.Empty;
144142
return false;
145143
}
@@ -148,7 +146,7 @@ internal async Task<bool> ProcessSelectedDocumentAsync(string file)
148146
var docType = await Task.Run(() => DocumentManager.GetFileDocumentType(file));
149147
if (docType == DocumentType.Unsupported)
150148
{
151-
MessageBoxAdv.Show(this, "The selected filetype is unsupported.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
149+
MessageBoxAdv2.Show("The selected filetype is unsupported.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
152150
LblState.Text = string.Empty;
153151
return false;
154152
}
@@ -157,7 +155,7 @@ internal async Task<bool> ProcessSelectedDocumentAsync(string file)
157155
var (tooLarge, sizeMB) = await Task.Run(() => DocumentManager.CheckDocumentSize(file));
158156
if (tooLarge)
159157
{
160-
MessageBoxAdv.Show(this, $"The selected document is too large.\r\n\r\nIt's {sizeMB:N2} MB, while the max is {Variables.AppSettings.DocumentMaxSizeMB} MB.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
158+
MessageBoxAdv2.Show($"The selected document is too large.\r\n\r\nIt's {sizeMB:N2} MB, while the max is {Variables.AppSettings.DocumentMaxSizeMB} MB.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
161159
LblState.Text = string.Empty;
162160
return false;
163161
}
@@ -196,7 +194,7 @@ internal async Task<bool> ProcessSelectedDocumentAsync(string file)
196194
catch (Exception ex)
197195
{
198196
Log.Fatal(ex, "[DOCUMENT] Error while checking document '{doc}': {err}", file, ex.Message);
199-
MessageBoxAdv.Show(this, "Something went wrong while checking the document.\r\n\r\nPlease check the logs and try again.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
197+
MessageBoxAdv2.Show("Something went wrong while checking the document.\r\n\r\nPlease check the logs and try again.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
200198
LblState.Text = string.Empty;
201199
return false;
202200
}
@@ -235,7 +233,7 @@ internal async void ExecuteTranslation()
235233

236234
if (!File.Exists(file))
237235
{
238-
MessageBoxAdv.Show(this, "The selected document doesn't exist (anymore).\r\n\r\nPlease select a new one.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
236+
MessageBoxAdv2.Show("The selected document doesn't exist (anymore).\r\n\r\nPlease select a new one.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
239237
LblState.Text = string.Empty;
240238
return;
241239
}
@@ -269,7 +267,7 @@ internal async void ExecuteTranslation()
269267

270268
if (targetLanguage == null)
271269
{
272-
MessageBoxAdv.Show(this, "Please select a valid target language.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
270+
MessageBoxAdv2.Show("Please select a valid target language.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
273271
LblState.Text = string.Empty;
274272
return;
275273
}
@@ -283,7 +281,7 @@ internal async void ExecuteTranslation()
283281
// check if it's already there
284282
if (File.Exists(targetFile))
285283
{
286-
var confirm = MessageBoxAdv.Show(this, $"The proposed target file already exists:\r\n\r\n{targetFile}\r\n\r\nDo you want to overwrite it?", Variables.MessageBoxTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
284+
var confirm = MessageBoxAdv2.Show($"The proposed target file already exists:\r\n\r\n{targetFile}\r\n\r\nDo you want to overwrite it?", Variables.MessageBoxTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
287285
if (confirm != DialogResult.Yes)
288286
{
289287
LblState.Text = string.Empty;
@@ -516,7 +514,7 @@ private async void DocumentsPage_DragDrop(object sender, DragEventArgs e)
516514
// do we support it?
517515
if (!DocumentManager.FileIsSupported(file))
518516
{
519-
MessageBoxAdv.Show(this, "The selected filetype is unsupported.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
517+
MessageBoxAdv2.Show("The selected filetype is unsupported.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
520518
return;
521519
}
522520

@@ -565,7 +563,7 @@ private void LockInterface(bool @lock = true)
565563

566564
private void LblFormalityInfo_Click(object sender, EventArgs e)
567565
{
568-
MessageBoxAdv.Show(this, HelperFunctions.GetFormalityExplanation(), Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
566+
MessageBoxAdv2.Show(HelperFunctions.GetFormalityExplanation(), Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
569567
}
570568

571569
private void BtnClean_Click(object sender, EventArgs e)

src/DeepLClient/Controls/TextPage.cs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
using DeepL;
22
using DeepL.Model;
3-
using DeepLClient.Forms;
43
using DeepLClient.Functions;
54
using DeepLClient.Managers;
65
using Serilog;
7-
using Syncfusion.Windows.Forms;
8-
using System.Diagnostics;
96
using System.Diagnostics.CodeAnalysis;
7+
using DeepLClient.Forms.Dialogs;
108

119
namespace DeepLClient.Controls
1210
{
@@ -113,7 +111,7 @@ private async void ExecuteTranslation()
113111

114112
if (targetLanguage == null)
115113
{
116-
MessageBoxAdv.Show(this, "Please select a valid target language.", Variables.MessageBoxTitle,
114+
MessageBoxAdv2.Show("Please select a valid target language.", Variables.MessageBoxTitle,
117115
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
118116
return;
119117
}
@@ -169,17 +167,17 @@ private async void ExecuteTranslation()
169167
catch (ConnectionException ex)
170168
{
171169
Log.Fatal(ex, "[TEXT] Connection error while translating the text: {err}", ex.Message);
172-
MessageBoxAdv.Show(this, "Unable to establish a connection to DeepL's servers.\r\n\r\nPlease try again later.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
170+
MessageBoxAdv2.Show("Unable to establish a connection to DeepL's servers.\r\n\r\nPlease try again later.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
173171
}
174172
catch (DocumentTranslationException ex)
175173
{
176174
Log.Fatal(ex, "[TEXT] Error while translating the text: {err}", ex.Message);
177-
MessageBoxAdv.Show(this, "Something went wrong on DeepL's end while translating the text.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
175+
MessageBoxAdv2.Show("Something went wrong on DeepL's end while translating the text.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
178176
}
179177
catch (Exception ex)
180178
{
181179
Log.Fatal(ex, "[TEXT] Error while attempting to translate the text: {err}", ex.Message);
182-
MessageBoxAdv.Show(this, "Something went wrong on our end while translating the text.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
180+
MessageBoxAdv2.Show("Something went wrong on our end while translating the text.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
183181
}
184182
finally
185183
{
@@ -257,14 +255,14 @@ private void TextPage_DragDrop(object sender, DragEventArgs e)
257255
// is it supported?
258256
if (!DocumentManager.FileIsSupported(file, true))
259257
{
260-
MessageBoxAdv.Show(this, "Only .txt documents are supported here.\r\n\r\nFor other formats, use the 'documents' tab.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
258+
MessageBoxAdv2.Show("Only .txt documents are supported here.\r\n\r\nFor other formats, use the 'documents' tab.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
261259
return;
262260
}
263261

264262
// and does it still exist?
265263
if (!File.Exists(file))
266264
{
267-
MessageBoxAdv.Show(this, "The selected document doesn't exist (anymore).", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
265+
MessageBoxAdv2.Show("The selected document doesn't exist (anymore).", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
268266
return;
269267
}
270268

@@ -389,7 +387,7 @@ private void LockInterface(bool @lock = true)
389387

390388
private void LblFormalityInfo_Click(object sender, EventArgs e)
391389
{
392-
MessageBoxAdv.Show(this, HelperFunctions.GetFormalityExplanation(), Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
390+
MessageBoxAdv2.Show(HelperFunctions.GetFormalityExplanation(), Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
393391
}
394392

395393
private void TbSource_KeyDown(object sender, KeyEventArgs e)
@@ -452,15 +450,15 @@ private void BtnSave_Click(object sender, EventArgs e)
452450

453451
File.WriteAllText(dialog.FileName, TbTranslated.Text);
454452

455-
var q = MessageBoxAdv.Show(this, "Page succesfully saved as a text file!\r\n\nClick 'ok' to open its folder.", Variables.MessageBoxTitle, MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
453+
var q = MessageBoxAdv2.Show("Page succesfully saved as a text file!\r\n\nClick 'ok' to open its folder.", Variables.MessageBoxTitle, MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
456454
if (q != DialogResult.OK) return;
457455

458456
HelperFunctions.OpenFileInExplorer(dialog.FileName);
459457
}
460458
catch (Exception ex)
461459
{
462460
Log.Fatal(ex, "[URL] Error while saving to pdf: {err}", ex.Message);
463-
MessageBoxAdv.Show(this, "Something went wrong while saving the page to pdf.\r\n\r\nTry using the print method with Window's pdf printer.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
461+
MessageBoxAdv2.Show("Something went wrong while saving the page to pdf.\r\n\r\nTry using the print method with Window's pdf printer.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
464462
}
465463
finally
466464
{
@@ -486,13 +484,13 @@ private void BtnPrint_Click(object sender, EventArgs e)
486484
var result = PrintFunctions.PrintText(TbTranslated.Text, printDialog.PrinterSettings);
487485

488486
// done
489-
if (result) MessageBoxAdv.Show(this, "The translated text has been sent to your printer.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
490-
else MessageBoxAdv.Show(this, "Something went wrong when trying to print the translated text.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
487+
if (result) MessageBoxAdv2.Show("The translated text has been sent to your printer.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
488+
else MessageBoxAdv2.Show("Something went wrong when trying to print the translated text.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
491489
}
492490
catch (Exception ex)
493491
{
494492
Log.Fatal(ex, "[URL] Error while trying to print: {err}", ex.Message);
495-
MessageBoxAdv.Show(this, "Something went wrong while trying to print.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
493+
MessageBoxAdv2.Show("Something went wrong while trying to print.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
496494
}
497495
finally
498496
{

src/DeepLClient/Controls/UrlPage.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@
22
using System.Diagnostics.CodeAnalysis;
33
using System.Text;
44
using DeepL;
5-
using DeepL.Model;
6-
using DeepLClient.Forms;
75
using DeepLClient.Functions;
86
using DeepLClient.Managers;
97
using Microsoft.Web.WebView2.Core;
10-
using Microsoft.Web.WebView2.WinForms;
118
using Serilog;
12-
using SmartReader;
13-
using Syncfusion.Windows.Forms;
14-
using Windows.Globalization;
9+
using DeepLClient.Forms.Dialogs;
1510
using Newtonsoft.Json;
1611

1712
namespace DeepLClient.Controls
@@ -116,7 +111,7 @@ private async Task<bool> InitializeAsync()
116111

117112
Log.Fatal(ex, "[URL] WebView2 runtime not found, unable to initialize: {err}", ex.Message);
118113

119-
var q = MessageBoxAdv.Show(this, "Microsoft's WebView2 runtime isn't found on your machine. This is a required component for showing your webpages.\r\n\r\n" +
114+
var q = MessageBoxAdv2.Show("Microsoft's WebView2 runtime isn't found on your machine. This is a required component for showing your webpages.\r\n\r\n" +
120115
"Usually this is handled by the installer, but you can still install it manually.\r\n\r\n" +
121116
"Do you want to download the runtime installer?", Variables.MessageBoxTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Error);
122117
if (q != DialogResult.Yes) return false;
@@ -564,7 +559,7 @@ private void PbWarning_Click(object sender, EventArgs e)
564559
warning.AppendLine("");
565560
warning.AppendLine("Your website is therefore shown as-is.");
566561

567-
MessageBoxAdv.Show(this, warning.ToString(), Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
562+
MessageBoxAdv2.Show(warning.ToString(), Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
568563
}
569564

570565
private void TbUrl_KeyUp(object sender, KeyEventArgs e)
@@ -591,11 +586,11 @@ private async void BtnSave_Click(object sender, EventArgs e)
591586
var printed = await WebView.CoreWebView2.PrintToPdfAsync(dialog.FileName);
592587
if (!printed)
593588
{
594-
MessageBoxAdv.Show(this, "Something went wrong while saving the page to pdf.\r\n\r\nTry using the print method with Window's pdf printer.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
589+
MessageBoxAdv2.Show("Something went wrong while saving the page to pdf.\r\n\r\nTry using the print method with Window's pdf printer.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
595590
return;
596591
}
597592

598-
var q = MessageBoxAdv.Show(this, "Page succesfully saved to pdf!\r\n\nClick 'ok' to open its folder.", Variables.MessageBoxTitle, MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
593+
var q = MessageBoxAdv2.Show("Page succesfully saved to pdf!\r\n\nClick 'ok' to open its folder.", Variables.MessageBoxTitle, MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
599594
if (q != DialogResult.OK) return;
600595

601596
var argument = "/select, \"" + dialog.FileName + "\"";
@@ -604,7 +599,7 @@ private async void BtnSave_Click(object sender, EventArgs e)
604599
catch (Exception ex)
605600
{
606601
Log.Fatal(ex, "[URL] Error while saving to pdf: {err}", ex.Message);
607-
MessageBoxAdv.Show(this, "Something went wrong while saving the page to pdf.\r\n\r\nTry using the print method with Window's pdf printer.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
602+
MessageBoxAdv2.Show("Something went wrong while saving the page to pdf.\r\n\r\nTry using the print method with Window's pdf printer.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
608603
}
609604
finally
610605
{
@@ -638,7 +633,7 @@ private async void BtnOpenInBrowser_Click(object sender, EventArgs e)
638633
catch (Exception ex)
639634
{
640635
Log.Fatal(ex, "[URL] Error while opening in browser: {err}", ex.Message);
641-
MessageBoxAdv.Show(this, "Something went wrong while opening the page in your browser.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
636+
MessageBoxAdv2.Show("Something went wrong while opening the page in your browser.", Variables.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
642637
}
643638
finally
644639
{

src/DeepLClient/DeepLClient.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<ImplicitUsings>enable</ImplicitUsings>
99
<ApplicationIcon>Resources\icon_white_32.ico</ApplicationIcon>
1010
<Title>DeepL Translator</Title>
11-
<Version>2023.3.15.2</Version>
11+
<Version>2023.3.16.0</Version>
1212
<Authors>LAB02 RESEARCH</Authors>
1313
<Description>Front-end client for DeepL translation services.</Description>
1414
</PropertyGroup>
@@ -48,13 +48,13 @@
4848
<Compile Update="Forms\About.cs">
4949
<SubType>Form</SubType>
5050
</Compile>
51-
<Compile Update="Forms\LimitExceeded.cs">
51+
<Compile Update="Forms\Dialogs\LimitExceeded.cs">
5252
<SubType>Form</SubType>
5353
</Compile>
5454
<Compile Update="Forms\SubscriptionInfo.cs">
5555
<SubType>Form</SubType>
5656
</Compile>
57-
<Compile Update="Forms\ConfirmDocument.cs">
57+
<Compile Update="Forms\Dialogs\ConfirmDocument.cs">
5858
<SubType>Form</SubType>
5959
</Compile>
6060
<Compile Update="Properties\Resources.Designer.cs">

src/DeepLClient/Forms/About.Designer.cs

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)