80 lines
2.0 KiB
C#
80 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
|
|
namespace ILSOS_KS.Views.Dialog
|
|
{
|
|
public interface IDialogService
|
|
{
|
|
string ShowInputDialog(string windowTitle, string iputLable);
|
|
}
|
|
|
|
public class DialogService : IDialogService
|
|
{
|
|
private static DialogService _instance;
|
|
public static DialogService Instance
|
|
{
|
|
get
|
|
{
|
|
if (_instance == null)
|
|
_instance = new DialogService();
|
|
return _instance;
|
|
}
|
|
}
|
|
|
|
private DialogService() { }
|
|
|
|
public string ShowInputDialog(string windowTitle, string iputLable)
|
|
{
|
|
string result = null;
|
|
|
|
// UI 스레드에서 InputWindow 생성 및 ShowDialog 호출
|
|
Application.Current.Dispatcher.Invoke(() =>
|
|
{
|
|
var window = new InputWindow(windowTitle, iputLable);
|
|
|
|
bool? dialogResult = window.ShowDialog();
|
|
if (dialogResult == true)
|
|
result = window.InputValue;
|
|
});
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
public class InputService
|
|
{
|
|
private static InputService _instance;
|
|
public static InputService Instance
|
|
{
|
|
get
|
|
{
|
|
if (_instance == null)
|
|
_instance = new InputService(DialogService.Instance);
|
|
return _instance;
|
|
}
|
|
}
|
|
|
|
private readonly IDialogService _dialogService;
|
|
|
|
private InputService(IDialogService dialogService)
|
|
{
|
|
_dialogService = dialogService;
|
|
}
|
|
|
|
public string RequestUserInput(string windowTitle, string iputLable)
|
|
{
|
|
string input = _dialogService.ShowInputDialog(windowTitle, iputLable);
|
|
if (!string.IsNullOrEmpty(input))
|
|
{
|
|
return input;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|