示例#1
0
        private void btnSaveProfile_Click(object sender, EventArgs e)
        {
            string str = Interaction.InputBox("Please enter a name for the profile:");

            if (str == null || str.Length <= 0)
            {
                return;
            }

            if (!Directory.Exists("profiles"))
            {
                Directory.CreateDirectory("profiles");
            }

            if (System.IO.File.Exists("profiles/" + str + ".xml"))
            {
                if (MessageBox.Show("There is already a profile file '" + str + ".xml'. Overwrite?", "Warning", MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.Yes)
                {
                    return;
                }
            }


            DiffProfile p = new DiffProfile();

            p.Name = str;
            p.Generate(lstPatches);
            p.Save("profiles/" + str + ".xml");
        }
示例#2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter           = "Exe file (*.exe)|*.exe";
            sfd.FileName         = file.FileInfo.Name.Replace(".xdiff", "_patched.exe");
            sfd.DefaultExt       = "*.exe";
            sfd.OverwritePrompt  = true;
            sfd.InitialDirectory = new System.IO.FileInfo(txtExeFile.Text).DirectoryName;

            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                System.IO.FileStream str     = new System.IO.FileStream("lastPatches.xml", System.IO.FileMode.Create, System.IO.FileAccess.Write);
                SoapFormatter        soap    = new SoapFormatter();
                IEnumerable <int>    patches = rightPatches.Where(patch => patch != int.MaxValue);
                soap.Serialize(str, patches.ToArray <int>());
                str.Close();

                //int i = 0;
                //foreach (KeyValuePair<int, DiffPatchBase> p in file.xPatches)
                //{
                //    if (p.Value is DiffPatchGroup)
                //        continue;
                //    /*if (rightPatches.Contains(p.Key))
                //        ((DiffPatch)file.xPatches[p.Key]).Apply = true;
                //    else
                //        ((DiffPatch)file.xPatches[p.Key]).Apply = false;*/
                //}

                foreach (TreeNode n in lstPatches.Nodes)
                {
                    if (n.Tag is DiffPatch)
                    {
                        ((DiffPatch)n.Tag).Apply = n.Checked;
                    }

                    foreach (TreeNode m in n.Nodes)
                    {
                        if (m.Tag is DiffPatch)
                        {
                            ((DiffPatch)m.Tag).Apply = m.Checked;
                        }
                    }
                }

                /*foreach (KeyValuePair<string, DiffPatch> p in indexedPatches)
                 * {
                 *  if (rightPatches.Contains(i))
                 *      file.Patches[p.Key].Apply = true;
                 *  else
                 *      file.Patches[p.Key].Apply = false;
                 *  i++;
                 * }*/

                DiffProfile profile = new DiffProfile();
                profile.Name = "Last Patches";
                profile.Generate(lstPatches);
                profile.Save("lastPatches.xml");

                file.Patch(txtExeFile.Text, sfd.FileName);
            }
        }