예제 #1
0
        private void DialogHandler_DialogRequested(DialogRequestedEventArgs args)
        {
            var isDownload = args.Operation == FileSystemOperation.Save;
            var isUpload   = args.Operation == FileSystemOperation.Open;
            var isAllowed  = (isDownload && settings.AllowDownloads) || (isUpload && settings.AllowUploads);

            if (isAllowed)
            {
                var result = fileSystemDialog.Show(args.Element, args.Operation, args.InitialPath, title: args.Title, parent: window);

                if (result.Success)
                {
                    args.FullPath = result.FullPath;
                    args.Success  = result.Success;
                    logger.Debug($"User selected path '{result.FullPath}' when asked to {args.Operation}->{args.Element}.");
                }
                else
                {
                    logger.Debug($"User aborted file system dialog to {args.Operation}->{args.Element}.");
                }
            }
            else
            {
                logger.Info($"Blocked file system dialog to {args.Operation}->{args.Element}, as {(isDownload ? "downloading" : "uploading")} is not allowed.");
            }
        }
예제 #2
0
        private void AskForApplicationPath(ApplicationNotFoundEventArgs args)
        {
            var message = text.Get(TextKey.FolderDialog_ApplicationLocation).Replace("%%NAME%%", args.DisplayName).Replace("%%EXECUTABLE%%", args.ExecutableName);
            var result  = fileSystemDialog.Show(FileSystemElement.Folder, FileSystemOperation.Open, message: message, parent: splashScreen);

            if (result.Success)
            {
                args.CustomPath = result.FullPath;
                args.Success    = true;
            }
        }
        private void DialogHandler_DialogRequested(DialogRequestedEventArgs args)
        {
            var isDownload  = args.Operation == FileSystemOperation.Save;
            var isUpload    = args.Operation == FileSystemOperation.Open;
            var isAllowed   = (isDownload && settings.AllowDownloads) || (isUpload && settings.AllowUploads);
            var initialPath = default(string);

            if (isDownload)
            {
                initialPath = args.InitialPath;
            }
            else
            {
                initialPath = string.IsNullOrEmpty(settings.DownAndUploadDirectory) ? KnownFolders.Downloads.ExpandedPath : Environment.ExpandEnvironmentVariables(settings.DownAndUploadDirectory);
            }

            if (isAllowed)
            {
                var result = fileSystemDialog.Show(
                    args.Element,
                    args.Operation,
                    initialPath,
                    title: args.Title,
                    parent: window,
                    restrictNavigation: !settings.AllowCustomDownAndUploadLocation);

                if (result.Success)
                {
                    args.FullPath = result.FullPath;
                    args.Success  = result.Success;
                    logger.Debug($"User selected path '{result.FullPath}' when asked to {args.Operation}->{args.Element}.");
                }
                else
                {
                    logger.Debug($"User aborted file system dialog to {args.Operation}->{args.Element}.");
                }
            }
            else
            {
                logger.Info($"Blocked file system dialog to {args.Operation}->{args.Element}, as {(isDownload ? "downloading" : "uploading")} is not allowed.");
            }
        }