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


C# IFileDialog.Show方法代码示例

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


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

示例1: ShowDialog

        public CommonFileDialogResult ShowDialog()
        {
            CommonFileDialogResult result;

            try
            {
                // Fetch derived native dialog (i.e. Save or Open)
                InitializeNativeFileDialog();
                nativeDialog = GetNativeFileDialog();

                // Process custom controls, and validate overall state
                ProcessControls();
                ValidateCurrentDialogState();

                // Apply outer properties to native dialog instance
                ApplyNativeSettings(nativeDialog);
                InitializeEventSink(nativeDialog);

                // Show dialog
                showState = NativeDialogShowState.Showing;
                int hresult = nativeDialog.Show(GetHandleFromWindow(parentWindow));
                showState = NativeDialogShowState.Closed;

                // Create return information
                if (ErrorHelper.Matches(hresult, Win32ErrorCode.ERROR_CANCELLED))
                {
                    canceled = true;
                    fileNames.Clear();
                }
                else
                {
                    canceled = false;

                    // Populate filenames - though only if user didn't cancel
                    PopulateWithFileNames(fileNames);
                }
                result = new CommonFileDialogResult(canceled.Value);
            }
            finally
            {
                CleanUpNativeFileDialog();
            }
            return result;
        }
开发者ID:ssickles,项目名称:archive,代码行数:44,代码来源:CommonFileDialog.cs

示例2: ShowDialog

        /// <summary>
        /// Displays the dialog.
        /// </summary>
        /// <returns>A <see cref="Microsoft.SDK.Samples.VistaBridge.Library.CommonFileDialogResult"/> object.</returns>
        public CommonFileDialogResult ShowDialog()
        {
            CommonFileDialogResult result;

            try
            {
                // Fetch derived native dialog (i.e. Save or Open).
                InitializeNativeFileDialog();
                nativeDialog = GetNativeFileDialog();

                // Apply outer properties to native dialog instance.
                ApplyNativeSettings(nativeDialog);
                InitializeEventSink(nativeDialog);

                // Clear user data if Reset has been called 
                // since the last show.
                if (resetSelections)
                {
                    resetSelections = false;
                }

                // Show dialog.
                showState = NativeDialogShowState.Showing;
                int hresult = nativeDialog.Show(
                    CommonFileDialog.GetHandleFromWindow(parentWindow));
                showState = NativeDialogShowState.Closed;

                // Create return information.
                if (ErrorHelper.Matches(hresult, 
                    Win32ErrorCode.ERROR_CANCELLED))
                {
                    canceled = true;
                    fileNames.Clear();
                }
                else
                {
                    canceled = false;

                    // Populate filenames if user didn't cancel.
                    PopulateWithFileNames(fileNames);
                }
                result = new CommonFileDialogResult(canceled.Value);
            }
            finally
            {
                CleanUpNativeFileDialog();
            }
            return result;
        }
开发者ID:dbremner,项目名称:J.-River-Media-Center-Windows-7-Shell-Integration,代码行数:53,代码来源:commonfiledialog.cs

示例3: ShowDialog

        /// <summary>
        /// Displays the dialog.
        /// </summary>
        /// <returns>A <see cref="CommonFileDialogResult"/> object.</returns>
        public CommonFileDialogResult ShowDialog()
        {
            CommonFileDialogResult result;

            // Fetch derived native dialog (i.e. Save or Open).
            InitializeNativeFileDialog();
            nativeDialog = GetNativeFileDialog();

            // Apply outer properties to native dialog instance.
            ApplyNativeSettings(nativeDialog);
            InitializeEventSink(nativeDialog);

            // Clear user data if Reset has been called 
            // since the last show.
            if (resetSelections)
            {
                resetSelections = false;
            }

            // Show dialog.
            showState = DialogShowState.Showing;
            int hresult = nativeDialog.Show(parentWindow);
            showState = DialogShowState.Closed;

            // Create return information.
            if (CoreErrorHelper.Matches(hresult, (int)HResult.Win32ErrorCanceled))
            {
                canceled = true;
                result = CommonFileDialogResult.Cancel;
                filenames.Clear();
            }
            else
            {
                canceled = false;
                result = CommonFileDialogResult.Ok;

                // Populate filenames if user didn't cancel.
                PopulateWithFileNames(filenames);

                // Populate the actual IShellItems
                PopulateWithIShellItems(items);
            }

            return result;
        }
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:49,代码来源:CommonFileDialog.cs

示例4: ShowDialog

        public bool? ShowDialog()
        {
            bool? result = null;

            try
            {
                // Fetch derived native dialog (i.e. Save or Open)

                InitializeNativeFileDialog();
                nativeDialog = GetNativeFileDialog();

                // Process custom controls, and validate overall state
                ProcessControls();
                ValidateCurrentDialogState();

                // Apply outer properties to native dialog instance
                ApplyNativeSettings(nativeDialog);

                // Show dialog
                showState = NativeDialogShowState.Showing;
                int hresult = nativeDialog.Show(GetHandleFromWindow(parentWindow));
                showState = NativeDialogShowState.Closed;

                // Create return information
                if (ErrorHelper.Matches(hresult, Win32ErrorCode.ERROR_CANCELLED))
                {
                    canceled = true;
                    fileNames.Clear();
                }
                else
                {
                    canceled = false;

                    // Populate filenames - though only if user didn't cancel
                    PopulateWithFileNames(fileNames);
                }
                result = !canceled.Value;
            }
            catch
            {
                //If Vista Style dialog is unavailable, fall back to Windows Forms

                System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
                dialog.SelectedPath = fileName;
                dialog.ShowNewFolderButton = true;
                dialog.Description = this.Title;

                result = (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK);
                if (result.HasValue && result.Value)
                {
                    canceled = false;
                    fileNames.Clear();
                    fileNames.Add(dialog.SelectedPath);
                }
                else
                {
                    fileNames.Clear();
                    canceled = true;
                }
            }
            finally
            {
                CleanUpNativeFileDialog();
                showState = NativeDialogShowState.Closed;
            }
            return result;
        }
开发者ID:hexafluoride,项目名称:byteflood,代码行数:67,代码来源:WPFFolderBrowserDialog.cs


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