示例#1
0
 public Task Launch()
 {
     try {
         Deck = (DeckPath == null) ? null : new MetaDeck(DeckPath);
         var win = new DeckBuilderWindow(Deck, true);
         Application.Current.MainWindow = win;
         win.Show();
     } catch (UserMessageException e) {
         TopMostMessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Asterisk);
         this.Shutdown = true;
     }
     return(Task.CompletedTask);
 }
示例#2
0
        protected override async Task <Window> Load(ILoadingView loadingView)
        {
            try {
                var fn = Path.GetFileName(DeckPath);
                loadingView.UpdateStatus($"Loading Deck '{fn}'...");

                await Task.Run(() => {
                    Deck = (DeckPath == null) ? null : new MetaDeck(DeckPath);
                });

                Window win = null;
                await Dispatcher.CurrentDispatcher.InvokeAsync(() => {
                    win = new DeckBuilderWindow(Deck, true);

                    win.WindowStartupLocation = WindowStartupLocation.CenterScreen;

                    win.Show();
                }, DispatcherPriority.Background);

                return(win);
            } catch (Exception e) {
                string msg;
                if (string.IsNullOrWhiteSpace(DeckPath))
                {
                    msg = $"Deck editor failed to launch: {e.Message}";
                }
                else
                {
                    msg = $"Deck editor failed to launch '{DeckPath}': {e.Message}";
                }

                Log.Warn(msg, e);

                throw new UserMessageException(
                          UserMessageExceptionMode.Blocking,
                          msg,
                          e
                          );
            }
        }
示例#3
0
 private void DeckBuilder_Click(object sender, RoutedEventArgs e)
 {
     var DeckBuilderWindow = new DeckBuilderWindow();
     DeckBuilderWindow.ShowDialog();
 }
示例#4
0
文件: Program.cs 项目: karlnp/OCTGN
        internal static void Start()
        {
            //SetupWindows.Instance.RegisterCustomProtocol(typeof(Program).Assembly);
            //SetupWindows.Instance.RegisterDeckExtension(typeof(Program).Assembly);
            Application.Current.MainWindow = new Window();
            KillOtherOctgn();
#if (DEBUG)
            //var cwin = new OctgnChrome();
            //var dm = new DeckManager();
            //cwin.Content = dm;
            //cwin.Show();
            //cwin.Closed += delegate { Program.Exit(); };
            //return;
#endif
            bool isUpdate = RunUpdateChecker();
            if (isUpdate)
            {
                KillOtherOctgn(true);
                UpdateManager.Instance.UpdateAndRestart();
                return;
            }
            Log.Info("Ping back");
            System.Threading.Tasks.Task.Factory.StartNew(pingOB);

            bool tableOnlyFailed = false;

            int? hostport = null;
            Guid?gameid   = null;

            var os = new Mono.Options.OptionSet()
            {
                { "t|table", x => TableOnly = true },
                { "g|game=", x => gameid = Guid.Parse(x) },
                { "d|deck", x => DeckEditorOnly = true }
            };
            try
            {
                os.Parse(Environment.GetCommandLineArgs());
            }
            catch (Exception e)
            {
                Log.Warn("Parse args exception: " + String.Join(",", Environment.GetCommandLineArgs()), e);
            }

            if (TableOnly)
            {
                try
                {
                    new GameTableLauncher().Launch(hostport, gameid);
                }
                catch (Exception e)
                {
                    Log.Warn("Couldn't host/join table mode", e);
                    tableOnlyFailed = true;
                    Program.Exit();
                }
            }
            if (DeckEditorOnly)
            {
                var win = new DeckBuilderWindow();
                Application.Current.MainWindow = win;
                win.Show();
            }

            if ((!TableOnly || tableOnlyFailed) && !DeckEditorOnly)
            {
                Log.Info("Creating main window...");
                WindowManager.Main = new Main();
                Log.Info("Main window Created, Launching it.");
                Application.Current.MainWindow = WindowManager.Main;
                Log.Info("Main window set.");
                Log.Info("Launching Main Window");
                WindowManager.Main.Show();
                Log.Info("Main Window Launched");
            }
        }