示例#1
0
 private void ExportCollectionButton_OnClick(object sender, RoutedEventArgs e)
 {
     try {
         var game = ProcessMonitor.RunningGameType;
         if (!game.HasValue)
         {
             return;
         }
         var collection = ArchetypeManager.GetCollection(game.Value);
         if (collection != null)
         {
             string export = ArchetypeManager.GetExportedDeck(game.Value, collection);
             if (WindowsHelper.TryCopyToClipboard(export, out string blockingWindowText))
             {
                 MessageBox.Show("Collection exported to clipboard", "Success");
             }
             else
             {
                 MessageBox.Show(blockingWindowText != null ? $"Unable to access clipboard.\nPlease close this window: {blockingWindowText}" : "Unable to access clipboard.", "Error");
             }
         }
         else
         {
             MessageBox.Show("Something went wrong...", "Error");
         }
     } catch (Exception ex) {
         Logger.LogError(ex.ToString());
         MessageBox.Show($"Something went wrong...\n\n{ex.Message}", "Error");
     }
 }
示例#2
0
 private void ExportPlayerDeckToFileMenuItem_OnClick(object sender, RoutedEventArgs e)
 {
     try
     {
         var deck = (((sender as MenuItem)?.CommandParameter as ContextMenu)?.PlacementTarget as ListViewItem)?.DataContext as Deck;
         if (deck == null)
         {
             return;
         }
         var export = new StringBuilder();
         export.AppendLine($"### {deck.Name} ###");
         export.Append(ArchetypeManager.GetExportedDeck(deck.GameType, deck.Cards));
         SaveFileDialog saveDeck = new SaveFileDialog
         {
             Title            = "Export Deck",
             FileName         = string.Join("", deck.Name.Split(Path.GetInvalidFileNameChars())),
             InitialDirectory = Logger.GameDataDirectory,
             Filter           = "Deck tracker deck file (*.dtdeck)|*.dtdeck",
             RestoreDirectory = true
         };
         if (saveDeck.ShowDialog() == true)
         {
             File.WriteAllText(saveDeck.FileName, export.ToString());
             MessageBox.Show($"{deck.Name} exported to\n{saveDeck.FileName}", "Success");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show($"Something went wrong...\n{ex.Message}", "Error");
     }
 }
示例#3
0
 private void ExportOpponentDecksMenuItem_OnClick(object sender, RoutedEventArgs e)
 {
     try {
         var deck        = DecksListView.SelectedItem as Deck;
         var againstDeck = (((sender as MenuItem)?.CommandParameter as ContextMenu)?.PlacementTarget as ListViewItem)?.DataContext as AgainstDeck;
         if (deck == null || againstDeck == null)
         {
             return;
         }
         var export = new StringBuilder();
         int count  = 0;
         foreach (var game in againstDeck.Games)
         {
             if (!model.GameModes.First(mode => mode.Name == game.Mode).IsEnabled)
             {
                 continue;
             }
             if (export.Length > 0)
             {
                 export.AppendLine();
             }
             export.AppendLine($"### {game.OpponentDeck.Name} ### {game.Start:F} ###");
             export.Append(ArchetypeManager.GetExportedDeck(game.GameType, game.OpponentDeck.Cards));
             count++;
         }
         if (WindowsHelper.TryCopyToClipboard(export.ToString(), out string blockingWindowText))
         {
             MessageBox.Show($"{count} opponent decks have been exported to clipboard", "Success");
         }
         else
         {
             MessageBox.Show(blockingWindowText != null ? $"Unable to access clipboard.\nPlease close this window: {blockingWindowText}" : "Unable to access clipboard.", "Error");
         }
     } catch (Exception ex) {
         Logger.LogError(ex.ToString());
         MessageBox.Show($"Something went wrong...\n{ex.Message}", "Error");
     }
 }
 private void ExportPlayerDeckMenuItem_OnClick(object sender, RoutedEventArgs e)
 {
     try {
         var deck = (((sender as MenuItem)?.CommandParameter as ContextMenu)?.PlacementTarget as ListViewItem)?.DataContext as Deck;
         if (deck == null)
         {
             return;
         }
         var export = new StringBuilder();
         export.AppendLine($"### {deck.Name} ###");
         export.Append(ArchetypeManager.GetExportedDeck(deck.GameType, deck.Cards));
         if (WindowsHelper.TryCopyToClipboard(export.ToString(), out string blockingWindowText))
         {
             MessageBox.Show("Last played deck has been exported to clipboard", "Success");
         }
         else
         {
             MessageBox.Show(blockingWindowText != null ? $"Unable to access clipboard.\nPlease close this window: {blockingWindowText}" : "Unable to access clipboard.", "Error");
         }
     } catch (Exception ex) {
         MessageBox.Show($"Something went wrong...\n{ex.Message}", "Error");
     }
 }