101 lines
3.7 KiB
C#
101 lines
3.7 KiB
C#
using System.Collections.Generic;
|
|
using System.Windows;
|
|
|
|
namespace XLAB
|
|
{
|
|
internal interface IDialogService
|
|
{
|
|
DocumentEditorResult ShowCreateDocumentDialog(DocumentEditorResult seed);
|
|
|
|
IReadOnlyList<AvailableInstrumentItem> ShowInstrumentPickerDialog(string customerName, IReadOnlyList<AvailableInstrumentItem> instruments);
|
|
|
|
InstrumentTypeSelectionResult ShowInstrumentTypeDialog(string customerName, IReadOnlyList<AvailableInstrumentItem> instrumentTypes);
|
|
|
|
VerificationEditResult ShowVerificationDialog(
|
|
VerificationEditSeed seed,
|
|
IReadOnlyList<PersonReference> verifiers,
|
|
IReadOnlyList<DocumentFormReference> documentForms);
|
|
|
|
bool Confirm(string message);
|
|
|
|
void ShowError(string message);
|
|
|
|
void ShowInfo(string message);
|
|
|
|
void ShowWarning(string message);
|
|
}
|
|
|
|
internal sealed class DialogService : IDialogService
|
|
{
|
|
private readonly Window _owner;
|
|
|
|
public DialogService(Window owner)
|
|
{
|
|
_owner = owner;
|
|
}
|
|
|
|
public DocumentEditorResult ShowCreateDocumentDialog(DocumentEditorResult seed)
|
|
{
|
|
var viewModel = new CreateDocumentWindowViewModel(seed);
|
|
var window = new CreateDocumentWindow(viewModel);
|
|
window.Owner = _owner;
|
|
|
|
var result = window.ShowDialog();
|
|
return result.HasValue && result.Value ? viewModel.ToResult() : null;
|
|
}
|
|
|
|
public IReadOnlyList<AvailableInstrumentItem> ShowInstrumentPickerDialog(string customerName, IReadOnlyList<AvailableInstrumentItem> instruments)
|
|
{
|
|
var viewModel = new SelectInstrumentsWindowViewModel(customerName, instruments);
|
|
var window = new SelectInstrumentsWindow(viewModel);
|
|
window.Owner = _owner;
|
|
|
|
var result = window.ShowDialog();
|
|
return result.HasValue && result.Value ? viewModel.GetSelectedItems() : null;
|
|
}
|
|
|
|
public InstrumentTypeSelectionResult ShowInstrumentTypeDialog(string customerName, IReadOnlyList<AvailableInstrumentItem> instrumentTypes)
|
|
{
|
|
var viewModel = new SelectInstrumentTypeWindowViewModel(customerName, instrumentTypes);
|
|
var window = new SelectInstrumentTypeWindow(viewModel);
|
|
window.Owner = _owner;
|
|
|
|
var result = window.ShowDialog();
|
|
return result.HasValue && result.Value ? viewModel.GetResult() : null;
|
|
}
|
|
|
|
public VerificationEditResult ShowVerificationDialog(
|
|
VerificationEditSeed seed,
|
|
IReadOnlyList<PersonReference> verifiers,
|
|
IReadOnlyList<DocumentFormReference> documentForms)
|
|
{
|
|
var viewModel = new VerificationEditWindowViewModel(seed, verifiers, documentForms);
|
|
var window = new VerificationEditWindow(viewModel);
|
|
window.Owner = _owner;
|
|
|
|
var result = window.ShowDialog();
|
|
return result.HasValue && result.Value ? viewModel.ToResult() : null;
|
|
}
|
|
|
|
public bool Confirm(string message)
|
|
{
|
|
return MessageBox.Show(_owner, message, "ПСВ", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes;
|
|
}
|
|
|
|
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 void ShowWarning(string message)
|
|
{
|
|
MessageBox.Show(_owner, message, "ПСВ", MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
}
|
|
}
|
|
}
|