} //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
public MainWindow() { InitializeComponent(); ShowInTaskbar = false; ni.Icon = new System.Drawing.Icon("raccoonFace.ico"); ni.Visible = true; ni.DoubleClick += delegate(object sender, EventArgs args) { Show(); WindowState = WindowState.Normal; Activate(); }; ni.Text = "PoE NetWorth. Double-click to show the app when minimized"; List <League> leagues = DataManagement.processJsonFromApi <List <League> >(Properties.Settings.Default.poeApiActiveLeagues); leagues.RemoveAll(DataManagement.LeagueStartsWithSSF); foreach (League l in leagues) { cBLeague.Items.Add(l.id); } LoadUserSettings(); if (frmShown) { frm.Show(); } }
} //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 SaveTabs() { Dictionary <string, bool> ast = new Dictionary <string, bool>(); foreach (StashTabOnForm sof in stashTabsOnForm) { ast.Add(sof.id, sof.active); } DataManagement.SaveJson(ast, "active_stash_tabs.json"); //TODO: handle this moronic case... }//TODO: move
} //TODO: move private void SaveCharacters() { Dictionary <string, bool> ac = new Dictionary <string, bool>(); foreach (CharacterOnForm cof in charsOnForm) { ac.Add(cof.name, cof.active); } DataManagement.SaveJson(ac, "active_characters.json"); //TODO: handle this moronic case... }//TODO: move
private void worker_DoWork(object sender, DoWorkEventArgs e) { if (!firstTimePrices) { Thread.Sleep(Properties.Settings.Default.refreshTime * 1000); } firstTimePrices = false; lblPricesStatus.Dispatcher.Invoke(() => { lblPricesStatus.Content = "Fetching Prices..."; }); string poeNinjaApi = Properties.Settings.Default.NinjaApi; string league = "league=" + Properties.Settings.Default.League; NinjaCurrencyData fragments = DataManagement.processJsonFromApi <NinjaCurrencyData>(poeNinjaApi + "GetFragmentOverview" + "?" + league); NinjaCurrencyData currencies = DataManagement.processJsonFromApi <NinjaCurrencyData>(poeNinjaApi + "GetCurrencyOverview" + "?" + league); NinjaItemData essences = DataManagement.processJsonFromApi <NinjaItemData>(poeNinjaApi + "GetEssenceOverview" + "?" + league); NinjaItemData divCards = DataManagement.processJsonFromApi <NinjaItemData>(poeNinjaApi + "GetDivinationCardsOverview" + "?" + league); NinjaItemData prophecies = DataManagement.processJsonFromApi <NinjaItemData>(poeNinjaApi + "GetProphecyOverview" + "?" + league); NinjaItemData uniqueMap = DataManagement.processJsonFromApi <NinjaItemData>(poeNinjaApi + "GetUniqueMapOverview" + "?" + league); NinjaItemData uniqueJewels = DataManagement.processJsonFromApi <NinjaItemData>(poeNinjaApi + "GetUniqueJewelOverview" + "?" + league); NinjaItemData uniqueFlasks = DataManagement.processJsonFromApi <NinjaItemData>(poeNinjaApi + "GetUniqueFlaskOverview" + "?" + league); NinjaItemData uniqueWeapons = DataManagement.processJsonFromApi <NinjaItemData>(poeNinjaApi + "GetUniqueWeaponOverview" + "?" + league); NinjaItemData uniqueArmours = DataManagement.processJsonFromApi <NinjaItemData>(poeNinjaApi + "GetUniqueArmourOverview" + "?" + league); NinjaItemData uniqueAccessories = DataManagement.processJsonFromApi <NinjaItemData>(poeNinjaApi + "GetUniqueAccessoryOverview" + "?" + league); NinjaItemData maps = DataManagement.processJsonFromApi <NinjaItemData>(poeNinjaApi + "GetMapOverview" + "?" + league); List <NinjaCurrencyData> ccyPrices = new List <NinjaCurrencyData>(); ccyPrices.Add(fragments); ccyPrices.Add(currencies); List <NinjaItemData> itemPrices = new List <NinjaItemData>(); itemPrices.Add(essences); itemPrices.Add(divCards); itemPrices.Add(prophecies); itemPrices.Add(uniqueMap); itemPrices.Add(uniqueJewels); itemPrices.Add(uniqueFlasks); itemPrices.Add(uniqueWeapons); itemPrices.Add(uniqueArmours); itemPrices.Add(uniqueAccessories); itemPrices.Add(maps); NinjaPrices.RefreshPrices(ccyPrices, itemPrices); worker.DoWork -= worker_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; }