AreaComAdminWindow: Allow users to create new reeds inline
This commit is contained in:
@ -13,10 +13,15 @@ using System.Threading;
|
||||
using System.Windows.Markup;
|
||||
using System.Reflection;
|
||||
using Elwig.Helpers.Printing;
|
||||
using Elwig.Windows;
|
||||
using Elwig.Dialogs;
|
||||
|
||||
namespace Elwig {
|
||||
public partial class App : Application {
|
||||
|
||||
protected static App CurrentApp;
|
||||
public static int NumWindows => CurrentApp.Windows.Count;
|
||||
|
||||
public static readonly string DataPath = @"C:\ProgramData\Elwig\";
|
||||
public static readonly string ExePath = @"C:\Program Files\Elwig\";
|
||||
public static readonly string TempPath = Path.Combine(Path.GetTempPath(), "Elwig");
|
||||
@ -56,6 +61,7 @@ namespace Elwig {
|
||||
Directory.CreateDirectory(DataPath);
|
||||
MainDispatcher = Dispatcher;
|
||||
Scales = Array.Empty<IScale>();
|
||||
CurrentApp = this;
|
||||
}
|
||||
|
||||
protected override void OnStartup(StartupEventArgs evt) {
|
||||
@ -168,5 +174,49 @@ namespace Elwig {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static T FocusWindow<T>(Func<T> constructor, Predicate<T>? selector = null) where T : Window {
|
||||
foreach (Window w in CurrentApp.Windows) {
|
||||
if (w is T t && (selector == null || selector(t))) {
|
||||
if (t.WindowState == WindowState.Minimized)
|
||||
t.WindowState = WindowState.Normal;
|
||||
t.Activate();
|
||||
return t;
|
||||
}
|
||||
}
|
||||
var n = constructor();
|
||||
n.Show();
|
||||
return n;
|
||||
}
|
||||
|
||||
public static DeliveryAdminWindow FocusReceipt() {
|
||||
return FocusWindow<DeliveryAdminWindow>(() => new(true), w => w.IsReceipt);
|
||||
}
|
||||
|
||||
public static DeliveryAdminWindow FocusMemberDeliveries(int mgnr) {
|
||||
return FocusWindow<DeliveryAdminWindow>(() => new(mgnr), w => w.MgNr == mgnr);
|
||||
}
|
||||
|
||||
public static AreaComAdminWindow FocusMemberAreaComs(int mgnr) {
|
||||
return FocusWindow<AreaComAdminWindow>(() => new(mgnr), w => w.MgNr == mgnr);
|
||||
}
|
||||
|
||||
public static BaseDataWindow FocusBaseData() {
|
||||
return FocusWindow<BaseDataWindow>(() => new());
|
||||
}
|
||||
|
||||
public static BaseDataWindow FocusBaseDataAreaComType() {
|
||||
var w = FocusBaseData();
|
||||
w.AreaCommitmentTypes.Focus();
|
||||
return w;
|
||||
}
|
||||
|
||||
public static SeasonFinishWindow FocusSeasonFinish() {
|
||||
return FocusWindow<SeasonFinishWindow>(() => new());
|
||||
}
|
||||
|
||||
public static DeliveryConfirmationsWindow FocusDeliveryConfirmations(int year) {
|
||||
return FocusWindow<DeliveryConfirmationsWindow>(() => new(year), w => w.Year == year);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user