Skip to content

Commit e1f8068

Browse files
committed
Fix catalog menu styling and shutdown crash
1 parent 7c6e699 commit e1f8068

1 file changed

Lines changed: 20 additions & 11 deletions

File tree

SynixApp/UI/ModPluginManager.cs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ internal sealed class ModPluginManager : Form
3131
private readonly ModernSettingsButton _installFramework;
3232
private readonly ModernSettingsButton _browseCatalog;
3333
private readonly ModernSettingsButton _openFolder;
34+
private readonly ContextMenuStrip _catalogMenu = new();
3435
private ModSystemDetection? _detection;
3536
private IReadOnlyList<ModInventoryItem> _items = [];
3637
private bool _updatingSelectors;
@@ -48,6 +49,12 @@ internal ModPluginManager(GameServer server)
4849
BackColor = SettingsPalette.Window;
4950
ForeColor = SettingsPalette.PrimaryText;
5051
Font = new Font("Segoe UI", 9.5F);
52+
_catalogMenu.BackColor = SettingsPalette.Card;
53+
_catalogMenu.ForeColor = SettingsPalette.PrimaryText;
54+
_catalogMenu.Font = Font;
55+
_catalogMenu.Padding = new Padding(4);
56+
_catalogMenu.ShowImageMargin = false;
57+
_catalogMenu.Renderer = new SynixMenuRenderer();
5158

5259
Label pageHeading = Heading("Mod & Plugin Manager", 28, 20, 640, 42, 19F);
5360
pageHeading.Name = "modPluginManagerHeading";
@@ -243,6 +250,13 @@ protected override void OnShown(EventArgs eventArgs)
243250
RefreshInventory();
244251
}
245252

253+
protected override void Dispose(bool disposing)
254+
{
255+
base.Dispose(disposing);
256+
if (disposing)
257+
_catalogMenu.Dispose();
258+
}
259+
246260
private void ProfileChanged()
247261
{
248262
if (_updatingSelectors || _profileBox.SelectedItem is not ModSystemProfile profile)
@@ -656,27 +670,22 @@ private void BrowseCatalog()
656670
return;
657671
}
658672

659-
ContextMenuStrip menu = new()
660-
{
661-
BackColor = SettingsPalette.Card,
662-
ForeColor = SettingsPalette.PrimaryText,
663-
Font = Font,
664-
ShowImageMargin = false
665-
};
673+
_catalogMenu.Items.Clear();
666674
foreach (CatalogChoice catalog in catalogs)
667675
{
668676
ToolStripMenuItem item = new(catalog.Name)
669677
{
670678
ForeColor = SettingsPalette.PrimaryText,
671679
BackColor = SettingsPalette.Card,
672680
AutoSize = false,
673-
Size = new Size(220, 34)
681+
Margin = new Padding(0, 2, 0, 2),
682+
Padding = new Padding(8, 3, 8, 3),
683+
Size = new Size(220, 38)
674684
};
675685
item.Click += (_, _) => OpenCatalog(catalog.Uri);
676-
menu.Items.Add(item);
686+
_catalogMenu.Items.Add(item);
677687
}
678-
menu.Closed += (_, _) => menu.Dispose();
679-
menu.Show(_browseCatalog, new Point(0, _browseCatalog.Height));
688+
_catalogMenu.Show(_browseCatalog, new Point(0, _browseCatalog.Height + 4));
680689
}
681690

682691
private void OpenCatalog(Uri uri)

0 commit comments

Comments
 (0)