当前位置: 首页>>代码示例>>C#>>正文


C# CommonOpenFileDialog.ShowDialog方法代码示例

本文整理汇总了C#中Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog.ShowDialog方法的典型用法代码示例。如果您正苦于以下问题:C# CommonOpenFileDialog.ShowDialog方法的具体用法?C# CommonOpenFileDialog.ShowDialog怎么用?C# CommonOpenFileDialog.ShowDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog的用法示例。


在下文中一共展示了CommonOpenFileDialog.ShowDialog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnOutputPathButtonClick

        private void OnOutputPathButtonClick(object sender, RoutedEventArgs e)
        {
            string path = string.Empty;

            if (CommonFileDialog.IsPlatformSupported)
            {
                using (CommonOpenFileDialog dialog = new CommonOpenFileDialog())
                {
                    dialog.IsFolderPicker = true;
                    dialog.Multiselect = false;
                    dialog.DefaultDirectory = this.OutputPathBox.Text;
                    if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
                    {
                        path = dialog.FileName;
                    }
                }
            }
            else
            {
                using (FolderBrowserDialog dialog = new FolderBrowserDialog())
                {
                    dialog.RootFolder = Environment.SpecialFolder.MyMusic;
                    if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        path = dialog.SelectedPath;
                    }
                }
            }

            extractor.OutputPath = path;
        }
开发者ID:alocay,项目名称:ExtractorProject,代码行数:31,代码来源:MainWindow.xaml.cs

示例2: Button_Click_1

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            //var dialog = new System.Windows.Forms.FolderBrowserDialog();
            //System.Windows.Forms.DialogResult result = dialog.ShowDialog();

            //// Configure open file dialog box
            //Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            //dlg.FileName = "Document"; // Default file name
            //dlg.DefaultExt = ".txt"; // Default file extension
            //dlg.Filter = "Text documents (.txt)|*.txt"; // Filter files by extension

            //// Show open file dialog box
            //Nullable<bool> result = dlg.ShowDialog();

            //// Process open file dialog box results
            //if (result == true)
            //{
            //    // Open document
            //    string filename = dlg.FileName;
            //}

            //Check to see if the user is >Vista
            if (CommonFileDialog.IsPlatformSupported)
            {
                var dialog = new CommonOpenFileDialog();
                dialog.IsFolderPicker = true;
                CommonFileDialogResult result = dialog.ShowDialog();
                if (result == CommonFileDialogResult.Ok)
                {
                    dirName = dialog.FileName;
                    textbox.Text = dirName;
                }
            }
        }
开发者ID:kevininspace,项目名称:PhotoContactSheetBackup,代码行数:34,代码来源:MainWindow.xaml.cs

示例3: BrowseForFolder

        public static string BrowseForFolder(string startingPath)
        {
            string initialDirectory = _lastDirectory ?? startingPath;
            string ret = null;

            try
            {
                var cfd = new CommonOpenFileDialog
                {
                    InitialDirectory = initialDirectory,
                    IsFolderPicker = true
                };

                if (cfd.ShowDialog() == CommonFileDialogResult.Ok)
                {
                    ret = cfd.FileName;
                }
            }
            catch (System.PlatformNotSupportedException)
            {
                var fd = new System.Windows.Forms.FolderBrowserDialog
                {
                    SelectedPath = initialDirectory
                };

                if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    ret = fd.SelectedPath;
                }
            }

            _lastDirectory = ret;
            return ret;
        }
开发者ID:Haacked,项目名称:SeeGit,代码行数:34,代码来源:WindowsExtensions.cs

示例4: ImportImages

        private async void ImportImages()
        {
            var dialog = new CommonOpenFileDialog();
            dialog.Filters.Add(new CommonFileDialogFilter("Images", "png,gif,jpg,jpeg,bmp"));

            dialog.Title = "Select Images";
            dialog.EnsureFileExists = true;
            dialog.EnsurePathExists = true;
            dialog.EnsureReadOnly = false;
            dialog.EnsureValidNames = true;
            dialog.Multiselect = true;
            dialog.ShowPlacesList = true;

            if (dialog.ShowDialog() != CommonFileDialogResult.Ok)
                return;

            var images = dialog.FileNames
                .Where(p => System.IO.File.Exists(p))
                .Select(p => PromptImage(new BitmapImage(new Uri(p)), p))
                .Where(m => m != null)
                .ToList();
            
            var reporter = new Progress<ProgressDialogState>();
            var stopwatch = new Stopwatch();
            var progress = ProgressDialog.Open(reporter, stopwatch);

            stopwatch.Start();
            await _importer.AddImagesAsync(images, reporter);
            stopwatch.Stop();
            progress.Close();

            RefreshSheet();
        }
开发者ID:Tesserex,项目名称:C--MegaMan-Engine,代码行数:33,代码来源:TilesetImporterViewModel.cs

示例5: SelectFiles

        public void SelectFiles()
        {
            if (CommonFileDialog.IsPlatformSupported)
            {
                var commonOpenFileDialog = new CommonOpenFileDialog("Select the audio files that you want to link to the zune social")
                                               {
                                                   Multiselect = true,
                                                   EnsureFileExists = true
                                               };

                commonOpenFileDialog.Filters.Add(new CommonFileDialogFilter("Audio Files", "*.mp3;*.wma;*.m4a"));
                commonOpenFileDialog.Filters.Add(new CommonFileDialogFilter("MP3 Files", "*.mp3"));
                commonOpenFileDialog.Filters.Add(new CommonFileDialogFilter("WMA Files", "*.wma"));
                commonOpenFileDialog.Filters.Add(new CommonFileDialogFilter("Mpeg4 Files", "*.m4a"));

                if (commonOpenFileDialog.ShowDialog() == CommonFileDialogResult.OK)
                    ReadFiles(commonOpenFileDialog.FileNames);
            }
            else
            {
                var ofd = new OpenFileDialog {
                    Multiselect = true,
                    Filter = "Audio files .mp3,.wma,.m4a |*.mp3;*.wma;*.m4a",
                    AutoUpgradeEnabled = true,
                    Title = "Select the audio files that you want to link to the zune social",
                    CheckFileExists = true
                };

                if (ofd.ShowDialog() == DialogResult.OK)
                    ReadFiles(ofd.FileNames);
            }
        }
开发者ID:leetreveil,项目名称:Zune-Social-Tagger,代码行数:32,代码来源:SelectAudioFilesViewModel.cs

示例6: SelectDirectoryDialog

        public string SelectDirectoryDialog(string defaultPath, string title = null)
        {
            var dlg = new CommonOpenFileDialog()
            {
                Title = "",
                IsFolderPicker = true,
                InitialDirectory = defaultPath,
                AddToMostRecentlyUsedList = false,
                AllowNonFileSystemItems = false,
                DefaultDirectory = defaultPath,
                EnsureFileExists = true,
                EnsurePathExists = true,
                EnsureReadOnly = false,
                EnsureValidNames = true,
                Multiselect = false,
                ShowPlacesList = true
            };

            if (dlg.ShowDialog() == CommonFileDialogResult.Ok)
            {
                return dlg.FileName;
            }

            return null;
        }
开发者ID:komaflash,项目名称:dump,代码行数:25,代码来源:DialogService.cs

示例7: btnOpen_Click

        private void btnOpen_Click( object sender, RoutedEventArgs e )
        {
            CommonOpenFileDialog openDialog = new CommonOpenFileDialog();
              openDialog.ShowPlacesList = true;
              openDialog.Multiselect = false;
              openDialog.IsFolderPicker = false;
              openDialog.AddToMostRecentlyUsedList = true;
              openDialog.Filters.Add( new CommonFileDialogFilter( "PNG images", "*.png" ) );
              if ( openDialog.ShowDialog( this ) == CommonFileDialogResult.Ok ) {
            soureFilePath = openDialog.FileName;
            // get comment meta
            using ( FileStream fileStream = new FileStream( soureFilePath, FileMode.Open, FileAccess.Read ) ) {
              pngReader = new PngReader( fileStream );
              // 参考自Hjg.Pngcs的SampleCustomChunk项目
              // get last line: this forces loading all chunks
              pngReader.ReadChunksOnly();
              tblkComment.Text = pngReader.GetMetadata().GetTxtForKey( Key_SemanticInfo );
              pngReader.End();
              fileStream.Close();
            }

            image.BeginInit();
            image.Source = new BitmapImage( new Uri( soureFilePath ) );
            image.EndInit();
              }
        }
开发者ID:taurenshaman,项目名称:SemanticImage,代码行数:26,代码来源:MainView.xaml.cs

示例8: ChooseDataPath

        private void ChooseDataPath()
        {
            var dialog = new CommonOpenFileDialog
            {
                IsFolderPicker = true,
                InitialDirectory = Settings.Default.DataPath
            };

            var result = dialog.ShowDialog();
            if (result == CommonFileDialogResult.Ok)
            {
                var particleDir = Path.Combine(dialog.FileName, "art", "meshes", "Particle");
                if (!Directory.Exists(particleDir))
                {
                    MessageBox.Show("The chosen data directory does not seem to be valid.\n"
                                    + "Couldn't find subdirectory art\\meshes\\Particle.",
                        "Invalid Data Directory");
                    return;
                }

                Settings.Default.DataPath = dialog.FileName;
                Settings.Default.Save();
                PreviewControl.DataPath = dialog.FileName;
            }
        }
开发者ID:ema29,项目名称:TemplePlus,代码行数:25,代码来源:MainWindow.xaml.cs

示例9: OpenFileDialogCustomizationClicked

        private void OpenFileDialogCustomizationClicked(object sender, RoutedEventArgs e)
        {
            CommonOpenFileDialog openFileDialog = new CommonOpenFileDialog();
            currentFileDialog = openFileDialog;

            ApplyOpenDialogSettings(openFileDialog);
            
            // set the 'allow multi-select' flag
            openFileDialog.Multiselect = true;

            openFileDialog.EnsureFileExists = true;

            AddOpenFileDialogCustomControls(openFileDialog);

            CommonFileDialogResult result = openFileDialog.ShowDialog();
            if (result == CommonFileDialogResult.Ok)
            {
                string output = "";
                foreach (string fileName in openFileDialog.FileNames)
                {
                    output += fileName + Environment.NewLine;
                }
                
                output += Environment.NewLine + GetCustomControlValues();

                MessageBox.Show(output, "Files Chosen", MessageBoxButton.OK, MessageBoxImage.Information );
            }
        }
开发者ID:Corillian,项目名称:Windows-API-Code-Pack-1.1,代码行数:28,代码来源:window1.xaml.cs

示例10: browseSmfPath_Click

        private void browseSmfPath_Click(object sender, EventArgs e)
        {
            // Get us a new FolderBrowserDialog
            CommonOpenFileDialog fb = new CommonOpenFileDialog();
            fb.IsFolderPicker = true;
            fb.Title = "Please select the directory that your environment resides in.";
            fb.EnsurePathExists = true;
            CommonFileDialogResult rs = fb.ShowDialog();

            if (rs == CommonFileDialogResult.Cancel)
                return;

            // Get the path.
            string s = fb.FileName;
            if (Directory.Exists(s))
            {
                smfPath.Text = s;

                if (File.Exists(s + "/index.php"))
                {
                    string contents = File.ReadAllText(s + "/index.php");

                    Match match = Regex.Match(contents, @"'SMF ([^']*)'");
                    if (match.Success)
                        dsmfver.Text = match.Groups[1].Value;
                    else
                        dsmfver.Text = "(unknown)";
                }
                else
                    dsmfver.Text = "(unknown)";
            }
        }
开发者ID:Yoshi2889,项目名称:ModManager,代码行数:32,代码来源:Options.cs

示例11: ShowFolderBrowserDialog

 public string ShowFolderBrowserDialog()
 {
     using (CommonOpenFileDialog dialog = new CommonOpenFileDialog { IsFolderPicker = true })
     {
         return dialog.ShowDialog() == CommonFileDialogResult.Ok ? dialog.FileName : null;
     }
 }
开发者ID:JLignell,项目名称:MP3Downloader,代码行数:7,代码来源:DialogService.cs

示例12: BtnUserImage_Click

        // Lets the user choose and upload an image from file to the blob storage.
        // The file is saved under the name "User[id]img".
        // The method then calls the GetImage() method to display the uploaded image.
        private async void BtnUserImage_Click(object sender, RoutedEventArgs e)
        {
            var cofd = new CommonOpenFileDialog();
            cofd.Filters.Add(new CommonFileDialogFilter("JPEG Files", "*.jpg"));
            cofd.Filters.Add(new CommonFileDialogFilter("PNG Files", "*.png"));

            if (cofd.ShowDialog() == CommonFileDialogResult.Ok)
            {
                try
                {
                    string name = "User" + selectedUID + "img";
                    CloudBlockBlob blockBlob = (App.Current as App).blobcontainer.GetBlockBlobReference(name);
                    blockBlob.Properties.ContentType = "image/jpg";
                    using (var fileStream = System.IO.File.OpenRead(cofd.FileName))
                    {
                        await blockBlob.UploadFromStreamAsync(fileStream);
                        {
                            GetImage();
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + ex.InnerException, "uploading or downloading image error");
                }
            }
        }
开发者ID:niklasstromberg,项目名称:LexiconCVDB,代码行数:30,代码来源:Page1.xaml.cs

示例13: SelectRepoButtonClick

        private async void SelectRepoButtonClick(object sender, RoutedEventArgs e)
        {
            using (var dialog = new CommonOpenFileDialog())
            {
                dialog.IsFolderPicker = true;

                if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
                {
                    commandFactory = new CommandFactory(resultCommandMapper, dialog.FileName);
                    var statusCommand = commandFactory.GetCommand<StatusResult>();
                    statusCommand.Execute();

                    if (statusCommand.Result.ExecutionResult == ExecutionResult.NoRepository)
                    {
                        commandFactory = null;
                        MessageBox.Show("The selected file contains no git repository.", "Error!", MessageBoxButton.OK);
                    }
                    else
                    {
                        currentBranch.Text = "Current branch: " + statusCommand.Result.CurrentBranch;
                    }

                    await ListNormalCommits();
                }
            }
        }
开发者ID:Thulur,项目名称:GitStatisticsAnalyzer,代码行数:26,代码来源:MainWindow.xaml.cs

示例14: GetGameLocation

        public static GameLocationInfo GetGameLocation(FFXIIIGamePart gamePart)
        {
            try
            {
                using (RegistryKey localMachine = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
                using (RegistryKey registryKey = localMachine.OpenSubKey(GetSteamRegistyPath(gamePart)))
                {
                    if (registryKey == null)
                        throw Exceptions.CreateException("Запись в реестре не обнаружена.");

                    GameLocationInfo result = new GameLocationInfo((string)registryKey.GetValue(GameLocationSteamRegistryProvider.SteamGamePathTag));
                    result.Validate();

                    return result;
                }
            }
            catch
            {
                return Application.Current.Dispatcher.Invoke(() =>
                {
                    using (CommonOpenFileDialog dlg = new CommonOpenFileDialog(String.Format("Укажите каталог Final Fantasy XIII-{0}...", (int)gamePart)))
                    {
                        dlg.IsFolderPicker = true;
                        if (dlg.ShowDialog() != CommonFileDialogResult.Ok)
                            throw new OperationCanceledException();

                        GameLocationInfo result = new GameLocationInfo(dlg.FileName);
                        result.Validate();

                        return result;
                    }
                });
            }
        }
开发者ID:kidaa,项目名称:Pulse,代码行数:34,代码来源:PatcherService.cs

示例15: selectDirectory

        // MainWindow newMain; // Global Declaration
        //// Run directory processing on a new thread
        //public async Task<string> getDirectory(MainWindow mainWindow)
        //{
        //    newMain = mainWindow;
        //}
        ///////////////////////////////////////////////////////
        // Select Directory Button Handler
        // - Gets full path including sub-directories
        //
        // - Uses       string path = new DirButton().selectDirectory();
        // - Output     returns {string} path (selected in dialog)
        ///////////////////////////////////////////////////////
        public string selectDirectory()
        {
            // Define new MainWindow object (for reference)
            var mainWindow = ((MainWindow)System.Windows.Application.Current.MainWindow);

            // Begin Windows Dialog .DLL Extension usage
            var dlg = new CommonOpenFileDialog();
            var currentDirectory = "";
            dlg.Title = "Select Music Directory";
            dlg.IsFolderPicker = true;
            dlg.InitialDirectory = currentDirectory;
            dlg.AddToMostRecentlyUsedList = false;
            dlg.AllowNonFileSystemItems = false;
            dlg.DefaultDirectory = currentDirectory;
            dlg.EnsureFileExists = true;
            dlg.EnsurePathExists = true;
            dlg.EnsureReadOnly = false;
            dlg.EnsureValidNames = true;
            dlg.Multiselect = false;
            dlg.ShowPlacesList = true;

            if (dlg.ShowDialog() == CommonFileDialogResult.Ok)
            {
                string folder = dlg.FileName;

                //mainWindow.FileText.Text = folder;

                return folder;
            }
            else
            {
                return null;
            }
        }
开发者ID:no1redsfan,项目名称:WeListenPlayer,代码行数:47,代码来源:DirButton.cs


注:本文中的Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog.ShowDialog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。