Here are the examples of the csharp api Microsoft.Win32.CommonDialog.ShowDialog() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
838 Examples
19
Source : SettingsView.xaml.cs
with MIT License
from AlexanderPro
with MIT License
from AlexanderPro
private void BrowseImageFile_Click(object sender, RoutedEventArgs e)
{
var viewModel = (SettingsViewModel)DataContext;
var openFileDialog = new OpenFileDialog
{
Filter = $"Image files ({string.Join(";", viewModel.Settings.GalleryFileExtensions)})|{string.Join(";", viewModel.Settings.GalleryFileExtensions)}|All files (*.*)|*.*"
};
if (openFileDialog.ShowDialog() == true)
{
viewModel.ImageFileName = openFileDialog.FileName;
}
}
19
Source : VideoView.xaml.cs
with MIT License
from AlexanderPro
with MIT License
from AlexanderPro
private void Open_Executed(object sender, ExecutedRoutedEventArgs e)
{
var viewModel = (VideoViewModel)DataContext;
var openFileDialog = new OpenFileDialog
{
Filter = $"Media files ({string.Join(";", viewModel.Settings.VideoFileExtensions)})|{string.Join(";", viewModel.Settings.VideoFileExtensions)}|All files (*.*)|*.*"
};
if (openFileDialog.ShowDialog() == true)
{
mediaPlayer.Source = new Uri(openFileDialog.FileName);
if (viewModel.Settings.VideoAutoPlay)
{
Play();
}
}
}
19
Source : WpfFileDialogService.cs
with GNU General Public License v3.0
from alexdillon
with GNU General Public License v3.0
from alexdillon
public string ShowSaveFileDialog(string replacedle, IEnumerable<FileFilter> filters, string defaultFileName = "")
{
var saveFileDialog = new SaveFileDialog
{
Filter = this.MakeWin32Filters(filters),
replacedle = replacedle,
FileName = defaultFileName,
};
if (saveFileDialog.ShowDialog() == true)
{
return saveFileDialog.FileName;
}
else
{
return string.Empty;
}
}
19
Source : WpfFileDialogService.cs
with GNU General Public License v3.0
from alexdillon
with GNU General Public License v3.0
from alexdillon
public string ShowOpenFileDialog(string replacedle, IEnumerable<FileFilter> filters)
{
var openFileDialog = new OpenFileDialog
{
Filter = this.MakeWin32Filters(filters),
replacedle = replacedle,
};
if (openFileDialog.ShowDialog() == true)
{
return openFileDialog.FileName;
}
else
{
return string.Empty;
}
}
19
Source : MessageBoxService.cs
with MIT License
from alexleen
with MIT License
from alexleen
public bool? ShowOpenFileDialog(out string fileName)
{
OpenFileDialog ofd = new OpenFileDialog();
bool? showDialog = ofd.ShowDialog();
if (showDialog.IsTrue())
{
fileName = ofd.FileName;
return true;
}
fileName = null;
return showDialog;
}
19
Source : Export.cs
with MIT License
from alfarok
with MIT License
from alfarok
public static void ToPng(UserControl control)
{
RenderTargetBitmap rtb = new RenderTargetBitmap((int)control.ActualWidth, (int)control.ActualHeight, 96, 96, PixelFormats.Pbgra32);
rtb.Render(control);
PngBitmapEncoder png = new PngBitmapEncoder();
png.Frames.Add(BitmapFrame.Create(rtb));
MemoryStream stream = new MemoryStream();
png.Save(stream);
var image = System.Drawing.Image.FromStream(stream);
SaveFileDialog dialog = new SaveFileDialog();
dialog.FileName = "NodeModelChart"; // Default file name
dialog.DefaultExt = ".png"; // Default file extension
dialog.Filter = "Image files (*.png) | *.png"; // Filter files by extension
// Show save file dialog box
Nullable<bool> result = dialog.ShowDialog();
// Process save file dialog box results
if (result == true)
{
// Save doreplacedent
string filename = dialog.FileName;
image.Save(filename, ImageFormat.Png);
}
}
19
Source : MainWindow.xaml.cs
with MIT License
from AliFlux
with MIT License
from AliFlux
private void saveButton_Click(object sender, RoutedEventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Images|*.png;*.bmp;*.jpg";
if (sfd.ShowDialog() != null)
{
string ext = System.IO.Path.GetExtension(sfd.FileName);
BitmapEncoder encoder = new BmpBitmapEncoder();
switch (ext)
{
case ".jpg":
encoder = new JpegBitmapEncoder();
break;
case ".bmp":
encoder = new PngBitmapEncoder();
break;
}
encoder.Frames.Add(BitmapFrame.Create(demoImage.Source as BitmapSource));
using (var fileStream = new System.IO.FileStream(sfd.FileName, System.IO.FileMode.Create))
{
encoder.Save(fileStream);
}
}
}
19
Source : OpenVideoWindow.xaml.cs
with MIT License
from Alkl58
with MIT License
from Alkl58
private void ButtonOpenSingleSource_Click(object sender, RoutedEventArgs e)
{
// OpenFileDialog for a Single Video File
OpenFileDialog openVideoFileDialog = new OpenFileDialog();
openVideoFileDialog.Filter = "Video Files|*.mp4;*.mkv;*.webm;*.flv;*.avi;*.mov;*.wmv;|All Files|*.*";
// Avoid NULL being returned resulting in crash
Nullable<bool> result = openVideoFileDialog.ShowDialog();
if (result == true)
{
// Sets the Video Path which the main window gets
// with the function at the beginning
VideoPath = openVideoFileDialog.FileName;
ProjectFile = false;
BatchFolder = false;
QuitCorrectly = true;
// Closes the Window
this.Close();
}
}
19
Source : OpenVideoWindow.xaml.cs
with MIT License
from Alkl58
with MIT License
from Alkl58
private void ButtonProjectFile_Click(object sender, RoutedEventArgs e)
{
// OpenFileDialog for a Project File
OpenFileDialog openVideoFileDialog = new OpenFileDialog();
openVideoFileDialog.Filter = "Project File|*.xml;";
openVideoFileDialog.InitialDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Jobs");
// Avoid NULL being returned resulting in crash
Nullable<bool> result = openVideoFileDialog.ShowDialog();
if (result == true)
{
// Sets the Video Path which the main window gets
// with the function at the beginning
VideoPath = openVideoFileDialog.FileName;
ProjectFile = true;
BatchFolder = false;
QuitCorrectly = true;
// Closes the Window
this.Close();
}
}
19
Source : Settings.xaml.cs
with MIT License
from Alkl58
with MIT License
from Alkl58
private void ButtonSetBGImage_Click(object sender, RoutedEventArgs e)
{
try
{
OpenFileDialog openFileDialog = new OpenFileDialog();
if (openFileDialog.ShowDialog() == true)
{
Uri fileUri = new Uri(openFileDialog.FileName);
if (File.Exists("background.txt")) { File.Delete("background.txt"); }
Helpers.WriteToFileThreadSafe(openFileDialog.FileName, "background.txt");
}
else
{
// Reset BG Image
if (File.Exists("background.txt")) { try { File.Delete("background.txt"); } catch { } }
}
}
catch { }
}
19
Source : NotepadViewModel.cs
with MIT License
from AngryCarrot789
with MIT License
from AngryCarrot789
public void OpenNotepadFromFileExplorer()
{
try
{
OpenFileDialog ofd = new OpenFileDialog
{
replacedle = "Select Files to open",
Multiselect = true
};
if (ofd.ShowDialog() == true)
{
int i;
for (i = 0; i < ofd.FileNames.Length; i++)
{
string paths = ofd.FileNames[i];
OpenNotepadFromPath(paths, true);
}
Information.Show($"Opened {i} files", InfoTypes.FileIO);
}
}
catch (Exception e) { Information.Show(e.Message, "Error while opening file from f.explorer"); }
}
19
Source : NotepadViewModel.cs
with MIT License
from AngryCarrot789
with MIT License
from AngryCarrot789
public void SaveNotepadAs(TextDoreplacedentViewModel fivm)
{
try
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter =
"Plain Text (.txt)|*.txt|" +
"Text..? ish (.text)|*.text|" +
"C# File (.cs)|*.cs|" +
"C File (.c)|*.c|" +
"C++ File (.cpp)|*.cpp|" +
"C/C++ Header File (.h)|*.h|" +
"XAML File (.xaml)|*.xaml|" +
"XML File (.xml)|*.xml|" +
"HTM File (.htm)|*.htm|" +
"HTML File (.html)|*.html|" +
"CSS File (.css)|*.css|" +
"JS File (.js)|*.js|" +
"EXE File (.exe)|*.exe|" +
"All files|*.*";
sfd.replacedle = "Select Files to save";
sfd.FileName = fivm.Doreplacedent.FileName;
sfd.FilterIndex = 1;
sfd.RestoreDirectory = true;
if (sfd.ShowDialog() == true)
{
string newFilePath = sfd.FileName;
if (SaveFile(newFilePath, fivm.Doreplacedent.Text, fivm.Doreplacedent.IsReadOnly))
{
fivm.HasMadeChanges = false;
}
fivm.Doreplacedent.FileName = Path.GetFileName(newFilePath);
fivm.Doreplacedent.FilePath = newFilePath;
}
}
catch (Exception e) { Information.Show(e.Message, "Error while saving (manual) notepaditem as..."); }
}
19
Source : FileOpener.cs
with Apache License 2.0
from anmcgrath
with Apache License 2.0
from anmcgrath
public async void BeginOpenDicomDoseAsync()
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Multiselect = false;
openFileDialog.replacedle = "Open Dicom Dose";
if (openFileDialog.ShowDialog() == true)
{
var progressItem = ProgressService.CreateNew("Loading Dose File...", false);
var progress = new Progress<double>(x => { progressItem.ProgressAmount = (int)x; });
DicomDoseObject openedObject = null;
await Task.Run(async () =>
{
try
{
openedObject = await DicomLoader.LoadDicomDoseAsync(openFileDialog.FileName, progress);
}
catch (Exception e)
{
Messenger.Default.Send(new NotificationMessage("Could not open file: " + e.Message));
}
});
if (openedObject != null)
Messenger.Default.Send(new RTDicomViewer.Message.RTObjectAddedMessage<DicomDoseObject>(openedObject));
ProgressService.End(progressItem);
}
}
19
Source : FileOpener.cs
with Apache License 2.0
from anmcgrath
with Apache License 2.0
from anmcgrath
public async void BeginOpenEgsDoseAsync()
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Multiselect = false;
openFileDialog.replacedle = "Open 3D Dose File";
if (openFileDialog.ShowDialog() == true)
{
var progressItem = ProgressService.CreateNew("Loading 3DDose File...", false);
var progress = new Progress<double>(x => { progressItem.ProgressAmount = (int)x; });
EgsDoseObject openedObject = null;
await Task.Run(async () =>
{
try
{
openedObject = await DicomLoader.LoadEgsObjectAsync(openFileDialog.FileName, progress);
}
catch (Exception e)
{
Messenger.Default.Send(new NotificationMessage("Could not open file: " + e.Message));
}
});
if (openedObject != null)
Messenger.Default.Send(new RTDicomViewer.Message.RTObjectAddedMessage<EgsDoseObject>(openedObject));
ProgressService.End(progressItem);
}
}
19
Source : FileOpener.cs
with Apache License 2.0
from anmcgrath
with Apache License 2.0
from anmcgrath
private string[] getFileNames(string replacedle, bool allowMultiple)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Multiselect = allowMultiple;
openFileDialog.replacedle = replacedle;
if(openFileDialog.ShowDialog() == true)
{
return openFileDialog.FileNames;
}else
{
return null;
}
}
19
Source : AttachmentFileOverlay.xaml.cs
with MIT License
from anoyetta
with MIT License
from anoyetta
public static (bool Result, string[] FileNames) SelectFiles()
{
var fileNames = new string[0];
OpenFileDialog.InitialDirectory = Config.Instance.FileDirectory;
var result = OpenFileDialog.ShowDialog() ?? false;
if (result)
{
fileNames = OpenFileDialog.FileNames;
Config.Instance.FileDirectory = Path.GetDirectoryName(fileNames.First());
}
return (result, fileNames);
}
19
Source : FileOpenSaveService.cs
with MIT License
from AntonyCorbett
with MIT License
from AntonyCorbett
public string? GetBibleNotesExportFilePath(string replacedle)
{
var saveFileDialog = new SaveFileDialog
{
AddExtension = true,
replacedle = replacedle,
Filter = "Excel file (*.xlsx)|*.xlsx",
InitialDirectory = ExportDirectory ?? GetDefaultExportFolder(),
};
if (saveFileDialog.ShowDialog() == true)
{
ExportDirectory = Path.GetDirectoryName(saveFileDialog.FileName);
return saveFileDialog.FileName;
}
return null;
}
19
Source : FileOpenSaveService.cs
with MIT License
from AntonyCorbett
with MIT License
from AntonyCorbett
public string? GetBibleNotesImportFilePath(string replacedle)
{
var openFileDialog = new OpenFileDialog
{
AddExtension = true,
CheckFileExists = true,
DefaultExt = ".txt",
replacedle = replacedle,
Filter = "Text file (*.txt)|*.txt",
InitialDirectory = ImportDirectory ?? GetDefaultImportFolder(),
};
if (openFileDialog.ShowDialog() == true)
{
ImportDirectory = Path.GetDirectoryName(openFileDialog.FileName);
return openFileDialog.FileName;
}
return null;
}
19
Source : FileOpenSaveService.cs
with MIT License
from AntonyCorbett
with MIT License
from AntonyCorbett
public string? GetSaveFilePath(string replacedle)
{
var saveFileDialog = new SaveFileDialog
{
AddExtension = true,
replacedle = replacedle,
Filter = "JW Library backup file (*.jwlibrary)|*.jwlibrary",
InitialDirectory = SaveDirectory ?? GetDefaultSaveFolder(),
};
if (saveFileDialog.ShowDialog() == true)
{
SaveDirectory = Path.GetDirectoryName(saveFileDialog.FileName);
return saveFileDialog.FileName;
}
return null;
}
19
Source : DialogService.cs
with GNU General Public License v3.0
from AnyStatus
with GNU General Public License v3.0
from AnyStatus
private static DialogResult Show(FileDialog fileDialog, Microsoft.Win32.FileDialog win32Dialog)
{
var result = win32Dialog.ShowDialog();
fileDialog.FileName = win32Dialog.FileName;
return result != null && result.Value ? DialogResult.OK : DialogResult.Cancel;
}
19
Source : AddDynamicWallpaperTask.xaml.cs
with MIT License
from Apollo199999999
with MIT License
from Apollo199999999
private void PickImageBtn_Click(object sender, RoutedEventArgs e)
{
//handle the event handler when the pickimage btn is clicked
//cast the tag of the pickimage btn as an image control
Button PickImageBtn = sender as Button;
Image WallpaperImage = PickImageBtn.Tag as Image;
//open a file dialog to pick the image
OpenFileDialog WallpaperFileDialog = new OpenFileDialog();
WallpaperFileDialog.Filter = "All Image files (*.jpg;*.jpeg;*.bmp;.png;)" +
"|*.jpg;*.jpeg;*.bmp;*.png;";
if (WallpaperFileDialog.ShowDialog() == true)
{
//set the wallpaperimage image as the filename of the open file dialog
WallpaperImage.Source = new BitmapImage(new Uri(WallpaperFileDialog.FileName));
}
}
19
Source : MainWindow.xaml.cs
with GNU General Public License v3.0
from arminkz
with GNU General Public License v3.0
from arminkz
private void Load_Audio(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.replacedle = "Select Audio File";
ofd.Filter = "All Supported Files (*.wav;*.mp3)|*.wav;*.mp3";
bool? result = ofd.ShowDialog();
if(result.HasValue && result.Value)
{
aud.Stop();
aud.Load(ofd.FileName);
Play_Button.IsEnabled = true;
Pause_Button.IsEnabled = true;
Stop_Button.IsEnabled = true;
}
}
19
Source : MainWindow.xaml.cs
with GNU General Public License v3.0
from arminkz
with GNU General Public License v3.0
from arminkz
private void Load_Image(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.replacedle = "Select Image File";
//ofd.Filter = "All Supported Files (*.wav;*.mp3)|*.wav;*.mp3";
bool? result = ofd.ShowDialog();
if (result.HasValue && result.Value)
{
Ch0Image = new BitmapImage(new Uri(ofd.FileName));
CHO_ImageBox.Source = Ch0Image;
scn.UpdateTextureBitmap(gl, 1, ImageHelper.BitmapImage2Bitmap(Ch0Image));
}
}
19
Source : StartPageView.xaml.cs
with MIT License
from aschearer
with MIT License
from aschearer
private void OnOpen(object sender, ExecutedRoutedEventArgs e)
{
var openFileDialog = new OpenFileDialog();
openFileDialog.InitialDirectory = GetDefaultUnityLogPath();
openFileDialog.DefaultExt = ".log";
openFileDialog.Filter = "Unity Editor.log file (*.log)|*.log";
var result = openFileDialog.ShowDialog();
if (result.HasValue && result.Value)
{
var fileName = openFileDialog.FileName;
((StartPageViewModel)this.DataContext).OpenFile(fileName);
}
}
19
Source : Utils.cs
with MIT License
from Assistant
with MIT License
from Assistant
public static string GetManualDir()
{
var dialog = new SaveFileDialog()
{
replacedle = (string)Application.Current.FindResource("Utils:InstallDir:Dialogreplacedle"),
Filter = "Directory|*.this.directory",
FileName = "select"
};
if (dialog.ShowDialog() == true)
{
string path = dialog.FileName;
path = path.Replace("\\select.this.directory", "");
path = path.Replace(".this.directory", "");
path = path.Replace("\\select.directory", "");
if (File.Exists(Path.Combine(path, "Beat Saber.exe")))
{
string store;
if (File.Exists(Path.Combine(path, "Beat Saber_Data", "Plugins", "steam_api64.dll"))
|| File.Exists(Path.Combine(path, "Beat Saber_Data", "Plugins", "x86_64", "steam_api64.dll")))
{
store = "Steam";
}
else
{
store = "Oculus";
}
return SetDir(path, store);
}
}
return null;
}
19
Source : Utils.cs
with MIT License
from Assistant
with MIT License
from Assistant
public static string GetManualFile(string filter = "", string replacedle = "Open File")
{
var dialog = new OpenFileDialog()
{
replacedle = replacedle,
Filter = filter,
Multiselect = false,
};
if (dialog.ShowDialog() == true)
{
return dialog.FileName;
}
return null;
}
19
Source : SelectAssemblyPage.xaml.cs
with MIT License
from avestura
with MIT License
from avestura
private void Button_Click(object sender, RoutedEventArgs e)
{
var dialog = new OpenFileDialog
{
Filter = "replacedembly (*.exe, *.dll)|*.dll;*.exe",
CheckFileExists = true,
CheckPathExists = true,
Multiselect = false,
replacedle = "Select replacedembly"
};
if(dialog.ShowDialog() == true)
{
try
{
var asm = replacedembly.LoadFrom(dialog.FileName);
ParentFrame.Navigate(new InspectorPage(asm, ParentFrame));
}
catch(Exception ex)
{
MessageBox.Show($"File not valid, Reason: {ex.Message}" + ((ex.InnerException != null) ? $"\nInner{ex.InnerException.Message}" : ""));
}
}
}
19
Source : Home_Remote.xaml.cs
with Apache License 2.0
from beckzhu
with Apache License 2.0
from beckzhu
private void Button_PrivateKey_Upload_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog op = new OpenFileDialog();
//op.InitialDirectory=默认的打开路径
op.RestoreDirectory = true;
op.Filter = "所有文件(*.*)|*.*";
op.ShowDialog();
if (!string.IsNullOrEmpty(op.FileName))
{
FileInfo fileInfo = new FileInfo(op.FileName);
if (fileInfo.Length <= 10000)
{
RemoteItems.ItemRemoteLink.PrivateKey = File.ReadAllText(op.FileName);
TextBox_PrivateKey.Text = RemoteItems.ItemRemoteLink.PrivateKey;
RemoteItems.UpdateItemRemoteLink();
}
else MainWindow.ShowMessageDialog("错误", "密钥文件不能大于10000个字节");
}
}
19
Source : SettingsControl.xaml.cs
with MIT License
from boonwin
with MIT License
from boonwin
private void cbDisconector_Checked(object sender, RoutedEventArgs e)
{
if (_config.IsAdmin) {
if (!String.IsNullOrEmpty(_config.GamePath))
{
btnDisconecterCreate.IsEnabled = true;
_config.UseDisconect = true;
_config.save();
}
else
{
OpenFileDialog fileDialog = new OpenFileDialog();
fileDialog.Filter = "Hearthstone.exe (Hearthstone.exe)|Hearthstone.exe";
fileDialog.FilterIndex = 1;
fileDialog.Multiselect = false;
Nullable<bool> result = fileDialog.ShowDialog();
if (result == true)
{
_config.GamePath = Path.GetFullPath(fileDialog.FileName);
btnDisconecterCreate.IsEnabled = true;
_config.UseDisconect = true;
_config.save();
}
}
} else
{
MessageBox.Show("DOOOD IF YOU WANT TO USE THIS, YOU NEED TO BE ADMIN, CANT YOU READ? RESTART DECK TRACKER AS ADMIN....", "Boomer Settings");
cbDisconector.IsChecked = false;
}
}
19
Source : SystemInfo.xaml.cs
with MIT License
from builtbybel
with MIT License
from builtbybel
private void textExport_Click(object sender, RoutedEventArgs e)
{
SaveFileDialog dlg = new SaveFileDialog();
dlg.FileName = "My System information"; // Default filename
dlg.DefaultExt = ".text";
dlg.Filter = "Text file (.txt)|*.txt";
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
File.WriteAllText(dlg.FileName, textSystemInfo.Text);
}
}
19
Source : SettingsViewModel.cs
with MIT License
from C1rdec
with MIT License
from C1rdec
public void SelectCustomSound()
{
if (!this.HasCustomTradeSound)
{
try
{
if (this._currentTradeAlert != null)
{
this._currentTradeAlert.Stop();
this._currentTradeAlert = null;
}
replacedetService.Delete(SoundService.TradeAlertFileName);
}
catch
{
// Sound was playing.
this.HasCustomTradeSound = true;
}
return;
}
var openFileDialog = new OpenFileDialog
{
Filter = "MP3 files (*.mp3)|*.mp3",
};
if (openFileDialog.ShowDialog() == true)
{
var fileName = openFileDialog.FileName;
if (!File.Exists(fileName))
{
return;
}
var content = File.ReadAllBytes(fileName);
replacedetService.Create(SoundService.TradeAlertFileName, content);
}
else
{
this.HasCustomTradeSound = false;
}
}
19
Source : MainWindow.xaml.cs
with MIT License
from cdmxz
with MIT License
from cdmxz
private void save_Click(object sender, RoutedEventArgs e)
{
try
{
SaveFileDialog dialog = new SaveFileDialog();
dialog.RestoreDirectory = true;
dialog.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*,*";
if (!(bool)dialog.ShowDialog())
return;
using (FileStream fs = new FileStream(dialog.FileName, FileMode.OpenOrCreate, FileAccess.Write))
using (StreamWriter sw = new StreamWriter(fs))
{
string content;
for (int i = 0; i < listView1.Items.Count; i++)
{
var list = (FileList)listView1.Items[i];
content = string.Format($"时间:{list.Time}|操作:{list.Operation}|大小:{list.Size}|路径:{list.Path}");
if (!string.IsNullOrEmpty(list.NewPath))
content += $"|新路径:{list.NewPath}";
sw.WriteLine(content);
sw.Flush();
}
}
}
catch (Exception ex)
{
MessageBox.Show("错误:\n" + ex.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}
e.Handled = true;
}
19
Source : AddTask.xaml.cs
with GNU General Public License v2.0
from Cdorey
with GNU General Public License v2.0
from Cdorey
private async void BT_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog()
{
Filter = "BT下载的种子文件 (*.torrent)|*.torrent"
};
var result = openFileDialog.ShowDialog();
if (result == true)
{
await Aria2Methords.AddTorrent(openFileDialog.FileName);
Close();
}
}
19
Source : AddTask.xaml.cs
with GNU General Public License v2.0
from Cdorey
with GNU General Public License v2.0
from Cdorey
private async void MT_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog()
{
Filter = "MetaLink文件 (*.metalink)|*.metalink"
};
var result = openFileDialog.ShowDialog();
if (result == true)
{
await Aria2Methords.AddMetalink(openFileDialog.FileName);
Close();
}
}
19
Source : MainWindow.xaml.cs
with MIT License
from chrisnas
with MIT License
from chrisnas
private string SelectDumpFile()
{
// select the dump file to open
OpenFileDialog ofd = new OpenFileDialog()
{
DefaultExt = ".dmp",
Filter = "Dump files (.dmp)|*.dmp",
};
Nullable<bool> result = ofd.ShowDialog();
if (result == true)
{
if (string.IsNullOrEmpty(ofd.FileName))
return null;
}
else
{
return null;
}
return ofd.FileName;
}
19
Source : DatabaseFile.xaml.cs
with GNU General Public License v3.0
from CitizensReactor
with GNU General Public License v3.0
from CitizensReactor
private void Temporary_Save_Button(object sender, RoutedEventArgs e)
{
MainWindow.SetStatus($"Compiling database...");
var data = Database.GetDatabaseBinary();
string filepath = null;
if (CommonSaveFileDialog.IsPlatformSupported)
{
var dialog = new CommonSaveFileDialog();
dialog.DefaultFileName = "Game.dcb";
CommonFileDialogResult result = dialog.ShowDialog();
if (result == CommonFileDialogResult.Ok)
{
filepath = dialog.FileName;
}
}
else
{
var dialog = new SaveFileDialog();
dialog.FileName = "Game.dcb";
if (dialog.ShowDialog() ?? false)
{
filepath = dialog.FileName;
}
}
if (filepath != null)
{
using (FileStream fs = new FileStream(filepath, FileMode.Create, FileAccess.Write))
{
fs.Write(data, 0, data.Length);
}
MainWindow.SetStatus($"Saved {filepath}");
}
else
{
MainWindow.SetStatus($"Failed to save database");
}
}
19
Source : MainWindow.xaml.cs
with GNU General Public License v3.0
from CitizensReactor
with GNU General Public License v3.0
from CitizensReactor
private void Menu_Open_Click(object _sender, RoutedEventArgs e)
{
var sender = _sender as MenuItem;
if (!(sender?.IsEnabled ?? false)) return;
if (FilesystemManager != null)
{
FilesystemManager.Dispose();
FilesystemManager = null;
}
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Package container files (*.p4k)|*.p4k|All files (*.*)|*.*";
if (openFileDialog.ShowDialog() != true) return;
OpenStarcitizen(openFileDialog.FileName);
}
19
Source : FilesystemView.xaml.cs
with GNU General Public License v3.0
from CitizensReactor
with GNU General Public License v3.0
from CitizensReactor
private bool ExtractTo(IFilesystemEntry filesystemEntry, MainWindow.ExtractionMode mode)
{
if (!filesystemEntry.IsDirectory)
{
string filepath = null;
if (CommonSaveFileDialog.IsPlatformSupported)
{
var dialog = new CommonSaveFileDialog();
dialog.DefaultFileName = filesystemEntry.Name;
CommonFileDialogResult result = dialog.ShowDialog();
if (result == CommonFileDialogResult.Ok)
{
filepath = dialog.FileName;
}
}
else
{
var dialog = new SaveFileDialog();
dialog.FileName = filesystemEntry.Name;
if (dialog.ShowDialog() ?? false)
{
filepath = dialog.FileName;
}
}
if (filepath != null)
{
MainWindow.PrimaryWindow.ExtractFiles(filesystemEntry as P4KFilesystemEntry, mode, filepath);
}
else
{
MainWindow.SetStatus($"Failed to save {filesystemEntry.Name}");
}
return true;
}
if (filesystemEntry.IsDirectory)
{
string directory = null;
if (CommonOpenFileDialog.IsPlatformSupported)
{
var dialog = new CommonOpenFileDialog();
dialog.IsFolderPicker = true;
CommonFileDialogResult result = dialog.ShowDialog();
if (result == CommonFileDialogResult.Ok)
{
directory = dialog.FileName;
}
}
else
{
using (var dialog = new System.Windows.Forms.FolderBrowserDialog())
{
System.Windows.Forms.DialogResult result = dialog.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK || result == System.Windows.Forms.DialogResult.Yes)
{
directory = System.IO.Path.GetDirectoryName(dialog.SelectedPath);
}
}
}
if (directory != null && Directory.Exists(directory))
{
//var files = filesystemTreeViewItem.GetP4KFiles();
MainWindow.PrimaryWindow.ExtractFiles(filesystemEntry as P4KFilesystemEntry, mode, directory);
}
else
{
MainWindow.SetStatus($"Failed to save {filesystemEntry.Name}");
}
return true;
}
return false;
}
19
Source : MainWindow.xaml.cs
with GNU General Public License v3.0
from CitizensReactor
with GNU General Public License v3.0
from CitizensReactor
private void OpenCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
{
if (FilesystemManager != null)
{
FilesystemManager.Dispose();
FilesystemManager = null;
}
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Package container files (*.p4k)|*.p4k|All files (*.*)|*.*";
if (openFileDialog.ShowDialog() != true) return;
OpenStarcitizen(openFileDialog.FileName);
}
19
Source : Utils.cs
with GNU General Public License v3.0
from CodeDead
with GNU General Public License v3.0
from CodeDead
internal static async Task<bool> ExportProcessDetails(LogController logController)
{
SaveFileDialog sfd = new SaveFileDialog
{
Filter = "Text file (*.txt)|*.txt|HTML file (*.html)|*.html|CSV file (*.csv)|*.csv|Excel file (*.csv)|*.csv"
};
if (sfd.ShowDialog() != true) return false;
try
{
// ReSharper disable once SwitchStatementMissingSomeCases
switch (sfd.FilterIndex)
{
// Filter index starts at 1
case 1:
ProcessDetailExporter.ExportText(sfd.FileName, await GetProcessDetails(logController));
break;
case 2:
ProcessDetailExporter.ExportHtml(sfd.FileName, await GetProcessDetails(logController));
break;
case 3:
ProcessDetailExporter.ExportCsv(sfd.FileName, await GetProcessDetails(logController));
break;
case 4:
ProcessDetailExporter.ExportExcel(sfd.FileName, await GetProcessDetails(logController));
break;
}
return true;
}
catch (Exception ex)
{
logController.AddLog(new ErrorLog(ex.Message));
MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
}
return false;
}
19
Source : SettingsWindow.xaml.cs
with GNU General Public License v3.0
from CodeDead
with GNU General Public License v3.0
from CodeDead
private void BtnFileView_OnClick(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog { Filter = "All files (*.*)|*.*" };
if (ofd.ShowDialog() == true)
{
TxtExclusion.Text = ofd.FileName;
}
}
19
Source : Utils.cs
with GNU General Public License v3.0
from CodeDead
with GNU General Public License v3.0
from CodeDead
internal static bool ExportRamSticks(LogController logController)
{
List<RamStick> ramSticks = GetRamSticks();
if (ramSticks == null || ramSticks.Count == 0) return false;
SaveFileDialog sfd = new SaveFileDialog
{
Filter = "Text file (*.txt)|*.txt|HTML file (*.html)|*.html|CSV file (*.csv)|*.csv|Excel file (*.csv)|*.csv"
};
if (sfd.ShowDialog() != true) return false;
try
{
// ReSharper disable once SwitchStatementMissingSomeCases
switch (sfd.FilterIndex)
{
// Filter index starts at 1
case 1:
RamDataExporter.ExportText(sfd.FileName, ramSticks);
break;
case 2:
RamDataExporter.ExportHtml(sfd.FileName, ramSticks);
break;
case 3:
RamDataExporter.ExportCsv(sfd.FileName, ramSticks);
break;
case 4:
RamDataExporter.ExportExcel(sfd.FileName, ramSticks);
break;
}
return true;
}
catch (Exception ex)
{
logController.AddLog(new ErrorLog(ex.Message));
MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
}
return false;
}
19
Source : ApplicationAdder.cs
with MIT License
from Codectory
with MIT License
from Codectory
public void GetFile()
{
OpenFileDialog fileDialog = new OpenFileDialog();
fileDialog.DefaultExt = ".exe";
fileDialog.Filter = "Executables (.exe)|*.exe";
Nullable<bool> result = fileDialog.ShowDialog();
string filePath = string.Empty;
if (result == true)
filePath = fileDialog.FileName;
else
return;
if (!File.Exists(filePath))
throw new Exception("Invalid file path.");
FilePath = filePath;
if (string.IsNullOrEmpty(DisplayName))
DisplayName = new FileInfo(FilePath).Name.Replace(".exe", "");
ApplicationItem = new ApplicationItem(DisplayName, FilePath);
}
19
Source : Utils.cs
with GNU General Public License v3.0
from CodeDead
with GNU General Public License v3.0
from CodeDead
internal static bool ExportLogs(LogType? logType, LogController logController)
{
if (logController.GetLogs(logType).Count == 0) return false;
SaveFileDialog sfd = new SaveFileDialog
{
Filter = "Log file (*.log)|*.log|Text file (*.txt)|*.txt|HTML file (*.html)|*.html|CSV file (*.csv)|*.csv|Excel file (*.csv)|*.csv"
};
if (sfd.ShowDialog() != true) return false;
ExportType type;
switch (sfd.FilterIndex)
{
default:
type = ExportType.Text;
break;
case 2:
type = ExportType.Html;
break;
case 3:
type = ExportType.Csv;
break;
case 4:
type = ExportType.Excel;
break;
}
try
{
logController.Export(sfd.FileName, logType, type);
return true;
}
catch (Exception ex)
{
logController.AddLog(new ErrorLog(ex.Message));
MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
}
return false;
}
19
Source : Utils.cs
with GNU General Public License v3.0
from CodeDead
with GNU General Public License v3.0
from CodeDead
internal static bool ExportRamUsage(RamController ramController, LogController logController)
{
if (ramController.GetRamUsageHistory().Count == 0) return false;
SaveFileDialog sfd = new SaveFileDialog
{
Filter = "Text file (*.txt)|*.txt|HTML file (*.html)|*.html|CSV file (*.csv)|*.csv|Excel file (*.csv)|*.csv"
};
if (sfd.ShowDialog() != true) return false;
ExportType type;
switch (sfd.FilterIndex)
{
default:
type = ExportType.Text;
break;
case 2:
type = ExportType.Html;
break;
case 3:
type = ExportType.Csv;
break;
case 4:
type = ExportType.Excel;
break;
}
try
{
ramController.Export(sfd.FileName, type);
return true;
}
catch (Exception ex)
{
logController.AddLog(new ErrorLog(ex.Message));
MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
}
return false;
}
19
Source : MainWindow.xaml.cs
with GNU General Public License v3.0
from CodeDead
with GNU General Public License v3.0
from CodeDead
private void Exporreplacedem_OnClick(object sender, RoutedEventArgs e)
{
if (_keyInfo == null) return;
SaveFileDialog sfd = new SaveFileDialog
{Filter = "Text file (*.txt)|*.txt|HTML (*.html)|*.html|CSV (*.csv)|*.csv|Excel (*.csv)|*.csv|JSON (*.json)|*.json"};
ExportManager exportManager = new ExportManager(_keyInfo);
if (sfd.ShowDialog() != true) return;
try
{
switch (sfd.FilterIndex)
{
default:
exportManager.ExportToTxt(sfd.FileName);
break;
case 2:
exportManager.ExportToHtml(sfd.FileName);
break;
case 3:
exportManager.ExportToCsv(sfd.FileName);
break;
case 4:
exportManager.ExportToExcel(sfd.FileName);
break;
case 5:
exportManager.ExportToJson(sfd.FileName);
break;
}
MessageBox.Show("Key exported!", "PK Finder", MessageBoxButton.OK, MessageBoxImage.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "PK Finder", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
19
Source : FileEntryBox.xaml.cs
with MIT License
from coldino
with MIT License
from coldino
private void Browse_Click(object sender, RoutedEventArgs e)
{
var dialog = new OpenFileDialog()
{
AddExtension = true,
CheckFileExists = true,
CheckPathExists = true,
DefaultExt = DefaultExt,
DereferenceLinks = true,
Filter = Filter,
Multiselect = false,
replacedle = replacedle,
FileName = Value,
};
var result = dialog.ShowDialog();
if (result == true)
{
Value = dialog.FileName;
}
}
19
Source : HitSounds.xaml.cs
with GNU General Public License v3.0
from ComputerElite
with GNU General Public License v3.0
from ComputerElite
private void Choose(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = MainWindow.globalLanguage.hitSounds.code.soundFile + " (*.mp3, *.ogg, *.wav)|*.mp3;*.ogg;*.wav";
bool? result = ofd.ShowDialog();
if (result == true)
{
//Get the path of specified file
if(File.Exists(ofd.FileName))
{
SelectedSound = ofd.FileName;
Sound.Text = SelectedSound;
} else
{
SelectedSound = MainWindow.globalLanguage.hitSounds.code.nothing;
MessageBox.Show(MainWindow.globalLanguage.hitSounds.code.selectValidFile, "BMBF Manager - HitSound installing", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
}
19
Source : Support.xaml.cs
with GNU General Public License v3.0
from ComputerElite
with GNU General Public License v3.0
from ComputerElite
private void ChooseImage(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = MainWindow.globalLanguage.settings.code.pictures + " (*.jpg, *.png, *.bmp, *.img, *.tif, *.tiff, *.webp)|*.jpg;*.png;*.bmp;*.img;*.tif;*.tiff;*.webp";
ofd.Multiselect = false;
bool? result = ofd.ShowDialog();
if (result == true)
{
//Get the path of specified file
if (File.Exists(ofd.FileName))
{
MainWindow.config.CustomImageSource = ofd.FileName;
MainWindow.config.CustomImage = true;
UpdateImage();
txtbox.AppendText("\n\n" + MainWindow.globalLanguage.settings.code.restartProgram);
}
else
{
MessageBox.Show(MainWindow.globalLanguage.settings.code.selectFile, "BMBF Manager - Settings", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
}
19
Source : ConnectionDialog.xaml.cs
with MIT License
from conwid
with MIT License
from conwid
void Browsereplacedembly(object sender, RoutedEventArgs e)
{
var dialog = new Microsoft.Win32.OpenFileDialog() { replacedle = "Choose custom replacedembly", DefaultExt = ".dll" };
if ((dialog.ShowDialog() ?? false) == true)
{
cxInfo.CustomTypeInfo.CustomreplacedemblyPath = dialog.FileName;
}
}
See More Examples