public static List <Card> LoadCollection(Account account, string strType = CollectionString) { List <Card> lstRet = new List <Card>(); string strPath = DustUtilityPlugin.GetFullFileName(account, strType); if (File.Exists(strPath)) { List <CachedCard> lstCachedCards = new List <CachedCard>(); using (StreamReader reader = new StreamReader(strPath)) { XmlSerializer serializer = new XmlSerializer(typeof(List <CachedCard>)); lstCachedCards = (List <CachedCard>)serializer.Deserialize(reader); } for (int i = 0; i < lstCachedCards.Count; i++) { CachedCard cachedCard = lstCachedCards[i]; lstRet.Add(new Card(cachedCard.Id, cachedCard.Count, cachedCard.IsGolden)); } } else { } return(lstRet); }
public static List <Card> LoadCollection(Account account) { List <Card> lstRet = new List <Card>(); try { string strPath = DustUtilityPlugin.GetFullFileName(account, CollectionString); if (File.Exists(strPath)) { List <CachedCard> lstCachedCards = FileManager.Load <List <CachedCard> >(strPath); for (int i = 0; i < lstCachedCards.Count; i++) { CachedCard cachedCard = lstCachedCards[i]; lstRet.Add(new Card(cachedCard.Id, cachedCard.Count, cachedCard.IsGolden)); } } else { } } catch (System.Exception ex) { Log.WriteLine($"Exception occured while loading collection: {ex}", LogType.Error); } return(lstRet); }
public static bool SaveDecks(Account account) { bool blnRet = false; List <Deck> lstDecks = Reflection.GetDecks(); if (lstDecks != null && (lstDecks.Count > 0 && lstDecks[0].Cards.Count > 0) && !s_blnSaveDecksInProgress) { s_blnSaveDecksInProgress = true; List <CachedDeck> lstCachedDecks = new List <CachedDeck>(); for (int i = 0; i < lstDecks.Count; i++) { Deck deck = lstDecks[i]; CachedDeck cachedDeck = new CachedDeck() { Id = deck.Id, Name = deck.Name, Hero = deck.Hero, IsWild = deck.IsWild, Type = deck.Type, SeasonId = deck.SeasonId, CardBackId = deck.CardBackId, HeroPremium = deck.HeroPremium, Cards = deck.Cards.ToCachedCards() }; lstCachedDecks.Add(cachedDeck); } string strPath = DustUtilityPlugin.GetFullFileName(account, DecksString); if (File.Exists(strPath)) { File.Delete(strPath); } else { } using (StreamWriter writer = new StreamWriter(strPath)) { XmlSerializer serializer = new XmlSerializer(typeof(List <CachedDeck>)); serializer.Serialize(writer, lstCachedDecks); } blnRet = true; s_blnSaveDecksInProgress = false; } else { } return(blnRet); }
private static void SaveHistory(Account account, List <CachedCardEx> lstCardsHistory) { Log.WriteLine($"Saving history for \"{account.AccountString}\"", LogType.Debug); string strPath = DustUtilityPlugin.GetFullFileName(account, HistoryString); FileManager.Write(strPath, lstCardsHistory); }
private static List <CachedCardEx> LoadHistory(Account account) { Log.WriteLine($"Loading history for \"{account.AccountString}\"", LogType.Debug); string strPath = DustUtilityPlugin.GetFullFileName(account, HistoryString); return(FileManager.Load <List <CachedCardEx> >(strPath)); }
private void OnOpenSelectionClick(object sender, System.Windows.RoutedEventArgs e) { if (m_selectionWindow == null) { List <DataGridCardItem> lstSelection = m_account.AccountPreferences.CardSelection.ConvertAll(c => { CardWrapper wrapper = new CardWrapper(new HearthMirror.Objects.Card(c.Id, c.Count, c.IsGolden)); return(DataGridCardItem.FromCardWrapper(wrapper)); }); m_selectionWindow = new CardSelectionWindow(lstSelection) { Owner = this }; m_selectionWindow.Closed += (s, args) => { m_account.AccountPreferences.CardSelection.Clear(); if (m_selectionWindow.SaveSelection) { m_account.AccountPreferences.CardSelection = m_selectionWindow.CurrentItems.ConvertAll(i => { return(new CachedCard { Id = i.Tag.Card.Id, Count = i.Tag.Card.Count, IsGolden = i.Tag.Card.Premium }); }); m_account.SavePreferenes(); } else { } openSelectionButton.IsEnabled = true; m_selectionWindow = null; }; m_selectionWindow.Show(); openSelectionButton.IsEnabled = false; } else { DustUtilityPlugin.BringWindowToFront(m_selectionWindow); } }
//public static bool SaveProcessSuccessful => s_blnSavedCollection && s_blnSavedDecks; #endregion #region SaveCollection public static bool SaveCollection(Account account, List <Card> lstCollection = null, string strType = CollectionString) { bool blnRet = false; if (lstCollection == null) { lstCollection = Reflection.GetCollection(); } else { } if (lstCollection != null && lstCollection.Count > 0 && !s_blnSaveCollectionInProgress) { s_blnSaveCollectionInProgress = true; string strPath = DustUtilityPlugin.GetFullFileName(account, strType); List <CachedCard> lstCachedCards = lstCollection.ToCachedCards(); if (File.Exists(strPath)) { File.Delete(strPath); } else { } using (StreamWriter writer = new StreamWriter(strPath)) { XmlSerializer serializer = new XmlSerializer(typeof(List <CachedCard>)); serializer.Serialize(writer, lstCachedCards); } blnRet = true; s_blnSaveCollectionInProgress = false; } else { } return(blnRet); }
public MainWindow(DustUtilityPlugin plugin, Account account, bool offlineMode) : this() { m_plugin = plugin; m_account = account; m_cardCollector = new CardCollector(this, m_account, offlineMode); if (Settings.SearchParameters == null) { m_parameters = new Parameters(true); } else { m_parameters = Settings.SearchParameters.DeepClone(); } if (!m_account.IsEmpty) { Title = $"{Title} [{m_account.BattleTag.Name} ({m_account.Region})]"; } else { } if (offlineMode) { Title = $"{Title} [OFFLINE MODE]"; switchAccountButton.IsEnabled = m_plugin.HasMultipleAccounts; } else { } //if (Settings.OfflineMode) //{ // historyButton.Visibility = System.Windows.Visibility.Visible; //} //else { } Log.WriteLine($"Account={m_account.AccountString}", LogType.Debug); Log.WriteLine($"OfflineMode={offlineMode}", LogType.Debug); }
public static List <Deck> LoadDecks(Account account) { List <Deck> lstRet = new List <Deck>(); try { string strPath = DustUtilityPlugin.GetFullFileName(account, DecksString); if (File.Exists(strPath)) { List <CachedDeck> lstCachedDecks = FileManager.Load <List <CachedDeck> >(strPath); for (int i = 0; i < lstCachedDecks.Count; i++) { CachedDeck cachedDeck = lstCachedDecks[i]; Deck deck = new Deck() { Id = cachedDeck.Id, Name = cachedDeck.Name, Hero = cachedDeck.Hero, IsWild = cachedDeck.IsWild, Type = cachedDeck.Type, SeasonId = cachedDeck.SeasonId, CardBackId = cachedDeck.CardBackId, HeroPremium = cachedDeck.HeroPremium, Cards = cachedDeck.Cards.ToCards() }; lstRet.Add(deck); } } else { } } catch (System.Exception ex) { Log.WriteLine($"Exception occured while loading decks: {ex}", LogType.Error); } return(lstRet); }
public static List <Deck> LoadDecks(Account account) { List <Deck> lstRet = new List <Deck>(); string strPath = DustUtilityPlugin.GetFullFileName(account, DecksString); if (File.Exists(strPath)) { List <CachedDeck> lstCachedDecks = new List <CachedDeck>(); using (StreamReader reader = new StreamReader(strPath)) { XmlSerializer serializer = new XmlSerializer(typeof(List <CachedDeck>)); lstCachedDecks = (List <CachedDeck>)serializer.Deserialize(reader); } for (int i = 0; i < lstCachedDecks.Count; i++) { CachedDeck cachedDeck = lstCachedDecks[i]; Deck deck = new Deck() { Id = cachedDeck.Id, Name = cachedDeck.Name, Hero = cachedDeck.Hero, IsWild = cachedDeck.IsWild, Type = cachedDeck.Type, SeasonId = cachedDeck.SeasonId, CardBackId = cachedDeck.CardBackId, HeroPremium = cachedDeck.HeroPremium, Cards = cachedDeck.Cards.ToCards() }; lstRet.Add(deck); } } else { } return(lstRet); }
private void OnCollectionInfoClick(object sender, System.Windows.RoutedEventArgs e) { //await this.ShowMessageAsync("Collection Value", $"Your collection is worth: {m_cardCollector.GetTotalDustValueForAllCards()} Dust"); if (m_collectionWindow == null) { m_collectionWindow = new CollectionInfoWindow(m_account) { Owner = this }; m_collectionWindow.Closed += (s, args) => m_collectionWindow = null; m_collectionWindow.Show(); } else { DustUtilityPlugin.BringWindowToFront(m_collectionWindow); } }
private void OnDecksClick(object sender, System.Windows.RoutedEventArgs e) { if (m_decksWindow == null) { m_decksWindow = new DecksInfoWindow(m_account) { Owner = this }; m_decksWindow.Closed += (s, args) => { m_decksWindow = null; m_account.SavePreferenes(); }; m_decksWindow.Show(); } else { DustUtilityPlugin.BringWindowToFront(m_decksWindow); } }
private static bool SaveDecks(Account account) { bool blnRet = false; List <Deck> lstAllDecks = Reflection.GetDecks(); if (lstAllDecks != null && (lstAllDecks.Count > 0 && lstAllDecks[0].Cards.Count > 0) && !s_blnSaveDecksInProgress) { s_blnSaveDecksInProgress = true; string strPath = DustUtilityPlugin.GetFullFileName(account, DecksString); List <Deck> lstDecks = new List <Deck>(lstAllDecks.Count); for (int i = 0; i < lstAllDecks.Count; i++) { if (lstAllDecks[i].Type == 1) { lstDecks.Add(lstAllDecks[i]); } else { } } FileManager.Write(strPath, lstDecks.ToCachedDecks()); blnRet = true; s_blnSaveDecksInProgress = false; } else { } return(blnRet); }
//public static bool SaveProcessSuccessful => s_blnSavedCollection && s_blnSavedDecks; #endregion #region SaveCollection private static bool SaveCollection(Account account) { bool blnRet = false; List <Card> lstCollection = Reflection.GetCollection(); if (lstCollection != null && lstCollection.Count > 0 && !s_blnSaveCollectionInProgress) { s_blnSaveCollectionInProgress = true; string strPath = DustUtilityPlugin.GetFullFileName(account, CollectionString); FileManager.Write(strPath, lstCollection.ToCachedCards()); blnRet = true; s_blnSaveCollectionInProgress = false; } else { } return(blnRet); }
private void OnSwitchAccountClick(object sender, System.Windows.RoutedEventArgs e) { DustUtilityPlugin.SwitchAccounts(); }