本文整理汇总了C#中Microsoft.Win32.OpenFileDialog.ShowDialog方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Win32.OpenFileDialog.ShowDialog方法的具体用法?C# Microsoft.Win32.OpenFileDialog.ShowDialog怎么用?C# Microsoft.Win32.OpenFileDialog.ShowDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Win32.OpenFileDialog
的用法示例。
在下文中一共展示了Microsoft.Win32.OpenFileDialog.ShowDialog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnMessage_Comment_Browse_Click
private void btnMessage_Comment_Browse_Click(object sender, RoutedEventArgs e)
{
try
{
ClGlobul.CommentMessagesList.Clear();
txtCommentMessage.IsReadOnly = true;
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.DefaultExt = ".txt";
dlg.Filter = "Text documents (.txt)|*.txt";
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
txtCommentMessage.Text = dlg.FileName.ToString();
}
try
{
ClGlobul.CommentMessagesList = GlobusFileHelper.ReadFile(txtCommentMessage.Text.Trim());
}
catch (Exception ex)
{
GlobusLogHelper.log.Info(" Please Select File ");
}
}
catch (Exception ex)
{
GlobusLogHelper.log.Error("Error :" + ex.StackTrace);
}
}
示例2: Load
// Get the recipe xml file
public void Load()
{
// Show file dialog
Microsoft.Win32.OpenFileDialog LoadRecipeDialog = new Microsoft.Win32.OpenFileDialog();
LoadRecipeDialog.DefaultExt = ".xml";
Nullable<bool> result = LoadRecipeDialog.ShowDialog();
if (result == true)
{
// Open document
string filename = LoadRecipeDialog.FileName;
string ext = System.IO.Path.GetExtension(filename);
// Check if file is of type xml
if (ext != ".xml")
{
MessageBox.Show("Invalid file type selected. \n Please open a xml recipe file");
LoadRecipeDialog.ShowDialog();
}
else
{
ParseRecipeFile(filename);
}
}
}
示例3: UpdateThumbnail
public void UpdateThumbnail(object sender, EventArgs e)
{
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.FileName = ""; // Default file name
dlg.DefaultExt = ".png"; // Default file extension
dlg.Filter = "Image Files(*.PNG;*.JPG;*.BMP;*.GIF)|*.PNG;*.JPG;*.BMP;*.GIF|All files (*.*)|*.*";
Nullable<bool> result = dlg.ShowDialog();
if (true == result)
{
if (null != dlg.FileName && 0 < dlg.FileName.Length && File.Exists(dlg.FileName))
{
// loadimage
try
{
// fetch via URL
Uri imageUri = new Uri(dlg.FileName);
BitmapDecoder bmd = BitmapDecoder.Create(imageUri, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
// reset width
ThumbnailImage.Width = double.NaN;
// set the source
_thumbnailImage.Source = bmd.Frames[0];
_isDefault = false;
}
catch (Exception) { /* noop */ }
}
}
}
示例4: OpenFolderOrFile
private void OpenFolderOrFile(object sender, ExecutedRoutedEventArgs e)
{
var dialog = new Microsoft.Win32.OpenFileDialog { CheckFileExists = true, CheckPathExists = true, Multiselect = false };
if (lastAddedPath != null)
{
dialog.FileName = lastAddedPath;
}
var ret = dialog.ShowDialog(this);
if (ret.HasValue && ret.Value)
{
lastAddedPath = dialog.FileName;
string filename = null;
if (File.Exists(lastAddedPath))
{
filename = lastAddedPath;
lastAddedPath = Path.GetDirectoryName(lastAddedPath);
}
DirectoryController.Scan(lastAddedPath);
DirectoryController.SelectFile(filename);
ShowFile();
}
}
示例5: Load
public static IronPythonEngine.Types.Set Load()
{
try
{
var openFileDialog = new Microsoft.Win32.OpenFileDialog();
var set = new IronPythonEngine.Types.Set(10);
openFileDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
if (openFileDialog.ShowDialog() == true)
{
using (var stream = System.IO.File.OpenText(openFileDialog.FileName))
{
string line;
while ((line = stream.ReadLine()) != null)
{
var d = Convert.ToDouble(line);
set.Add(d);
}
}
return set;
}
}
catch (Exception ex)
{
MainWindow.ErrorDialog(ex.Message);
}
return new IronPythonEngine.Types.Set(0);
}
示例6: Button_Click_1
private void Button_Click_1(object sender, RoutedEventArgs e)
{
var ofd = new Microsoft.Win32.OpenFileDialog();
var result = ofd.ShowDialog();
if (result == false) return;
nombreArchivo.Text = ofd.FileName;
}
示例7: cc_Click
private void cc_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog d = new Microsoft.Win32.OpenFileDialog();
d.Filter = "JPEG Image (*.JPG)|*.JPG";
bool? result = d.ShowDialog(this);
if (result == true)
{
System.IO.FileInfo fi = new System.IO.FileInfo(d.FileName);
//fi.CopyTo("..\\..\\Resources\\"+fi.Name,true);
XmlDataProvider xdp = this.Resources["BookData"] as XmlDataProvider;
System.Xml.XmlElement xe = (System.Xml.XmlElement)(e.Source as System.Windows.Controls.ContentControl).Content;
if (xe["Image"] != null)
{
xe["Image"].InnerText = fi.FullName;
//System.Xml.XmlTextWriter xr = new System.Xml.XmlTextWriter(new System.IO.FileStream(@"C:\a.txt", System.IO.FileMode.OpenOrCreate), Encoding.Unicode);
//xe.WriteTo(xr);
//xr.Close();
}
else
{
System.Xml.XPath.XPathNavigator navigator = xe.CreateNavigator();
navigator.AppendChildElement(null, "Image", null, fi.FullName);
this.listBox.Items.Refresh();
}
}
}
示例8: BrowseWaitingListButton_Click
private void BrowseWaitingListButton_Click(object sender, RoutedEventArgs e)
{
// Create OpenFileDialog
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
if (!string.IsNullOrEmpty(WaitingListFileTextBox.Text))
{
string dir = System.IO.Path.GetDirectoryName(WaitingListFileTextBox.Text);
if (Directory.Exists(dir))
{
dlg.InitialDirectory = dir;
}
}
// Set filter for file extension and default file extension
dlg.DefaultExt = ".csv";
dlg.Filter = "CSV Files (*.csv)|*.csv";
// Display OpenFileDialog by calling ShowDialog method
Nullable<bool> result = dlg.ShowDialog();
// Get the selected file name and display in a TextBox
if (result == true)
{
WaitingListFileTextBox.Text = dlg.FileName;
}
}
示例9: loadDocumentBtn_Click
private void loadDocumentBtn_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.DefaultExt = ".png";
dlg.Filter = "Image documents (.png)|*.png";
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
ocrData.clearData();
filePath = dlg.FileName;
sourcePathTxtBox.Text = filePath;
BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.UriSource = new Uri(filePath);
bi.EndInit();
sourceImage.Stretch = Stretch.Uniform;
sourceImage.Source = bi;
ocrData.filename = Regex.Match(filePath, @".*\\([^\\]+$)").Groups[1].Value;
ocrData.created = File.GetCreationTime(filePath);
processBtn.IsEnabled = true;
}
}
示例10: BT_AddImage_Click
private void BT_AddImage_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog();
dialog.DefaultExt = ".jpeg";
dialog.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif";
Nullable<bool> result = dialog.ShowDialog();
if (result == true)
{
CB_Images.Items.Add(dialog.FileName.ToString());
IMG_SelectedImage.Source = CloneImage(dialog.FileName.ToString());
imageSource.Add(dialog.FileName.ToString());
imageCaptions.Add("");
if( (CB_Images.Items.Count-1) == 0 )
{
CB_Images.SelectedIndex = 0;
}
else
{
CB_Images.SelectedIndex = CB_Images.Items.Count - 1;
}
}
}
示例11: btLoad_Click
private void btLoad_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog();
dialog.FileOk += dialog_FileOk;
dialog.ShowDialog();
}
示例12: menuItemFileOpen_Click
private void menuItemFileOpen_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog openXmlFileDialog = new Microsoft.Win32.OpenFileDialog();
openXmlFileDialog.DefaultExt = "xml";
openXmlFileDialog.Filter = "XML(.xml)|*.xml";
//show dialog
Nullable<bool> result = openXmlFileDialog.ShowDialog();
//wait the result
if (result == true && openXmlFileDialog.FileName != "")
{
try
{
//http://blog.csdn.net/zengjibing/archive/2009/01/16/3797837.aspx
XmlDocument answerXmlSource = new XmlDocument();
answerXmlSource.Load(openXmlFileDialog.FileName);
XmlDataProvider answerXmlprovider = this.FindResource("answerXmlDoc") as XmlDataProvider;
answerXmlprovider.Document = answerXmlSource;
answerXmlprovider.XPath = "/ArrayOfQuestion/Question";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
示例13: btnBrowse_Click
//<< -------------------------- >>//
private void btnBrowse_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
// Set filter for file extension and default file extension
dlg.DefaultExt = ".jpg";
dlg.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif";
// Display OpenFileDialog by calling ShowDialog method
Nullable<bool> result = dlg.ShowDialog();
// Get the selected file name and display in a TextBox
if (result == true)
{
// Open document
string filename = dlg.FileName;
lblFilename.Content = filename;
imgCategoryImage.Source = new BitmapImage(new Uri(filename));
}
}
示例14: OnCommand
private void OnCommand()
{
// Configure open file dialog box
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
//dlg.FileName = "Document"; // Default file name
dlg.DefaultExt = ".jws"; // Default file extension
dlg.Filter = "Jade Workspace files (.jws)|*.jws"; // Filter files by extension
dlg.CheckFileExists = true;
dlg.CheckPathExists = true;
// Show open file dialog box
Nullable<bool> result = dlg.ShowDialog();
// Process open file dialog box results
if (result == true)
{
// Open document
string filename = dlg.FileName;
try
{
JadeData.Workspace.IWorkspace workspace = JadeData.Persistence.Workspace.Reader.Read(filename);
_viewModel.Workspace = new JadeControls.Workspace.ViewModel.Workspace(workspace);
}
catch (System.Exception e)
{
}
}
}
示例15: FindFileDialogue
public FindFileDialogue(string filter)
{
// Create OpenFileDialog
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
// Set filter for file extension and default file extension
switch (filter)
{
case "csv":
dlg.DefaultExt = ".csv";
dlg.Filter = "CSV Files (*.csv)|*.csv|All Files |*.*";
break;
}
// Display OpenFileDialog by calling ShowDialog method
Nullable<bool> result = dlg.ShowDialog();
// Get the selected file name and display in a TextBox
if (result == true)
{
// Open document
string filename = dlg.FileName;
LocationOfFile = filename;
}
}