Skip to content

Commit

Permalink
Make the text in the preset list always visible (Close #13)
Browse files Browse the repository at this point in the history
  • Loading branch information
Premo36 committed Feb 1, 2022
1 parent 66acec2 commit 354616f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
9 changes: 5 additions & 4 deletions DoomModLoader2C/Forms/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions DoomModLoader2C/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
Expand Down Expand Up @@ -736,6 +737,33 @@ private void openPORTCONFIGFolderToolStripMenuItem_Click(object sender, EventArg
{
Process.Start(PORT_CONFIGfolderPath);
}

/// <summary>
/// When opening the preset combobox, resize the width in order to make all text visible
/// </summary>
private void cmbPreset_DropDown(object sender, EventArgs e)
{
ComboBox senderComboBox = (ComboBox)sender;
int width = senderComboBox.DropDownWidth;
Graphics g = senderComboBox.CreateGraphics();
Font font = senderComboBox.Font;
int vertScrollBarWidth =
(senderComboBox.Items.Count > senderComboBox.MaxDropDownItems)
? SystemInformation.VerticalScrollBarWidth : 0;

int newWidth;
foreach (PathName p in ((ComboBox)sender).Items)
{

newWidth = (int)g.MeasureString(p.name, font).Width
+ vertScrollBarWidth;
if (width < newWidth)
{
width = newWidth;
}
}
senderComboBox.DropDownWidth = width;
}
#endregion

#region METHODS
Expand Down Expand Up @@ -1758,5 +1786,6 @@ private void ApplyPreferences()

#endregion


}
}

0 comments on commit 354616f

Please sign in to comment.