private void loadBtn_Click(object sender, RoutedEventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "json (*.json)|*.json"; dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); if (dlg.ShowDialog() == true) { using (StreamReader r = new StreamReader(dlg.FileName)) { string json = r.ReadToEnd(); AppDataManager.Instance().MyBuildSkillGems.Clear(); var list = JsonConvert.DeserializeObject <ObservableCollection <SkillGem> >(json); foreach (var item in list) { //find corresponding gem in the AllList var gem = AllSkillGems.Where(x => x.Name == item.Name).SingleOrDefault(); if (gem != null) { gem.CharacterClass = AppDataManager.Instance().Settings.User.Class; AppDataManager.Instance().MyBuildSkillGems.Add(gem); } } } } }
public void UpdateGemsPerLevel() { SkillsPerLevel.Clear(); var groupedList = AppDataManager.Instance().MyBuildSkillGems.GroupBy(gem => gem.RequiredLevel).OrderBy(grp => Convert.ToInt32(grp.Key)); foreach (var level in groupedList) { SkillGemPerLevel gemPerLevel = new SkillGemPerLevel(); int groupLevel = Convert.ToInt32(level.Key); foreach (var gem in level) { gemPerLevel.GroupGemsPerLevel.Add(gem); } //Display that they are available with a different UI gemPerLevel.Available = groupLevel <= CurrentLevel; gemPerLevel.SectionTitle = $"Level {level.Key}"; //gemPerLevel.SectionTitle = gemPerLevel.Available ? $"Level {level.Key} UNLOCKED":$"Level {level.Key}"; SkillsPerLevel.Add(gemPerLevel); } }
private void gemLabel_MouseDoubleClick(object sender, MouseButtonEventArgs e) { GemLabelMouseDoubleClick?.Invoke(sender, e); var label = sender as TextBox; AppDataManager.Instance().MyBuildSkillGems.Remove((SkillGem)label.DataContext); // UpdateGemsPerLevel(); }
private void cbClass_SelectionChanged(object sender, SelectionChangedEventArgs e) { string charClass = ((sender as ComboBox).SelectedItem as ComboBoxItem).Content as string; AppDataManager.Instance().Settings.User.Class = charClass; //refresh all build gem quest reward by chosen class foreach (SkillGem gem in AppDataManager.Instance().MyBuildSkillGems) { if (gem.QuestRewards == null) { continue; } gem.CharacterClass = charClass; } }
private void saveBtn_Click(object sender, RoutedEventArgs e) { //Save the gems in the build into a list var json = JsonConvert.SerializeObject(AppDataManager.Instance().MyBuildSkillGems); //TODO:Only save gem name SaveFileDialog dlg = new SaveFileDialog(); dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); dlg.FileName = "MyBuildSkillGems.json"; dlg.Filter = "json (*.json)|*.json"; if (dlg.ShowDialog() == true) { //save File.WriteAllText(dlg.FileName, json); } }
private void Save() { AppDataManager.Instance().Settings.User.Character = character.Text; AppDataManager.Instance().Settings.User.POEFolder = poeFolder.Text; AppDataManager.Instance().Settings.User.Class = cbClass.Text; for (int i = 0; i < tabActs.Items.Count; i++) { TabItem tabItem = tabActs.Items[i] as TabItem; TextBox txtBox = tabItem.Content as TextBox; string value = txtBox.Text; AppDataManager.Instance().Settings.User.ActNotes[$"Act{i+1}"] = value; } AppDataManager.Instance().Settings.Save(); }
private void Load() { AppDataManager.Instance().Settings.Load(); poeFolder.Text = AppDataManager.Instance().Settings.User.POEFolder; character.Text = AppDataManager.Instance().Settings.User.Character; cbClass.Text = AppDataManager.Instance().Settings.User.Class; for (int i = 0; i < tabActs.Items.Count; i++) { TabItem tabItem = tabActs.Items[i] as TabItem; TextBox txtBox = tabItem.Content as TextBox; string key = $"Act{i + 1}"; if (AppDataManager.Instance().Settings.User.ActNotes.ContainsKey(key)) { txtBox.Text = AppDataManager.Instance().Settings.User.ActNotes[key]; } } }
public void Add(SkillGem gem) { AppDataManager.Instance().MyBuildSkillGems.Add(gem); // UpdateGemsPerLevel(); }
public SkillGemsPerLevelCtrl() { //MyBuildSkillGems = new ObservableCollection<SkillGem>(); AppDataManager.Instance().MyBuildSkillGems.CollectionChanged += OnMyBuildSkillGemsChanged; InitializeComponent(); }