private void c_InjectFile_Click(object sender, EventArgs e)
 {
     OpenFileDialog ofd = new OpenFileDialog();
     ofd.Multiselect = true;
     if (ofd.ShowDialog() == DialogResult.OK)
     {
         Forms.EntryAction ea = new Party_Buffalo.Forms.EntryAction(ofd.FileNames, ((Folder)treeView1.SelectedNode.Tag), Party_Buffalo.Forms.EntryAction.Method.Inject);
         ea.ShowDialog(this);
     }
 }
 private void c_InjectFolder_Click(object sender, EventArgs e)
 {
     if (!Aero)
     {
         FolderBrowserDialog fbd = new FolderBrowserDialog();
         if (fbd.ShowDialog() == DialogResult.OK)
         {
             Forms.EntryAction ea = new Party_Buffalo.Forms.EntryAction(new string[] { fbd.SelectedPath }, (Folder)treeView1.SelectedNode.Tag, Party_Buffalo.Forms.EntryAction.Method.Inject);
             ea.ShowDialog(this);
         }
     }
     else
     {
         CommonOpenFileDialog cfd = new CommonOpenFileDialog();
         cfd.IsFolderPicker = true;
         cfd.Multiselect = true;
         if (cfd.ShowDialog() == CommonFileDialogResult.Ok)
         {
             Forms.EntryAction ea = new Party_Buffalo.Forms.EntryAction(cfd.FileNames.ToArray(), (Folder)treeView1.SelectedNode.Tag, Party_Buffalo.Forms.EntryAction.Method.Inject);
             ea.ShowDialog(this);
         }
     }
 }
 private void c_Delete_Click(object sender, EventArgs e)
 {
     // String.format is a little redundant here...
     DialogResult dr = DialogResult.No;
     if (!Aero)
     {
         dr = MessageBox.Show(string.Format("Are you sure you want to delete the selected{0}?", (listView1.SelectedItems.Count > 1) ? " " + listView1.SelectedItems.Count.ToString() + " items" : " item"), "Confirm Deletion", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
     }
     else
     {
         TaskDialog td = new TaskDialog();
         td.Caption = "Confirm Deletion";
         td.InstructionText = "Confirm Deletion";
         td.Text = string.Format("Are you sure you want to delete the selected{0}?", (listView1.SelectedItems.Count > 1) ? " " + listView1.SelectedItems.Count.ToString() + " items" : " item");
         td.StandardButtons = TaskDialogStandardButtons.Yes | TaskDialogStandardButtons.No | TaskDialogStandardButtons.Cancel;
         if (td.ShowDialog(this.Handle) == TaskDialogResult.Yes)
         {
             dr = DialogResult.Yes;
         }
     }
     if (dr == DialogResult.Yes)
     {
         List<Entry> items = new List<Entry>();
         foreach (ListViewItem li in listView1.SelectedItems)
         {
             items.Add((Entry)li.Tag);
         }
         Forms.EntryAction ea = new Party_Buffalo.Forms.EntryAction(items.ToArray(), Party_Buffalo.Forms.EntryAction.Method.Delete, "");
         ea.ShowDialog();
     }
 }
 private void c_Extract_Click(object sender, EventArgs e)
 {
     if (listView1.SelectedItems.Count == 1 && !((Entry)listView1.FocusedItem.Tag).IsFolder)
     {
         SaveFileDialog sfd = new SaveFileDialog();
         sfd.FileName = ((Entry)listView1.FocusedItem.Tag).Name;
         if (sfd.ShowDialog() == DialogResult.OK)
         {
             Forms.EntryAction ea = new Party_Buffalo.Forms.EntryAction(new Entry[] { ((Entry)listView1.FocusedItem.Tag) }, Party_Buffalo.Forms.EntryAction.Method.Extract, sfd.FileName);
             ea.ShowDialog();
         }
     }
     else
     {
         if (!Aero)
         {
             FolderBrowserDialog fbd = new FolderBrowserDialog();
             if (fbd.ShowDialog() == DialogResult.OK)
             {
                 List<Entry> entries = new List<Entry>();
                 foreach (ListViewItem li in listView1.SelectedItems)
                 {
                     entries.Add((Entry)li.Tag);
                 }
                 Forms.EntryAction ea = new Party_Buffalo.Forms.EntryAction(entries.ToArray(), Party_Buffalo.Forms.EntryAction.Method.Extract, fbd.SelectedPath);
                 ea.ShowDialog();
             }
         }
         else
         {
             CommonOpenFileDialog cfd = new CommonOpenFileDialog();
             cfd.IsFolderPicker = true;
             cfd.Multiselect = false;
             if (cfd.ShowDialog() == CommonFileDialogResult.Ok)
             {
                 List<Entry> entries = new List<Entry>();
                 foreach (ListViewItem li in listView1.SelectedItems)
                 {
                     entries.Add((Entry)li.Tag);
                 }
                 Forms.EntryAction ea = new Party_Buffalo.Forms.EntryAction(entries.ToArray(), Party_Buffalo.Forms.EntryAction.Method.Extract, cfd.FileName);
                 ea.ShowDialog();
             }
         }
     }
 }
 private void t_Extract_Click(object sender, EventArgs e)
 {
     if (!Aero)
     {
         FolderBrowserDialog fbd = new FolderBrowserDialog();
         if (fbd.ShowDialog() == DialogResult.OK)
         {
             Forms.EntryAction ea = new Party_Buffalo.Forms.EntryAction(new Entry[] { (Folder)rightClickedNode.Tag }, Party_Buffalo.Forms.EntryAction.Method.Extract, fbd.SelectedPath);
             ea.ShowDialog();
         }
     }
     else
     {
         CommonOpenFileDialog cfd = new CommonOpenFileDialog();
         cfd.IsFolderPicker = true;
         cfd.Multiselect = false;
         if (cfd.ShowDialog() == CommonFileDialogResult.Ok)
         {
             Forms.EntryAction ea = new Party_Buffalo.Forms.EntryAction(new Entry[] { (Folder)rightClickedNode.Tag }, Party_Buffalo.Forms.EntryAction.Method.Extract, cfd.FileName);
             ea.ShowDialog();
         }
     }
 }
        void Watcher_Created(object sender, System.IO.FileSystemEventArgs e)
        {
            // Get the directory that the temporary file was moved to
            string OutputDirectory = System.IO.Directory.GetParent(e.FullPath).FullName;
            // Delete the temporary file
            try
            {
                System.IO.File.Delete(e.FullPath);
            }
            catch
            {
                System.Threading.Thread.Sleep(500);
                System.IO.File.Delete(e.FullPath);
            }
            // Disable the watchers
            foreach (System.IO.FileSystemWatcher Watcher in Watchers)
            {
                Watcher.EnableRaisingEvents = false;
            }

            this.Invoke((MethodInvoker)delegate
            {
                // Round up the entries!
                List<Entry> entries = new List<Entry>();
                foreach (ListViewItem li in listView1.SelectedItems)
                {
                    entries.Add((Entry)li.Tag);
                }

                // If we're dealing with one entry and it's a file, we'll probably want to
                if (entries.Count == 1 && !((Entry)listView1.FocusedItem.Tag).IsFolder)
                {
                    OutputDirectory += "\\" + ((Entry)listView1.FocusedItem.Tag).Name;
                }

                // Start extracting
                Forms.EntryAction ea = new Party_Buffalo.Forms.EntryAction(entries.ToArray(), Party_Buffalo.Forms.EntryAction.Method.Extract, OutputDirectory);
                ea.ShowDialog();
            });
        }
        private void t_Delete_Click(object sender, EventArgs e)
        {
            DialogResult dr = DialogResult.No;
            if (!Aero)
            {
                dr = MessageBox.Show("Are you sure you want to delete the selected folder?", "Confirm Deletion", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            }
            else
            {
                TaskDialog td = new TaskDialog();
                td.Caption = "Confirm Deletion";
                td.InstructionText = "Confirm Deletion";
                td.Text = string.Format("Are you sure you want to delete folder \"{0}\"?", rightClickedNode.Name);
                td.StandardButtons = TaskDialogStandardButtons.Yes | TaskDialogStandardButtons.No | TaskDialogStandardButtons.Cancel;
                if (td.ShowDialog(this.Handle) == TaskDialogResult.Yes)
                {
                    dr = DialogResult.Yes;
                }
            }

            if (dr == DialogResult.Yes)
            {
                List<Entry> items = new List<Entry>();
                items.Add((Entry)rightClickedNode.Tag);
                if (rightClickedNode == treeView1.SelectedNode)
                {
                    foreach (ListViewItem li in listView1.SelectedItems)
                    {
                        items.Add((Entry)li.Tag);
                    }
                }
                Forms.EntryAction ea = new Party_Buffalo.Forms.EntryAction(items.ToArray(), Party_Buffalo.Forms.EntryAction.Method.Delete, "");
                ea.ShowDialog();
                // Remove those treeview items
                foreach (Entry en in items)
                {
                    if (en.IsFolder)
                    {
                        try
                        {
                            treeView1.SelectedNode.Nodes.Find(en.Name, false)[0].Remove();
                        }
                        catch { }
                    }
                    if (rightClickedNode == treeView1.SelectedNode)
                    {
                        listView1.Items.Find(en.Name, false)[0].Remove();
                    }
                }
                ((Folder)rightClickedNode.Tag).Reload();
            }
        }
 private void m_RestoreImage_Click(object sender, EventArgs e)
 {
     OpenFileDialog ofd = new OpenFileDialog();
     ofd.Filter = "Backup File(*.bin)|*.bin";
     if (ofd.ShowDialog() == DialogResult.OK)
     {
         Forms.EntryAction ea = new Party_Buffalo.Forms.EntryAction(Drive, Party_Buffalo.Forms.EntryAction.Method.Restore, ofd.FileName);
         ea.ShowDialog();
     }
 }
 private void m_QuickAdd_Click(object sender, EventArgs e)
 {
     OpenFileDialog ofd = new OpenFileDialog();
     ofd.Multiselect = true;
     if (ofd.ShowDialog() == DialogResult.OK)
     {
         Forms.EntryAction ea = new Party_Buffalo.Forms.EntryAction(ofd.FileNames, Drive, Party_Buffalo.Forms.EntryAction.Method.Inject);
         ea.ShowDialog(this);
     }
 }
 private void m_ExtractSecuritySector_Click(object sender, EventArgs e)
 {
     SaveFileDialog sfd = new SaveFileDialog();
     sfd.Filter = "Backup File(*.bin)|*.bin";
     sfd.FileName = "Security Sector " + Drive.LengthFriendly + ".bin";
     if (sfd.ShowDialog() == DialogResult.OK)
     {
         Forms.EntryAction ea = new Party_Buffalo.Forms.EntryAction(Drive, Party_Buffalo.Forms.EntryAction.Method.ExtractSS, sfd.FileName);
         ea.ShowDialog();
     }
 }
 private void menuItem2_Click(object sender, EventArgs e)
 {
     Forms.CustomBackup cb = new Party_Buffalo.Forms.CustomBackup();
     if (cb.ShowDialog() == DialogResult.OK)
     {
         if (!Aero)
         {
             FolderBrowserDialog fbd = new FolderBrowserDialog();
             if (fbd.ShowDialog() == DialogResult.OK)
             {
                 List<Folder> Partitions = new List<Folder>();
                 for (int i = 0; i < treeView1.Nodes[0].Nodes.Count; i++)
                 {
                     Partitions.Add((Folder)treeView1.Nodes[0].Nodes[i].Tag);
                 }
                 Forms.EntryAction ea = new Party_Buffalo.Forms.EntryAction(Partitions.ToArray(), Party_Buffalo.Forms.EntryAction.Method.Extract, cb.FoldersToSkip, fbd.SelectedPath);
                 ea.ShowDialog();
             }
         }
         else
         {
             CommonOpenFileDialog cfd = new CommonOpenFileDialog();
             cfd.Multiselect = false;
             cfd.IsFolderPicker = true;
             if (cfd.ShowDialog() == CommonFileDialogResult.Ok)
             {
                 List<Folder> Partitions = new List<Folder>();
                 for (int i = 0; i < treeView1.Nodes[0].Nodes.Count; i++)
                 {
                     Partitions.Add((Folder)treeView1.Nodes[0].Nodes[i].Tag);
                 }
                 Forms.EntryAction ea = new Party_Buffalo.Forms.EntryAction(Partitions.ToArray(), Party_Buffalo.Forms.EntryAction.Method.Extract, cb.FoldersToSkip, cfd.FileName);
                 ea.ShowDialog();
             }
         }
     }
 }