public MainWindow() { Instance = this; InitializeComponent(); loadConfiguration(); Registry.SetValue("HKEY_CURRENT_USER\\Software\\Thingamahoochie\\WinMerge\\Backup", "EnableFile", (UInt32)0, RegistryValueKind.DWord); if (Directory.Exists(LeftPath)) { tabControl.SelectedIndex = 1; } new PleaseWait(null, "Updating Index...", delegate(PleaseWait progress) { NameRegistry.Files = NameRegistry.Groups = new NameRegistry("reg_file.txt"); NameRegistry.Types = new NameRegistry("reg_type.txt"); NameRegistry.Properties = new NameRegistry("reg_property.txt"); if (!File.Exists("Not present in Spore")) { File.WriteAllText("Not Present in Spore", ""); File.SetAttributes("Not Present in Spore", FileAttributes.ReadOnly); } FilesEditor.SetPath(0, LeftPath, progress); }).ShowDialog(); }
void Btn_Unpack_Click(object sender, RoutedEventArgs e) { var filenames = (from ListViewItem item in PackageList.Items select item.Content as String).ToArray(); new PleaseWait(null, "Unpacking", delegate(PleaseWait progress) { try { FilesEditor.SetPath(0, null, progress); Directory.CreateDirectory(LeftPath); var streams = (from f in filenames select File.OpenRead(f) as Stream).ToArray(); progress.beginTask(0.3, 1.0); var b = new PackageUnpack(streams, LeftPath, progress); progress.endTask(); progress.beginTask(0.7, 1.0); FilesEditor.SetPath(0, LeftPath, progress); progress.endTask(); } catch (Exception exc) { progress.complete(); MessageBox.Show(exc.ToString(), "Error unpacking packages"); } }).ShowDialog(); }
void Unpack_Mod_Click(object sender, RoutedEventArgs e) { // TODO: PleaseWait try { string path = buildRightPath(ModPath.Text); if (Directory.Exists(path)) { if (MessageBox.Show("This will overwrite any changes you have made\nsince the last time you packed this mod!\n\nAre you sure?", "Warning", MessageBoxButton.YesNo) != MessageBoxResult.Yes) { return; } } FilesEditor.SetPath(1, null, null); var stream = File.OpenRead(ModPath.Text); var b = new PackageUnpack(new Stream[] { stream }, path, null); checkModReady(); } catch (Exception exc) { MessageBox.Show(exc.ToString(), "Error unpacking mod"); } }
void checkModReady() { FilesEditor.SetPath(1, null, null); if (RightPath != null) { FullTextIndex.ResetPath(RightPath); } if (ModPath.Text != "") { RightPath = buildRightPath(ModPath.Text); Unpack_Mod.IsEnabled = File.Exists(ModPath.Text); if (Directory.Exists(RightPath)) { FilesEditor.SetPath(1, RightPath, null); TabFilesEditor.IsEnabled = true; Pack_Mod.IsEnabled = true; Unpack_Mod_Doc.Text = "You have unpacked this mod. Edit it in the Files tab."; Pack_Mod_Doc.Text = "You must pack the mod to see changes in Spore."; } else { TabFilesEditor.IsEnabled = false; Pack_Mod.IsEnabled = false; Unpack_Mod_Doc.Text = "You must unpack this mod before editing it."; Pack_Mod_Doc.Text = ""; } } else { Unpack_Mod.IsEnabled = false; Pack_Mod.IsEnabled = false; Unpack_Mod_Doc.Text = ""; Pack_Mod_Doc.Text = ""; RightPath = null; } }