예제 #1
0
        void OnChooseFolderDialog(object sender, RoutedEventArgs e)
        {
            var dlg = new FileOpenDialog
            {
                Multiselect     = true,
                FolderPicker    = true,
                CheckPathExists = true,
            };

            var target = e.Source as FrameworkElement;

            string directory = target.Tag as string;

            if (!string.IsNullOrEmpty(directory))
            {
                // Get first path in the list
                directory = directory.Split(',')[0].TrimEnd(Path.PathSeparator);
                // Make relative paths absolute (relative to the config file)
                directory            = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(configFilePath), directory));
                dlg.InitialDirectory = directory;
            }

            if (dlg.ShowDialog(this) == true)
            {
                target.Tag = string.Join(",", dlg.FileNames);
            }
        }
예제 #2
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            DialogResult result = FileOpenDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                string   file = FileOpenDialog.FileName;
                string[] CDs  = File.ReadAllLines(file);
                listCD = new List <CDInformation>();
                if (CDs == null || CDs.Count() == 0)
                {
                    MessageBox.Show("File is empty!!!", "Empty File", MessageBoxButtons.OK);
                    return;
                }
                foreach (string CD in CDs)
                {
                    string[]      CDInfo = CD.Split('~');
                    CDInformation info   = new CDInformation(
                        CDInfo[0],
                        CDInfo[1],
                        CDInfo[2],
                        CDInfo[3],
                        int.Parse(CDInfo[4]));
                    string[] songs = CDInfo[5].Split('#');
                    foreach (string song in songs)
                    {
                        info.Song.Add(song);
                    }
                    listCD.Add(info);
                }
                loadListData();
            }
        }
예제 #3
0
        public string BrowseBoot(Window owner, PresetModel preset, BootType type)
        {
            using (var dialog = new FileOpenDialog())
            {
                const string BiosFileName = "etfsboot.com";
                const string UefiFileName = "efisys.bin";

                string bootFolderPath;
                string bootFileName;
                string bootFileExtension;
                string extension;
                string clientGuid;
                string title;
                string fileName;

                if (type == BootType.Bios)
                {
                    GetFilePathInfo(preset.BiosBoot, out bootFolderPath, out bootFileName, out bootFileExtension);
                    extension  = Path.GetExtension(BiosFileName);
                    clientGuid = "E8BEE349-1A4A-4E04-B8B9-B15FF1EF9125";
                    title      = "BIOS";
                    fileName   = bootFileName ?? BiosFileName;
                }
                else if (type == BootType.Uefi)
                {
                    GetFilePathInfo(preset.UefiBoot, out bootFolderPath, out bootFileName, out bootFileExtension);
                    extension  = Path.GetExtension(UefiFileName);
                    clientGuid = "A6A65946-6FCD-4DCA-AEB1-85ABF5FE3CAE";
                    title      = "UEFI";
                    fileName   = bootFileName ?? UefiFileName;
                }
                else
                {
                    throw new InvalidOperationException("The specified boot type is not implemented.");
                }

                dialog.SetClientGuid(new Guid(clientGuid));
                dialog.SetDefaultFolder(Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
                dialog.SetTitle($"{title} boot sector file");
                dialog.SetFileTypes($"Boot files (*{extension})|*{extension}|All files (*.*)|*.*");
                dialog.SetFileName(fileName);
                dialog.SetFileTypeIndex(bootFileExtension == null || bootFileExtension.Equals(extension, StringComparison.OrdinalIgnoreCase) ? 1 : 2);
                dialog.SetOkButtonLabel("Select");
                dialog.SetCancelButtonLabel("Cancel");
                dialog.SetFileNameLabel("Boot sector file :");
                dialog.DontAddToRecent = true;

                if (PathHelper.DirectoryExists(bootFolderPath))
                {
                    dialog.SetFolder(bootFolderPath);
                }

                return(dialog.ShowDialog(owner) == true?dialog.GetResult() : null);
            }
        }
예제 #4
0
 public void SetPath()
 {
     this.Dispatcher.BeginInvoke(new Action(() => {
         string path = FileOpenDialog.ShowDialog();
         if (path != string.Empty)
         {
             AppPropertys.appSetting.DownloadFolder = path + "\\";
             defaultFolder.Text = AppPropertys.appSetting.DownloadFolder;
         }
     }));
 }
예제 #5
0
        private void OnSelectDocDefinitionFilePathnameRequested(object sender, EventArgs e)
        {
            var pathnameSelector = new FileOpenDialog();

            pathnameSelector.Title = "Specify the pathname of the file containing the document-definition.";
            //  pathnameSelector.InitialDirectory = _viewModel.DocDefinitionFilePathname;
            if (StringLib.HasNothing(_viewModel.DocDefinitionFilePathname))
            {
                // pathnameSelector.SelectedFilename = "CodeMetricsComparisonReport.txt";
            }
            var r = pathnameSelector.ShowDialog();

            if (r == DisplayUxResult.Ok)
            {
                _viewModel.DocDefinitionFilePathname = pathnameSelector.SelectedFilename;
            }
        }
예제 #6
0
        private LinkedList <string> processingOpenFileCommand()
        {
            JSONParser          jsonParser = new JSONParser();
            LinkedList <string> sites      = new LinkedList <string>();

            crawlerHandler.ConsoleOutput = "Processing...\n";
            string json = FileOpenDialog.ShowDialog();

            if (json != "Canceled")
            {
                sites = jsonParser.parse(json);
            }
            else
            {
                crawlerHandler.ConsoleOutput = "Canceled.\n\n";
            }
            return(sites);
        }
예제 #7
0
        void OnChooseFolderDialog(object sender, RoutedEventArgs e)
        {
            var    target         = e.Source as FrameworkElement;
            string origFirstValue = (target.Tag as string ?? string.Empty).Split(',')[0].TrimEnd(Path.PathSeparator);

            var dlg = new FileOpenDialog
            {
                Multiselect      = true,
                FolderPicker     = true,
                CheckPathExists  = true,
                InitialDirectory = origFirstValue
            };

            if (dlg.ShowDialog(this) == true)
            {
                target.Tag = string.Join(",", dlg.FileNames);
            }
        }
예제 #8
0
        void OnChoosePresetDialog(object sender, RoutedEventArgs e)
        {
            string origFirstValue = (Preset.Text ?? string.Empty).Split(',')[0];

            var dlg = new FileOpenDialog
            {
                CheckPathExists  = true,
                CheckFileExists  = false,
                Filter           = "Preset Files (*.ini, *.txt)|*.ini;*.txt",
                FileName         = origFirstValue,
                DefaultExt       = ".ini",
                InitialDirectory = Path.GetDirectoryName(origFirstValue),
            };

            if (dlg.ShowDialog(this) == true)
            {
                Preset.Text = dlg.FileName;
            }
        }
예제 #9
0
        //End of Transfer Tab and start of Comparer Tab

        private void OpenFile(bool is2)
        {
#if DEBUG
            Log.GetInstence().WriteLine("OpenFile has been called");
#endif
            FileOpenDialog.Multiselect = false;
            DialogResult result = FileOpenDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                if (is2)
                {
                    File2Loc.Text = FileOpenDialog.FileName;
                }
                else
                {
                    File1Loc.Text = FileOpenDialog.FileName;
                }
            }
        }
예제 #10
0
        public string BrowseSource(Window owner, string source)
        {
            using (var dialog = new FileOpenDialog())
            {
                dialog.SetClientGuid(new Guid("6DD0F3B6-0F48-4F5B-8690-4866D4B9EAF2"));
                dialog.SetDefaultFolder(Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
                dialog.SetTitle("Source location of the files and folders to be included in the image");
                dialog.SetOkButtonLabel("Select");
                dialog.SetCancelButtonLabel("Cancel");
                dialog.SetFileNameLabel("Source location :");
                dialog.PickFolders     = true;
                dialog.DontAddToRecent = true;

                if (PathHelper.DirectoryExists(source))
                {
                    dialog.SetFolder(source);
                }

                return(dialog.ShowDialog(owner) == true?dialog.GetResult() : null);
            }
        }
예제 #11
0
        public string BrowseFile(Window owner, string filePath)
        {
            using (var dialog = new FileOpenDialog())
            {
                dialog.SetClientGuid(new Guid("1941C841-398F-486F-8542-A0B2250F406F"));
                dialog.SetDefaultFolder(Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
                dialog.SetTitle("Location of the file to be computed");
                dialog.SetOkButtonLabel("Select");
                dialog.SetCancelButtonLabel("Cancel");
                dialog.SetFileNameLabel("File name :");
                dialog.DontAddToRecent = true;

                if (PathHelper.FileExists(filePath))
                {
                    dialog.SetFileName(Path.GetFileName(filePath));
                    dialog.SetFolder(Path.GetDirectoryName(filePath));
                }

                return(dialog.ShowDialog(owner) == true?dialog.GetResult() : null);
            }
        }
예제 #12
0
        void OnChoosePresetDialog(object sender, RoutedEventArgs e)
        {
            var dlg = new FileOpenDialog
            {
                CheckPathExists = true,
                CheckFileExists = false,
                Filter          = "Preset Files (*.ini, *.txt)|*.ini;*.txt",
                DefaultExt      = ".ini",
            };

            string filename = Preset.Text ?? string.Empty;

            filename = filename.Split(',')[0];
            if (!string.IsNullOrEmpty(filename))
            {
                dlg.FileName         = filename;
                dlg.InitialDirectory = Path.GetDirectoryName(filename);
            }

            if (dlg.ShowDialog(this) == true)
            {
                Preset.Text = dlg.FileName;
            }
        }
예제 #13
0
 private void BtnSelectFile_Click(object sender, EventArgs e)
 {
     FileOpenDialog.ShowDialog();
 }