Ejemplo n.º 1
0
        internal static async Task <bool> FillOptionsAsync(Options options)
        {
            var wpfDispatcherBox = new TaskCompletionSource <Dispatcher>();
            var wpfThread        = new Thread(() =>
            {
                try
                {
                    wpfDispatcherBox.TrySetResult(Dispatcher.CurrentDispatcher);
                    Dispatcher.Run();
                }
                catch (Exception ex)
                {
                    wpfDispatcherBox.TrySetException(ex);
                }
            });

            wpfThread.SetApartmentState(ApartmentState.STA);
            wpfThread.Start();
            var wpfDispatcher = await wpfDispatcherBox.Task.ConfigureAwait(false);

            try
            {
                return(await wpfDispatcher.InvokeAsync(() =>
                {
                    DispatcherHelper.Initialize();
                    var viewModel = new InputViewModel(options);
                    var window = new InputWindow(viewModel);
                    Register(Messenger.Default, window);

                    if (window.ShowDialog() != true)
                    {
                        return false;
                    }

                    options.PackDefinitionFilePaths = viewModel.PackFiles.Select(fp => fp.Value).ToArray();
                    options.JavaBinDirectoryPath = viewModel.JavaBinFolder;
                    options.OutputDirectoryPath = viewModel.OutputFolder;
                    options.DownloadDirectoryPath = viewModel.DownloadFolder;
                    options.SteamDirectoryPath = viewModel.SteamFolder;
                    options.ScreenHeight = viewModel.ScreenHeight;
                    options.ScreenWidth = viewModel.ScreenWidth;
                    options.FullScreenMode = viewModel.SelectedFullScreenMode;
                    options.GraphicsPreset = viewModel.SelectedGraphicsPreset;
                    return options.MightBeValid;
                }).Task.ConfigureAwait(false));
            }
            finally
            {
                wpfDispatcher.InvokeShutdown();
                wpfThread.Join();
            }
        }
Ejemplo n.º 2
0
 public InputWindow(InputViewModel viewModel)
 {
     this.ViewModel = viewModel;
     this.InitializeComponent();
 }