Files
StarterNG/StarterNG/Views/MenuItems.cs
maj00r 82429010d4 Rework the depot, warehouse and vehicle base
A consist added to the warehouse gets a name there. The crew type stays through
loading a consist. The vehicle base window replaces the texture base. The depot
follows consists changed on the scenarios page, also with the warehouse tab
left open.
2026-11-01 16:06:16 +01:00

27 lines
956 B
C#

using System;
using Avalonia.Controls;
using Avalonia.Input;
namespace StarterNG.Views;
/// <summary>A menu entry that runs something when clicked, as nearly all of them do.</summary>
internal static class MenuItems
{
/// <param name="header">The text, or a control where a row holds more than that.</param>
public static MenuItem Item(object header, Action run, bool enabled = true, KeyGesture? gesture = null)
{
var item = new MenuItem { Header = header, IsEnabled = enabled, InputGesture = gesture };
item.Click += (_, _) => run();
return item;
}
/// <summary>The entry at the end of a menu or a submenu.</summary>
public static MenuItem AddItem(this ItemsControl menu, object header, Action run, bool enabled = true,
KeyGesture? gesture = null)
{
var item = Item(header, run, enabled, gesture);
menu.Items.Add(item);
return item;
}
}