Beispiel #1
0
        /// <summary>
        /// Converts a URL into a ConverterDeck, then returns it
        /// </summary>
        /// <param name="deckURL">The URL of the deck to get</param>
        /// <param name="game">The Game that should be chosen in the Wizard</param>
        /// <returns>a ConverterDeck containing cards parsed from the deck file</returns>
        public static OCTGNDeckConverter.Model.ConverterDeck ConvertURLUsingWizard(
            string deckURL,
            Octgn.DataNew.Entities.Game game)
        {
            ImportDeckWizardVM idwvm = new ImportDeckWizardVM();

            // If more than one Game is installed, the ChooseGame page will be active.  Select the game
            if (idwvm.CurrentWizardPageVM is WizardPage_ChooseGame)
            {
                (idwvm.CurrentWizardPageVM as WizardPage_ChooseGame).ChooseGameCommand.Execute(game);
            }

            Assert.IsTrue(idwvm.CurrentWizardPageVM is WizardPage_ChooseDeckSourceType);
            (idwvm.CurrentWizardPageVM as WizardPage_ChooseDeckSourceType).ChooseDeckSourceTypeCommand.Execute(DeckSourceTypes.Webpage);

            Assert.IsTrue(idwvm.CurrentWizardPageVM is WizardPage_EnterWebpage);
            idwvm.Converter.DeckURL = deckURL;
            idwvm.MoveToNextStep();

            // It might take some time for the conversion, (or for the database to load) so wait for it
            DateTime waitForConversionUntil = DateTime.Now.Add(TimeSpan.FromSeconds(300));

            while (!(idwvm.CurrentWizardPageVM is WizardPage_CompareCards) && DateTime.Now < waitForConversionUntil)
            {
                System.Threading.Thread.Sleep(TimeSpan.FromMilliseconds(100));
            }

            Assert.IsTrue(idwvm.CurrentWizardPageVM is WizardPage_CompareCards);

            return(idwvm.Converter.ConverterDeck);
        }
        /// <summary>
        /// Fired when the DataContext of MainWindow changes.  It will store a reference to the DataContext if it is
        /// of type ImportDeckWizardVM, and subscribe to it's Close event.  Previous DataContexts will be unsubscribed.
        /// </summary>
        /// <param name="sender">The sender of the Event</param>
        /// <param name="e">The DependencyPropertyChangedEventArgs property</param>
        private void MainWindow_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (this._ImportDeckWizardVM != null)
            {
                this._ImportDeckWizardVM.Close -= new System.EventHandler(this.ImportDeckWizardVM_Close);
            }

            this._ImportDeckWizardVM = null;

            if (e.NewValue != null && e.NewValue is ImportDeckWizardVM)
            {
                this._ImportDeckWizardVM        = e.NewValue as ImportDeckWizardVM;
                this._ImportDeckWizardVM.Close += new System.EventHandler(this.ImportDeckWizardVM_Close);
            }
        }