using System; using System.IO; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Navigation; using BetterPatchFileCreator.Code; namespace BetterPatchFileCreator.XAML.PageFuncs { /// /// Interaction logic for SelectConfig.xaml /// public partial class SelectConfigPageFunc : ObjectPageFunc { public SelectConfigPageFunc() { Configs = DataProvider.PatchConfigs; InitializeComponent(); } public PatchConfigCollection Configs { get; set; } private void ConfigListMouseDoubleClick(object sender, MouseButtonEventArgs e) { ListView lv = sender as ListView; if(lv == null) return; if(lv.SelectedItem == null) return; PatchConfig config = lv.SelectedItem as PatchConfig; if (!CheckConfigDirs(config)) { MessageBox.Show("Config corrupted. Please choose another config, the selected config will get removed."); DataProvider.PatchConfigs.Remove(config); lv.Items.Refresh(); return; } ReturnValue(lv.SelectedItem); } private static bool CheckConfigDirs(PatchConfig config) { if(!Directory.Exists(config.GetBasePath())) return false; if(!Directory.Exists(config.XmlPath)) return false; if(!Directory.Exists(config.PatchFilePath)) return false; return true; } private void CreateNewClick(object sender, RoutedEventArgs e) { var page = new CreateNewConfigPageFunc(); page.OnReturn += OnCreateNewReturn; DataProvider.MainWindowInstance.Navigate(page); } private void OnCreateNewReturn(object sender, PageFunctionEventArgs pageFunctionEventArgs) { lvConfigs.Items.Refresh(); DataProvider.MainWindowInstance.Navigate(this); } } }