diff --git a/XLAB/MainWindow.xaml b/XLAB/MainWindow.xaml index ba3789f..13a0139 100644 --- a/XLAB/MainWindow.xaml +++ b/XLAB/MainWindow.xaml @@ -46,6 +46,8 @@ Click="TypeSizeDirectoryMenuItem_Click" /> + diff --git a/XLAB/MainWindow.xaml.cs b/XLAB/MainWindow.xaml.cs index b82cd8f..135b1e1 100644 --- a/XLAB/MainWindow.xaml.cs +++ b/XLAB/MainWindow.xaml.cs @@ -100,6 +100,13 @@ namespace XLAB window.ShowDialog(); } + private void PlanningMenuItem_Click(object sender, RoutedEventArgs e) + { + var window = new PlanningWindow(); + window.Owner = this; + window.ShowDialog(); + } + private void SpoiDirectoryMenuItem_Click(object sender, RoutedEventArgs e) { var window = new SpoiDirectoryWindow(); diff --git a/XLAB/PlanningDialogService.cs b/XLAB/PlanningDialogService.cs new file mode 100644 index 0000000..e8f6e0b --- /dev/null +++ b/XLAB/PlanningDialogService.cs @@ -0,0 +1,70 @@ +using System.Collections.Generic; +using System.Windows; + +namespace XLAB +{ + internal interface IPlanningDialogService + { + PlanningEditResult ShowPlanningEditDialog(PlanningEditSeed seed, bool isNew, IReadOnlyList instruments, PlanningService service); + + EkzDirectoryItem ShowEkzEditDialog(EkzDirectoryItem seed, bool isNew, IReadOnlyList existingItems, EkzDirectoryService service); + + bool Confirm(string message); + + void ShowError(string message); + + void ShowInfo(string message); + + void ShowWarning(string message); + } + + internal sealed class PlanningDialogService : IPlanningDialogService + { + private readonly Window _owner; + + public PlanningDialogService(Window owner) + { + _owner = owner; + } + + public bool Confirm(string message) + { + return MessageBox.Show(_owner, message, "ПСВ", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes; + } + + public EkzDirectoryItem ShowEkzEditDialog(EkzDirectoryItem seed, bool isNew, IReadOnlyList existingItems, EkzDirectoryService service) + { + var viewModel = new EkzEditWindowViewModel(seed, isNew, existingItems, service); + var window = new EkzEditWindow(viewModel); + window.Owner = _owner; + + var result = window.ShowDialog(); + return result.HasValue && result.Value ? viewModel.ToResult() : null; + } + + public void ShowError(string message) + { + MessageBox.Show(_owner, message, "ПСВ", MessageBoxButton.OK, MessageBoxImage.Error); + } + + public void ShowInfo(string message) + { + MessageBox.Show(_owner, message, "ПСВ", MessageBoxButton.OK, MessageBoxImage.Information); + } + + public PlanningEditResult ShowPlanningEditDialog(PlanningEditSeed seed, bool isNew, IReadOnlyList instruments, PlanningService service) + { + var viewModel = new PlanningEditWindowViewModel(seed, isNew, instruments, service); + var window = new PlanningEditWindow(viewModel); + window.Owner = _owner; + + var result = window.ShowDialog(); + return result.HasValue && result.Value ? viewModel.ToResult() : null; + } + + public void ShowWarning(string message) + { + MessageBox.Show(_owner, message, "ПСВ", MessageBoxButton.OK, MessageBoxImage.Warning); + } + } +} diff --git a/XLAB/PlanningEditWindow.xaml b/XLAB/PlanningEditWindow.xaml new file mode 100644 index 0000000..f07613c --- /dev/null +++ b/XLAB/PlanningEditWindow.xaml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +