summaryrefslogtreecommitdiff
path: root/Aktywator/MainForm.cs
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2017-11-18 18:02:05 +0100
committeremkael <emkael@tlen.pl>2017-11-18 18:02:05 +0100
commitc11772fd05c82af11645bff5059ce70545e86e0c (patch)
treeaa33ae7a87d7a8eb028c2ec42d6e618fc989331a /Aktywator/MainForm.cs
parent0f90cab947e23f36fdd6f15c877c99a76fe16165 (diff)
Shortening filename if it wouldn't fit the toolstrip label.
Fixes #23.
Diffstat (limited to 'Aktywator/MainForm.cs')
-rw-r--r--Aktywator/MainForm.cs15
1 files changed, 15 insertions, 0 deletions
diff --git a/Aktywator/MainForm.cs b/Aktywator/MainForm.cs
index 8e02320..68f9408 100644
--- a/Aktywator/MainForm.cs
+++ b/Aktywator/MainForm.cs
@@ -68,6 +68,8 @@ namespace Aktywator
bws.convert();
labelFilename.Text = filename;
+ this.shortenFilenameLabel();
+
this.fillSectionSelector(bws.getSections());
cbNamesSection.Items.Clear();
foreach (object i in cbSettingsSection.Items)
@@ -95,6 +97,19 @@ namespace Aktywator
this.WindowState = FormWindowState.Normal;
}
+ private void shortenFilenameLabel()
+ {
+ String originalLabel = (String)labelFilename.Text.Clone();
+ int firstBackslash = originalLabel.IndexOf('\\') + 1;
+ int lettersToCut = 5;
+ while (Graphics.FromHwnd(IntPtr.Zero).MeasureString(labelFilename.Text, labelFilename.Font).Width > 400)
+ {
+ lettersToCut++;
+ labelFilename.Text = originalLabel.Substring(0, firstBackslash) + "[...]"
+ + originalLabel.Substring(firstBackslash + lettersToCut);
+ }
+ }
+
private Tournament detectTeamyTournament()
{
try