} //TODO: move private void charactersWorker_DoWork(object sender, DoWorkEventArgs e) { lblCharactersStatus.Dispatcher.Invoke(() => { tbPOESESSID.IsEnabled = false; tbUsername.IsEnabled = false; cBLeague.IsEnabled = false; lblCharactersStatus.Content = "Fetching Characters..."; }); charsOnForm.Clear(); List <Character> chars = DataManagement.processJsonFromApi <List <Character> >(Properties.Settings.Default.poeApiCharacterWindow + "get-characters?account=" + Properties.Settings.Default.PoeUsername); foreach (Character c in chars) { if (c.league == Properties.Settings.Default.League)//TODO: this might need to change... { CharacterOnForm cof = new CharacterOnForm(c); charsOnForm.Add(cof); } } activeCharacters = DataManagement.LoadJson <Dictionary <string, bool> >("active_characters.json"); //TODO: handle this moronic location... foreach (CharacterOnForm cof in charsOnForm) { cof.ActivateDeactivateCharacter(activeCharacters); } charactersWorker.DoWork -= charactersWorker_DoWork; } //TODO: move
} //TODO: move private void tabsWorker_DoWork(object sender, DoWorkEventArgs e) { lblTabStatus.Dispatcher.Invoke(() => { tbPOESESSID.IsEnabled = false; tbUsername.IsEnabled = false; cBLeague.IsEnabled = false; lblTabStatus.Content = "Fetching Tabs..."; }); stashTabsOnForm.Clear(); Stash stash = DataManagement.processJsonFromApi <Stash>(Properties.Settings.Default.poeApiCharacterWindow + "get-stash-items?accountName=" + Properties.Settings.Default.PoeUsername + "&league=" + Properties.Settings.Default.League + "&tabIndex=0&tabs=1"); //TODO: this needs work foreach (Tab t in stash.tabs) { StashTabOnForm sof = new StashTabOnForm(t); stashTabsOnForm.Add(sof); } activeStashTabs = DataManagement.LoadJson <Dictionary <string, bool> >("active_stash_tabs.json"); //TODO: handle this moronic location... foreach (StashTabOnForm sof in stashTabsOnForm) { sof.ActivateDeactivateStashTab(activeStashTabs); } tabsWorker.DoWork -= tabsWorker_DoWork; } //TODO: move
} //TODO: move private void itemsWorker_DoWork(object sender, DoWorkEventArgs e) { if (!firstTimeItems) { Thread.Sleep(Properties.Settings.Default.itemsRefreshTime * 1000); } else { Thread.Sleep(3000); } firstTimeItems = false; items.Clear(); Dictionary <string, bool> chars = new Dictionary <string, bool>(); Dictionary <string, bool> stashes = new Dictionary <string, bool>(); chars = DataManagement.LoadJson <Dictionary <string, bool> >("active_characters.json"); stashes = DataManagement.LoadJson <Dictionary <string, bool> >("active_stash_tabs.json"); //item source: characters (inventory + skill tree) lblItems.Dispatcher.Invoke(() => { lblItems.Content = "Calculating Character Networth..."; }); foreach (KeyValuePair <string, bool> kvp in chars) { if (kvp.Value) { CharacterInventory c = DataManagement.processJsonFromApi <CharacterInventory>("https://pathofexile.com/character-window/get-items?eqData=false&character=" + kvp.Key); //TODO: move to app settings... foreach (Item i in c.items) { ItemOnForm iof = new ItemOnForm(i, NinjaPrices.priceOf); items.Add(iof); } SkillTree s = DataManagement.processJsonFromApi <SkillTree>("http://www.pathofexile.com/character-window/get-passive-skills?eqData=false&character=" + kvp.Key); foreach (Item i in s.items) { ItemOnForm iof = new ItemOnForm(i, NinjaPrices.priceOf); items.Add(iof); } } } lblItems.Dispatcher.Invoke(() => { lblItems.Content = "Calculating Stash Tabs Networth..."; }); Stash stash = DataManagement.processJsonFromApi <Stash>(Properties.Settings.Default.poeApiCharacterWindow + "get-stash-items?accountName=" + Properties.Settings.Default.PoeUsername + "&league=" + Properties.Settings.Default.League + "&tabIndex=-1&tabs=1"); //TODO: this needs work foreach (KeyValuePair <string, bool> kvp in stashes) { if (kvp.Value) { int tabIndex = 1000000; //this sould yield an error from the api foreach (Tab t in stash.tabs) { if (kvp.Key == t.id) { tabIndex = t.i; } } Stash s = DataManagement.processJsonFromApi <Stash>(Properties.Settings.Default.poeApiCharacterWindow + "get-stash-items?accountName=" + Properties.Settings.Default.PoeUsername + "&league=" + Properties.Settings.Default.League + "&tabIndex=" + tabIndex.ToString() + "&tabs=0"); foreach (Item i in s.items) { ItemOnForm iof = new ItemOnForm(i, NinjaPrices.priceOf); items.Add(iof); } } } itemsWorker.DoWork -= itemsWorker_DoWork; }