Ejemplo n.º 1
0
        public static DialogResult GetUsersFilesFolder(string title, string dir, string name, string ext, string ext2 = "")
        {
            FoldorFile.FileOrFolderChoice choice = ChooseFiles();
            if (choice == FoldorFile.FileOrFolderChoice.Cancel)
            {
                return(DialogResult.Cancel);
            }

            if (choice == FoldorFile.FileOrFolderChoice.Folder)
            {
                string xs = UIIntegration.GetUsersFolder("Select folder", dir);
                if (!String.IsNullOrEmpty(xs))
                {
                    NC.App.AppContext.FileInput     = xs;
                    NC.App.AppContext.FileInputList = null;  // no explicit file list
                    return(DialogResult.OK);
                }
                else
                {
                    return(DialogResult.Cancel);
                }
            }
            // choice == files
            System.Windows.Forms.OpenFileDialog RestoreFileDialog = new System.Windows.Forms.OpenFileDialog();
            List <string> paths = new List <string>();

            RestoreFileDialog.CheckFileExists = false;
            RestoreFileDialog.DefaultExt      = "ext";
            RestoreFileDialog.Filter          = name + " files (." + ext + ")|*." + ext;
            if (!String.IsNullOrEmpty(ext2))
            {
                RestoreFileDialog.Filter += "| (." + ext2 + ")|*." + ext2;
            }
            RestoreFileDialog.Filter          += "|All files (*.*)|*.*";
            RestoreFileDialog.InitialDirectory = NC.App.AppContext.FileInput;
            RestoreFileDialog.Title            = title;
            RestoreFileDialog.Multiselect      = true;
            RestoreFileDialog.RestoreDirectory = true;
            DialogResult r = DialogResult.No;

            r = RestoreFileDialog.ShowDialog();
            if (r == DialogResult.OK)
            {
                foreach (string s in RestoreFileDialog.FileNames)
                {
                    paths.Add(s);
                }
                FileSel fs = new FileSel(paths);
                r = fs.ShowDialog();
                if (r == DialogResult.OK)
                {
                    NC.App.AppContext.FileInputList = paths;
                    NC.App.AppContext.FileInput     = null; // no explicit folder System.IO.Path.GetDirectoryName(paths[0]);
                }
            }
            return(r);
        }
Ejemplo n.º 2
0
 public static DialogResult GetUsersFilesFolder(string title, string dir, string name, string ext, string ext2 = "")
 {
     if (!ChooseFiles())
     {
         string xs = UIIntegration.GetUsersFolder("Select folder", dir);
         if (!String.IsNullOrEmpty(xs))
         {
             NC.App.AppContext.FileInput = xs;
             NC.App.AppContext.FileInputList = null;  // no explicit file list
             return DialogResult.OK;                }
         else
             return DialogResult.Cancel;
     }
     System.Windows.Forms.OpenFileDialog RestoreFileDialog = new System.Windows.Forms.OpenFileDialog(); 
     List<string> paths = new List<string>();
     RestoreFileDialog.CheckFileExists = false;
     RestoreFileDialog.DefaultExt = "ext";
     RestoreFileDialog.Filter = name + " files (." + ext + ")|*." + ext ;
     if (!String.IsNullOrEmpty(ext2))
     {
         RestoreFileDialog.Filter += "| (." + ext2 + ")|*." + ext2;
     }
     RestoreFileDialog.Filter += "|All files (*.*)|*.*";
     RestoreFileDialog.InitialDirectory = NC.App.AppContext.FileInput;
     RestoreFileDialog.Title = title;
     RestoreFileDialog.Multiselect = true;
     RestoreFileDialog.RestoreDirectory = true;
     DialogResult r = DialogResult.No; 
     r = RestoreFileDialog.ShowDialog();
     if (r == DialogResult.OK)
     { 
         foreach (string s in RestoreFileDialog.FileNames)
         {
             paths.Add(s);
         }
         FileSel fs = new FileSel(paths);
         r = fs.ShowDialog();
         if (r == DialogResult.OK)
         {
             NC.App.AppContext.FileInputList = paths;
             NC.App.AppContext.FileInput = null;  // no explicit folder System.IO.Path.GetDirectoryName(paths[0]);
         }
     }
     return r;
 }