/// <summary> /// Add silkroad server information /// </summary> private void AddSilkroad() { // Build dialog to search the Silkroad path VistaFolderBrowserDialog folderBrowser = new VistaFolderBrowserDialog { Description = "Please, select your Silkroad Online folder", RootFolder = Environment.SpecialFolder.MyComputer, UseDescriptionForTitle = true }; // Confirm that the folder has been selected if (folderBrowser.ShowDialog() != true) { return; } // Prepares the extractor to be shown as dialog Pk2Extractor extractorWindow = new Pk2Extractor { // Set parent to lock it as dialog Owner = m_Window }; // Creates the viewmodel that will handle all the process Pk2ExtractorViewModel extractorWindowVM = new Pk2ExtractorViewModel(extractorWindow, folderBrowser.SelectedPath); // Set the viewmodel extractorWindow.DataContext = extractorWindowVM; // Confirm that pk2 has been closed/extracted successfully if (extractorWindow.ShowDialog() != true) { return; } // Remove duplicates, just in case! for (int i = 0; i < Settings.Silkroads.Count; i++) { if (Settings.Silkroads[i].ID == extractorWindowVM.Silkroad.ID) { Settings.Silkroads.RemoveAt(i--); } } // Fix duplicated names, just in case! for (int i = 0; i < Settings.Silkroads.Count; i++) { if (Settings.Silkroads[i].Name == extractorWindowVM.Silkroad.Name) { extractorWindowVM.Silkroad.Name += "*"; i = 0; } } // Added Successfully Settings.Silkroads.Add(extractorWindowVM.Silkroad); Settings.Save(); WriteLine("Silkroad Server [" + extractorWindowVM.Silkroad.Name + "] has been added"); }
/// <summary> /// Updates the silkroad server information from selected one /// </summary> /// <param name="Silkroad">Silkroad selected : <see cref="SilkroadSetupViewModel"/></param> private void UpdateSilkroad(object SelectedSilkroad) { // Make sure it's selected if (SelectedSilkroad != null) { var setup = (SilkroadSetupViewModel)SelectedSilkroad; // Prepares the extractor to be shown as dialog Pk2Extractor extractorWindow = new Pk2Extractor { // Set parent to lock it as dialog Owner = m_Window }; // Creates the viewmodel that will handle all the process Pk2ExtractorViewModel extractorWindowVM = new Pk2ExtractorViewModel(extractorWindow, setup.Path, setup); // Set the viewmodel extractorWindow.DataContext = extractorWindowVM; // Show extractor dialog extractorWindow.ShowDialog(); // Fix duplicated names, just in case! for (int i = 0; i < Settings.Silkroads.Count; i++) { if (Settings.Silkroads[i] != setup && Settings.Silkroads[i].Name == setup.Name) { setup.Name += "*"; i = 0; } } // Override the changes no matter what Settings.SaveAsync(); WriteLine("Silkroad Server [" + setup.Name + "] has been updated"); } }