Skip to content

Commit 11ba580

Browse files
committed
Adjust controls so they fit after changing the display
1 parent f65afa8 commit 11ba580

5 files changed

Lines changed: 42 additions & 14 deletions

File tree

CountWordsPerLanguage/App.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
<setting name="LetterCountPerLanguageFileName" serializeAs="String">
4141
<value>LetterCountPerLanguage.xml</value>
4242
</setting>
43+
<setting name="_fontSize" serializeAs="String">
44+
<value>10</value>
45+
</setting>
4346
</CountWordsPerLanguage.Properties.Settings>
4447
</userSettings>
4548
</configuration>

CountWordsPerLanguage/FormMain.Designer.cs

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

CountWordsPerLanguage/FormMain.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public FormMain()
4343
readonly Dictionary<string, string> _languageDicoEn = new Dictionary<string, string>();
4444
readonly Dictionary<string, string> _languageDicoFr = new Dictionary<string, string>();
4545
private string _currentLanguage = "english";
46-
private float _fontSize = 10;
46+
private float _fontSize;
4747

4848
private void QuitToolStripMenuItem_Click(object sender, EventArgs e)
4949
{
@@ -77,6 +77,7 @@ private void LoadSettingsAtStartup()
7777
GetWindowValue();
7878
LoadLanguages();
7979
SetLanguage(Settings.Default.LastLanguageUsed);
80+
AdjustAllControls();
8081
}
8182

8283
private static void LoadComboBox(ComboBox cb, string fileName)
@@ -337,6 +338,7 @@ private void GetWindowValue()
337338
Left = Settings.Default.WindowLeft < 0 ? 0 : Settings.Default.WindowLeft;
338339
SetDisplayOption(Settings.Default.DisplayToolStripMenuItem);
339340
comboBoxLanguage.SelectedIndex = Settings.Default.comboBoxLanguage;
341+
_fontSize = Settings.Default._fontSize;
340342
}
341343

342344
private void SaveWindowValue()
@@ -348,6 +350,7 @@ private void SaveWindowValue()
348350
Settings.Default.LastLanguageUsed = frenchToolStripMenuItem.Checked ? "French" : "English";
349351
Settings.Default.DisplayToolStripMenuItem = GetDisplayOption();
350352
Settings.Default.comboBoxLanguage = comboBoxLanguage.SelectedIndex;
353+
Settings.Default._fontSize = _fontSize;
351354
Settings.Default.Save();
352355
}
353356

@@ -672,15 +675,15 @@ private void MediumToolStripMenuItem_Click(object sender, EventArgs e)
672675
{
673676
UncheckAllOptions();
674677
MediumToolStripMenuItem.Checked = true;
675-
_fontSize = 12f;
678+
_fontSize = 11f;
676679
AdjustAllControls();
677680
}
678681

679682
private void LargeToolStripMenuItem_Click(object sender, EventArgs e)
680683
{
681684
UncheckAllOptions();
682685
LargeToolStripMenuItem.Checked = true;
683-
_fontSize = 14f;
686+
_fontSize = 12f;
684687
AdjustAllControls();
685688
}
686689

@@ -697,12 +700,13 @@ private void AdjustControls(params Control[] listOfControls)
697700
{
698701
if (isFirstControl)
699702
{
703+
control.Font = new Font(new FontFamily("Verdana"), _fontSize);
700704
isFirstControl = false;
701705
}
702706
else
703707
{
704-
control.Left = position + 10;
705-
position += control.Width;
708+
control.Left = position + 25;
709+
position += control.Width + 10;
706710
control.Font = new Font(new FontFamily("Verdana"), _fontSize);
707711
}
708712
}
@@ -717,12 +721,12 @@ private float GetFontSize()
717721

718722
if (MediumToolStripMenuItem.Checked)
719723
{
720-
return 12;
724+
return 11;
721725
}
722726

723727
if (LargeToolStripMenuItem.Checked)
724728
{
725-
return 14;
729+
return 12;
726730
}
727731

728732
return 10;
@@ -732,6 +736,12 @@ private void AdjustAllControls()
732736
{
733737
AdjustControls(labelChooseLanguage, comboBoxLanguage, buttonCountWords, buttonClear);
734738
AdjustControls(labelWordsCount, labelCharacterCount);
739+
AdjustControlsTextBased(textBoxSource);
740+
}
741+
742+
private void AdjustControlsTextBased(Control textBox)
743+
{
744+
textBox.Font = new Font(new FontFamily("Verdana"), _fontSize);
735745
}
736746

737747
private void buttonCountWords_Click(object sender, EventArgs e)

CountWordsPerLanguage/Properties/Settings.Designer.cs

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

CountWordsPerLanguage/Properties/Settings.settings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,8 @@
3232
<Setting Name="LetterCountPerLanguageFileName" Type="System.String" Scope="User">
3333
<Value Profile="(Default)">LetterCountPerLanguage.xml</Value>
3434
</Setting>
35+
<Setting Name="_fontSize" Type="System.Single" Scope="User">
36+
<Value Profile="(Default)">10</Value>
37+
</Setting>
3538
</Settings>
3639
</SettingsFile>

0 commit comments

Comments
 (0)