edit
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
|
||||
@@ -13,6 +14,8 @@ namespace XLAB2
|
||||
|
||||
IReadOnlyList<string> ShowCloneVerificationDialog(CloneVerificationSeed seed);
|
||||
|
||||
GroupOption ShowAccountingBookEditDialog(GroupOption seed, bool isNew, IReadOnlyList<GroupOption> existingItems);
|
||||
|
||||
SpoiDirectoryItem ShowSpoiEditDialog(SpoiDirectoryItem seed, bool isNew, IReadOnlyList<SpoiDirectoryItem> existingItems);
|
||||
|
||||
SpnmtpDirectoryItem ShowSpnmtpEditDialog(SpnmtpDirectoryItem seed, bool isNew, IReadOnlyList<SpnmtpDirectoryItem> existingItems);
|
||||
@@ -33,6 +36,8 @@ namespace XLAB2
|
||||
|
||||
internal sealed class DialogService : IDialogService
|
||||
{
|
||||
private readonly DocumentNumberDirectoryService _documentNumberDirectoryService;
|
||||
|
||||
public DialogService()
|
||||
{
|
||||
}
|
||||
@@ -42,11 +47,18 @@ namespace XLAB2
|
||||
Owner = owner;
|
||||
}
|
||||
|
||||
public DialogService(Window owner, DocumentNumberDirectoryService documentNumberDirectoryService)
|
||||
{
|
||||
Owner = owner;
|
||||
_documentNumberDirectoryService = documentNumberDirectoryService;
|
||||
}
|
||||
|
||||
public Window Owner { get; set; }
|
||||
|
||||
public DocumentEditorResult ShowCreateDocumentDialog(DocumentEditorResult seed)
|
||||
{
|
||||
var viewModel = new CreateDocumentWindowViewModel(seed);
|
||||
var directory = (_documentNumberDirectoryService ?? CreateDefaultDocumentNumberDirectoryService()).LoadDirectory();
|
||||
var viewModel = new CreateDocumentWindowViewModel(seed, directory);
|
||||
var window = new CreateDocumentWindow(viewModel);
|
||||
AttachOwner(window);
|
||||
|
||||
@@ -84,6 +96,16 @@ namespace XLAB2
|
||||
return result.HasValue && result.Value ? viewModel.GetSerialNumbers() : null;
|
||||
}
|
||||
|
||||
public GroupOption ShowAccountingBookEditDialog(GroupOption seed, bool isNew, IReadOnlyList<GroupOption> existingItems)
|
||||
{
|
||||
var viewModel = new AccountingBookEditWindowViewModel(seed, isNew, existingItems);
|
||||
var window = new AccountingBookEditWindow(viewModel);
|
||||
AttachOwner(window);
|
||||
|
||||
var result = window.ShowDialog();
|
||||
return result.HasValue && result.Value ? viewModel.ToResult() : null;
|
||||
}
|
||||
|
||||
public SpoiDirectoryItem ShowSpoiEditDialog(SpoiDirectoryItem seed, bool isNew, IReadOnlyList<SpoiDirectoryItem> existingItems)
|
||||
{
|
||||
var viewModel = new SpoiEditWindowViewModel(seed, isNew, existingItems);
|
||||
@@ -157,5 +179,10 @@ namespace XLAB2
|
||||
|
||||
MessageBox.Show(Owner, message, "ПСВ", MessageBoxButton.OK, image);
|
||||
}
|
||||
|
||||
private static DocumentNumberDirectoryService CreateDefaultDocumentNumberDirectoryService()
|
||||
{
|
||||
return new DocumentNumberDirectoryService(System.IO.Path.Combine(AppContext.BaseDirectory, "Assets", "document-number-directory.json"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user