示例#1
0
        /// <summary>
        /// Interop method to display a WinForms dialog, setting the owner to the active window</summary>
        /// <param name="dialog">WinForms dialog to display</param>
        /// <returns>System.Windows.Forms.DialogResult.OK if user clicks OK in the dialog box,
        /// otherwise System.Windows.Forms.DialogResult.Cancel.</returns>
        public static System.Windows.Forms.DialogResult ShowParentedDialog(System.Windows.Forms.CommonDialog dialog)
        {
            Window window = GetActiveWindow();
            var    helper = new WindowInteropHelper(window);

            return(dialog.ShowDialog(new WindowWrapper(helper.Handle)));
        }
示例#2
0
        public static System.Windows.Forms.DialogResult ShowDialogTSS(
            System.Windows.Forms.CommonDialog target)
        {
            Exception e = new Exception();

            throw e;
        }
示例#3
0
        /// <inheritdoc />
        public override FileBrowserDialogResult ShowDialog()
        {
            System.Windows.Forms.CommonDialog dialog = null;
            if (IsFolderBrowser)
            {
                var folderDialog = new System.Windows.Forms.FolderBrowserDialog();
                folderDialog.Description         = Title;
                folderDialog.ShowNewFolderButton = false;
                folderDialog.SelectedPath        = Properties.Settings.Default.LastBrowseFolder;
                dialog = folderDialog;
            }
            else
            {
                var fileDialog = new System.Windows.Forms.OpenFileDialog();
                fileDialog.Title            = Title;
                fileDialog.Multiselect      = Multiselect;
                fileDialog.CheckFileExists  = EnsureFileExists;
                fileDialog.CheckPathExists  = EnsurePathExists;
                fileDialog.InitialDirectory = Properties.Settings.Default.LastBrowseFolder;
                if (_filters.Any())
                {
                    StringBuilder filterBuilder    = new StringBuilder();
                    var           baseFormatString = "{0} ({1})|{1}";
                    var           formatString     = baseFormatString;
                    foreach (var filter in _filters)
                    {
                        var extensions = "*" + string.Join(";*", filter.Value);
                        filterBuilder.AppendFormat(formatString, filter.Key, extensions);
                        formatString = "|" + baseFormatString;
                    }
                    fileDialog.Filter = filterBuilder.ToString();
                }
                dialog = fileDialog;
            }

            var result = (FileBrowserDialogResult)dialog.ShowDialog();

            if (result == FileBrowserDialogResult.Ok)
            {
                if (IsFolderBrowser)
                {
                    Properties.Settings.Default.LastBrowseFolder = (dialog as System.Windows.Forms.FolderBrowserDialog).SelectedPath;
                    _files = new List <string>()
                    {
                        Properties.Settings.Default.LastBrowseFolder
                    };
                }
                else
                {
                    _files = (dialog as System.Windows.Forms.OpenFileDialog).FileNames;
                    Properties.Settings.Default.LastBrowseFolder = System.IO.Path.GetDirectoryName(_files.First());
                }
            }

            return(result);
        }
示例#4
0
        public static System.Windows.Forms.DialogResult ShowDialogMSS(
            System.Windows.Forms.CommonDialog target)
        {
            object result;

            if (TestSpecificStubsUtil.RunTestSpecificStub(System.Reflection.MethodBase.GetCurrentMethod(), new object[] { target }, out result))
            {
                return((System.Windows.Forms.DialogResult)result);
            }
            else
            {
                return(target.ShowDialog());
            }
        }
        public DialogResult ShowDialog(System.Windows.Forms.CommonDialog dialog)
        {
#if DEBUG
            bool?dialogResult;
            if (Stub(dialog, out dialogResult))
            {
                return(DialogResult.OK);
            }
#endif

            var window = InferOwnerOf(null);
            if (window != null)
            {
                return(dialog.ShowDialog(new Win32Stub(new WindowInteropHelper(window).Handle)));
            }
            else
            {
                return(dialog.ShowDialog());
            }
        }
示例#6
0
 public static System.Windows.Forms.DialogResult ShowDialog(this System.Windows.Forms.CommonDialog dialog, Window parent)
 {
     return(dialog.ShowDialog(new Wpf32Window(parent)));
 }
示例#7
0
 public static System.Windows.Forms.DialogResult ShowDialogForm(System.Windows.Forms.CommonDialog dialog)
 {
     return(dialog.ShowDialog(Global.mainForm));
 }