コード例 #1
0
        public CardRenderWindow(CmdCards launcherCommand, CommandViewModel vm)
        {
            Command = launcherCommand;
            Game = new CardGame(this);

            InitializeComponent();

            stopwatch = new Stopwatch();

            renderTick = new DispatcherTimer();
            renderTick.Interval = TimeSpan.FromMilliseconds(10);
            renderTick.Tick += MainLoop;
        }
コード例 #2
0
        public CardRenderWindow LaunchCardWindow(CmdCards cmd)
        {
            CardRenderWindow res = null;

            cardWindowThread = new Thread(() =>
            {
                CardRenderWindow crw = new CardRenderWindow(cmd, this);
                res = crw;
                crw.Closed += (sender, e) =>
                {
                    crw.Dispatcher.InvokeShutdown();
                    cmd.ReleaseInput();
                };

                crw.Show();
                System.Windows.Threading.Dispatcher.Run();
            });

            cardWindowThread.SetApartmentState(ApartmentState.STA);
            cardWindowThread.Start();

            Window.Dispatcher.Invoke(PrintingFormatted, "&e&*Starting Window...\r");

            while (res == null) // sorta hacky workaround
            {
                Thread.Sleep(1); // prevent excessive memory use
            }

            return res;
        }