コード例 #1
0
ファイル: FormMain.cs プロジェクト: ConorSheehan1/nbuexplorer
        private void exportSelectedFolderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (treeViewDirs.SelectedNode != null)
            {
                if (Fbd.ShowDialog() == DialogResult.OK)
                {
                    overWriteDialog = null;                     // reset possible "yes to all / no to all" from previous operation
                    this.Enabled    = false;
                    try
                    {
                        string   subpath = Fbd.SelectedPath;
                        TreeNode tn      = treeViewDirs.SelectedNode;

                        foreach (FileInfo fi in (List <FileInfo>)tn.Tag)
                        {
                            if (!interactiveSaveFile(subpath, fi))
                            {
                                this.Enabled = true;
                                return;
                            }
                        }
                        exportFolder(subpath, tn.Nodes);
                    }
                    catch (Exception exc)
                    {
                        MessageBox.Show(exc.Message, exc.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    this.Enabled = true;
                }
            }
        }
コード例 #2
0
ファイル: FormMain.cs プロジェクト: ConorSheehan1/nbuexplorer
        private bool interactiveSaveFile(string targetPath, FileInfo fi)
        {
            string targetFilename = Path.Combine(targetPath, fi.SafeFilename);

            if (File.Exists(targetFilename))
            {
                DialogResult dr;

                if (overWriteDialog == null)
                {
                    overWriteDialog      = new MessageBoxWithMemory();
                    overWriteDialog.Text = "File already exists";
                }

                if (overWriteDialog.MemorizedDialogResult == DialogResult.None)
                {
                    overWriteDialog.MessageText = string.Format("Overwrite file '{0}'?", fi.Filename);
                    dr = overWriteDialog.ShowDialog();
                }
                else
                {
                    dr = overWriteDialog.MemorizedDialogResult;
                }

                if (dr == DialogResult.No)
                {
                    return(true);
                }
                if (dr == DialogResult.Cancel)
                {
                    return(false);
                }
            }

            try
            {
                writeFile(fi, targetFilename);
            }
            catch (Exception exc)
            {
                if (MessageBox.Show(string.Format("Error exporting file '{0}': {1}\r\nContinue?", targetFilename, exc.Message), this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.No)
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #3
0
ファイル: FormMain.cs プロジェクト: ConorSheehan1/nbuexplorer
        private void exportAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (treeViewDirs.Nodes.Count == 0)
            {
                return;
            }

            if (Fbd.ShowDialog() == DialogResult.OK)
            {
                overWriteDialog = null;                 // reset possible "yes to all / no to all" from previous operation
                this.Enabled    = false;
                try
                {
                    exportFolder(Fbd.SelectedPath, treeViewDirs.Nodes);
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message, exc.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                this.Enabled = true;
            }
        }
コード例 #4
0
ファイル: FormMain.cs プロジェクト: sunny256/nbuexplorer
        private bool interactiveSaveFile(string targetPath, FileInfo fi)
        {
            string targetFilename = Path.Combine(targetPath, fi.SafeFilename);

            if (File.Exists(targetFilename))
            {
                DialogResult dr;

                if (overWriteDialog == null)
                {
                    overWriteDialog = new MessageBoxWithMemory();
                    overWriteDialog.Text = "File already exists";
                }

                if (overWriteDialog.MemorizedDialogResult == DialogResult.None)
                {
                    overWriteDialog.MessageText = string.Format("Overwrite file '{0}'?", fi.Filename);
                    dr = overWriteDialog.ShowDialog();
                }
                else
                {
                    dr = overWriteDialog.MemorizedDialogResult;
                }

                if (dr == DialogResult.No) return true;
                if (dr == DialogResult.Cancel) return false;
            }

            try
            {
                writeFile(fi, targetFilename);
            }
            catch (Exception exc)
            {
                if (MessageBox.Show(string.Format("Error exporting file '{0}': {1}\r\nContinue?", targetFilename, exc.Message), this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.No)
                {
                    return false;
                }
            }

            return true;
        }
コード例 #5
0
ファイル: FormMain.cs プロジェクト: sunny256/nbuexplorer
        private void exportSelectedFolderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (treeViewDirs.SelectedNode != null)
            {
                if (Fbd.ShowDialog() == DialogResult.OK)
                {
                    overWriteDialog = null; // reset possible "yes to all / no to all" from previous operation
                    this.Enabled = false;
                    try
                    {
                        string subpath = Fbd.SelectedPath;
                        TreeNode tn = treeViewDirs.SelectedNode;

                        foreach (FileInfo fi in (List<FileInfo>)tn.Tag)
                        {
                            if (!interactiveSaveFile(subpath, fi))
                            {
                                this.Enabled = true;
                                return;
                            }
                        }
                        exportFolder(subpath, tn.Nodes);
                    }
                    catch (Exception exc)
                    {
                        MessageBox.Show(exc.Message, exc.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    this.Enabled = true;
                }
            }
        }
コード例 #6
0
ファイル: FormMain.cs プロジェクト: sunny256/nbuexplorer
 private void exportSelectedFilesToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (listViewFiles.SelectedItems.Count == 0)
     {
         return;
     }
     else if (listViewFiles.SelectedItems.Count == 1)
     {
         listViewFiles_DoubleClick(sender, e);
     }
     else
     {
         if (Fbd.ShowDialog() == DialogResult.OK)
         {
             overWriteDialog = null; // reset possible "yes to all / no to all" from previous operation
             this.Enabled = false;
             try
             {
                 foreach (ListViewItem lvi in listViewFiles.SelectedItems)
                 {
                     FileInfo fi = lvi.Tag as FileInfo;
                     if (!interactiveSaveFile(fbd.SelectedPath, fi)) break;
                 }
             }
             catch (Exception exc)
             {
                 MessageBox.Show(exc.Message, exc.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             this.Enabled = true;
         }
     }
 }
コード例 #7
0
ファイル: FormMain.cs プロジェクト: sunny256/nbuexplorer
        private void exportAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (treeViewDirs.Nodes.Count == 0) return;

            if (Fbd.ShowDialog() == DialogResult.OK)
            {
                overWriteDialog = null; // reset possible "yes to all / no to all" from previous operation
                this.Enabled = false;
                try
                {
                    exportFolder(Fbd.SelectedPath, treeViewDirs.Nodes);
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message, exc.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                this.Enabled = true;
            }
        }