/// <summary>
        /// Shows the according dialog for the control.
        /// </summary>
        /// <returns></returns>
        protected override async Task ShowDialogAsync()
        {
            OpenFileDialogArguments args = null;

            if (DialogArgs != null)
            {
                args = new OpenFileDialogArguments(DialogArgs);
            }
            else
            {
                args = new OpenFileDialogArguments();
            }

            if (!string.IsNullOrWhiteSpace(File))
            {
                string directory = Path.GetDirectoryName(File);

                if (!string.IsNullOrWhiteSpace(directory) && Directory.Exists(directory))
                {
                    args.CurrentDirectory = directory;
                }
            }

            OpenFileDialogResult result = null;

            if (DialogHost != null)
            {
                result = await OpenFileDialog.ShowDialogAsync(DialogHost, args);
            }
            else
            {
                result = await OpenFileDialog.ShowDialogAsync(DialogHostName, args);
            }

            if (result != null && result.Confirmed)
            {
                File = result.FileInfo.FullName;
            }
        }
Exemple #2
0
        /// <summary>
        /// Shows a new <see cref="OpenFileDialog" />.
        /// </summary>
        /// <param name="dialogHost">The <see cref="DialogHost" /></param>
        /// <param name="args">The arguments for the dialog initialization</param>
        /// <returns></returns>
        public static async Task <OpenFileDialogResult> ShowDialogAsync(DialogHost dialogHost, OpenFileDialogArguments args)
        {
            OpenFileDialog dialog = InitDialog(
                args.Width,
                args.Height,
                args.CurrentDirectory,
                args.Filters,
                args.FilterIndex,
                args.ShowHiddenFilesAndDirectories,
                args.ShowSystemFilesAndDirectories
                );

            return(await dialogHost.ShowDialog(dialog, args.OpenedHandler, args.ClosingHandler) as OpenFileDialogResult);
        }
Exemple #3
0
        /// <summary>
        /// Shows a new <see cref="OpenFileDialog" />.
        /// </summary>
        /// <param name="dialogHostName">The name of the <see cref="DialogHost" /></param>
        /// <param name="args">The arguments for the dialog initialization</param>
        /// <returns></returns>
        public static async Task <OpenFileDialogResult> ShowDialogAsync(string dialogHostName, OpenFileDialogArguments args)
        {
            OpenFileDialog dialog = InitDialog(
                args.Width,
                args.Height,
                args.CurrentDirectory,
                args.Filters,
                args.FilterIndex,
                args.ShowHiddenFilesAndDirectories,
                args.ShowSystemFilesAndDirectories,
                args.SwitchPathPartsAsButtonsEnabled,
                args.PathPartsAsButtons
                );

            return(await DialogHost.Show(dialog, dialogHostName, args.OpenedHandler, args.ClosingHandler) as OpenFileDialogResult);
        }
Exemple #4
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="args"></param>
 public OpenFileDialogArguments(OpenFileDialogArguments args)
     : base(args)
 {
 }