private void MenuItemMissingDust_OnClick(object sender, RoutedEventArgs e)
        {
            var deck = DeckPickerList.GetSelectedDeckVersion();

            if (deck == null)
            {
                return;
            }
            this.ShowMissingCardsMessage(deck);
        }
        private void BtnClipboard_OnClick(object sender, RoutedEventArgs e)
        {
            var deck = DeckPickerList.GetSelectedDeckVersion();

            if (deck == null)
            {
                return;
            }
            Clipboard.SetText(Helper.DeckToIdString(deck));
            this.ShowMessage("", "copied to clipboard");
            Logger.WriteLine("Copied " + deck.GetDeckInfo() + " to clipboard", "Export");
        }
        private async void BtnSaveToFile_OnClick(object sender, RoutedEventArgs e)
        {
            var deck = DeckPickerList.GetSelectedDeckVersion();

            if (deck == null)
            {
                return;
            }
            var path = Helper.GetValidFilePath("SavedDecks", deck.Name, ".xml");

            XmlManager <Deck> .Save(path, deck);
            await ShowSavedFileMessage(path, "SavedDecks");

            Logger.WriteLine("Saved " + deck.GetDeckInfo() + " to file: " + path, "Export");
        }
Beispiel #4
0
        private async void BtnCancelEdit_Click(object sender, RoutedEventArgs e)
        {
            if (_newDeckUnsavedChanges)
            {
                var result =
                    await
                    this.ShowMessageAsync(EditingDeck? "Cancel editing" : "Cancel deck creation",
                                          EditingDeck? "All changes made to the deck will be lost." : "The new deck will be lost.",
                                          MessageDialogStyle.AffirmativeAndNegative);

                if (result != MessageDialogResult.Affirmative)
                {
                    return;
                }
            }
            ListViewDeck.ItemsSource = DeckPickerList.SelectedDeck != null?DeckPickerList.GetSelectedDeckVersion().Cards : null;

            CloseNewDeck();
            EditingDeck    = false;
            editedDeckName = string.Empty;
        }
        private async void BtnScreenhot_Click(object sender, RoutedEventArgs e)
        {
            if (DeckPickerList.SelectedDeck == null)
            {
                return;
            }
            Logger.WriteLine("Creating screenshot of " + DeckPickerList.GetSelectedDeckVersion().GetDeckInfo(), "Screenshot");
            var screenShotWindow = new PlayerWindow(Config.Instance, DeckPickerList.GetSelectedDeckVersion().Cards, true);

            screenShotWindow.Show();
            screenShotWindow.Top  = 0;
            screenShotWindow.Left = 0;
            await Task.Delay(100);

            var source = PresentationSource.FromVisual(screenShotWindow);

            if (source == null)
            {
                return;
            }

            var dpiX = 96.0 * source.CompositionTarget.TransformToDevice.M11;
            var dpiY = 96.0 * source.CompositionTarget.TransformToDevice.M22;

            var fileName = Helper.ScreenshotDeck(screenShotWindow.ListViewPlayer, dpiX, dpiY, DeckPickerList.GetSelectedDeckVersion().Name);

            screenShotWindow.Shutdown();
            if (fileName == null)
            {
                await this.ShowMessageAsync("", "Error saving screenshot");
            }
            else
            {
                await ShowSavedFileMessage(fileName, "Screenshots");
            }
        }
Beispiel #6
0
        private async void BtnCloneSelectedVersion_Click(object sender, RoutedEventArgs e)
        {
            var deck = DeckPickerList.GetSelectedDeckVersion();

            if (deck == null)
            {
                return;
            }
            var cloneStats =
                (await
                 this.ShowMessageAsync("Clone game history?", "(Cloned games do not count towards class or overall stats.)",
                                       MessageDialogStyle.AffirmativeAndNegative,
                                       new MetroDialogSettings
            {
                AffirmativeButtonText = "clone history",
                NegativeButtonText = "do not clone history"
            })) == MessageDialogResult.Affirmative;
            var clone = (Deck)deck.Clone();

            clone.ResetVersions();

            var originalStatsEntry = clone.DeckStats;

            while (DeckList.DecksList.Any(d => d.Name == clone.Name))
            {
                var settings = new MetroDialogSettings {
                    AffirmativeButtonText = "Set", DefaultText = clone.Name
                };
                var name =
                    await
                    this.ShowInputAsync("Name already exists", "You already have a deck with that name, please select a different one.", settings);

                if (string.IsNullOrEmpty(name))
                {
                    return;
                }

                clone.Name = name;
            }

            DeckList.DecksList.Add(clone);
            DeckPickerList.AddAndSelectDeck(clone);
            WriteDecks();

            var newStatsEntry = DeckStatsList.Instance.DeckStats.FirstOrDefault(d => d.Name == clone.Name);

            if (newStatsEntry == null)
            {
                newStatsEntry = new DeckStats(clone.Name);
                DeckStatsList.Instance.DeckStats.Add(newStatsEntry);
            }

            //clone game stats
            if (cloneStats)
            {
                foreach (var game in originalStatsEntry.Games)
                {
                    newStatsEntry.AddGameResult(game.CloneWithNewId());
                }
                Logger.WriteLine("cloned gamestats");
            }

            DeckStatsList.Save();
            DeckPickerList.UpdateList();
        }