WIP half-broken garbage
This commit is contained in:
parent
c7dab1a42b
commit
ab4a65e6c1
19
MainForm.Designer.cs
generated
19
MainForm.Designer.cs
generated
@ -29,6 +29,7 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.menuLabel = new System.Windows.Forms.Label();
|
this.menuLabel = new System.Windows.Forms.Label();
|
||||||
|
this.waccaListTest = new WACCALauncher.WaccaList();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// menuLabel
|
// menuLabel
|
||||||
@ -44,12 +45,28 @@
|
|||||||
this.menuLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
this.menuLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
this.menuLabel.Visible = false;
|
this.menuLabel.Visible = false;
|
||||||
//
|
//
|
||||||
|
// waccaListTest
|
||||||
|
//
|
||||||
|
this.waccaListTest.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.waccaListTest.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
|
this.waccaListTest.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;
|
||||||
|
this.waccaListTest.Enabled = false;
|
||||||
|
this.waccaListTest.ForeColor = System.Drawing.Color.White;
|
||||||
|
this.waccaListTest.FormattingEnabled = true;
|
||||||
|
this.waccaListTest.ItemHeight = 40;
|
||||||
|
this.waccaListTest.Location = new System.Drawing.Point(200, 240);
|
||||||
|
this.waccaListTest.Name = "waccaListTest";
|
||||||
|
this.waccaListTest.Size = new System.Drawing.Size(680, 600);
|
||||||
|
this.waccaListTest.TabIndex = 1;
|
||||||
|
this.waccaListTest.Visible = false;
|
||||||
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.BackColor = System.Drawing.Color.Black;
|
this.BackColor = System.Drawing.Color.Black;
|
||||||
this.ClientSize = new System.Drawing.Size(1080, 1080);
|
this.ClientSize = new System.Drawing.Size(1080, 1080);
|
||||||
|
this.Controls.Add(this.waccaListTest);
|
||||||
this.Controls.Add(this.menuLabel);
|
this.Controls.Add(this.menuLabel);
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||||
this.KeyPreview = true;
|
this.KeyPreview = true;
|
||||||
@ -59,7 +76,6 @@
|
|||||||
this.Text = "WACCA Launcher";
|
this.Text = "WACCA Launcher";
|
||||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
|
||||||
this.Load += new System.EventHandler(this.Form1_Load);
|
this.Load += new System.EventHandler(this.Form1_Load);
|
||||||
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.KeyPressed);
|
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -67,6 +83,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private System.Windows.Forms.Label menuLabel;
|
private System.Windows.Forms.Label menuLabel;
|
||||||
|
public WaccaList waccaListTest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
223
MainForm.cs
223
MainForm.cs
@ -44,6 +44,8 @@ namespace WACCALauncher
|
|||||||
private readonly Process _gameProcess = new Process();
|
private readonly Process _gameProcess = new Process();
|
||||||
private bool _gameRunning = false;
|
private bool _gameRunning = false;
|
||||||
|
|
||||||
|
public MenuManager _menuManager;
|
||||||
|
|
||||||
public MainForm()
|
public MainForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -93,16 +95,6 @@ namespace WACCALauncher
|
|||||||
|
|
||||||
private bool _autoLaunch = true;
|
private bool _autoLaunch = true;
|
||||||
private int _currentMenuItem;
|
private int _currentMenuItem;
|
||||||
public ConfigMenu CurrentMenu;
|
|
||||||
|
|
||||||
public readonly ConfigMenu MainMenu = new ConfigMenu("Launcher Settings", rootMenu: true) {
|
|
||||||
//new ConfigMenuItem("bruh"),
|
|
||||||
//new ConfigMenuItem("moments"),
|
|
||||||
//new ConfigMenuItem("of"),
|
|
||||||
//new ConfigMenuItem("history")
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||||
{
|
{
|
||||||
@ -110,11 +102,19 @@ namespace WACCALauncher
|
|||||||
{
|
{
|
||||||
if (keyData == Keys.Up) { CursorUp(); return true; }
|
if (keyData == Keys.Up) { CursorUp(); return true; }
|
||||||
else if (keyData == Keys.Down) { CursorDown(); return true; }
|
else if (keyData == Keys.Down) { CursorDown(); return true; }
|
||||||
|
else if (keyData == Keys.Enter) { MenuSelect(); return true; }
|
||||||
|
else if (keyData == Keys.Escape)
|
||||||
|
{
|
||||||
|
if (_autoLaunch) MenuShow();
|
||||||
|
else MenuBack();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return base.ProcessCmdKey(ref msg, keyData);
|
return base.ProcessCmdKey(ref msg, keyData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
private void KeyPressed(object sender, KeyPressEventArgs e)
|
private void KeyPressed(object sender, KeyPressEventArgs e)
|
||||||
{
|
{
|
||||||
if (_gameRunning) return;
|
if (_gameRunning) return;
|
||||||
@ -130,7 +130,7 @@ namespace WACCALauncher
|
|||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
private async void Tick(object sender, EventArgs e)
|
private async void Tick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@ -194,29 +194,24 @@ namespace WACCALauncher
|
|||||||
private void CursorUp()
|
private void CursorUp()
|
||||||
{
|
{
|
||||||
// move cursor up
|
// move cursor up
|
||||||
Console.WriteLine("CursorUp");
|
var idx = ((waccaListTest.SelectedIndex - 1) + waccaListTest.Items.Count) % waccaListTest.Items.Count;
|
||||||
CurrentMenu[_currentMenuItem].Deactivate();
|
waccaListTest.SelectedIndex = idx;
|
||||||
_currentMenuItem = ((_currentMenuItem - 1) + CurrentMenu.Count) % CurrentMenu.Count;
|
|
||||||
Console.WriteLine($"Item {_currentMenuItem}");
|
|
||||||
RefreshMenu();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CursorDown()
|
private void CursorDown()
|
||||||
{
|
{
|
||||||
// move cursor down
|
// move cursor down
|
||||||
Console.WriteLine("CursorDown");
|
var idx = (waccaListTest.SelectedIndex + 1) % waccaListTest.Items.Count;
|
||||||
CurrentMenu[_currentMenuItem].Deactivate();
|
waccaListTest.SelectedIndex = idx;
|
||||||
_currentMenuItem = (_currentMenuItem + 1) % CurrentMenu.Count;
|
|
||||||
Console.WriteLine($"Item {_currentMenuItem}");
|
|
||||||
RefreshMenu();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MenuShow()
|
public void MenuShow()
|
||||||
{
|
{
|
||||||
_delayTimer.Stop();
|
_delayTimer.Stop();
|
||||||
_loadingLabel.Visible = false;
|
_loadingLabel.Hide();
|
||||||
menuLabel.Visible = true;
|
menuLabel.Show();
|
||||||
GenerateMenu(MainMenu);
|
waccaListTest.Visible = waccaListTest.Enabled = true;
|
||||||
|
waccaListTest.SelectedIndex = 0;
|
||||||
_autoLaunch = false;
|
_autoLaunch = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,10 +219,7 @@ namespace WACCALauncher
|
|||||||
{
|
{
|
||||||
_autoLaunch = true;
|
_autoLaunch = true;
|
||||||
menuLabel.Hide();
|
menuLabel.Hide();
|
||||||
foreach (var item in CurrentMenu)
|
waccaListTest.Visible = waccaListTest.Enabled = false;
|
||||||
{
|
|
||||||
item.label.Dispose();
|
|
||||||
}
|
|
||||||
_loadingLabel.Show();
|
_loadingLabel.Show();
|
||||||
|
|
||||||
_delayTimer = new System.Timers.Timer(5000);
|
_delayTimer = new System.Timers.Timer(5000);
|
||||||
@ -240,7 +232,7 @@ namespace WACCALauncher
|
|||||||
{
|
{
|
||||||
// select menu item
|
// select menu item
|
||||||
Console.WriteLine("MenuSelect");
|
Console.WriteLine("MenuSelect");
|
||||||
CurrentMenu[_currentMenuItem].Select(this, CurrentMenu);
|
(waccaListTest.SelectedItem as ConfigMenuItem).Select(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MenuBack()
|
private void MenuBack()
|
||||||
@ -249,6 +241,9 @@ namespace WACCALauncher
|
|||||||
Console.WriteLine("MenuBack");
|
Console.WriteLine("MenuBack");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
private void MenuReturn()
|
private void MenuReturn()
|
||||||
{
|
{
|
||||||
GenerateMenu(MainMenu);
|
GenerateMenu(MainMenu);
|
||||||
@ -261,6 +256,8 @@ namespace WACCALauncher
|
|||||||
this.Controls.Add(CurrentMenu[_currentMenuItem].label);
|
this.Controls.Add(CurrentMenu[_currentMenuItem].label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
private static void vfd_test()
|
private static void vfd_test()
|
||||||
{
|
{
|
||||||
var vfd = new WaccaVFD();
|
var vfd = new WaccaVFD();
|
||||||
@ -279,6 +276,7 @@ namespace WACCALauncher
|
|||||||
private void Form1_Load(object sender, EventArgs e)
|
private void Form1_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_loadingLabel = new Label();
|
_loadingLabel = new Label();
|
||||||
|
waccaListTest.Font = _menuFont;
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
|
|
||||||
_loadingLabel.Font = _menuFont;
|
_loadingLabel.Font = _menuFont;
|
||||||
@ -309,7 +307,7 @@ namespace WACCALauncher
|
|||||||
|
|
||||||
LoadVersionsFromConfig();
|
LoadVersionsFromConfig();
|
||||||
|
|
||||||
var defVerMenu = new ConfigMenu("default version");
|
var defVerMenu = new List<ConfigMenuItem>();
|
||||||
|
|
||||||
foreach (var ver in Versions)
|
foreach (var ver in Versions)
|
||||||
{
|
{
|
||||||
@ -319,18 +317,22 @@ namespace WACCALauncher
|
|||||||
|
|
||||||
defVerMenu.Add(new ConfigMenuItem("Return to settings", ConfigMenuAction.Return));
|
defVerMenu.Add(new ConfigMenuItem("Return to settings", ConfigMenuAction.Return));
|
||||||
|
|
||||||
MainMenu.Add(new ConfigMenuItem("set default version", ConfigMenuAction.Submenu, submenu: defVerMenu));
|
var mainMenu = new List<ConfigMenuItem>() {
|
||||||
|
new ConfigMenuItem("set default version", ConfigMenuAction.Submenu, submenu: defVerMenu),
|
||||||
|
new ConfigMenuItem("test VFD", ConfigMenuAction.Command, method: vfd_test),
|
||||||
|
new ConfigMenuItem("exit to windows", ConfigMenuAction.Command, method: Application.Exit),
|
||||||
|
new ConfigMenuItem("launch game", ConfigMenuAction.Return)
|
||||||
|
};
|
||||||
|
|
||||||
MainMenu.Add(new ConfigMenuItem("test VFD", ConfigMenuAction.Command, method: vfd_test));
|
_menuManager = new MenuManager(mainMenu, "Launcher Settings");
|
||||||
|
waccaListTest.AssignMenuManager(_menuManager);
|
||||||
MainMenu.Add(new ConfigMenuItem("exit to windows", ConfigMenuAction.Command, method: Application.Exit));
|
|
||||||
|
|
||||||
MainMenu.Add(new ConfigMenuItem("launch game", ConfigMenuAction.Return));
|
|
||||||
|
|
||||||
_loadingLabel.Font = _menuFont;
|
_loadingLabel.Font = _menuFont;
|
||||||
menuLabel.Font = _menuFont;
|
menuLabel.Font = _menuFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
public void GenerateMenu(ConfigMenu menu, int selectedIndex = 0)
|
public void GenerateMenu(ConfigMenu menu, int selectedIndex = 0)
|
||||||
{
|
{
|
||||||
if (menu == null || menu == CurrentMenu) return;
|
if (menu == null || menu == CurrentMenu) return;
|
||||||
@ -367,6 +369,8 @@ namespace WACCALauncher
|
|||||||
RefreshMenu();
|
RefreshMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
private static void KillExplorer()
|
private static void KillExplorer()
|
||||||
{
|
{
|
||||||
Process.Start(@"C:\Windows\System32\taskkill.exe", @"/F /IM explorer.exe");
|
Process.Start(@"C:\Windows\System32\taskkill.exe", @"/F /IM explorer.exe");
|
||||||
@ -409,8 +413,8 @@ namespace WACCALauncher
|
|||||||
private void LaunchDefault(Object source, ElapsedEventArgs e)
|
private void LaunchDefault(Object source, ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
_delayTimer.Stop();
|
_delayTimer.Stop();
|
||||||
KillExplorer();
|
//KillExplorer();
|
||||||
LaunchGame(DefaultVer);
|
//LaunchGame(DefaultVer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadVersionsFromConfig()
|
private void LoadVersionsFromConfig()
|
||||||
@ -581,93 +585,18 @@ namespace WACCALauncher
|
|||||||
Return
|
Return
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ConfigMenu : IList<ConfigMenuItem>
|
|
||||||
{
|
|
||||||
public readonly string Name;
|
|
||||||
public bool RootMenu = false;
|
|
||||||
public ConfigMenu ParentMenu = null;
|
|
||||||
private readonly List<ConfigMenuItem> _items = new List<ConfigMenuItem>();
|
|
||||||
|
|
||||||
public ConfigMenu(string name, bool rootMenu = false)
|
|
||||||
{
|
|
||||||
this.Name = name;
|
|
||||||
this.RootMenu = rootMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConfigMenuItem this[int index] { get => _items[index]; set => _items[index] = value; }
|
|
||||||
|
|
||||||
public int Count => _items.Count;
|
|
||||||
|
|
||||||
public bool IsReadOnly => false;
|
|
||||||
|
|
||||||
public void Add(ConfigMenuItem item)
|
|
||||||
{
|
|
||||||
_items.Add(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Clear()
|
|
||||||
{
|
|
||||||
_items.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Contains(ConfigMenuItem item)
|
|
||||||
{
|
|
||||||
return _items.Contains(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CopyTo(ConfigMenuItem[] array, int arrayIndex)
|
|
||||||
{
|
|
||||||
_items.CopyTo(array, arrayIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerator<ConfigMenuItem> GetEnumerator()
|
|
||||||
{
|
|
||||||
return _items.GetEnumerator();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int IndexOf(ConfigMenuItem item)
|
|
||||||
{
|
|
||||||
return _items.IndexOf(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Insert(int index, ConfigMenuItem item)
|
|
||||||
{
|
|
||||||
_items.Insert(index, item);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Remove(ConfigMenuItem item)
|
|
||||||
{
|
|
||||||
return _items.Remove(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RemoveAt(int index)
|
|
||||||
{
|
|
||||||
_items.RemoveAt(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerator IEnumerable.GetEnumerator()
|
|
||||||
{
|
|
||||||
return _items.GetEnumerator();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Destroy()
|
|
||||||
{
|
|
||||||
Clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ConfigMenuItem
|
public class ConfigMenuItem
|
||||||
{
|
{
|
||||||
public readonly string Name;
|
public readonly string Name;
|
||||||
private readonly ConfigMenuAction _action;
|
private readonly ConfigMenuAction _action;
|
||||||
private readonly Action _method;
|
private readonly Action _method;
|
||||||
private readonly ConfigMenu _submenu;
|
public readonly List<ConfigMenuItem> submenu;
|
||||||
private readonly List<string> _options;
|
private readonly List<string> _options;
|
||||||
private readonly Version _version;
|
private readonly Version _version;
|
||||||
|
|
||||||
public Label label;
|
public Label label;
|
||||||
|
|
||||||
public ConfigMenuItem(string name, ConfigMenuAction action = ConfigMenuAction.None, Action method = null, ConfigMenu submenu = null, List<string> options = null, Version version = null) {
|
public ConfigMenuItem(string name, ConfigMenuAction action = ConfigMenuAction.None, Action method = null, List<ConfigMenuItem> submenu = null, List<string> options = null, Version version = null) {
|
||||||
this.Name = name;
|
this.Name = name;
|
||||||
this._action = action;
|
this._action = action;
|
||||||
|
|
||||||
@ -681,7 +610,7 @@ namespace WACCALauncher
|
|||||||
throw new ArgumentException($"Menu item '{name}' was defined with VersionSelect type, but has no version associated.");
|
throw new ArgumentException($"Menu item '{name}' was defined with VersionSelect type, but has no version associated.");
|
||||||
|
|
||||||
this._method = method;
|
this._method = method;
|
||||||
this._submenu = submenu;
|
this.submenu = submenu;
|
||||||
this._options = options;
|
this._options = options;
|
||||||
this._version = version;
|
this._version = version;
|
||||||
}
|
}
|
||||||
@ -696,17 +625,19 @@ namespace WACCALauncher
|
|||||||
label.ForeColor = Color.White;
|
label.ForeColor = Color.White;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Select(MainForm form, ConfigMenu menu)
|
public void Select(MainForm form)
|
||||||
{
|
{
|
||||||
if (_action == ConfigMenuAction.Command)
|
if (_action == ConfigMenuAction.Command)
|
||||||
{
|
{
|
||||||
// only works with static methods, why
|
// only works with static methods, why
|
||||||
this._method();
|
this._method();
|
||||||
}
|
}
|
||||||
else if (_action == ConfigMenuAction.Submenu && _submenu != null)
|
else if (_action == ConfigMenuAction.Submenu && submenu != null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("attempting submenu");
|
Console.WriteLine("attempting submenu");
|
||||||
form.GenerateMenu(_submenu);
|
form._menuManager.NavigateToSubMenu(Name);
|
||||||
|
form.waccaListTest.Update();
|
||||||
|
//form.GenerateMenu(_submenu);
|
||||||
}
|
}
|
||||||
else if (_action == ConfigMenuAction.ItemSelect && _options != null)
|
else if (_action == ConfigMenuAction.ItemSelect && _options != null)
|
||||||
{
|
{
|
||||||
@ -720,16 +651,54 @@ namespace WACCALauncher
|
|||||||
for (int i = 0; i < form.Versions.Count; i++)
|
for (int i = 0; i < form.Versions.Count; i++)
|
||||||
{
|
{
|
||||||
var name = form.Versions[i].GameVersion == VersionType.Custom ? form.Versions[i].CustomName : form.Versions[i].ToString();
|
var name = form.Versions[i].GameVersion == VersionType.Custom ? form.Versions[i].CustomName : form.Versions[i].ToString();
|
||||||
menu[i].label.Text = $"({(form.Versions[i] == form.DefaultVer ? 'X' : ' ')}) {name}".ToUpper();
|
//menu[i].label.Text = $"({(form.Versions[i] == form.DefaultVer ? 'X' : ' ')}) {name}".ToUpper();
|
||||||
}
|
}
|
||||||
form.RefreshMenu();
|
//form.RefreshMenu();
|
||||||
}
|
}
|
||||||
else if (_action == ConfigMenuAction.Return)
|
else if (_action == ConfigMenuAction.Return) { form.MenuHide(); }
|
||||||
if(form.CurrentMenu == form.MainMenu)
|
}
|
||||||
{
|
|
||||||
form.MenuHide();
|
public override string ToString()
|
||||||
}
|
{
|
||||||
else form.GenerateMenu(form.CurrentMenu.ParentMenu);
|
return Name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class MenuManager
|
||||||
|
{
|
||||||
|
private List<ConfigMenuItem> currentMenu;
|
||||||
|
public readonly string name;
|
||||||
|
|
||||||
|
public MenuManager(List<ConfigMenuItem> menu, string menuName)
|
||||||
|
{
|
||||||
|
currentMenu = menu;
|
||||||
|
name = menuName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ConfigMenuItem> GetCurrentMenu()
|
||||||
|
{
|
||||||
|
return currentMenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void NavigateToSubMenu(string optionName)
|
||||||
|
{
|
||||||
|
if (optionName != string.Empty && optionName != null)
|
||||||
|
{
|
||||||
|
var selectedItem = currentMenu.Find(x => x.Name == optionName);
|
||||||
|
if (selectedItem.submenu != null && selectedItem.submenu.Count > 0)
|
||||||
|
{
|
||||||
|
currentMenu = selectedItem.submenu;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//public void NavigateBack()
|
||||||
|
//{
|
||||||
|
// if (currentMenu > 0 && currentMenu[0].Parent != null)
|
||||||
|
// {
|
||||||
|
// currentMenu = currentMenu[0].Parent.SubItems;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,9 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="WaccaList.cs">
|
||||||
|
<SubType>Component</SubType>
|
||||||
|
</Compile>
|
||||||
<Compile Include="WaccaVFD.cs" />
|
<Compile Include="WaccaVFD.cs" />
|
||||||
<EmbeddedResource Include="MainForm.resx">
|
<EmbeddedResource Include="MainForm.resx">
|
||||||
<DependentUpon>MainForm.cs</DependentUpon>
|
<DependentUpon>MainForm.cs</DependentUpon>
|
||||||
|
54
WaccaList.cs
Normal file
54
WaccaList.cs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace WACCALauncher
|
||||||
|
{
|
||||||
|
public partial class WaccaList : System.Windows.Forms.ListBox
|
||||||
|
{
|
||||||
|
private MenuManager menuManager;
|
||||||
|
|
||||||
|
public WaccaList()
|
||||||
|
{
|
||||||
|
BackColor = Color.Black;
|
||||||
|
BorderStyle = BorderStyle.None;
|
||||||
|
DrawMode = DrawMode.OwnerDrawVariable;
|
||||||
|
ItemHeight = 40;
|
||||||
|
Size = new System.Drawing.Size(680, 600);
|
||||||
|
Location = new System.Drawing.Point(200, 240);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AssignMenuManager(MenuManager manager)
|
||||||
|
{
|
||||||
|
menuManager = manager;
|
||||||
|
Items.Clear();
|
||||||
|
Items.AddRange(menuManager.GetCurrentMenu().ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDrawItem(DrawItemEventArgs e)
|
||||||
|
{
|
||||||
|
e.Graphics.FillRectangle(new SolidBrush(BackColor), e.Bounds);
|
||||||
|
|
||||||
|
if (Items.Count < 1) return;
|
||||||
|
|
||||||
|
var text = Items[e.Index].ToString().ToUpper();
|
||||||
|
var selected = (e.State & DrawItemState.Selected) == DrawItemState.Selected;
|
||||||
|
|
||||||
|
e.Graphics.DrawString(text, Font, selected ? Brushes.Red : Brushes.White, e.Bounds);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnInvalidated(InvalidateEventArgs e)
|
||||||
|
{
|
||||||
|
Items.Clear();
|
||||||
|
Items.AddRange(menuManager.GetCurrentMenu().ToArray());
|
||||||
|
SelectedIndex = 0;
|
||||||
|
base.OnInvalidated(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user