public void StartNew(WinFileSystem win, ClientInfo client, FileFolderInfo selectedFile) { ControlledClient = client; string path = FileSystemDialog.GetSaveFile(null, true, false, selectedFile.Name); if (path != null) { FileTransmissionInfo trans = new FileTransmissionInfo() { File = selectedFile }; try { download = new DownloadingInfo(win, client, path, trans); } catch (Exception ex) { TaskDialog.ShowException(ex, "建立本地文件失败!"); return; } Telnet.Instance.FileSystemDownloadErrorReceived += FileSystemDownloadErrorReceived; Telnet.Instance.FileSystemDownloadPartReceived += FileSystemDownloadPartReceived; Telnet.Instance.Send(new CommandBody( File_AskForDownloading, Global.CurrentClient.ID, client.ID, trans)); download.Dialog.ShowDialog(); } }
private static void SetDefaultDirectory(FileSystemDialog sfd) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { sfd.Directory = Path.Combine("/media", Environment.UserName); } if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { sfd.Directory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); } }
public void StartNew(WinFileSystem win, ClientInfo client, string remoteFolderPath) { this.win = win; ControlledClient = client; string path = FileSystemDialog.GetOpenFile(); if (path != null) { var trans = new FileTransmissionInfo { File = new FileFolderInfo() { Path = Path.Combine(remoteFolderPath, Path.GetFileName(path)), Length = new FileInfo(path).Length } }; currentUpload = new UploadInfo(win, ControlledClient, path, trans); Telnet.Instance.Send(new CommandBody(File_AskForStartUpload, Global.CurrentClient.ID, ControlledClient.ID, trans)); } Telnet.Instance.FileSystemPrepareForUploadingReceived += FileSystemPrepareForUploadingReceived;; }
private void SetImageButton_MouseDown(object sender, MouseButtonEventArgs e) { _sourceImagePath = FileSystemDialog.OpenFileDialog("bmp"); }
private void FolderButton_MouseDown(object sender, MouseButtonEventArgs e) { _resultFolderPath = FileSystemDialog.SelectFolder(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { FileSystemDialog.GetSaveFile(new FileFilterCollection() .Add("文本", "txt") .Add("图片", "png"), ensureExtension: true); }
private void EncodeButton_MouseDown(object sender, MouseButtonEventArgs e) { _resultFolderPath = FileSystemDialog.SelectFolder(); LSB.EncodeImage(_sourceImagePath, _sourceTextPath, _resultFolderPath); MessageBox.Show("Finished!", "Result", MessageBoxButtons.OK); }
private void SetTextButton_MouseDown(object sender, MouseButtonEventArgs e) { _sourceTextPath = FileSystemDialog.OpenFileDialog("txt"); }
/// <summary> /// Initializes a new instance of the <see cref="ManagedDialogViewModel" /> class. /// </summary> /// <param name="dialog">The dialog.</param> /// <param name="options">The options.</param> /// <exception cref="ArgumentException">dialog</exception> public ManagedDialogViewModel(FileSystemDialog dialog, ManagedFileDialogOptions options) { _options = options; _disposables = new CompositeDisposable(); var quickSources = AvaloniaLocator.Current .GetService <ManagedDialogSources>() ?? new ManagedDialogSources(); var sub1 = AvaloniaLocator.Current .GetService <IMountedVolumeInfoProvider>() .Listen(ManagedDialogSources.MountedVolumes); var sub2 = Observable.FromEventPattern(ManagedDialogSources.MountedVolumes, nameof(ManagedDialogSources.MountedVolumes.CollectionChanged)) .ObserveOn(AvaloniaScheduler.Instance) .Subscribe(x => RefreshQuickLinks(quickSources)); _disposables.Add(sub1); _disposables.Add(sub2); CompleteRequested += delegate { _disposables?.Dispose(); }; CancelRequested += delegate { _disposables?.Dispose(); }; RefreshQuickLinks(quickSources); Title = dialog.Title ?? ( dialog is OpenFileDialog ? "Open file" : dialog is SaveFileDialog ? "Save file" : dialog is OpenFolderDialog ? "Select directory" : throw new ArgumentException(nameof(dialog))); var directory = dialog.Directory; if (directory == null || !Directory.Exists(directory)) { directory = Directory.GetCurrentDirectory(); } if (dialog is FileDialog fd) { if (fd.Filters?.Count > 0) { Filters.AddRange(fd.Filters.Select(f => new ManagedDialogFilterViewModel(f))); _selectedFilter = Filters[0]; ShowFilters = true; } if (dialog is OpenFileDialog ofd) { if (ofd.AllowMultiple) { SelectionMode = SelectionMode.Multiple; } FileName = ofd.InitialFileName; } } SelectingFolder = dialog is OpenFolderDialog; if (dialog is SaveFileDialog sfd) { _savingFile = true; _defaultExtension = sfd.DefaultExtension; FileName = sfd.InitialFileName; } Navigate(directory, (dialog as FileDialog)?.InitialFileName); SelectedItems.CollectionChanged += OnSelectionChangedAsync; }