private void BtnOkClick(object sender, RoutedEventArgs e) { btnOk.IsEnabled = false; pbLoading.Visibility = Visibility.Visible; var chara = (CharWrapper)cbChars.SelectedItem; var worker = new BackgroundWorker(); _getStandingAccess = true; worker.RunWorkerCompleted += delegate { if (_getStandingAccess == true) { DialogResult = true; } else { Dispatcher.Invoke(new Action(Close)); } }; worker.DoWork += delegate { var sheet = new CharacterSheet(chara.KeyId, chara.VCode, chara.CharId.ToString(CultureInfo.InvariantCulture)); sheet.Query(); foreach (CharacterSheet.Skill skill in sheet.skills) { if (skill.typeID == 3446) //"Broker Relations" { profile.brokerRelations = skill.level; } if (skill.typeID == 16622) //"Accounting" { profile.accounting = skill.level; } } Dispatcher.Invoke(new Action(delegate { var aisfw = new ApiImportSelectFactionWindow(chara) { Topmost = true, Top = Top + 10, Left = Left + 10, }; _getStandingAccess = aisfw.ShowDialog(); if (_getStandingAccess == true) { profile.corpStanding = aisfw.corpStanding; profile.factionStanding = aisfw.factionStanding; profile.corporation = aisfw.corpName; profile.faction = aisfw.factionName; } else { _getStandingAccess = false; } })); profile.charName = chara.Charname; profile.charId = chara.CharId; if (profile.corporation != null) { profile.profileName = chara.Charname + " - " + profile.corporation; } else { profile.profileName = chara.Charname + " - no corporation"; } }; worker.RunWorkerAsync(); }
private void BtnOkClick(object sender, RoutedEventArgs e) { btnOk.IsEnabled = false; pbLoading.Visibility = Visibility.Visible; var chara = (CharWrapper) cbChars.SelectedItem; var worker = new BackgroundWorker(); _getStandingAccess = true; worker.RunWorkerCompleted += delegate { if (_getStandingAccess == true) DialogResult = true; else Dispatcher.Invoke(new Action(Close)); }; worker.DoWork += delegate { var sheet = new CharacterSheet(chara.KeyId, chara.VCode, chara.CharId.ToString(CultureInfo.InvariantCulture)); sheet.Query(); foreach (CharacterSheet.Skill skill in sheet.skills) { if (skill.typeID == 3446) //"Broker Relations" Settings.BrokerRelations = skill.level; if (skill.typeID == 16622) //"Accounting" Settings.Accounting = skill.level; } Dispatcher.Invoke(new Action(delegate { var aisfw = new ApiImportSelectFactionWindow(chara) { Topmost = true, Top = Top + 10, Left = Left + 10, }; _getStandingAccess = aisfw.ShowDialog(); if (_getStandingAccess == true) { Settings.CorpStanding = aisfw.Corp; Settings.FactionStanding = aisfw.Faction; } else { _getStandingAccess = false; } })); Settings.ProfileName = chara.Charname; }; worker.RunWorkerAsync(); }