public ItemListSettings ImportFromCode(string code) { if (string.IsNullOrEmpty(code) || string.IsNullOrWhiteSpace(code)) { ValidationMessage = "You must enter an import/export code"; Core.Logger.Log("You must enter an import/export code"); } try { ItemListSettings newSettings; var decompressedXml = ExportHelper.Decompress(ExportCode); if (decompressedXml.StartsWith("<")) { newSettings = TrinityStorage.GetSettingsInstance <ItemListSettings>(decompressedXml); } else { JsonSerializer.Deserialize(decompressedXml, this); newSettings = this; } Grouping = GroupingType.None; using (Collection.DeferRefresh()) { SelectedItems = newSettings.SelectedItems; UpdateSelectedItems(); } ItemTypes = newSettings.ItemTypes; } catch (Exception ex) { ValidationMessage = $"Error importing itemlist. {ex.Message} {ex.InnerException}"; Core.Logger.Log("Error importing itemlist. {0} {1}", ex.Message, ex.InnerException); } return(this); }
public ConfigViewModel(TrinityStorage trinityStorage, SettingsModel model) { try { _model = model; _originalStorage = trinityStorage; _storage = new TrinityStorage(); _originalStorage.CopyTo(_storage); InitializeResetCommand(); SaveCommand = new RelayCommand( parameter => { try { SaveSettings(_storage); UILoader.CloseWindow(); } catch (Exception ex) { Core.Logger.Log("Exception in UI SaveCommand {0}", ex); } }); DumpBackpackCommand = new RelayCommand( parameter => { try { Core.Logger.Log( "\n############################################\n" + "\nDumping Backpack Items. This will hang your client. Please wait....\n" + "##########################"); UILoader.CloseWindow(); DebugUtil.DumpItems(DebugUtil.DumpItemLocation.Backpack); } catch (Exception ex) { Core.Logger.Log("Exception dumping Backpack: {0}", ex); } }); DumpQuickItemsCommand = new RelayCommand( parameter => { try { Core.Logger.Log( "\n############################################\n" + "\nQuick Dumping Items. This will hang your client. Please wait....\n" + "##########################"); UILoader.CloseWindow(); DebugUtil.DumpQuickItems(); } catch (Exception ex) { Core.Logger.Log("Exception Quick Dumping: {0}", ex); } }); DumpAllItemsCommand = new RelayCommand( parameter => { try { Core.Logger.Log( "\n############################################\n" + "\nDumping ALL Items. This will hang your client. Please wait....\n" + "##########################"); UILoader.CloseWindow(); DebugUtil.DumpItems(DebugUtil.DumpItemLocation.All); } catch (Exception ex) { Core.Logger.Log("Exception Dumping ALL Items: {0}", ex); } }); DumpSkillsAndItemsCommand = new RelayCommand( parameter => { try { UILoader.CloseWindow(); DebugUtil.LogBuildAndItems(TrinityLogLevel.Info); } catch (Exception ex) { Core.Logger.Log("Exception Dumping Skill/Rune/Passive Items: {0}", ex); } }); DumpInvalidItemsCommand = new RelayCommand( parameter => { try { UILoader.CloseWindow(); DebugUtil.LogInvalidItems(TrinityLogLevel.Info); } catch (Exception ex) { Core.Logger.Log("Exception Dumping Invalid Items: {0}", ex); } }); DumpItemSNOReference = new RelayCommand( parameter => { try { UILoader.CloseWindow(); DebugUtil.DumpItemSNOReference(); } catch (Exception ex) { Core.Logger.Log("Exception in DumpItemSNOReference: {0}", ex); } }); DumpReferenceItems = new RelayCommand( parameter => { try { UILoader.CloseWindow(); DebugUtil.DumpReferenceItems(); } catch (Exception ex) { Core.Logger.Log("Exception in DumpReferenceItems: {0}", ex); } }); GenerateGameData = new RelayCommand( parameter => { try { UILoader.CloseWindow(); //DebugUtil.GenerateGameData(); } catch (Exception ex) { Core.Logger.Log("Exception in DumpReferenceItems: {0}", ex); } }); DumpMerchantItemsCommand = new RelayCommand( parameter => { try { Core.Logger.Log( "\n############################################\n" + "\nDumping Merchant Items. This will hang your client. Please wait....\n" + "##########################"); UILoader.CloseWindow(); DebugUtil.DumpItems(DebugUtil.DumpItemLocation.Merchant); } catch (Exception ex) { Core.Logger.Log("Exception dumping Merchant: {0}", ex); } }); DumpEquippedCommand = new RelayCommand( parameter => { try { Core.Logger.Log( "\n############################################\n" + "\nDumping Equipped Items. This will hang your client. Please wait....\n" + "##########################"); UILoader.CloseWindow(); DebugUtil.DumpItems(DebugUtil.DumpItemLocation.Equipped); } catch (Exception ex) { Core.Logger.Log("Exception dumping Equipped: {0}", ex); } }); DumpGroundItemsCommand = new RelayCommand( parameter => { try { Core.Logger.Log( "\n############################################\n" + "\nDumping Ground Items. This will hang your client. Please wait....\n" + "##########################"); UILoader.CloseWindow(); DebugUtil.DumpItems(DebugUtil.DumpItemLocation.Ground); } catch (Exception ex) { Core.Logger.Log("Exception dumping Ground: {0}", ex); } }); DumpStashCommand = new RelayCommand( parameter => { try { Core.Logger.Log( "\n############################################\n" + "\nDumping Stash Items. This will hang your client. Please wait....\n" + "##########################"); UILoader.CloseWindow(); DebugUtil.DumpItems(DebugUtil.DumpItemLocation.Stash); } catch (Exception ex) { Core.Logger.Log("Exception dumping Stash: {0}", ex); } }); TestScoreCommand = new RelayCommand( parameter => { }); HelpLinkCommand = new RelayCommand( parameter => { var link = parameter as string; if (!string.IsNullOrWhiteSpace(link)) { Process.Start(link); } }); } catch (Exception ex) { Core.Logger.Error("Error creating TrinityPlugin View Model {0}", ex); } }
public void LoadSettings(TrinityStorage model, IEnumerable <string> ignorePropertyNames = null) { TrinityStorage.CopyTo(model, _storage, ignorePropertyNames); _storage.LoadDynamicSettings(); _storage.FireOnLoadedEvents(); }
private void SaveSettings(TrinityStorage storage) { storage.CopyTo(_originalStorage); _originalStorage.Save(); }