add restart with windows and autorestart
This commit is contained in:
@@ -47,26 +47,34 @@ namespace VirtualKeyboard.Wpf
|
||||
|
||||
public static Task<string> OpenAsync(string initialValue = "")
|
||||
{
|
||||
if (_windowHost != null) throw new InvalidOperationException();
|
||||
|
||||
_tcs = new TaskCompletionSource<string>();
|
||||
_windowHost = (Window)Activator.CreateInstance(_hostType);
|
||||
_windowHost.DataContext = new VirtualKeyboardViewModel(initialValue);
|
||||
((ContentControl)_windowHost.FindName(_keyboardValueName)).Content = new KeyboardValueView();
|
||||
((ContentControl)_windowHost.FindName(_keyboardName)).Content = new VirtualKeyboardView();
|
||||
void handler(object s, CancelEventArgs a)
|
||||
try
|
||||
{
|
||||
var result = GetResult();
|
||||
((Window)s).Closing -= handler;
|
||||
_windowHost = null;
|
||||
_tcs?.SetResult(result);
|
||||
_tcs = null;
|
||||
if (_windowHost != null) throw new InvalidOperationException();
|
||||
|
||||
|
||||
_windowHost = (Window)Activator.CreateInstance(_hostType);
|
||||
_windowHost.DataContext = new VirtualKeyboardViewModel(initialValue);
|
||||
((ContentControl)_windowHost.FindName(_keyboardValueName)).Content = new KeyboardValueView();
|
||||
((ContentControl)_windowHost.FindName(_keyboardName)).Content = new VirtualKeyboardView();
|
||||
void handler(object s, CancelEventArgs a)
|
||||
{
|
||||
var result = GetResult();
|
||||
((Window)s).Closing -= handler;
|
||||
_windowHost = null;
|
||||
_tcs?.SetResult(result);
|
||||
_tcs = null;
|
||||
}
|
||||
|
||||
_windowHost.Closing += handler;
|
||||
|
||||
_windowHost.Owner = Application.Current.MainWindow;
|
||||
_windowHost.Show();
|
||||
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
||||
_windowHost.Closing += handler;
|
||||
|
||||
_windowHost.Owner = Application.Current.MainWindow;
|
||||
_windowHost.Show();
|
||||
}
|
||||
return _tcs.Task;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user